aim2dat.aiida_workflows.cp2k.combined_work_chains
¶
Aiida workchains for cp2k to run advanced tasks combining different basic workchains.
Module Contents¶
Classes¶
Work chain to optimize the unit cell and calculate different electronic properties. |
|
Work chain to converge the slab size and optimize the atomic positions of the converged |
Attributes¶
-
class aim2dat.aiida_workflows.cp2k.combined_work_chains.ElectronicPropertiesWorkChain(inputs: dict | None =
None
, logger: logging.Logger | None =None
, runner: aiida.engine.runners.Runner | None =None
, enable_persistence: bool =True
)[source]¶ Bases:
aiida.engine.WorkChain
Work chain to optimize the unit cell and calculate different electronic properties.
- class SaveKeys¶
Bases:
enum.Enum
Keys used to identify things in the saved instance state bundle.
Overview
¶ name
()The name of the Enum member.
value
()The value of the Enum member.
-
CALC_ID : str =
'calc_id'
¶
- name()¶
The name of the Enum member.
- value()¶
The value of the Enum member.
-
CALC_ID : str =
Overview
¶ Get the context.
Return the inputs attribute dictionary or an empty one.
Return the metadata that were specified when this process instance was launched.
Return the ProcessNode used by this process to represent itself in the database.
Get process runner.
Return the UUID of the process which corresponds to the UUID of its associated ProcessNode.
¶ class The process type.
decode_input_args
(encoded)Decode saved input arguments as they came from the saved instance state Bundle
define
(spec)class Specify inputs and outputs.
Perform the cell relaxation.
Calculate the electronic properties of the crystal.
encode_input_args
(inputs)Encode input arguments such that they may be saved in a Bundle
Return the namespace of exit codes defined for this WorkChain through its ProcessSpec.
exposed_inputs
(process_class, namespace, agglomerate)Gather a dictionary of the inputs that were exposed for a given Process class under an optional namespace.
exposed_outputs
(node, process_class, namespace, agglomerate)Return the outputs which were exposed from the
process_class
and emitted by the specificnode
Find mixing parameters that converge the Kohn-Sham equations.
class -
get_exit_statuses
(exit_code_labels)class Return the exit status (integers) for the given exit code labels.
class Create a process node that represents what happened in this process.
Get the parent process node
Get provenance input iterator.
init
()-
is_valid_cache
(node)class Check if the given node can be cached from.
kill
(msg)Kill the process and all the children calculations it called
load_instance_state
(saved_state, load_context)Load instance state.
Called when a Process is created.
on_entered
(from_state)After entering a new state, save a checkpoint and update the latest process state change timestamp.
on_except
(exc_info)Log the exception by calling the report method with formatted stack trace from exception info object
Ensure that any unstored nodes in the context are stored, before the state is exited
on_finish
(result, successful)Set the finish status on the process node.
on_output_emitting
(output_port, value)The process has emitted a value on the given output port.
on_paused
(msg)The Process was paused so set the paused attribute on the process node
The Process was unpaused so remove the paused attribute on the process node
on_run
()-
Called when a Process enters a terminal state.
on_wait
(awaitables)Entering the WAITING state.
out
(output_port, value)Attach output to output port.
out_many
(out_dict)Attach outputs to multiple output ports.
Post-processing routine.
report
(msg, *args, **kwargs)Log a message to the logger, which should get saved to the database through the attached DbLogHandler.
run
()-
run_el_prop_wc
(task_label, work_chain, structure, remote_folder, scf_parameters, extra_input)Run electronic properties calculation.
save_instance_state
(out_state, save_context)Save instance state.
set_input_parameter
(work_chain_builder, input_key, value)static Set input parameter for a child work chain.
set_status
(status)The status of the Process is about to be changed, so we reflect this is in node’s attribute proxy.
setup
()Set up calculation parameters.
Whether to run a cell optimization.
spec
()class -
Return the metadata port namespace of the process specification of this process.
submit
(process, **kwargs)Submit process for execution.
to_context
(**kwargs)Add a dictionary of awaitables to the context.
Attach new outputs to the node since the last call.
-
SINGLE_OUTPUT_LINKNAME : str =
'result'
¶
- property ctx : aiida.common.extendeddicts.AttributeDict¶
Get the context.
- property inputs : plumpy.utils.AttributesFrozendict¶
Return the inputs attribute dictionary or an empty one.
This overrides the property of the base class because that can also return
None
. This override ensures calling functions that they will always get an instance ofAttributesFrozenDict
.
- property metadata : aiida.common.extendeddicts.AttributeDict¶
Return the metadata that were specified when this process instance was launched.
- Returns:¶
metadata dictionary
- property node : aiida.orm.WorkChainNode¶
Return the ProcessNode used by this process to represent itself in the database.
- Returns:¶
instance of sub class of ProcessNode
- property runner : aiida.engine.runners.Runner¶
Get process runner.
- property uuid : str¶
Return the UUID of the process which corresponds to the UUID of its associated ProcessNode.
- Returns:¶
the UUID associated to this process instance
- classmethod build_process_type() str ¶
The process type.
- Returns:¶
string of the process type
Note: This could be made into a property ‘process_type’ but in order to have it be a property of the class it would need to be defined in the metaclass, see https://bugs.python.org/issue20659
- decode_input_args(encoded: str) dict[str, Any] ¶
Decode saved input arguments as they came from the saved instance state Bundle
- encode_input_args(inputs: dict[str, Any]) str ¶
Encode input arguments such that they may be saved in a Bundle
- exit_codes() aiida.engine.processes.exit_code.ExitCodesNamespace ¶
Return the namespace of exit codes defined for this WorkChain through its ProcessSpec.
The namespace supports getitem and getattr operations with an ExitCode label to retrieve a specific code. Additionally, the namespace can also be called with either the exit code integer status to retrieve it.
- Returns:¶
ExitCodesNamespace of ExitCode named tuples
-
exposed_inputs(process_class: type[Process], namespace: str | None =
None
, agglomerate: bool =True
) aiida.common.extendeddicts.AttributeDict ¶ Gather a dictionary of the inputs that were exposed for a given Process class under an optional namespace.
- Parameters:¶
- process_class: type[Process]¶
Process class whose inputs to try and retrieve
- namespace: str | None =
None
¶ PortNamespace in which to look for the inputs
- agglomerate: bool =
True
¶ If set to true, all parent namespaces of the given
namespace
will also be searched for inputs. Inputs in lower-lying namespaces take precedence.
- Returns:¶
exposed inputs
-
exposed_outputs(node: aiida.orm.ProcessNode, process_class: type[Process], namespace: str | None =
None
, agglomerate: bool =True
) aiida.common.extendeddicts.AttributeDict ¶ Return the outputs which were exposed from the
process_class
and emitted by the specificnode
- Parameters:¶
- node: aiida.orm.ProcessNode¶
process node whose outputs to try and retrieve
- namespace: str | None =
None
¶ Namespace in which to search for exposed outputs.
- agglomerate: bool =
True
¶ If set to true, all parent namespaces of the given
namespace
will also be searched for outputs. Outputs in lower-lying namespaces take precedence.
- Returns:¶
exposed outputs
- classmethod get_builder() aiida.engine.processes.builder.ProcessBuilder ¶
- classmethod get_exit_statuses(exit_code_labels: Iterable[str]) list[int] ¶
Return the exit status (integers) for the given exit code labels.
- Parameters:¶
- exit_code_labels: Iterable[str]¶
a list of strings that reference exit code labels of this process class
- Returns:¶
list of exit status integers that correspond to the given exit code labels
- Raises:¶
AttributeError – if at least one of the labels does not correspond to an existing exit code
- classmethod get_or_create_db_record() aiida.orm.ProcessNode ¶
Create a process node that represents what happened in this process.
- Returns:¶
A process node
- get_parent_calc() aiida.orm.ProcessNode | None ¶
Get the parent process node
- Returns:¶
the parent process node if there is one
- get_provenance_inputs_iterator() Iterator[tuple[str, aiida.engine.processes.ports.InputPort | aiida.engine.processes.ports.PortNamespace]] ¶
Get provenance input iterator.
- Return type:¶
filter
- init() None ¶
- classmethod is_valid_cache(node: aiida.orm.ProcessNode) bool ¶
Check if the given node can be cached from.
Overriding this method allows
Process
sub-classes to modify when corresponding process nodes are considered as a cache.Warning
When overriding this method, make sure to return
False
at least in all cases whensuper()._node.base.caching.is_valid_cache(node)
returnsFalse
. Otherwise, theinvalidates_cache
keyword on exit codes may have no effect.
-
kill(msg: str | None =
None
) bool | plumpy.futures.Future ¶ Kill the process and all the children calculations it called
- load_instance_state(saved_state, load_context)¶
Load instance state.
- on_create() None ¶
Called when a Process is created.
- on_entered(from_state: plumpy.process_states.State | None) None ¶
After entering a new state, save a checkpoint and update the latest process state change timestamp.
- on_except(exc_info: tuple[Any, Exception, types.TracebackType]) None ¶
Log the exception by calling the report method with formatted stack trace from exception info object and store the exception string as a node attribute
- on_exiting() None ¶
Ensure that any unstored nodes in the context are stored, before the state is exited
After the state is exited the next state will be entered and if persistence is enabled, a checkpoint will be saved. If the context contains unstored nodes, the serialization necessary for checkpointing will fail.
- on_finish(result: int | aiida.engine.processes.exit_code.ExitCode | None, successful: bool) None ¶
Set the finish status on the process node.
- on_output_emitting(output_port: str, value: Any) None ¶
The process has emitted a value on the given output port.
-
on_paused(msg: str | None =
None
) None ¶ The Process was paused so set the paused attribute on the process node
- on_playing() None ¶
The Process was unpaused so remove the paused attribute on the process node
- on_run()¶
- on_terminated() None ¶
Called when a Process enters a terminal state.
- on_wait(awaitables: collections.abc.Sequence[Awaitable])¶
Entering the WAITING state.
-
out(output_port: str, value: Any =
None
) None ¶ Attach output to output port.
The name of the port will be used as the link label.
- out_many(out_dict: dict[str, Any]) None ¶
Attach outputs to multiple output ports.
Keys of the dictionary will be used as output port names, values as outputs.
- report(msg: str, *args, **kwargs) None ¶
Log a message to the logger, which should get saved to the database through the attached DbLogHandler.
The pk, class name and function name of the caller are prepended to the given message
- run() Any ¶
- run_el_prop_wc(task_label, work_chain, structure, remote_folder, scf_parameters, extra_input)[source]¶
Run electronic properties calculation.
- save_instance_state(out_state, save_context)¶
Save instance state.
- static set_input_parameter(work_chain_builder, input_key, value)[source]¶
Set input parameter for a child work chain.
- set_status(status: str | None) None ¶
The status of the Process is about to be changed, so we reflect this is in node’s attribute proxy.
- classmethod spec() WorkChainSpec ¶
- spec_metadata() aiida.engine.processes.ports.PortNamespace ¶
Return the metadata port namespace of the process specification of this process.
- to_context(**kwargs: aiida.engine.processes.workchains.awaitable.Awaitable | aiida.orm.ProcessNode) None ¶
Add a dictionary of awaitables to the context.
This is a convenience method that provides syntactic sugar, for a user to add multiple intersteps that will assign a certain value to the corresponding key in the context of the work chain.
- update_outputs() None ¶
Attach new outputs to the node since the last call.
Does nothing, if self.metadata.store_provenance is False.
-
class aim2dat.aiida_workflows.cp2k.combined_work_chains.SurfaceOptWorkChain(inputs: dict | None =
None
, logger: logging.Logger | None =None
, runner: aiida.engine.runners.Runner | None =None
, enable_persistence: bool =True
)[source]¶ Bases:
aiida.engine.WorkChain
Work chain to converge the slab size and optimize the atomic positions of the converged slab.
- class SaveKeys¶
Bases:
enum.Enum
Keys used to identify things in the saved instance state bundle.
Overview
¶ name
()The name of the Enum member.
value
()The value of the Enum member.
-
CALC_ID : str =
'calc_id'
¶
- name()¶
The name of the Enum member.
- value()¶
The value of the Enum member.
-
CALC_ID : str =
Overview
¶ Get the context.
Return the inputs attribute dictionary or an empty one.
Return the metadata that were specified when this process instance was launched.
Return the ProcessNode used by this process to represent itself in the database.
Get process runner.
Return the UUID of the process which corresponds to the UUID of its associated ProcessNode.
¶ class The process type.
decode_input_args
(encoded)Decode saved input arguments as they came from the saved instance state Bundle
define
(spec)class Specify inputs and outputs.
encode_input_args
(inputs)Encode input arguments such that they may be saved in a Bundle
Return the namespace of exit codes defined for this WorkChain through its ProcessSpec.
exposed_inputs
(process_class, namespace, agglomerate)Gather a dictionary of the inputs that were exposed for a given Process class under an optional namespace.
exposed_outputs
(node, process_class, namespace, agglomerate)Return the outputs which were exposed from the
process_class
and emitted by the specificnode
Run the FindSCFParameters work chain.
geo_opt
()Run the GeoOpt work chain.
Run the GeoOpt work chain.
class -
get_exit_statuses
(exit_code_labels)class Return the exit status (integers) for the given exit code labels.
class Create a process node that represents what happened in this process.
Get the parent process node
Get provenance input iterator.
init
()-
Check if the previous work chain finished successful.
Check if the previous work chain finished successful.
is_valid_cache
(node)class Check if the given node can be cached from.
kill
(msg)Kill the process and all the children calculations it called
load_instance_state
(saved_state, load_context)Load instance state.
Called when a Process is created.
on_entered
(from_state)After entering a new state, save a checkpoint and update the latest process state change timestamp.
on_except
(exc_info)Log the exception by calling the report method with formatted stack trace from exception info object
Ensure that any unstored nodes in the context are stored, before the state is exited
on_finish
(result, successful)Set the finish status on the process node.
on_output_emitting
(output_port, value)The process has emitted a value on the given output port.
on_paused
(msg)The Process was paused so set the paused attribute on the process node
The Process was unpaused so remove the paused attribute on the process node
on_run
()-
Called when a Process enters a terminal state.
on_wait
(awaitables)Entering the WAITING state.
out
(output_port, value)Attach output to output port.
out_many
(out_dict)Attach outputs to multiple output ports.
Define outputs.
report
(msg, *args, **kwargs)Log a message to the logger, which should get saved to the database through the attached DbLogHandler.
run
()-
save_instance_state
(out_state, save_context)Save instance state.
set_status
(status)The status of the Process is about to be changed, so we reflect this is in node’s attribute proxy.
setup
()Define initial parameters.
Check whether additional calculations are run after the slab size is converged.
Check whether the convergence criteria is fulfilled and the slab size is not
spec
()class -
Return the metadata port namespace of the process specification of this process.
submit
(process, **kwargs)Submit process for execution.
to_context
(**kwargs)Add a dictionary of awaitables to the context.
Attach new outputs to the node since the last call.
-
SINGLE_OUTPUT_LINKNAME : str =
'result'
¶
- property ctx : aiida.common.extendeddicts.AttributeDict¶
Get the context.
- property inputs : plumpy.utils.AttributesFrozendict¶
Return the inputs attribute dictionary or an empty one.
This overrides the property of the base class because that can also return
None
. This override ensures calling functions that they will always get an instance ofAttributesFrozenDict
.
- property metadata : aiida.common.extendeddicts.AttributeDict¶
Return the metadata that were specified when this process instance was launched.
- Returns:¶
metadata dictionary
- property node : aiida.orm.WorkChainNode¶
Return the ProcessNode used by this process to represent itself in the database.
- Returns:¶
instance of sub class of ProcessNode
- property runner : aiida.engine.runners.Runner¶
Get process runner.
- property uuid : str¶
Return the UUID of the process which corresponds to the UUID of its associated ProcessNode.
- Returns:¶
the UUID associated to this process instance
- classmethod build_process_type() str ¶
The process type.
- Returns:¶
string of the process type
Note: This could be made into a property ‘process_type’ but in order to have it be a property of the class it would need to be defined in the metaclass, see https://bugs.python.org/issue20659
- decode_input_args(encoded: str) dict[str, Any] ¶
Decode saved input arguments as they came from the saved instance state Bundle
- encode_input_args(inputs: dict[str, Any]) str ¶
Encode input arguments such that they may be saved in a Bundle
- exit_codes() aiida.engine.processes.exit_code.ExitCodesNamespace ¶
Return the namespace of exit codes defined for this WorkChain through its ProcessSpec.
The namespace supports getitem and getattr operations with an ExitCode label to retrieve a specific code. Additionally, the namespace can also be called with either the exit code integer status to retrieve it.
- Returns:¶
ExitCodesNamespace of ExitCode named tuples
-
exposed_inputs(process_class: type[Process], namespace: str | None =
None
, agglomerate: bool =True
) aiida.common.extendeddicts.AttributeDict ¶ Gather a dictionary of the inputs that were exposed for a given Process class under an optional namespace.
- Parameters:¶
- process_class: type[Process]¶
Process class whose inputs to try and retrieve
- namespace: str | None =
None
¶ PortNamespace in which to look for the inputs
- agglomerate: bool =
True
¶ If set to true, all parent namespaces of the given
namespace
will also be searched for inputs. Inputs in lower-lying namespaces take precedence.
- Returns:¶
exposed inputs
-
exposed_outputs(node: aiida.orm.ProcessNode, process_class: type[Process], namespace: str | None =
None
, agglomerate: bool =True
) aiida.common.extendeddicts.AttributeDict ¶ Return the outputs which were exposed from the
process_class
and emitted by the specificnode
- Parameters:¶
- node: aiida.orm.ProcessNode¶
process node whose outputs to try and retrieve
- namespace: str | None =
None
¶ Namespace in which to search for exposed outputs.
- agglomerate: bool =
True
¶ If set to true, all parent namespaces of the given
namespace
will also be searched for outputs. Outputs in lower-lying namespaces take precedence.
- Returns:¶
exposed outputs
- classmethod get_builder() aiida.engine.processes.builder.ProcessBuilder ¶
- classmethod get_exit_statuses(exit_code_labels: Iterable[str]) list[int] ¶
Return the exit status (integers) for the given exit code labels.
- Parameters:¶
- exit_code_labels: Iterable[str]¶
a list of strings that reference exit code labels of this process class
- Returns:¶
list of exit status integers that correspond to the given exit code labels
- Raises:¶
AttributeError – if at least one of the labels does not correspond to an existing exit code
- classmethod get_or_create_db_record() aiida.orm.ProcessNode ¶
Create a process node that represents what happened in this process.
- Returns:¶
A process node
- get_parent_calc() aiida.orm.ProcessNode | None ¶
Get the parent process node
- Returns:¶
the parent process node if there is one
- get_provenance_inputs_iterator() Iterator[tuple[str, aiida.engine.processes.ports.InputPort | aiida.engine.processes.ports.PortNamespace]] ¶
Get provenance input iterator.
- Return type:¶
filter
- init() None ¶
- classmethod is_valid_cache(node: aiida.orm.ProcessNode) bool ¶
Check if the given node can be cached from.
Overriding this method allows
Process
sub-classes to modify when corresponding process nodes are considered as a cache.Warning
When overriding this method, make sure to return
False
at least in all cases whensuper()._node.base.caching.is_valid_cache(node)
returnsFalse
. Otherwise, theinvalidates_cache
keyword on exit codes may have no effect.
-
kill(msg: str | None =
None
) bool | plumpy.futures.Future ¶ Kill the process and all the children calculations it called
- load_instance_state(saved_state, load_context)¶
Load instance state.
- on_create() None ¶
Called when a Process is created.
- on_entered(from_state: plumpy.process_states.State | None) None ¶
After entering a new state, save a checkpoint and update the latest process state change timestamp.
- on_except(exc_info: tuple[Any, Exception, types.TracebackType]) None ¶
Log the exception by calling the report method with formatted stack trace from exception info object and store the exception string as a node attribute
- on_exiting() None ¶
Ensure that any unstored nodes in the context are stored, before the state is exited
After the state is exited the next state will be entered and if persistence is enabled, a checkpoint will be saved. If the context contains unstored nodes, the serialization necessary for checkpointing will fail.
- on_finish(result: int | aiida.engine.processes.exit_code.ExitCode | None, successful: bool) None ¶
Set the finish status on the process node.
- on_output_emitting(output_port: str, value: Any) None ¶
The process has emitted a value on the given output port.
-
on_paused(msg: str | None =
None
) None ¶ The Process was paused so set the paused attribute on the process node
- on_playing() None ¶
The Process was unpaused so remove the paused attribute on the process node
- on_run()¶
- on_terminated() None ¶
Called when a Process enters a terminal state.
- on_wait(awaitables: collections.abc.Sequence[Awaitable])¶
Entering the WAITING state.
-
out(output_port: str, value: Any =
None
) None ¶ Attach output to output port.
The name of the port will be used as the link label.
- out_many(out_dict: dict[str, Any]) None ¶
Attach outputs to multiple output ports.
Keys of the dictionary will be used as output port names, values as outputs.
- report(msg: str, *args, **kwargs) None ¶
Log a message to the logger, which should get saved to the database through the attached DbLogHandler.
The pk, class name and function name of the caller are prepended to the given message
- run() Any ¶
- save_instance_state(out_state, save_context)¶
Save instance state.
- set_status(status: str | None) None ¶
The status of the Process is about to be changed, so we reflect this is in node’s attribute proxy.
- should_run_add_calc()[source]¶
Check whether additional calculations are run after the slab size is converged.
- should_run_slab_conv()[source]¶
Check whether the convergence criteria is fulfilled and the slab size is not exceeding the maximum slab size.
- classmethod spec() WorkChainSpec ¶
- spec_metadata() aiida.engine.processes.ports.PortNamespace ¶
Return the metadata port namespace of the process specification of this process.
- to_context(**kwargs: aiida.engine.processes.workchains.awaitable.Awaitable | aiida.orm.ProcessNode) None ¶
Add a dictionary of awaitables to the context.
This is a convenience method that provides syntactic sugar, for a user to add multiple intersteps that will assign a certain value to the corresponding key in the context of the work chain.
- update_outputs() None ¶
Attach new outputs to the node since the last call.
Does nothing, if self.metadata.store_provenance is False.
- aim2dat.aiida_workflows.cp2k.combined_work_chains.BandStructureWC¶
- aim2dat.aiida_workflows.cp2k.combined_work_chains.CellOptWC¶
- aim2dat.aiida_workflows.cp2k.combined_work_chains.EigenvaluesWC¶
- aim2dat.aiida_workflows.cp2k.combined_work_chains.FindSCFParametersWC¶
- aim2dat.aiida_workflows.cp2k.combined_work_chains.GeoOptWC¶
- aim2dat.aiida_workflows.cp2k.combined_work_chains.PDOSWC¶
- aim2dat.aiida_workflows.cp2k.combined_work_chains.PartialChargesWC¶