Skip to content

Commit

Permalink
Commented out all Abinit functionality for now, added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed May 26, 2018
1 parent b815228 commit 0b1ee1c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/constants.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assets_dir = joinpath(@__DIR__, "../assets/")
const conversions = Dict{Symbol,Float64}(:bohr2ang => 0.529177)
conversions[:ang2bohr] = 1/conversions[:bohr2ang]
include("abinit/constants.jl")
# include("abinit/constants.jl")
include("qe/constants.jl")
include("wannier90/constants.jl")
2 changes: 1 addition & 1 deletion src/fileio.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include("qe/fileio.jl")
include("abinit/fileio.jl")
# include("abinit/fileio.jl")
include("wannier90/fileio.jl")


Expand Down
15 changes: 7 additions & 8 deletions src/input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ function DFInput(template::DFInput, filename, newflags...; excs=execs(template),
input = deepcopy(template)
input.filename = filename
input.execs = excs
setflags!(input, newflags...)
setflags!(input, newflags..., print=false)

if data != nothing
for (name, (option, data)) in data
setdata!(input, name, data, option=option)
setdata!(input, name, data, option=option, print=false)
end
end
return input
Expand Down Expand Up @@ -66,8 +66,7 @@ end

function setkpoints!(input::DFInput{QE}, k_grid::NTuple{6, Int}; print=true) #scf
calc = flag(input, :calculation)
@assert calc == "'scf'" || contains(calc, "relax") warn("Expected calculation to be 'scf', 'vc-relax', 'relax'.\nGot $calc.")

(calc == "'scf'" || contains(calc, "relax")) && warn("Expected calculation to be 'scf', 'vc-relax', 'relax'.\nGot $calc.")
setdata!(input, :k_points, [k_grid...], option = :automatic, print=print)
return input
end
Expand All @@ -80,8 +79,8 @@ sets the data in the k point `DataBlock` inside the specified calculation. The f
"""
function setkpoints!(input::DFInput{QE}, k_grid::Vector{NTuple{4, T}}; print=true, k_option=:crystal_b) where T<:AbstractFloat
calc = flag(input, :calculation)
@assert calc == "'bands'" warn("Expected calculation to be 'bands', got $calc.")
@assert k_option in [:tpiba_b, :crystal_b, :tpiba_c, :crystal_c] error("Only $([:tpiba_b, :crystal_b, :tpiba_c, :crystal_c]...) are allowed as a k_option, got $k_option.")
calc == "'bands'" && warn("Expected calculation to be 'bands', got $calc.")
@assert in(k_option, [:tpiba_b, :crystal_b, :tpiba_c, :crystal_c]) error("Only $([:tpiba_b, :crystal_b, :tpiba_c, :crystal_c]...) are allowed as a k_option, got $k_option.")
if k_option in [:tpiba_c, :crystal_c]
@assert length(k_grid) == 3 error("If $([:tpiba_c, :crystal_c]...) is selected the length of the k_points needs to be 3, got length: $(length(k_grid)).")
end
Expand All @@ -91,13 +90,13 @@ function setkpoints!(input::DFInput{QE}, k_grid::Vector{NTuple{4, T}}; print=tru
num_k += k[4]
end
if num_k > 100.
setflags!(input, :verbosity => "'high'")
setflags!(input, :verbosity => "'high'", print=print)
if print
dfprintln("Verbosity is set to high because num_kpoints > 100,\n
otherwise bands won't get printed.")
end
end
setdata!(input, :k_points, k_grid, option = k_option, print = print)
setdata!(input, :k_points, k_grid, option = k_option, print=print)
return input
end

Expand Down
16 changes: 15 additions & 1 deletion test/job_control_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ testjobpath = joinpath(@__DIR__, "testassets/test_job/")
job = DFJob(testjobpath);

nscf = DFControl.input(job, "nscf")
nscf2 = DFInput(nscf, "nscf2.in", data=[:testdata => (:testoption, "test")])
nscf2 = DFInput(nscf, "nscf2.in", data=[:testdata => (:testoption, "test"), :k_points => (:blabla, [1,1,1,1,1,1])])

@test data(job, "nscf2", :testdata) == nothing
@test data(nscf2, :testdata).option == :testoption
@test data(nscf2, :testdata).data == "test"
@test data(nscf2, :testdata).name == :testdata
@test data(nscf2, :k_points).option == :blabla
@test data(nscf2, :k_points).data == [1,1,1,1,1,1]

setkpoints!(nscf2, (3,3,3), print=false)
@test data(nscf2, :k_points).data == kgrid(3, 3, 3, :nscf)


setkpoints!(nscf2, [(3.,3.,3.,1.), (3.,3.,3.,1.)], print=false)
@test data(nscf2, :k_points).option == :crystal_b
@test data(nscf2, :k_points).data == [(3.,3.,3.,1.), (3.,3.,3.,1.)]

setkpoints!(nscf2, (3,3,3,0,0,1), print=false)
@test data(nscf2, :k_points).option == :automatic
@test data(nscf2, :k_points).data == [3,3,3,0,0,1]

fermi = read_qe_output(outpath(job, "nscf"))[:fermi]
@test fermi == read_fermi_from_qe_output(job.local_dir * "nscf.out")
Expand Down

0 comments on commit 0b1ee1c

Please sign in to comment.