aiida_vasp.workchains.v2.relax#

Relaxation workchain for VASP

Unfortunately, VASP does not check the convergence criteria properly:

  • it only check either force or energy convergence between the last two iterations

  • relaxation is performed with constant basis set, so a final singlepoint calculation is necessary if cell is to be relaxed

  • no check for the convergence of the atomic positions

  • no check about the convergence of the cell volume

Hence we have to control it externally to make sure the structures are properly relaxed, and perform additional singlepoint calculation where necessary.

In addition, using this workchain, there is no need to set the IBRION, NSW, ISIF and ALGO tags explicitly, the action can be controlled using the relax_setting input port. This will be merged with the parameters and passed downstream to the VaspBaseWorkChain which will work out the correct combinations for the three.

CHANGELOG

0.2.1 - added hybrid_calc_bootstrap options 0.3.0 - make singpoint calculation reuse the restart_folder 0.3.1 - called processes now have link labels. Added customisable settings and options for the final relaxation.

Module Contents#

Classes#

VaspRelaxWorkChain

Structure relaxation workchain.

VaspMultiStageRelaxWorkChain

Relxation with multiple stages

Functions#

compare_structures

Compare two StructreData objects A, B and return a delta (A - B) of the relevant properties.

get_step_structure

Get the step structure, but assume the positions are fractional

detect_tetrahedral_method

Check if the tetrahedral method is used for BZ integration.

get_maximum_force

Return the maximum value of an array of forces with size (N, 3)

Data#

API#

aiida_vasp.workchains.v2.relax.__version__ = '0.5.0'#
class aiida_vasp.workchains.v2.relax.VaspRelaxWorkChain(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, aiida_vasp.workchains.v2.mixins.WithBuilderUpdater, aiida_vasp.protocols.ProtocolMixin

Structure relaxation workchain.

Initialization

Construct a WorkChain instance.

Construct the instance only if it is a sub class of WorkChain, otherwise raise InvalidOperation.

Parameters:
  • inputs – work chain inputs

  • logger – aiida logger

  • runner – work chain runner

  • enable_persistence – whether to persist this work chain

_verbose: bool = True#
_base_workchain_string: str = 'vasp.v2.vasp'#
_base_workchain = 'WorkflowFactory(...)'#
option_class = None#
_protocol_tag: str = 'relax'#
classmethod define(spec: aiida.engine.ProcessSpec) None[source]#
classmethod get_builder_from_protocol(code: aiida.orm.AbstractCode, structure: aiida.orm.StructureData, protocol=None, overrides=None, options=None, relax_settings=None, **kwargs)[source]#

Return a builder prepopulated with inputs selected according to the chosen protocol. :param code: the Code instance configured for the abacus.abacus plugin. :param structure: the StructureData instance to use. :param protocol: protocol to use, if not specified, the default will be used. :param overrides: optional dictionary of inputs to override the defaults of the protocol. :param options: A dictionary of options that will be recursively set for the metadata.options input of all

the CalcJobs that are nested in this work chain.

Returns:

a process builder instance with all inputs defined ready for launch.

initialize() None[source]#

Initialize.

_check_input_parameters() None[source]#

Validate the input parameters and detect problems before running the workchain

_init_relax_input_additions() aiida.common.extendeddicts.AttributeDict[source]#

Initialise the relax_additions field inside the context. It is a AttributeDict that contains the inputs that should be updated while performing the relaxation.

run_next_relax() bool[source]#
run_relax() aiida.engine.ToContext[source]#

Perform the relaxation

run_static_calculation() aiida.engine.ToContext[source]#

Perform the relaxation

verify_next_workchain() None | aiida.engine.ExitCode[source]#

Verify and inherit exit status from child workchains.

verify_last_relax() None | aiida.engine.ExitCode[source]#

Verify and inherit exit status from the last relaxation

analyze_convergence() None | aiida.engine.ExitCode[source]#

Analyze the convergence of the relaxation.

Compare the input and output structures of the most recent relaxation run. If volume, shape and ion positions are all within a given threshold, consider the relaxation converged.

check_shape_convergence(delta: aiida.common.extendeddicts.AttributeDict) bool[source]#

Check the difference in cell shape before / after the last iteratio against a tolerance.

check_volume_convergence(delta: aiida.common.extendeddicts.AttributeDict) bool[source]#

Check the convergence of the volume, given a cutoff.

check_positions_convergence(delta: aiida.common.extendeddicts.AttributeDict) bool[source]#

Check the convergence of the atomic positions, given a cutoff.

store_relaxed() None | aiida.engine.ExitCode[source]#

Store the relaxed structure.

results() None | aiida.engine.ExitCode[source]#

Attach the remaining output results. This can either be the final static calculation or the last relaxation if the former is not needed.

As a final check - check if the maximum_force is lower than the predefined value.

finalize() None[source]#

Finalize the workchain. Clean the remote working directories of the called calcjobs

perform_relaxation() bool[source]#

Check if a relaxation is to be performed.

should_run_static_calculation() bool[source]#

Control whether the static calculation should be run

is_verbose() bool[source]#

Are we in the verbose mode?

relax_option_class() aiida_vasp.utils.opthold.RelaxOptions#

Class for relax options

aiida_vasp.workchains.v2.relax.compare_structures(structure_a: aiida.orm.StructureData, structure_b: aiida.orm.StructureData) aiida.common.extendeddicts.AttributeDict[source]#

Compare two StructreData objects A, B and return a delta (A - B) of the relevant properties.

aiida_vasp.workchains.v2.relax.get_step_structure(traj: aiida.orm.TrajectoryData, step: int) aiida.orm.StructureData[source]#

Get the step structure, but assume the positions are fractional

aiida_vasp.workchains.v2.relax.detect_tetrahedral_method(input_dict: dict) bool[source]#

Check if the tetrahedral method is used for BZ integration.

class aiida_vasp.workchains.v2.relax.VaspMultiStageRelaxWorkChain(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, aiida_vasp.workchains.v2.mixins.WithBuilderUpdater

Relxation with multiple stages

This workchain allows to run multiple stages of relaxation with different parameters, options and settings. The workchain takes a structure as input and runs a series of VaspRelaxWorkChain calculations, each with updated set of parameters, options and settings as specified in <name>_stages.

The output of the final workchain is exposed.

Example:

vasp_staged_relax = VaspMultiStageRelaxWorkChain.get_builder()
vasp_staged_relax.structure = structure
vasp_staged_relax.relax = <usual relax inputs>
# Set ismear to 0 for the first stage, -5 for the second stage
vasp_staged_relax.parameters_stages = {
    '0': {'incar': {'ismear': 0}},
    '1': {'incar': {'ismear': 1, 'gga': 'pe', 'lhfcalc': True}},
    }
# Switch to RMM-DIIS for the second stage
vasp_staged_relax.relax_settings_stages = {
'1': {'algo': 'rd'}}
# Include node in the second stage of the relaxation
vasp_staged_relax.settings_stages = {
    '1': {'parser_settings': {'inlude_node': ['dos']}},
    }

Note that the index starts from 0 - e.g. ‘0’ for the first stage, ‘1’ for the second stage, etc.

Initialization

Construct a WorkChain instance.

Construct the instance only if it is a sub class of WorkChain, otherwise raise InvalidOperation.

Parameters:
  • inputs – work chain inputs

  • logger – aiida logger

  • runner – work chain runner

  • enable_persistence – whether to persist this work chain

_base_workchain = None#
classmethod define(spec: aiida.engine.ProcessSpec) None[source]#
setup() None[source]#

Initialize context variables

should_run_stage() bool[source]#

Check if a stage should be run

run_stage() aiida.engine.ToContext[source]#

Run a stage

inspect_stage() None | aiida.engine.ExitCode[source]#

Inspect a stage

results() None[source]#

Attach the remaining output results. This can either be the final static calculation or the last relaxation if the former is not needed.

As a final check - check if the maximum_force is lower than the predefined value.

aiida_vasp.workchains.v2.relax.get_maximum_force(forces: numpy.ndarray, dof=None) float[source]#

Return the maximum value of an array of forces with size (N, 3)