aiida_vasp.protocols.generator#

Input generators based on protocols

This module aimed at interactive post-generation update for the builder created by .get_builder_from_protocol method of various workchain classes.

Module Contents#

Classes#

PresetConfig

Class to store the preset for inputs

BaseInputGenerator

BaseClass for all protocol builder updaters

VaspInputGenerator

Updater for VaspWorkChain’s builder

VaspRelaxInputGenerator

Updater for VaspRelaxWorkChain’s builder

VaspBandsInputGenerator

Updater for VaspBandsWorkChain’s builder

VaspConvergenceInputGenerator

Updater for VaspConvergenceWorkChain

VaspHybridBandsInputGenerator

Update for VaspHybridBandsWorkChain

Functions#

get_library_path

Get the path where the YAML files are stored within this package.

list_protocol_presets

List all available presets in the package.

update_dict_node

Update a Dict node with new content.

incar_dict_to_relax_settings

Convert INCAR tags to relax_settings and remove them from INCAR.

recursive_search_dict_with_key

Recursively search for Dict node with certain key

recursive_search_port_basename

Recursively search for Dict node with certain key

has_content

Check if a dictionary is all empty

Data#

API#

aiida_vasp.protocols.generator.__all__ = ['VaspBandsInputGenerator', 'VaspConvergenceInputGenerator', 'VaspHybridBandsInputGenerator', 'VaspI...#
aiida_vasp.protocols.generator.DEFAULT_PRESET = 'default_preset'#
aiida_vasp.protocols.generator.DEFAULT_PROTOCOL = 'balanced'#
aiida_vasp.protocols.generator.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:

pathlib.Path

aiida_vasp.protocols.generator.list_protocol_presets() list[pathlib.Path][source]#

List all available presets in the package.

class aiida_vasp.protocols.generator.PresetConfig[source]#

Class to store the preset for inputs

name: str = None#
default_protocol: str = None#
default_code: str = None#
code_specific: dict = 'field(...)'#
default_options: dict = 'field(...)'#
default_settings: dict = 'field(...)'#
protocol_overrides: dict = 'field(...)'#
default_relax_settings: dict = 'field(...)'#
default_band_settings: dict = 'field(...)'#
classmethod from_file(fname: str) aiida_vasp.protocols.generator.PresetConfig[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/protocol_presets/).

Parameters:

fname (str) – Name of the configuration file (without .yaml extension)

Returns:

ProtocolPresetConfig instance loaded from file

Return type:

ProtocolPresetConfig

Raises:

RuntimeError – If the preset definition file cannot be found

get_code_specific_options(code: str, namespace: str) dict[str, Any][source]#

Return code-specific options for a given namespace.

If code-specific options exist, they are merged with the default options for the namespace, with code-specific options taking precedence.

Parameters:
  • code (str) – Name/identifier of the computational code

  • namespace (str) – Configuration namespace (e.g., ‘options’, ‘settings’)

Returns:

Dictionary containing the merged options

Return type:

dict

class aiida_vasp.protocols.generator.BaseInputGenerator(preset_name: str = 'default', protocol: str | None = None, verbose: bool = False)[source]#

BaseClass for all protocol builder updaters

The protocol updater serves two purposes: - Generating a builder based on a user-defined “preset”, e.g. with options and overrides pre-loaded - Allow interactive modifications of common parameters such as incar tag’s, resources and options.

Initialization

Instantiate a pipeline

WF_ENTRYPOINT = 'vasp.vasp'#
get_builder(structure, code=None, protocol=None, overrides=None, **kwargs)[source]#

Generate builder base on a given structure and overrides (if supplied)

property reference_structure#
set_incar(incar_updates=None, update_all=True, ports=None, namespace='incar', **kwargs)[source]#

Set incar dictionary

set_options(option_updates=None, ports=None, update_all=True, **kwargs)[source]#

Set the options input port

set_resources(resources_updates=None, ports=None, update_all=True, **kwargs)[source]#

Set the options input port

_update_ports_by_base_name(value, port_basename, ports=None, update_all=True, merge=False, skip_empty=True)[source]#

Update a port by basename

_update_dict_node(port, update: dict, dict_node=None, namespace=None, reuse_if_possible=True)[source]#
_set_generic_port_by_dict(_port_name, value=None, ports=None, update_all=True, skip_empty=True, **kwargs)[source]#

Set a generic port by a value or kwargs

_get_port_node(port)[source]#

Return the node corresponds to specific port

_set_node_to_port(port, node: aiida.orm.Data)[source]#

Set a node to a specific port of hte builder

__repr__()[source]#
_repr_pretty_(p, _=None) str[source]#

Pretty representation for in the IPython console and notebooks.

set_kspacing(value, ports=None, update_all=True)[source]#

Update the kpoints spacing

set_kpoints_mesh(mesh: list[int], offset=(0.0, 0.0, 0.0), ports=None, update_all=True)[source]#

Set kpoints mesh

set_label(label=None)[source]#

Alias to set the self.builder.metadata.label

set_potential_family(value, ports=None, update_all=True)[source]#

Update the potential family

set_potential_mapping(value=None, ports=None, update_all=True, **kwargs)[source]#

Set the potential mapping

set_code(value, ports=None, update_all=True)[source]#

Update the code node

set_settings(value, ports=None, update_all=True, **kwargs)[source]#

Update the settings port.

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.

Parameters:
  • namespace (str) – Namespace path (e.g., ‘vasp.parameters’)

  • print_to_stdout (bool) – Whether to print help to stdout or return it

  • inout (str) – Whether to get help for ‘inputs’ or ‘outputs’

Returns:

Help message if print_to_stdout is False, otherwise None

Return type:

str or None

get_output_help(namespace: str, print_to_stdout: bool = True) str | None[source]#

Return the help message for a given output namespace.

Parameters:
  • namespace (str) – Output namespace path

  • print_to_stdout (bool) – Whether to print help to stdout or return it

Returns:

Help message if print_to_stdout is False, otherwise None

Return type:

str or None

get_input_help(namespace: str, print_to_stdout: bool = True) str | None[source]#

Return the help message for a given input namespace.

Parameters:
  • namespace (str) – Input namespace path

  • print_to_stdout (bool) – Whether to print help to stdout or return it

Returns:

Help message if print_to_stdout is False, otherwise None

Return type:

str or None

class aiida_vasp.protocols.generator.VaspInputGenerator(preset_name: str = 'default', protocol: str | None = None, verbose: bool = False)[source]#

Bases: aiida_vasp.protocols.generator.BaseInputGenerator

Updater for VaspWorkChain’s builder

Initialization

Instantiate a pipeline

class aiida_vasp.protocols.generator.VaspRelaxInputGenerator(preset_name: str = 'default', protocol: str | None = None, verbose: bool = False)[source]#

Bases: aiida_vasp.protocols.generator.BaseInputGenerator

Updater for VaspRelaxWorkChain’s builder

Initialization

Instantiate a pipeline

WF_ENTRYPOINT = 'vasp.relax'#
set_relax_settings(value=None, **kwargs)[source]#

Set the relax_settings port

get_builder(structure, code=None, protocol=None, overrides=None, **kwargs)[source]#
class aiida_vasp.protocols.generator.VaspBandsInputGenerator(preset_name: str = 'default', protocol: str | None = None, verbose: bool = False)[source]#

Bases: aiida_vasp.protocols.generator.BaseInputGenerator

Updater for VaspBandsWorkChain’s builder

Initialization

Instantiate a pipeline

WF_ENTRYPOINT = 'vasp.bands'#
set_band_settings(value=None, **kwargs)[source]#

Set the band_settings port

set_settings(*args, **kwargs)[source]#

Set the settings port

get_builder(structure, code=None, protocol=None, overrides=None, run_relax=True, **kwargs)[source]#

Generate builder base on a given structure and overrides (if supplied)

class aiida_vasp.protocols.generator.VaspConvergenceInputGenerator(preset_name: str = 'default', protocol: str | None = None, verbose: bool = False)[source]#

Bases: aiida_vasp.protocols.generator.BaseInputGenerator

Updater for VaspConvergenceWorkChain

Initialization

Instantiate a pipeline

WF_ENTRYPOINT = 'vasp.converge'#
set_conv_settings(value=None, **kwargs)[source]#

Set the conv_settings port

class aiida_vasp.protocols.generator.VaspHybridBandsInputGenerator(preset_name: str = 'default', protocol: str | None = None, verbose: bool = False)[source]#

Bases: aiida_vasp.protocols.generator.VaspBandsInputGenerator

Update for VaspHybridBandsWorkChain

Initialization

Instantiate a pipeline

WF_ENTRYPOINT = 'vasp.hybrid_bands'#
aiida_vasp.protocols.generator.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:
  • node (orm.Dict) – The Dict node to update

  • content (dict) – Dictionary content to merge into the node

  • namespace (str or None) – Optional namespace key within the Dict to update

  • reuse_if_possible (bool) – Whether to reuse the existing node if content is unchanged

Returns:

Updated Dict node (may be the same or a new node)

Return type:

orm.Dict

aiida_vasp.protocols.generator.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.

Parameters:

incar_in (dict) – Input dictionary containing INCAR parameters

Returns:

Tuple of (updated_incar_dict, relax_settings_dict)

Return type:

tuple

aiida_vasp.protocols.generator.recursive_search_dict_with_key(namespace, search_key)[source]#

Recursively search for Dict node with certain key

aiida_vasp.protocols.generator.recursive_search_port_basename(namespace, basename)[source]#

Recursively search for Dict node with certain key

aiida_vasp.protocols.generator.has_content(mapping)[source]#

Check if a dictionary is all empty