wfl.calculators package#
Subpackages#
- wfl.calculators.orca package
- Submodules
- wfl.calculators.orca.basinhopping module
- Module contents
ORCA
ORCA.calculate()
ORCA.cleanup()
ORCA.default_parameters
ORCA.get_default_multiplicity()
ORCA.implemented_properties
ORCA.is_converged()
ORCA.pick_task()
ORCA.read_dipole()
ORCA.read_frequencies()
ORCA.read_opt_atoms()
ORCA.read_results()
ORCA.read_trajectory()
ORCA.wfl_generic_default_autopara_info
ORCA.write_input()
natural_population_analysis()
parse_npa_output()
Submodules#
wfl.calculators.aims module#
FHI-Aims Calculator
- class wfl.calculators.aims.Aims(keep_files='default', rundir_prefix='run_Aims_', workdir=None, scratchdir=None, calculator_exec=None, **kwargs)#
Bases:
WFLFileIOCalculator
,Aims
Extension of ASE’s Aims calculator that can be used by wfl.calculators.generic.
The
`directory`
argument from the basic calculator implementation in ASE cannot be present. Use`rundir_prefix`
and`workdir`
instead.Note that in case the Calculator detects a structure that is non-periodic invalid keywords will automatically be removed. Specifically, all keywords that start with ‘k_’, contain the sub-string ‘k_grid’ or ‘stress’ or are equal to ‘relax_unit_cell’ or ‘external_pressure’ will be removed.
- Parameters
keep_files (bool / None / "default" / list(str), default "default") –
- What kind of files to keep from the run:
True : Everything kept.
None, False : Nothing kept, unless calculation fails.
”default” : Only ones needed for NOMAD uploads (‘control.in’, ‘geometry.in’, ‘aims.out’) are kept.
list(str) : List of file globs to save.
rundir_prefix (str / Path, default 'run_Aims_') – Run directory name prefix.
workdir (str / Path, default . at calculate time) – Path in which the run directory will be created.
scratchdir (str / Path, default None) – Temporary directory to execute calculations in and delete or copy back results (set by
`keep_files`
) if needed. For example, directory on a local disk with fast file I/O.calculator_exec (str) – command for Aims, without any prefix or redirection set. For example: “srun -n 4 /path/to/aims.*.scalapack.mpi.x”. Mutually exclusive with
`command`
.**kwargs (arguments for ase.calculators.aims.Aims) – See https://wiki.fysik.dtu.dk/ase/_modules/ase/calculators/aims.html.
- calculate(atoms=None, properties=['energy', 'forces', 'stress'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])#
Do the calculation.
Handles the working directories in addition to regular ASE calculation operations (writing input, executing, reading_results). Reimplements and extends GenericFileIOCalculator.calculate() for the development version of ASE or FileIOCalculator.calculate() for the v3.22.1.
Parameter:#
- atoms: ASE-Atoms object
Atomistic system to be calculated.
- properties: list(str)
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list(str)
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
- implemented_properties: List[str] = ['energy', 'forces', 'stress']#
Properties calculator can handle (energy, forces, …)
- wfl_generic_default_autopara_info = {'num_inputs_per_python_subprocess': 1}#
wfl.calculators.castep module#
Quantum Castep interface
- class wfl.calculators.castep.Castep(keep_files='default', rundir_prefix='run_CASTEP_', workdir=None, scratchdir=None, calculator_exec=None, **kwargs)#
Bases:
WFLFileIOCalculator
,Castep
Extension of ASE’s Castep calculator that can be used by wfl.calculators.generic
“directory” argument cannot be present. Use rundir_prefix and workdir instead.
- Parameters
keep_files (bool / None / "default" / list(str), default "default") –
- what kind of files to keep from the run
True : everything kept
None, False : nothing kept, unless calculation fails
”default” : only ones needed for NOMAD uploads (‘*.pwo’)
list(str) : list of file globs to save
rundir_prefix (str / Path, default 'run_CASTEP_') – Run directory name prefix
workdir (str / Path, default . at calculate time) – Path in which rundir will be created.
scratchdir (str / Path, default None) – temporary directory to execute calculations in and delete or copy back results (set by “keep_files”) if needed. For example, directory on a local disk with fast file I/O.
calculator_exec (str) – command for Castep, without any prefix or redirection set. for example: “mpirun -n 4 castep.mpi” Alternative for “castep_command”, for consistency with other wfl calculators.
**kwargs (arguments for ase.calculators.Castep.Castep) –
- calculate(atoms=None, properties=['energy', 'forces', 'stress'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])#
Do the calculation. Handles the working directories in addition to regular ASE calculation operations (writing input, executing, reading_results) Reimplements & extends GenericFileIOCalculator.calculate() for the development version of ASE or FileIOCalculator.calculate() for the v3.22.1
- implemented_properties: List[str] = ['energy', 'forces', 'stress']#
Properties calculator can handle (energy, forces, …)
- setup_calc_params(properties)#
- wfl_generic_default_autopara_info = {'num_inputs_per_python_subprocess': 1}#
wfl.calculators.committee module#
Committee of Models
Calculated properties with a list of models and saves them into info/arrays. Further operations (eg. mean, variance, etc.) with these are up to the user.
- wfl.calculators.committee.calculate_committee(atoms, calculator_list, properties=None, output_prefix='committee_{}_')#
Calculate energy and forces with a committee of models
Notes
Supports formatter string in the output_prefix arg, but currently only with a single field literally “{}”.
- Parameters
atoms (Atoms / list(Atoms)) – input atomic configs
calculator_list (list(Calculator) / list[(initializer, args, kwargs)]) – list of calculators to use as a committee of models on the configs
properties (list[str], default ['energy', 'forces', 'stress']) – properties to calculate
output_prefix (str, default="committee_") – prefix for results coming from the committee of models. If includes “{}” then will use it as a format string, otherwise puts a number at the end of prefix for the index of the model in the committee of models
- Returns
atoms
- Return type
Atoms / list(Atoms)
wfl.calculators.espresso module#
Quantum Espresso interface
- class wfl.calculators.espresso.Espresso(keep_files='default', rundir_prefix='run_QE_', workdir=None, scratchdir=None, calculator_exec=None, **kwargs)#
Bases:
WFLFileIOCalculator
,Espresso
Extension of ASE’s Espresso calculator that can be used by wfl.calculators.generic
“directory” argument cannot be present. Use rundir_prefix and workdir instead.
- Parameters
keep_files (bool / None / "default" / list(str), default "default") –
- what kind of files to keep from the run
True : everything kept
None, False : nothing kept, unless calculation fails
”default” : only ones needed for NOMAD uploads (‘*.pwo’)
list(str) : list of file globs to save
rundir_prefix (str / Path, default 'run_QE_') – Run directory name prefix
workdir (str / Path, default . at calculate time) – Path in which rundir will be created.
scratchdir (str / Path, default None) – temporary directory to execute calculations in and delete or copy back results (set by “keep_files”) if needed. For example, directory on a local disk with fast file I/O.
calculator_exec (str) – command for QE, without any prefix or redirection set. for example: “mpirun -n 4 /path/to/pw.x” mutually exclusive with “command” with “profile”
**kwargs (arguments for ase.calculators.espresso.Espresso) –
- calculate(atoms=None, properties=['energy', 'forces', 'stress'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])#
Do the calculation. Handles the working directories in addition to regular ASE calculation operations (writing input, executing, reading_results) Reimplements & extends GenericFileIOCalculator.calculate() for the development version of ASE or FileIOCalculator.calculate() for the v3.22.1
- implemented_properties: List[str] = ['energy', 'forces', 'stress']#
Properties calculator can handle (energy, forces, …)
- setup_calc_params(properties)#
Setup calculator params based on atoms structure (pbc) and requested properties
- wfl_generic_default_autopara_info = {'num_inputs_per_python_subprocess': 1}#
wfl.calculators.generic module#
- wfl.calculators.generic.calculate(*args, **kwargs)#
evaluates configs using an arbitrary calculator and store results in info/arrays entries or SinglePointCalculator.
Defaults to wfl_num_inputs_per_python_subprocess=10, to avoid recreating the calculator for each configuration, unless calculator class defines a wfl_generic_default_autopara_info attribute in which case that value is used for the default.
If Atoms.info contains ‘WFL_CALCULATOR_INITIALIZER’, ‘WFL_CALCULATOR_ARGS’ or ‘WFL_CALCULATOR_KWARGS’, an individual calculator will be created for that Atoms object. The initializer and *args will be _overridden_ by the corresponding Atoms.info entries, but the **kwargs will be _modified_ (dict.update) by the Atoms.info entry.
- Parameters
inputs (iterable(Atoms)) – input quantities of type Atoms
outputs (OutputSpec or None) – where to write output atomic configs, or None for no output (i.e. only side-effects)
calculator (Calculator / (initializer (callable), args (list), kwargs (dict))) – ASE calculator or routine to call to create calculator. If ‘WFL_CALCULATOR_ARGS’ …_INITIALIZER, or …_KWARGS are present in any Atoms.info dicts, calculator _must_ be a 3-tuple so that those initializer, *args or **kwargs can be used to override defaults.
properties (list(str), default ['energy', 'forces', stress']) – Properties to request from calculator. If any are not present after calculation (e.g. stress for nonperiodic configurations), a warning will be printed.
output_prefix (str, default _auto_) – String to prefix info/arrays key names where results will be stored. ‘_auto_’ for automatically determining name of calculator constructor, and None for SinglePointCalculator instead of info/arrays.
verbose (bool) – verbose output
autopara_info (AutoParaInfo / dict, optional) – information for automatic parallelization
- Returns
co – output configs
- Return type
wfl.calculators.kpts module#
Universal k-spacing functions
- wfl.calculators.kpts.universal_kspacing_k_mesh(cell, pbc, kspacing, kgamma=True, inversion_sym=False)#
Calculate universal kspacing, but never > 1 for pbc False
- Parameters
kspacing (float) – spacing in reciprocal space (assuming magnitude of reciprical lattice vectors includes factor of 2 pi
cell (ase.cell.Cell) – cell of atomic configuration
pbc ((bool, bool, bool)) – Whether direction is periodic and should be k-point sampled
kgamma (bool, default True) – use Gamma centered mesh
inversion_sym (bool, default False) – use inversion symmetry to fold k-points
- Returns
kmesh
- Return type
list((float, float, float)) positions of BZ points in reciprocal lattice coordinates
- wfl.calculators.kpts.universal_kspacing_n_k(cell, pbc, kspacing)#
Calculate universal kspacing, but never > 1 for pbc False
- Parameters
kspacing (float) – spacing in reciprocal space (assuming magnitude of reciprical lattice vectors includes factor of 2 pi
cell (ase.cell.Cell) – cell of atomic configuration
pbc ((bool, bool, bool)) – Whether direction is periodic and should be k-point sampled
- Returns
kmesh
- Return type
list((float, float, float)) positions of BZ points in reciprocal lattice coordinates
wfl.calculators.mopac module#
MOPAC interface
- class wfl.calculators.mopac.MOPAC(keep_files='default', rundir_prefix='run_MOPAC_', workdir=None, scratchdir=None, calculator_exec=None, **kwargs)#
Bases:
WFLFileIOCalculator
,MOPAC
Extension of ASE’s MOPAC claculator so that it can be used by wfl.calculators.generic (mainly each calculation is run in a separate directory)
- calculate(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])#
Do the calculation. Handles the working directories in addition to regular ASE calculation operations (writing input, executing, reading_results) Reimplements & extends GenericFileIOCalculator.calculate() for the development version of ASE or FileIOCalculator.calculate() for the v3.22.1
- wfl_generic_default_autopara_info = {'num_inputs_per_python_subprocess': 1}#
wfl.calculators.utils module#
- wfl.calculators.utils.clean_rundir(rundir, keep_files, default_keep_files, calculation_succeeded)#
clean up a run directory from a file-based calculator
- Parameters
rundir (str) – path to run dir
keep_files ('default' / list(str) / '*' / bool / None) – files to keep, None or False for nothing, ‘*’ or True for all
default_keep_files (list(str)) – files to keep if keep_files == ‘default’ or calculation_succeeded is False
calculation_succeeded (bool) –
- wfl.calculators.utils.parse_genericfileio_profile_argv(argv)#
Parse a command provided as a conventional argv into the separate structures that generic file-io calculators use to construct their Profile
- Parameters
argv (list(str)) – command to execute, split into separate arguments (e.g. using shlex.split?)
- Returns
binary (str binary to execute)
parallel_info (dict with parallel info, in particular “binary” for mpirun/mpiexec/srun etc,) – and additional fields to reconstruct rest of command line (all fake, depending on details of how ASE constructs the final command line
- wfl.calculators.utils.save_results(atoms, properties, results_prefix=None)#
saves results of a calculation in a SinglePointCalculator or info/arrays keys
If atoms.info[“__calculator_results_saved”] is true, assume that results have already been saved and instead just remove this key and continue
- Parameters
atoms (Atoms) – configuration
properties (list(str) or None) – list of calculated properties to save, or None to use atoms.calc.results dict keys
results_prefix (str / None , default None) – if None, store in SinglePointCalculator, else store in results_prefix+<property>. str with length 0 is forbidden
wfl.calculators.vasp module#
VASP calculator
- class wfl.calculators.vasp.Vasp(keep_files='default', rundir_prefix='run_VASP_', workdir=None, scratchdir=None, calculator_exec=None, calculator_exec_gamma=None, **kwargs)#
Bases:
WFLFileIOCalculator
,Vasp
Extension of ASE’s Vasp calculator that can be used by wfl.calculators.generic
Notes
“directory” argument cannot be present. Use rundir_prefix and workdir instead. “pp” defaults to “.”, so VASP_PP_PATH env var is absolute path to “<elem name>/POTCAR” files
- Parameters
keep_files (bool / None / "default" / list(str), default "default") –
- what kind of files to keep from the run
True, “*” : everything kept None, False : nothing kept “default” : only ones needed for NOMAD uploads (‘POSCAR’, ‘INCAR’, ‘KPOINTS’, ‘OUTCAR’, ‘vasprun.xml’, ‘vasp.out’) list(str) : list of file globs to save
rundir_prefix (str / Path, default 'run_VASP_') – Run directory name prefix
workdir (str / Path, default . at calculate time) – Path in which rundir will be created.
scratchdir (str / Path, default None) – temporary directory to execute calculations in and delete or copy back results (set by “keep_files”) if needed. For example, directory on a local disk with fast file I/O.
calculator_exec (str) – executable to run (without ASE-specific command line arguments). Mutually exclusive with ASE-built-in “command”
calculator_exec_gamma (str) – executable to run for nonperiodic systems (overrides ASE_VASP_COMMAND_GAMMA, VASP_COMMAND_GAMMA, VASP_SCRIPT_GAMMA). Mutually exclusive with ASE-built-in “command” and “command_gamma”
**kwargs (arguments for ase.calculators.vasp.vasp.Vasp) – remaining arguments to ASE’s Vasp calculator constructor
- calculate(atoms=None, properties=['energy', 'forces', 'stress'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])#
Do the calculation. Handles the working directories in addition to regular ASE calculation operations (writing input, executing, reading_results)
- default_parameters: Dict[str, Any] = {'ismear': 0, 'lcharg': False, 'lwave': False}#
Default parameters
- param_dict_of_key(k)#
- per_config_restore(atoms)#
- per_config_setup(atoms)#
- wfl_generic_num_inputs_per_python_subprocess = 1#
wfl.calculators.wfl_fileio_calculator module#
- class wfl.calculators.wfl_fileio_calculator.WFLFileIOCalculator(keep_files, rundir_prefix, workdir=None, scratchdir=None, **kwargs)#
Bases:
object
Mixin class implementing some methods that should be available to every WFL calculator that does I/O via files, i.e. DFT calculators
As a python mixin class, must be inherited from by the wrapping wfl calculator class _before_ the ASE calculator, i.e.
from ase.calculators.dftcode import DftCodeCalculator as ASE_DftCodeCalculator class DftCodeCalculator(WFLFileIOCalculator, ASE_DftCodeCalculator): . . .
- Parameters
keep_files (bool / None / "default" / list(str), default "default") –
- what kind of files to keep from the run
True, “*” : everything kept None, False : nothing kept “default” : default list, varies by calculator, usually only ones needed for NOMAD uploads list(str) : list of file globs to save
rundir_prefix (str / Path) – Run directory name prefix
workdir (str / Path, default . at calculate time) – Path in which rundir (rundir_prefix + temp suffix) will be created.
scratchdir (str / Path, default None) – temporary directory to execute calculations in and delete or copy back results (set by “keep_files”) if needed. For example, directory on a local disk with fast file I/O.
kwargs (dict) – remaining superclass constructor kwargs
- clean_rundir(_default_keep_files, calculation_succeeded)#
- cleanup()#
Clean all (empty) directories that could not have been removed immediately after the calculation, for example, because other parallel process might be using them. Done because self.workdir_root gets created upon initialisation, but we can’t ever be sure it’s not needed anymore, so let’s not do it automatically.
- setup_rundir()#