Skip to content

Commit abc428d

Browse files
committed
Formatting!
1 parent a4d8193 commit abc428d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4963
-2894
lines changed
File renamed without changes.

deps/asset_init.jl

Lines changed: 156 additions & 137 deletions
Large diffs are not rendered by default.

deps/build.jl

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
using BinDeps
2-
if !ispath(abspath(first(DEPOT_PATH), "config","DFControl"))
3-
mkpath(abspath(first(DEPOT_PATH), "config","DFControl"))
2+
if !ispath(abspath(first(DEPOT_PATH), "config", "DFControl"))
3+
mkpath(abspath(first(DEPOT_PATH), "config", "DFControl"))
44
end
5-
if !ispath(abspath(first(DEPOT_PATH), "config","DFControl", "user_defaults.jl"))
6-
open(abspath(first(DEPOT_PATH), "config","DFControl", "user_defaults.jl"), "w") do f
7-
write(f,"#Generated by DFControl.")
5+
if !ispath(abspath(first(DEPOT_PATH), "config", "DFControl", "user_defaults.jl"))
6+
open(abspath(first(DEPOT_PATH), "config", "DFControl", "user_defaults.jl"), "w") do f
7+
return write(f, "#Generated by DFControl.")
88
end
99
end
1010

11-
if !ispath(abspath(first(DEPOT_PATH), "config","DFControl", "job_registry.txt"))
12-
touch(abspath(first(DEPOT_PATH), "config","DFControl", "job_registry.txt"))
11+
if !ispath(abspath(first(DEPOT_PATH), "config", "DFControl", "job_registry.txt"))
12+
touch(abspath(first(DEPOT_PATH), "config", "DFControl", "job_registry.txt"))
1313
end
1414

1515
relpath = x -> joinpath(@__DIR__, x)
@@ -59,26 +59,31 @@ if !ispath(pythonpath)
5959
run(`$installer -b -f -p $pythonpath`)
6060
end
6161
if Sys.iswindows()
62-
run(Cmd(`$installer /S /AddToPath=0 /RegisterPython=0 /D=$pythonpath`, windows_verbatim=true))
62+
run(Cmd(`$installer /S /AddToPath=0 /RegisterPython=0 /D=$pythonpath`;
63+
windows_verbatim = true))
6364
end
6465

6566
tarpath = relpath("cif2cell.tar.gz")
6667
download("https://sourceforge.net/projects/cif2cell/files/latest/download", tarpath)
67-
run(unpack_cmd("cif2cell.tar.gz", @__DIR__, ".gz",".tar"))
68+
run(unpack_cmd("cif2cell.tar.gz", @__DIR__, ".gz", ".tar"))
6869
cif2celldir = relpath("cif2cell-1.2.10")
6970
cd(cif2celldir)
70-
pyex = Sys.iswindows() ? joinpath(pythonpath, "python") : joinpath(pythonpath, "bin", "python2")
71+
pyex = Sys.iswindows() ? joinpath(pythonpath, "python") :
72+
joinpath(pythonpath, "bin", "python2")
7173
run(`$pyex setup.py install --prefix=$pythonpath`)
7274
cd("..")
73-
#stupid urlopen
74-
starfile = Sys.iswindows() ? joinpath(pythonpath, "lib", "site-packages", "StarFile.py") : joinpath(pythonpath, "lib", "python2.7", "site-packages", "StarFile.py")
75+
#stupid urlopen
76+
starfile = Sys.iswindows() ?
77+
joinpath(pythonpath, "lib", "site-packages", "StarFile.py") :
78+
joinpath(pythonpath, "lib", "python2.7", "site-packages", "StarFile.py")
7579
starsource = read(starfile, String)
76-
starsource = replace(starsource, "filestream = urlopen(filename)"=>"filestream = urlopen('file:' + filename)")
80+
starsource = replace(starsource,
81+
"filestream = urlopen(filename)" => "filestream = urlopen('file:' + filename)")
7782
write(starfile, starsource)
78-
#
83+
#
7984
rm(tarpath)
80-
rm(relpath("cif2cell-1.2.10"), recursive=true)
81-
rm(relpath("downloads"), recursive=true)
85+
rm(relpath("cif2cell-1.2.10"); recursive = true)
86+
rm(relpath("downloads"); recursive = true)
8287
end
8388

8489
include("asset_init.jl")

docs/make.jl

Lines changed: 50 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Based on documentation of DFTK
2-
import LibGit2
3-
import Pkg
2+
using LibGit2: LibGit2
3+
using Pkg: Pkg
44

55
# To manually generate the docs:
66
#
@@ -18,17 +18,15 @@ CONTINUOUS_INTEGRATION = get(ENV, "CI", nothing) == "true"
1818

1919
# Python and Julia dependencies needed for running the notebooks
2020
# PYDEPS = ["ase", "pymatgen"]
21-
JLDEPS = [
22-
Pkg.PackageSpec(url="https://github.com/louisponet/DFControl.jl.git",
23-
rev=LibGit2.head(ROOTPATH)), # The current DFControl
24-
]
21+
JLDEPS = [Pkg.PackageSpec(; url = "https://github.com/louisponet/DFControl.jl.git",
22+
rev = LibGit2.head(ROOTPATH))]
2523

2624
# Setup julia dependencies for docs generation if not yet done
2725
Pkg.activate(@__DIR__)
2826
if !isfile(joinpath(@__DIR__, "Manifest.toml"))
29-
Pkg.develop(Pkg.PackageSpec(path=ROOTPATH))
27+
Pkg.develop(Pkg.PackageSpec(; path = ROOTPATH))
3028
Pkg.instantiate()
31-
Pkg.add(url="https://github.com/kimikage/Documenter.jl", rev="ansicolor")
29+
Pkg.add(; url = "https://github.com/kimikage/Documenter.jl", rev = "ansicolor")
3230
end
3331

3432
# Setup environment for making plots
@@ -44,19 +42,24 @@ using Literate
4442
# Collect examples from the example index (src/index.md)
4543
# The chosen examples are taken from the examples/ folder to be processed by Literate
4644
EXAMPLES = [String(m[1])
47-
for m in match.(r"\"(examples/[^\"]+.md)\"",
48-
readlines(joinpath(SRCPATH, "index.md")))
49-
if !isnothing(m)]
45+
for m in
46+
match.(r"\"(examples/[^\"]+.md)\"",
47+
readlines(joinpath(SRCPATH, "index.md"))) if !isnothing(m)]
5048

5149
# Collect files to treat with Literate (i.e. the examples and the .jl files in the docs)
5250
# The examples go to docs/literate_build/examples, the .jl files stay where they are
53-
literate_files = NamedTuple{(:src, :dest, :example), Tuple{String, String, Bool}}[(src=joinpath(ROOTPATH, splitext(file)[1] * ".jl"),
54-
dest=joinpath(SRCPATH, "examples"), example=true)
55-
for file in EXAMPLES]
51+
literate_files = NamedTuple{(:src, :dest, :example),Tuple{String,String,Bool}}[(src = joinpath(ROOTPATH,
52+
splitext(file)[1] *
53+
".jl"),
54+
dest = joinpath(SRCPATH,
55+
"examples"),
56+
example = true)
57+
for file in
58+
EXAMPLES]
5659
for (dir, directories, files) in walkdir(SRCPATH)
5760
for file in files
5861
if endswith(file, ".jl")
59-
push!(literate_files, (src=joinpath(dir, file), dest=dir, example=false))
62+
push!(literate_files, (src = joinpath(dir, file), dest = dir, example = false))
6063
end
6164
end
6265
end
@@ -68,56 +71,44 @@ for file in literate_files
6871
# preprocess=preprocess)
6972
# Literate.notebook(file.src, file.dest; credit=false,
7073
# execute=CONTINUOUS_INTEGRATION || DEBUG)
71-
Literate.markdown(file.src, file.dest; documenter=true, credit=false)
72-
Literate.notebook(file.src, file.dest; credit=false,
73-
execute=CONTINUOUS_INTEGRATION || DEBUG)
74+
Literate.markdown(file.src, file.dest; documenter = true, credit = false)
75+
Literate.notebook(file.src, file.dest; credit = false,
76+
execute = CONTINUOUS_INTEGRATION || DEBUG)
7477
end
7578

7679
# Generate the docs in BUILDPATH
77-
makedocs(
78-
modules = [DFControl],
79-
format = Documenter.HTML(
80-
# Use clean URLs, unless built as a "local" build
81-
prettyurls = CONTINUOUS_INTEGRATION,
82-
canonical = "https://louisponet.github.io/DFControl.jl/stable/",
83-
assets = ["assets/favicon.ico"],
84-
),
85-
sitename = "DFControl.jl",
86-
authors = "Louis Ponet",
87-
linkcheck = false, # TODO
88-
linkcheck_ignore = [
89-
# Ignore links that point to GitHub's edit pages, as they redirect to the
90-
# login screen and cause a warning:
91-
r"https://github.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)/edit(.*)",
92-
],
93-
pages = [
94-
"Home" => "index.md",
95-
"Getting started" => Any[
96-
"guide/installation.md",
97-
"guide/configuration.md",
98-
"Basic Tutorial" => "guide/basic_tutorial.md",
99-
"Advanced Tutorial" => "guide/advanced_tutorial.md"
100-
],
101-
"Usage" => Any[
102-
"guide/jobs.md",
103-
"guide/calculations.md",
104-
"guide/structure.md",
105-
],
106-
# "Examples" => EXAMPLES,
107-
"api.md",
108-
# "publications.md",
109-
],
110-
# strict = !DEBUG,
111-
)
80+
makedocs(; modules = [DFControl],
81+
format = Documenter.HTML(
82+
# Use clean URLs, unless built as a "local" build
83+
; prettyurls = CONTINUOUS_INTEGRATION,
84+
canonical = "https://louisponet.github.io/DFControl.jl/stable/",
85+
assets = ["assets/favicon.ico"]),
86+
sitename = "DFControl.jl", authors = "Louis Ponet", linkcheck = false, # TODO
87+
linkcheck_ignore = [
88+
# Ignore links that point to GitHub's edit pages, as they redirect to the
89+
# login screen and cause a warning:
90+
r"https://github.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)/edit(.*)"],
91+
pages = ["Home" => "index.md",
92+
"Getting started" => Any["guide/installation.md",
93+
"guide/configuration.md",
94+
"Basic Tutorial"=>"guide/basic_tutorial.md",
95+
"Advanced Tutorial"=>"guide/advanced_tutorial.md"],
96+
"Usage" => Any["guide/jobs.md", "guide/calculations.md",
97+
"guide/structure.md",],
98+
# "Examples" => EXAMPLES,
99+
"api.md"
100+
# "publications.md",
101+
]
102+
# strict = !DEBUG,
103+
)
112104

113105
# Dump files for managing dependencies in binder
114106
if CONTINUOUS_INTEGRATION
115107
cd(BUILDPATH) do
116108
open("environment.yml", "w") do io
117-
print(io,
118-
"""
119-
name: dfcontrol
120-
""")
109+
return print(io, """
110+
name: dfcontrol
111+
""")
121112
end
122113

123114
# Install Julia dependencies into build
@@ -130,16 +121,14 @@ if CONTINUOUS_INTEGRATION
130121
end
131122

132123
# Deploy docs to gh-pages branch
133-
deploydocs(
134-
repo = "github.com/louisponet/DFControl.jl.git",
135-
)
124+
deploydocs(; repo = "github.com/louisponet/DFControl.jl.git")
136125

137126
# Remove generated example files
138127
if !DEBUG
139128
for file in literate_files
140129
base = splitext(basename(file.src))[1]
141130
for ext in [".ipynb", ".md"]
142-
rm(joinpath(file.dest, base * ext), force=true)
131+
rm(joinpath(file.dest, base * ext); force = true)
143132
end
144133
end
145134
end

docs/src/guide/advanced_tutorial.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,35 @@
66
# in it.
77
using DFControl
88

9-
tjob = DFJob(joinpath(pathof(DFControl), "..","..","docs", "src", "assets", "job"))#hide
10-
tjob2 = DFJob(joinpath(pathof(DFControl), "..","..", "docs", "src", "assets", "Job2"))#hide
9+
tjob = DFJob(joinpath(pathof(DFControl), "..", "..", "docs", "src", "assets", "job"))#hide
10+
tjob2 = DFJob(joinpath(pathof(DFControl), "..", "..", "docs", "src", "assets", "Job2"))#hide
1111
if false#hide
12-
global job = DFJob("job")
12+
global job = DFJob("job")
1313
else#hide
14-
global job = deepcopy(tjob)#hide
15-
set_localdir!(job, "job"); #hide
16-
job#hide
14+
global job = deepcopy(tjob)#hide
15+
set_localdir!(job, "job") #hide
16+
job#hide
1717
end#hide
1818

1919
# Since the job created in the [Basic Tutorial](@ref) was saved in the "job" directory this will work, see the section on [Jobs](@ref) for
2020
# further details and options on how to load previously saved jobs.
2121

2222
# The next thing we may want to do is to change the directory where the job is running.
2323
if false#hide
24-
set_localdir!(job, "Job2", copy=true)
24+
set_localdir!(job, "Job2"; copy = true)
2525
else#hide
26-
global job = deepcopy(tjob2);#hide
27-
pop!(job);#hide
28-
pop!(job);#hide
29-
job#hide
26+
global job = deepcopy(tjob2)#hide
27+
pop!(job)#hide
28+
pop!(job)#hide
29+
job#hide
3030
end#hide
3131
# With the `copy=true` flag we let DFControl know that not only to create and set the
3232
# new directory, but also to copy the previous results and temporary files to the
3333
# new directory so we don't have to rerun the scf calculation.
3434

3535
# Next we would like to plot the projected density of states.
3636
# For that we create both an nscf calculation to get a uniform k-grid, and projwfc calculation.
37-
push!(job, gencalc_nscf(job["scf"], (6,6,6)))
37+
push!(job, gencalc_nscf(job["scf"], (6, 6, 6)))
3838

3939
# The second argument of gencalc_nscf is the kgrid. When passing a 3-Tuple,
4040
# the code will assume that an explicit k-grid is requested, which can be verified by
@@ -44,13 +44,13 @@ data(job["nscf"], :k_points)
4444
# energy window.
4545
# The arguments are structured as (template, Emin, Emax, deltaE) respectively.
4646
fermi = readfermi(job)
47-
push!(job, gencalc_projwfc(job["nscf"], fermi-10, fermi+1, 0.1))
47+
push!(job, gencalc_projwfc(job["nscf"], fermi - 10, fermi + 1, 0.1))
4848
# Next we disable the bands calculation and run the new ones.
4949
job["bands"].run = false
5050
if false#hide
51-
submit(job)
51+
submit(job)
5252
else#hide
53-
global job = deepcopy(tjob2)#hide
53+
global job = deepcopy(tjob2)#hide
5454
end#hide
5555

5656
# ## [Plot Results](@id results_plotting)

docs/src/guide/basic_tutorial.jl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using DFControl
1212
using Downloads
1313
cif_file = Downloads.download("http://www.crystallography.net/cod/9011998.cif", "Si.cif")
1414

15-
structure = Structure(cif_file, name="Si")
15+
structure = Structure(cif_file; name = "Si")
1616
set_pseudos!(structure, :pbesol)
1717

1818
# This assumes that the `:pbesol` pseudopotential set was installed during the
@@ -31,20 +31,18 @@ pw_execs = [Exec("mpirun", "", :np => 4), Exec("pw.x", "/opt/qe/bin/", :nk => 4)
3131
# Then we create the first calculation for our job, we name it scf, which will be used to reference it later.
3232
# We also pass the executables to be used and additional flags to be set to the constructor.
3333
# Afterwards we set the kpoints to be used in the scf calculation.
34-
scf_calculation = DFCalculation{QE}("scf", :calculation => "scf", execs=pw_execs)
35-
set_kpoints!(scf_calculation, (6,6,6,1,1,1))
34+
scf_calculation = DFCalculation{QE}("scf", :calculation => "scf"; execs = pw_execs)
35+
set_kpoints!(scf_calculation, (6, 6, 6, 1, 1, 1))
3636

3737
# The code recognizes internally that this 6-Tuple corresponds to a
3838
# `K_POINTS (automatic)` block in QE. Alternatively (leading to an identical final result):
3939

40-
scf_calculation = DFCalculation{QE}("scf", :calculation => "scf",
41-
execs=pw_execs,
42-
data=[InputData(:k_points, :automatic, (6,6,6,1,1,1))])
40+
scf_calculation = DFCalculation{QE}("scf", :calculation => "scf"; execs = pw_execs,
41+
data = [InputData(:k_points, :automatic,
42+
(6, 6, 6, 1, 1, 1))])
4343

4444
# We can now define our job:
45-
job = DFJob("Si", structure, [scf_calculation],
46-
:ecutwfc => 20,
47-
:conv_thr => 1e-6,
45+
job = DFJob("Si", structure, [scf_calculation], :ecutwfc => 20, :conv_thr => 1e-6;
4846
local_dir = "job")
4947

5048
# Additional calculations would be be added to the list `[scf_calculation]`.
@@ -53,10 +51,10 @@ job = DFJob("Si", structure, [scf_calculation],
5351

5452
# We are now ready to submit the job, which will run in the current working directory
5553
if false #hide
56-
submit(job)
54+
submit(job)
5755
else #hide
58-
global job = DFJob(joinpath(@__DIR__, "../../src/assets/job/"))#hide
59-
pop!(job); #hide
56+
global job = DFJob(joinpath(@__DIR__, "../../src/assets/job/"))#hide
57+
pop!(job) #hide
6058
end #hide
6159

6260
# This will generate and save all calculation files, and the corresponding job script (`job.tt`),
@@ -93,9 +91,10 @@ job
9391
# Seeing that all is right we submit the job again
9492
set_localdir!(job, "job"); #hide
9593
if false #hide
96-
submit(job)
94+
submit(job)
9795
else #hide
98-
global job = DFJob(joinpath(pathof(DFControl), "..","..", "docs", "src", "assets", "job"));#hide
96+
global job = DFJob(joinpath(pathof(DFControl), "..", "..", "docs", "src", "assets",
97+
"job"))#hide
9998
end #hide
10099

101100
# We can access the bands through
@@ -106,7 +105,7 @@ bands = outputdata(job["bands"])[:bands];
106105
# They can be plotted too
107106
fermi = readfermi(job) # = outputdata(job["scf"])[:fermi]
108107
using Plots
109-
plot(bands, fermi=fermi)
108+
plot(bands; fermi = fermi)
110109

111110
# Since more info (such as the structure) is available in the job,
112111
# plotting the job leads to a richer plot

0 commit comments

Comments
 (0)