Calculations

Contents

Index

DFControl.Calculations.CalculationType
Calculation{P<:Package}(name    ::String;
                        flags   ::AbstractDict = Dict{Symbol, Any}(),
                        data    ::Vector{InputData} = InputData[],
                        exec    ::Exec,
                        run     ::Bool = true,
                        infile  ::String = P == Wannier90 ? name * ".win" : name * ".in",
                        outfile ::String = name * ".out")

The representation of a DFT calculation of package P, holding the flags that will be written to the infile, the executable exec and the output written by the calculation to the outfile. It essentially represents a line in a job script similar to exec < infile.in > outfile.out. outdata stores the parsed calculation output after it was read at least once. The run field indicates whether the calculation should be actually performed, e.g. if run=false the corresponding line will be commented out in the job script.

Calculation{P<:Package}(name::AbstractString, flags::Pair{Symbol, Any}...; kwargs...)

Create a Calculation from name and flags, other kwargs... will be passed to the constructor.

Calculation(template::Calculation, name::AbstractString, flags::Pair{Symbol, Any}...; excs=deepcopy(template.exec), run=true, data=nothing)

Creates a new Calculation from the template, setting the flags of the newly created one to the specified ones.

source
DFControl.Calculations.InputDataType
InputData(name::Symbol, option::Symbol, data::Any)

Represents a more structured block of input data. e.g. InputData(:k_points, :automatic, (6,6,6,1,1,1)) would be translated for a QE calculation into

K_POINTS(automatic)
6 6 6 1 1 1
source

Basic interaction

DFControl.Calculations.set_name!Function
set_name!(c::Calculation, name::AbstractString)

Sets calculation.name, and calculation.infile and calculation.outfile to conform with the new name.

source
DFControl.Calculations.set_kpoints!Function
set_kpoints!(calculation::Calculation{QE}, k_grid::NTuple{3, Int}; print=true)
set_kpoints!(calculation::Calculation{QE}, k_grid::NTuple{6, Int}; print=true)
set_kpoints!(calculation::Calculation{QE}, k_grid::Vector{<:NTuple{4}}; print=true, k_option=:crystal_b)

Convenience function to set the :k_points data block of calculation. The three different methods are targeted at nscf, scf or vcrelax, and bands calculations, respectively. For the nscf version an explicit list of k_points will be generated.

set_kpoints!(calculation::Calculation{Wannier90}, k_grid::NTuple{3, Int})

Similar to the nscf targeted function in the sense that it will generate an explicit list of k_points, adhering to the same rules as for the nscf. The mp_grid flag will also automatically be set.

source

Flags

A big part of working with DFT calculations is specifying the various calculation flags. Remembering all the names of the flags, where they belong, and what types they are expected to be, is quite complicated and can lead to easily made mistakes like typos. DFControl tries to catch these as it knows which flags are allowed for which calculations. It will report when a flag can not be found for a given Calculation, and it will also try to convert a flag value to the expected type.

A Calculation behaves a lot as a normal Dict to interact with the stored flags. This means that the usual Dict operations such as haskey, get, and pop! work on a Calculation.

Base.getindexMethod
getindex(c::Calculation, n::Symbol)

Returns the flag with given symbol.

getindex(job::Job, flag::Symbol)

Searches through the job's calculations for the requested flag. A Dict will be returned with calculation names as the keys and the flags as values.

source
Base.setindex!Method
setindex!(c::Calculation, value, flag::Symbol)

Sets flags.

setindex!(job::Job, value, flag::Symbol)

Set flag in all the appropriate calculations to the value.

source
DFControl.Calculations.set_flags!Function
set_flags!(c::Calculation, flags::Pair{Symbol, Any}...; print=true, force=false)

Sets multiple flags in one go. Flag validity and type are verified.

set_flags!(job::Job, calculations::Vector{<:Calculation}, flags::Pair{Symbol,<:Any}...; print=true)
set_flags!(job::Job, flags::Pair{Symbol,<:Any}...; print=true)

Sets the flags in the names to the flags specified. This only happens if the specified flags are valid for the names.

source

Execs

DFControl.Calculations.ExecType
Exec(;exec::String = "", dir::String = "", flags::Vector{ExecFlag} = ExecFlag[])

Representation of an executable that will run the Calculation. Basically dir/exec --<flags> inside a job script.

Exec(exec::String, dir::String, flags::Pair{Symbol}...)

Will first transform flags into a Vector{ExecFlag}, and construct the Exec.

source

Generating new calculations

DFControl.Calculations.gencalc_vcrelaxMethod
gencalc_vcrelax(template::Calculation{QE}, kpoints::NTuple{6, Int}, newflags...; name="scf")

Uses the information from the template and supplied kpoints to generate a vcrelax calculation. Extra flags can be supplied which will be set for the generated calculation.

source
DFControl.Calculations.gencalc_scfMethod
gencalc_scf(template::Calculation{QE}, kpoints::NTuple{6, Int}, newflags...; name="scf")

Uses the information from the template and supplied kpoints to generate an scf calculation. Extra flags can be supplied which will be set for the generated calculation.

source
DFControl.Calculations.gencalc_bandsMethod
gencalc_bands(template::Calculation{QE}, kpoints::Vector{NTuple{4}}, newflags...; name="bands")

Uses the information from the template and supplied kpoints to generate a bands calculation. Extra flags can be supplied which will be set for the generated calculation.

source
DFControl.Calculations.gencalc_nscfMethod
gencalc_nscf(template::Calculation{QE}, kpoints::NTuple{3, Int}, newflags...; name="nscf")

Uses the information from the template and supplied kpoints to generate an nscf calculation. Extra flags can be supplied which will be set for the generated calculation.

source
DFControl.Calculations.gencalc_projwfcMethod
gencalc_projwfc(template::Calculation{QE}, Emin, Emax, DeltaE, newflags...; name="projwfc")

Uses the information from the template and supplied kpoints to generate a projwfc.x calculation. Extra flags can be supplied which will be set for the generated calculation.

source
DFControl.Calculations.gencalc_wanFunction
gencalc_wan(nscf::Calculation{QE}, structure::Structure, Emin, wanflags...;
            Epad     = 5.0,
            wanexec  = Exec(exec="wannier90.x", dir=""))

Generates a Wannier90 calculation 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.

source
gencalc_wan(job::Job, min_window_determinator::Real, extra_wan_flags...; kwargs...)

Automates the generation of wannier calculations based on the job. When a projwfc calculation is present in the job, min_window_determinator will be used to determine the threshold value for including a band in the window based on the projections, otherwise it will be used as the Emin value from which to start counting the number of bands needed for all projections. extra_wan_flags can be any extra flags for the Wannier90 calculation such as write_hr etc.

source