critcatworks.dft.cp2k package¶
Submodules¶
critcatworks.dft.cp2k.cp2ktasks module¶
-
class
critcatworks.dft.cp2k.cp2ktasks.
CP2KAnalysisTask
(*args, **kwargs)[source]¶ Bases:
fireworks.core.firework.FiretaskBase
Firetask to analyse CP2K calculations. Preparsing is needed for the main parser to run without throwing an error. The main parser is python package which reads most of the output fields. Only a fraction of them is actually transferred to the document in the simulation collection (positions, labels, is_converged, total_energy, number_of_frames_in_sequence, is_walltime_exceeded, nwarnings, simulation_cell). Upon failure (meaning incomplete or no output, or not converged) of the simulation, a detour is added to restart it (n_max_restarts times). If it fails for the last time, its children are defused (meaning the workflow gets paused, manual inspection is recommended).
- Parameters
target_path (str) – absolute path to the target directory (needs to exist) on the computing resource.
calc_id (int) – simulation id of the structure on which the calculation will be run
n_max_restarts (int) – number of times the calculation is restarted upon failure
- Returns
- Firework action, updates fw_spec, possibly defuses Firework children,
possibly adds Fireworks as detours to the workflow
- Return type
FWAction
-
optional_params
= []¶
-
required_params
= ['target_path', 'calc_id', 'n_max_restarts']¶
-
run_task
(fw_spec)[source]¶ This method gets called when the Firetask is run. It can take in a Firework spec, perform some task using that data, and then return an output in the form of a FWAction.
- Parameters
fw_spec (dict) – A Firework spec. This comes from the master spec. In addition, this spec contains a special “_fw_env” key that contains the env settings of the FWorker calling this method. This provides for abstracting out certain commands or settings. For example, “foo” may be named “foo1” in resource 1 and “foo2” in resource 2. The FWorker env can specify { “foo”: “foo1”}, which maps an abstract variable “foo” to the relevant “foo1” or “foo2”. You can then write a task that uses fw_spec[“_fw_env”][“foo”] that will work across all these multiple resources.
- Returns
(FWAction)
-
class
critcatworks.dft.cp2k.cp2ktasks.
CP2KRunTask
(*args, **kwargs)[source]¶ Bases:
fireworks.core.firework.FiretaskBase
Firetask to run CP2K calculations. It assumes that an srun command is used by the computing platform. It checks for the existence of a restart file. If it exists, the calculation will be restarted from there. The inputfile has to link to the structure file with the name structure.xyz. It descends to the folder given by target_path.
- Parameters
target_path (str) – absolute path to the target directory (needs to exist) on the computing resource.
calc_id (int) – simulation id of the structure on which the calculation will be run
n_max_restarts (int) – number of times the calculation is restarted upon failure
skip_dft (bool) – If set to true, the simulation step is skipped in all following simulation runs. Instead the structure is returned unchanged.
- Returns
Firework action, updates fw_spec
- Return type
FWAction
-
optional_params
= []¶
-
required_params
= ['target_path', 'calc_id', 'n_max_restarts', 'skip_dft']¶
-
run_task
(fw_spec)[source]¶ This method gets called when the Firetask is run. It can take in a Firework spec, perform some task using that data, and then return an output in the form of a FWAction.
- Parameters
fw_spec (dict) – A Firework spec. This comes from the master spec. In addition, this spec contains a special “_fw_env” key that contains the env settings of the FWorker calling this method. This provides for abstracting out certain commands or settings. For example, “foo” may be named “foo1” in resource 1 and “foo2” in resource 2. The FWorker env can specify { “foo”: “foo1”}, which maps an abstract variable “foo” to the relevant “foo1” or “foo2”. You can then write a task that uses fw_spec[“_fw_env”][“foo”] that will work across all these multiple resources.
- Returns
(FWAction)
-
class
critcatworks.dft.cp2k.cp2ktasks.
CP2KSetupTask
(*args, **kwargs)[source]¶ Bases:
fireworks.core.firework.FiretaskBase
Firetask to setup DFT calculations for CP2K. It alters the cellsize. The template has to link to the structure file with the name structure.xyz. It writes an input file with in the given folder. Other template alterations are not supported yet.
- Parameters
template (str) – input file for calculations represented as string. It works as a template which is later modified by the simulation-specific Firework.
target_path (str) – absolute path to the target directory (needs to exist) on the computing resource.
calc_id (int) – simulation id of the structure on which the calculation will be run
name (str) – individual calculation folder name is prefixed with the given string
n_max_restarts (int) – number of times the calculation is restarted upon failure
- Returns
Firework action (no action taken)
- Return type
FWAction
-
optional_params
= ['name']¶
-
required_params
= ['template', 'target_path', 'calc_id', 'n_max_restarts']¶
-
run_task
(fw_spec)[source]¶ This method gets called when the Firetask is run. It can take in a Firework spec, perform some task using that data, and then return an output in the form of a FWAction.
- Parameters
fw_spec (dict) – A Firework spec. This comes from the master spec. In addition, this spec contains a special “_fw_env” key that contains the env settings of the FWorker calling this method. This provides for abstracting out certain commands or settings. For example, “foo” may be named “foo1” in resource 1 and “foo2” in resource 2. The FWorker env can specify { “foo”: “foo1”}, which maps an abstract variable “foo” to the relevant “foo1” or “foo2”. You can then write a task that uses fw_spec[“_fw_env”][“foo”] that will work across all these multiple resources.
- Returns
(FWAction)
-
critcatworks.dft.cp2k.cp2ktasks.
additional_parse_stdout
(target_path)[source]¶ Helper function to parse CP2K output first simply. This prevents the main parser from failing most of the time.
- Parameters
target_path (str) – absolute path to the target directory (needs to exist) on the computing resource.
- Returns
- string (no_output, incorrect_termination, ok),
and dict of results.
- Return type
tuple
-
class
critcatworks.dft.cp2k.cp2ktasks.
cd
(newPath)[source]¶ Bases:
object
Context manager for changing the current working directory
-
critcatworks.dft.cp2k.cp2ktasks.
rerun_cp2k
(target_path, calc_id, n_max_restarts, n_restarts, simulation, skip_dft=False, extdb_connect={})[source]¶ Creates a mini-workflow consisting of: Firework 1: CP2KRunTask Firework 2: CP2KAnalysisTask
It is assumed that the CP2K input file along with the structure are already setup in the folder target_path. This workflow can be added as a detour in any workflow requiring a CP2K simulation. For more information about the individual steps, consult the documentation on CP2KRunTask and CP2KAnalysisTask.
- Parameters
target_path (str) – absolute path to the target directory (needs to exist) on the computing resource.
calc_id (int) – simulation id of the structure on which the calculation will be run
n_restarts (int) – number of times the calculation has already been restarted
n_max_restarts (int) – number of times the calculation is restarted upon failure
simulation (dict) – analysis step and stored in a new document
skip_dft (bool) – If set to true, the simulation step is skipped in all following simulation runs. Instead the structure is returned unchanged.
extdb_connect (dict) – dictionary containing the keys host, username, password, authsource and db_name.
- Returns
fireworks Workflow object
- Return type
Workflow
-
critcatworks.dft.cp2k.cp2ktasks.
setup_cp2k
(template, target_path, calc_id, simulation, name='cp2k_run_id', n_max_restarts=4, skip_dft=False, extdb_connect={})[source]¶ Creates a mini-workflow consisting of: Firework 1: two Firetasks CP2KSetupTask and CP2KRunTask. Firework 2: CP2KAnalysisTask
This workflow can be added as a detour in any workflow requiring a CP2K simulation. For more information about the individual steps, consult the documentation on CP2KSetupTask, CP2KRunTask and CP2KAnalysisTask.
- Parameters
template (str) – input file for calculations represented as string. It works as a template which is later modified by the simulation-specific Firework.
target_path (str) – absolute path to the target directory (needs to exist) on the computing resource.
calc_id (int) – simulation id of the structure on which the calculation will be run
simulation (dict) – analysis step and stored in a new document
name (str) – individual calculation folder name is prefixed with the given string
n_max_restarts (int) – number of times the calculation is restarted upon failure
skip_dft (bool) – If set to true, the simulation step is skipped in all following simulation runs. Instead the structure is returned unchanged.
extdb_connect (dict) – dictionary containing the keys host, username, password, authsource and db_name.
- Returns
fireworks Workflow object
- Return type
Workflow