Skip to content

Commit

Permalink
a little bit more consistent wancalc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Jul 4, 2019
1 parent c8e6737 commit 39498fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function Emin_from_projwfc(structure::AbstractStructure, projwfc::DFInput{QE}, t

end
if Emin == -10000.0
error("Couldn't find any band with occupation of relevant projections above $threshold.")
error("Couldn't find any band with occupation of relevant projections above $threshold, were any set in the structure?")
end
return Emin
end
Expand Down
18 changes: 8 additions & 10 deletions src/inputAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,15 @@ function gencalc_projwfc(template::DFInput, Emin, Emax, DeltaE, extraflags...; n
end

"""
gencalc_wan(structure::AbstractStructure, nscf::DFInput{QE}, Emin;
gencalc_wan(nscf::DFInput{QE}, structure::AbstractStructure, Emin;
Epad = 5.0,
wanflags = nothing,
wanexec = Exec("wannier90.x", ""))
Generates a Wannier90 input from the supplied Structure, Emin, nscf calculation and projections.
The nscf needs to have an bandsoutput because it will be used to find the energy range
for the frozen window of the Wannier90 calculation.
Currently only works with QE.
Generates a Wannier90 input to follow on the supplied `nscf` calculation. It uses the projections defined in the `structure`, and starts counting the required amount of bands from `Emin`.
The `nscf` needs to have a valid output since it will be used in conjunction with `Emin` to find the required amount of bands and energy window for the Wannier90 calculation.
"""
function gencalc_wan(structure::AbstractStructure, nscf::DFInput{QE}, Emin;
function gencalc_wan(nscf::DFInput{QE}, structure::AbstractStructure, Emin;
Epad = 5.0,
wanflags = nothing,
wanexec = Exec("wannier90.x", ""))
Expand Down Expand Up @@ -342,7 +340,7 @@ function gencalc_wan(structure::AbstractStructure, nscf::DFInput{QE}, Emin;
wanflags[:preprocess] = true
@info "mp_grid=$(join(wanflags[:mp_grid]," ")) (inferred from nscf input)."

isnoncolincalc(nscf) && (wanflags[:nspinor] = 2)
isnoncolincalc(nscf) && (wanflags[:spinors] = true)

kdata = InputData(:kpoints, :none, [k[1:3] for k in kpoints])

Expand All @@ -359,13 +357,13 @@ function gencalc_wan(structure::AbstractStructure, nscf::DFInput{QE}, Emin;
end

"""
gencalc_wan(structure::AbstractStructure, nscf::DFInput{QE}, projwfc::DFInput{QE}, threshold::Real; kwargs...)
gencalc_wan(nscf::DFInput{QE}, structure::AbstractStructure, projwfc::DFInput{QE}, threshold::Real; kwargs...)
Generates a wannier calculation. Instead of passing Emin manually, the output of a projwfc.x run
Generates a wannier calculation, that follows on the `nscf` calculation. Instead of passing Emin manually, the output of a projwfc.x run
can be used together with a `threshold` to determine the minimum energy such that the contribution of the
projections to the DOS is above the `threshold`.
"""
function gencalc_wan(structure::AbstractStructure, nscf::DFInput{QE}, projwfc::DFInput{QE}, threshold::Real; kwargs...)
function gencalc_wan(nscf::DFInput{QE}, structure::AbstractStructure, projwfc::DFInput{QE}, threshold::Real; kwargs...)
hasexec_assert(projwfc, "projwfc.x")
hasoutput_assert(projwfc)
Emin = Emin_from_projwfc(structure, projwfc, threshold)
Expand Down
5 changes: 2 additions & 3 deletions test/job_control_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ out = outputdata(job;print=false,onlynew=false);

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

@test data(nscf2, :testdata).option == :testoption
Expand Down Expand Up @@ -50,7 +49,7 @@ push!(job, gencalc_scf(job["scf"], (5,5,5,1,1,1), name="1scf2"))
wanflags = [:write_hr => true, :wannier_plot => true]

setprojections!(job, :Pt => [:s, :p, :d])
wancalc = gencalc_wan(structure(job), searchinput(job, "nscf"), fermi-7.0; Epad=5.0, wanflags=wanflags)
wancalc = gencalc_wan(job["nscf"], structure(job), fermi-7.0; Epad=5.0, wanflags=wanflags)
push!.((job,), wancalc)
@test job["wan"][:write_hr] == job["wan"][:wannier_plot] == true

Expand All @@ -75,7 +74,7 @@ job["nscf"][:starting_magnetization] = [[1.0, 2.0, 1.0]]

job["nscf"][:Hubbard_J] = [0 1 2]
@test job["nscf"][:Hubbard_J] == [0 1 2]
push!.((job,), gencalc_wan(structure(job), nscf, fermi-7.0, Epad=5.0, wanflags=wanflags))
push!.((job,), gencalc_wan(nscf, structure(job), fermi-7.0, Epad=5.0, wanflags=wanflags))

#TODO: add test with the new wancalc from projwfc

Expand Down

0 comments on commit 39498fa

Please sign in to comment.