aiida_vasp.common.builder_updater#
This module provides a set of updater classes and utility functions for constructing and managing AiiDA process builders for VASP-based workflows. The updaters encapsulate logic for applying presets, setting calculation options, managing input sets, and updating workflow-specific settings for various VASP workchains, including standard calculations, relaxations, NEB, convergence tests, and band structure calculations.
Key Classes:
VaspPresetConfig: Handles loading and managing preset configurations from YAML files.
BaseBuilderUpdater: Base class for builder updaters, providing common methods for builder manipulation.
VaspBuilderUpdater: Updater for standard VASP calculations.
VaspNEBUpdater: Updater for NEB (nudged elastic band) calculations.
VaspRelaxUpdater: Updater for relaxation workflows.
VaspMultiStageRelaxUpdater: Updater for multi-stage relaxation workflows.
VaspConvUpdater: Updater for convergence testing workflows.
VaspBandUpdater: Updater for band structure workflows.
VaspHybridBandUpdater: Updater for hybrid functional band structure workflows.
Key Utilities:
update_dict_node: Utility to safely update AiiDA Dict nodes.
builder_to_dict: Converts a builder to a Python dictionary for inspection.
incar_dict_to_relax_settings: Extracts relaxation settings from INCAR parameters.
is_specified: Checks if any values are set in a ProcessBuilderNamespace.
The module is designed to facilitate programmatic and reproducible setup of VASP workflows in AiiDA, supporting both interactive and automated use cases.
Module Contents#
Classes#
Class to store the preset for VaspBuilderUpdater |
|
Base class for builder updater |
|
An updater for VaspRelaxWorkChain |
|
An updater for VaspRelaxWorkChain |
|
Update for VaspConvergenceWorkChain |
|
Updater for VaspBandsWorkChain |
|
Updater for VaspHybridBandsWorkChain |
Functions#
Get the path where the YAML files are stored within this package. |
|
List all available presets in the package. |
|
Check if there is anything specified under a PortNamespace. |
|
Update a Dict node with new content. |
|
Convert a builder to a dictionary and optionally unpack certain nodes. |
|
Convert INCAR tags to relax_settings and remove them from INCAR. |
Data#
API#
- aiida_vasp.common.builder_updater.DEFAULT_PRESET = 'VaspPreset'#
- aiida_vasp.common.builder_updater.DEFAULT_INPUTSET = 'UCLRelaxSet'#
- aiida_vasp.common.builder_updater.__all__ = ('VaspBandUpdater', 'VaspBuilderUpdater', 'VaspConvUpdater', 'VaspHybridBandUpdater', 'VaspNEBUpdate...#
- aiida_vasp.common.builder_updater.get_library_path() pathlib.Path[source]#
Get the path where the YAML files are stored within this package.
- Returns:
Path to the library directory containing YAML configuration files
- Return type:
- aiida_vasp.common.builder_updater.list_presets() list[pathlib.Path][source]#
List all available presets in the package.
- aiida_vasp.common.builder_updater.OPTIONS_TEMPLATES = None#
- class aiida_vasp.common.builder_updater.VaspPresetConfig[source]#
Class to store the preset for VaspBuilderUpdater
- classmethod from_file(fname: str) aiida_vasp.common.builder_updater.VaspPresetConfig[source]#
Load preset configuration from a YAML file.
Searches for the configuration file in the package library path and user’s home directory (~/.aiida-vasp).
- Parameters:
fname (str) – Name of the configuration file (without .yaml extension)
- Returns:
VaspPresetConfig instance loaded from file
- Return type:
- Raises:
RuntimeError – If the preset definition file cannot be found
- class aiida_vasp.common.builder_updater.BaseBuilderUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, verbose: bool = False, inputset_name: str | None = None, set_name: str | None = None)[source]#
Base class for builder updater
Initialization
Instantiate a pipeline
- property builder: aiida.engine.processes.builder.ProcessBuilder#
The builder to be used for launching the calculation.
- Returns:
Process builder instance
- Return type:
ProcessBuilder
- submit() aiida.orm.WorkChainNode[source]#
Submit the workflow to the daemon and return the workchain node.
- Returns:
The submitted workchain node
- Return type:
orm.WorkChainNode
- run_get_node(verbose: bool = True) aiida.orm.WorkChainNode[source]#
Run the workflow with the current python process.
- Parameters:
verbose (bool) – If True, print debugging information for failed calculations
- Returns:
Tuple containing the workflow outputs and the workchain node
- Return type:
orm.WorkChainNode
- _get_help(namespace: str, print_to_stdout: bool = True, inout: str = 'inputs') str | None[source]#
Return the help message for a given namespace.
The . syntax for the namespace is supported for nested namespaces.
- get_output_help(namespace: str, print_to_stdout: bool = True) str | None[source]#
Return the help message for a given output namespace.
- class aiida_vasp.common.builder_updater.VaspBuilderUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, root_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, code: str | None = None, verbose: bool = False, inputset_name: str | None = None)[source]#
Bases:
aiida_vasp.common.builder_updater.BaseBuilderUpdater- WF_ENTRYPOINT = 'vasp.v2.vasp'#
- DEFAULT_INPUTSET = None#
- property reference_structure: aiida.orm.StructureData#
Reference structure used for setting kpoints and other calculations.
- Returns:
The structure data node used as reference
- Return type:
orm.StructureData
- clear() None[source]#
Clear all nodes set in the VASP and root namespaces.
Resets parameters, options, settings, kpoints, potential family/mapping, structure, and metadata label to None.
- apply_preset(initial_structure: aiida.orm.StructureData, code: str | None = None, label: str | None = None, overrides: dict[str, Any] | None = None, inputset_name: str | None = None) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Apply the complete preset configuration to the builder.
This method applies the input set, sets the computational code, options, settings, and label according to the preset configuration.
- Parameters:
initial_structure (orm.StructureData) – Structure to be used for the calculation
code (str or None) – Computational code to use (defaults to preset default)
label (str or None) – Label for the calculation (defaults to structure label)
overrides (dict or None) – Dictionary of parameter overrides
inputset_name (str or None) – Name of input set to use (defaults to preset default)
- Returns:
Self for method chaining
- Return type:
- use_inputset(structure: aiida.orm.StructureData, set_name: str | None = None, overrides: dict[str, Any] | None = None, apply_preset: bool = False, code: str | None = None, structure_port_name: str = 'structure', pmg_kwargs: dict[str, Any] | None = None) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Update the inputs ports for the VASP calculation.
- Parameters:
structure – The structure to be used for the calculation.
set_name – The name of the input set to be used.
overrides – Any overrides to be applied to the input set.
apply_preset – Whether to apply the preset options.
code – The code to be used for the calculation.
structure_node_name – The name of in put port where the structure should be set.
pmg_kwargs – Additional kwargs to be passed to pymatgen’s InputSet when using a pymatgen inputset.
:returns : self, the VaspBuilderUpdater instance with the input set applied.
- set_kspacing(kspacing: float) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set the k-point spacing and remove any existing k-point mesh.
- Parameters:
kspacing (float) – K-point spacing value in inverse Angstroms
- Returns:
Self for method chaining
- Return type:
- set_potential_family(family: str) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set the potential family for the VASP calculation.
- Parameters:
family (str) – Name of the potential family
- Returns:
Self for method chaining
- Return type:
- set_potential_mapping(mapping: dict[str, str]) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set the potential mapping for the VASP calculation.
- update_kspacing = None#
- property parameters: Union[aiida.orm.Dict, None]#
Return the parameters node containing INCAR settings.
- Returns:
Parameters node or None if not set
- Return type:
orm.Dict or None
- property settings: Union[aiida.orm.Dict, None]#
Return the settings node for VASP calculation options.
- Returns:
Settings node or None if not set
- Return type:
orm.Dict or None
- set_code(code: str | aiida.orm.Code | None = None) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set the Code for the VASP calculation.
- Parameters:
code (str, orm.Code, or None) – Code identifier string or Code node (defaults to preset default)
- Returns:
Self for method chaining
- Return type:
- update_code(code: str | aiida.orm.Code) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_incar(*args: Any, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Update INCAR parameters for the VASP calculation.
- Parameters:
args – Positional arguments passed to dict constructor
kwargs – INCAR parameter key-value pairs
- Returns:
Self for method chaining
- Return type:
- update_incar(*args: Any, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_options(*args: Any, code: str | None = None, apply_preset: bool = False, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set computational options for the VASP calculation.
- Parameters:
- Returns:
Self for method chaining
- Return type:
- update_options(*args: Any, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_kpoints_mesh(mesh: list[int], offset: list[float] = (0.0, 0.0, 0.0)) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set explicit k-points mesh for the calculation. The plugin generates the KPOINTS file with a Gamma-centered mesh. Monkhorst-Pack meshes can be applied by using the offset parameter, e.g. (0.5, 0.5, 0.5)
- Parameters:
- Returns:
Self for method chaining
- Return type:
- update_kpoints_mesh(mesh: list[int], offset: list[float]) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_settings(*args: Any, code: str | None = None, apply_preset: bool = False, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set the ‘settings’ input port.
- Parameters:
- Returns:
Self for method chaining
- Return type:
- update_settings(*args: Any, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_label(label: str | None = None) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set the top-level label for the calculation.
- Parameters:
label (str or None) – Label string (defaults to structure label if available)
- Returns:
Self for method chaining
- Return type:
- update_label(label: str | None = None) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_resources(**kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Update computational resources in the options. NOTE: The available options can be found in the documentation of the Calculation class. These are identical to those used in the metadata.options namespace.
- Parameters:
args – Positional arguments passed to dict constructor
kwargs – Resource key-value pairs
- Returns:
Self for method chaining
- Return type:
- Raises:
RuntimeError – If options are not set before calling this method
- update_resources(*args: Any, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- _set_options(option_class: type, option_name: str, target_namespace: aiida.engine.processes.builder.ProcessBuilder | aiida.engine.processes.builder.ProcessBuilderNamespace, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
Set options using a specific option class.
- Parameters:
option_class – Class used to validate and structure options
option_name (str) – Name of the option attribute in the target namespace
target_namespace (ProcessBuilder or ProcessBuilderNamespace) – Namespace where options should be set
kwargs – Option key-value pairs
- Returns:
Self for method chaining
- class aiida_vasp.common.builder_updater.VaspNEBUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, root_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, code: str | None = None, verbose: bool = False, inputset_name: str | None = None)[source]#
Bases:
aiida_vasp.common.builder_updater.VaspBuilderUpdater- WF_ENTRYPOINT = 'vasp.neb'#
- property reference_structure#
Return the reference structure for NEB calculations.
- Returns:
Initial structure for NEB calculation
- Return type:
orm.StructureData
- apply_preset(structure_init: aiida.orm.StructureData, structure_final: aiida.orm.StructureData, code: str | None = None, label: str | None = None, interpolate: bool = True, nimages: int = 5, **kwargs: Any) aiida_vasp.common.builder_updater.VaspNEBUpdater[source]#
- use_inputset(initial_structure: aiida.orm.StructureData, set_name: str | None = None, overrides: dict[str, Any] | None = None, apply_preset: bool = False, code: str | None = None) aiida_vasp.common.builder_updater.VaspNEBUpdater[source]#
- set_label(label: str | None = None) aiida_vasp.common.builder_updater.VaspNEBUpdater[source]#
Set the toplevel label, default to the label of the structure
- set_final_structure(final_structure: aiida.orm.StructureData) aiida_vasp.common.builder_updater.VaspNEBUpdater[source]#
Set the final structure for NEB calculation.
- Parameters:
final_structure (orm.StructureData) – Final structure for the NEB path
- Returns:
Self for method chaining
- Return type:
- set_neb_images(images: list | dict | aiida.common.extendeddicts.AttributeDict) aiida_vasp.common.builder_updater.VaspNEBUpdater[source]#
Set the intermediate NEB images.
- set_interpolated_images(nimages: int) aiida_vasp.common.builder_updater.VaspNEBUpdater[source]#
Generate and set interpolated images between initial and final structures.
This requires the initial and final structures to be set already. Also updates the final image with PBC issues fixed.
- Parameters:
nimages (int) – Number of intermediate images to generate
- Returns:
Self for method chaining
- Return type:
- view_images(*args: Any, **kwargs: Any) None[source]#
Visualize the NEB images using ASE viewer.
Displays all images including initial, intermediate, and final structures.
Hint: In a notebook environment, you can pass “viewer=’weas’” to use weas-widget viewer. This requires the ase-weas-widget package to be installed.
- class aiida_vasp.common.builder_updater.VaspRelaxUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, override_vasp_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, namespace_relax: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, code: str | None = None)[source]#
Bases:
aiida_vasp.common.builder_updater.VaspBuilderUpdaterAn updater for VaspRelaxWorkChain
Initialization
Initialise the update object.
- Parameters:
builder – The
ProcessBuilderorProcessBuilderNamespaceto be used for setting standard VaspWorkChain inputs.root_namespace – The namespace to be assumed to be the root, e.g. where the input structure should be specified. The v2 series of workchain in aiida-vasp usually has the StructureData input port at the top level interface, although there are a few exceptions.
preset_name – The name of the Preset to be used for the updater.
code – The code to be used for the calculation. If not specified, the default code from the preset will be used.
verbose – If True, print additional information during the update.
set_name – The name of the input set to be used. If not specified, the default input set from the preset will be used.
returns: An instance of VaspBuilderUpdater with the specified preset and builder.
- WF_ENTRYPOINT = 'vasp.v2.relax'#
- use_inputset(*args: Any, set_name: str | None = None, **kwargs: Any) aiida_vasp.common.builder_updater.VaspRelaxUpdater[source]#
- apply_preset(structure: aiida.orm.StructureData, code: str | None = None, label: str | None = None, **kwargs: Any) aiida_vasp.common.builder_updater.VaspRelaxUpdater[source]#
- set_relax_settings(**kwargs: Any) aiida_vasp.common.builder_updater.VaspRelaxUpdater[source]#
Set/update RelaxOptions controlling the operation of the workchain.
- Parameters:
kwargs – Relaxation option key-value pairs
- Returns:
Self for method chaining
- Return type:
- update_relax_settings = None#
- clear_relax_settings() aiida_vasp.common.builder_updater.VaspRelaxUpdater[source]#
Reset any existing relax options to defaults.
- Returns:
Self for method chaining
- Return type:
- clear() aiida_vasp.common.builder_updater.VaspRelaxUpdater[source]#
Clear all settings including relax-specific settings.
- Returns:
Self for method chaining
- Return type:
- class aiida_vasp.common.builder_updater.VaspMultiStageRelaxUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, override_vasp_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, namespace_relax: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, code: str | None = None)[source]#
Bases:
aiida_vasp.common.builder_updater.VaspRelaxUpdaterAn updater for VaspRelaxWorkChain
Initialization
Initialise the update object.
- Parameters:
builder – The
ProcessBuilderorProcessBuilderNamespaceto be used for setting standard VaspWorkChain inputs.root_namespace – The namespace to be assumed to be the root, e.g. where the input structure should be specified. The v2 series of workchain in aiida-vasp usually has the StructureData input port at the top level interface, although there are a few exceptions.
preset_name – The name of the Preset to be used for the updater.
code – The code to be used for the calculation. If not specified, the default code from the preset will be used.
verbose – If True, print additional information during the update.
set_name – The name of the input set to be used. If not specified, the default input set from the preset will be used.
returns: An instance of VaspBuilderUpdater with the specified preset and builder.
- WF_ENTRYPOINT = 'vasp.v2.staged_relax'#
- class aiida_vasp.common.builder_updater.VaspConvUpdater(preset_name=None, builder=None, root_namespace=None, code=None, verbose=False, inputset_name=None)[source]#
Bases:
aiida_vasp.common.builder_updater.VaspBuilderUpdaterUpdate for VaspConvergenceWorkChain
Initialization
Initialise the update object.
- Parameters:
builder – The
ProcessBuilderorProcessBuilderNamespaceto be used for setting standard VaspWorkChain inputs.root_namespace – The namespace to be assumed to be the root, e.g. where the input structure should be specified. The v2 series of workchain in aiida-vasp usually has the StructureData input port at the top level interface, although there are a few exceptions.
preset_name – The name of the Preset to be used for the updater.
code – The code to be used for the calculation. If not specified, the default code from the preset will be used.
verbose – If True, print additional information during the update.
set_name – The name of the input set to be used. If not specified, the default input set from the preset will be used.
returns: An instance of VaspBuilderUpdater with the specified preset and builder.
- WF_ENTRYPOINT = 'vasp.v2.converge'#
- apply_preset(initial_structure: aiida.orm.StructureData, code: str | None = None, label: str | None = None, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBuilderUpdater[source]#
- set_conv_settings(**kwargs: Any) aiida_vasp.common.builder_updater.VaspConvUpdater[source]#
Set the convergence testing settings.
- Parameters:
kwargs – Convergence option key-value pairs
- Returns:
Self for method chaining
- Return type:
- class aiida_vasp.common.builder_updater.VaspBandUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, override_vasp_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, code: str | None = None)[source]#
Bases:
aiida_vasp.common.builder_updater.VaspBuilderUpdaterUpdater for VaspBandsWorkChain
Initialization
Initialise the update object.
- Parameters:
builder – The
ProcessBuilderorProcessBuilderNamespaceto be used for setting standard VaspWorkChain inputs.root_namespace – The namespace to be assumed to be the root, e.g. where the input structure should be specified. The v2 series of workchain in aiida-vasp usually has the StructureData input port at the top level interface, although there are a few exceptions.
preset_name – The name of the Preset to be used for the updater.
code – The code to be used for the calculation. If not specified, the default code from the preset will be used.
verbose – If True, print additional information during the update.
set_name – The name of the input set to be used. If not specified, the default input set from the preset will be used.
returns: An instance of VaspBuilderUpdater with the specified preset and builder.
- WF_ENTRYPOINT = 'vasp.v2.bands'#
- get_relax_updater() aiida_vasp.common.builder_updater.VaspRelaxUpdater[source]#
Return the relax updater for this band structure calculation.
The relax updater can be used to populate the .relax namespace which will trigger the relaxation of the structure before band structure calculation.
- Returns:
VaspRelaxUpdater instance configured for this band calculation
- Return type:
- apply_preset(structure: aiida.orm.StructureData, run_relax: bool = False, label: str | None = None, **kwargs: Any) aiida_vasp.common.builder_updater.VaspBandUpdater[source]#
- set_band_settings(**kwargs: Any) aiida_vasp.common.builder_updater.VaspBandUpdater[source]#
Set band structure calculation specific settings.
- Parameters:
kwargs – Band calculation option key-value pairs
- Returns:
Self for method chaining
- Return type:
- class aiida_vasp.common.builder_updater.VaspHybridBandUpdater(preset_name: str | None = None, builder: aiida.engine.processes.builder.ProcessBuilder | None = None, override_vasp_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace | None = None, code: str | None = None)[source]#
Bases:
aiida_vasp.common.builder_updater.VaspBandUpdaterUpdater for VaspHybridBandsWorkChain
Initialization
Initialise the update object.
- Parameters:
builder – The
ProcessBuilderorProcessBuilderNamespaceto be used for setting standard VaspWorkChain inputs.root_namespace – The namespace to be assumed to be the root, e.g. where the input structure should be specified. The v2 series of workchain in aiida-vasp usually has the StructureData input port at the top level interface, although there are a few exceptions.
preset_name – The name of the Preset to be used for the updater.
code – The code to be used for the calculation. If not specified, the default code from the preset will be used.
verbose – If True, print additional information during the update.
set_name – The name of the input set to be used. If not specified, the default input set from the preset will be used.
returns: An instance of VaspBuilderUpdater with the specified preset and builder.
- WF_ENTRYPOINT = 'vasp.v2.hybrid_bands'#
- aiida_vasp.common.builder_updater.is_specified(port_namespace: aiida.engine.processes.builder.ProcessBuilderNamespace) bool[source]#
Check if there is anything specified under a PortNamespace.
- Parameters:
port_namespace (ProcessBuilderNamespace) – Namespace to check for specified values
- Returns:
True if any values are specified in the namespace
- Return type:
- aiida_vasp.common.builder_updater.update_dict_node(node: aiida.orm.Dict, content: dict[str, Any], namespace: str | None = None, reuse_if_possible: bool = True) aiida.orm.Dict[source]#
Update a Dict node with new content.
Optionally updates a specific namespace within the Dict node. If the node is stored and immutable, creates a new node with updated content.
- Parameters:
- Returns:
Updated Dict node (may be the same or a new node)
- Return type:
orm.Dict
- aiida_vasp.common.builder_updater.builder_to_dict(builder: aiida.engine.processes.builder.ProcessBuilder, unpack: bool = True) dict[str, Any][source]#
Convert a builder to a dictionary and optionally unpack certain nodes.
When unpacked, the resulting dictionary cannot be used for submit/run. The primary usage of the resulting dictionary is for pretty printing.
- aiida_vasp.common.builder_updater.incar_dict_to_relax_settings(incar_in: dict[str, Any]) tuple[dict[str, Any], dict[str, Any]][source]#
Convert INCAR tags to relax_settings and remove them from INCAR.
Extracts relaxation-specific INCAR parameters (NSW, IBRION, EDIFFG) and converts them to equivalent relax_settings options.