aiida_vasp.workchains package

Submodules

Bands workchain.

class aiida_vasp.workchains.bands.BandsWorkChain(*args: Any, **kwargs: Any)[source]

Bases: WorkChain

Extract the band structure using k-point paths fetched from SeeKpath.

classmethod define(spec)[source]

Define the specification of the process, including its inputs, outputs and known exit codes.

A metadata input namespace is defined, with optional ports that are not stored in the database.

finalize()[source]

Finalize the workchain.

get_kpoints_path()[source]

Fetch the k-point path.

Run SeeKpath to get the high symmetry lines of the given structure. This routine returns a new (potentially different to the input structure) primitive structure. It also returns the k-point path for this structure.

init_next_workchain()[source]

Initialize the next workchain.

initialize()[source]

Initialize.

results()[source]

Attach the remaining output results.

run_next_workchain()[source]

Run the next workchain.

verify_next_workchain()[source]

Verify and inherit exit status from child workchains.

aiida_vasp.workchains.bands.attach_labels(bands, kpoints)[source]
aiida_vasp.workchains.bands.seekpath_structure_analysis(structure, parameters)[source]

Workfunction to extract k-points in the reciprocal cell.

This workfunction will take a structure and pass it through SeeKpath to get the primitive cell and the path of high symmetry k-points through its Brillouin zone. Note that the returned primitive cell may differ from the original structure in which case the k-points are only congruent with the primitive cell.

Convergence workchain.

class aiida_vasp.workchains.converge.ConvergeWorkChain(*args: Any, **kwargs: Any)[source]

Bases: WorkChain

A workchain to perform convergence tests.

analyze_conv()[source]

Analyze convergence and store its parameters.

analyze_pw_after_comp()[source]

Return True if we are running compressed convergence tests.

analyze_pw_after_disp()[source]

Return True if we are running displaced convergence tests.

analyze_pw_conv()[source]

Analyze the plane wave convergence and store it if need be.

classmethod define(spec)[source]

Define the specification of the process, including its inputs, outputs and known exit codes.

A metadata input namespace is defined, with optional ports that are not stored in the database.

finalize()[source]

Finalize the workchain.

init_comp_conv()[source]

Initialize the compression convergence tests.

init_converged()[source]

Prepare to run the final calculation.

init_disp_conv()[source]

Initialize the displacement convergence tests.

init_kpoints_conv_calc()[source]

Initialize a single k-point grid convergence calculation.

init_next_workchain()[source]

Initialize the next workchain calculation.

init_pw_conv_calc()[source]

Initialize a single plane wave convergence calculation.

init_rel_conv()[source]

Initialize the relative convergence tests.

initialize()[source]

Initialize.

results()[source]

Attach the remaining output results.

results_kpoints_conv_calc()[source]

Fetch and store the relevant convergence parameters for each k-point grid calculation.

results_pw_conv_calc()[source]

Fetch and store the relevant convergence parameters for each plane wave calculation.

run_conv_calcs()[source]

Determines if convergence calcs are to be run at all.

run_kpoints_conv_calcs()[source]

Should a new kpoints convergence calculation run?

run_kpoints_conv_comp_calcs()[source]

Should a new kpoints compression convergence calculation run?

run_kpoints_conv_disp_calcs()[source]

Should a new kpoints displacement convergence calculation run?

run_next_workchain()[source]

Run next workchain.

run_pw_conv_calcs()[source]

Should a new plane wave cutoff convergence calculation run?

run_pw_conv_comp_calcs()[source]

Should a new plane wave cutoff compression convergence calculation run?

run_pw_conv_disp_calcs()[source]

Should a new plane wave cutoff displacement convergence calculation run?

store_conv()[source]

Set up the convergence data and put it in a data node.

verify_next_workchain()[source]

Verify and inherit exit status from child workchains.

aiida_vasp.workchains.converge.default_array(name, array)[source]

Used to set ArrayData for spec.input.

aiida_vasp.workchains.converge.store_conv_data(convergence_context)[source]

Store convergence data in the array.

aiida_vasp.workchains.converge.store_conv_data_single(array, key, data)[source]

Store a single convergence data entry in the dict.

aiida_vasp.workchains.converge.store_conv_kgrid(convergence_context)[source]

Store the recommended kpoints from the convergence.

aiida_vasp.workchains.converge.store_conv_pwcutoff(convergence_context)[source]

Store the recommended energy from the convergence.

Vasp immigrant workchain.

class aiida_vasp.workchains.immigrant.VaspImmigrantWorkChain(*args: Any, **kwargs: Any)[source]

Bases: BaseRestartWorkChain

Import a VASP run executed in the directory specified by folder_path.

classmethod define(spec)[source]

Define the process specification.

init_inputs()[source]

Set inputs of VaspImmigrant calculation

Initial inputs (self.ctx.inputs) AttributeDict is obtained from VaspImmigrant.get_inputs_from_folder(), where the following items are already set in respective AiiDA data types,

code metadata[‘options’] parameters structure kpoints potential (optional) remote_workdir

Master workchain.

class aiida_vasp.workchains.master.MasterWorkChain(*args: Any, **kwargs: Any)[source]

Bases: WorkChain

The master workchain that selects sub workchains to perform necessary calculations.

classmethod define(spec)[source]

Define the specification of the process, including its inputs, outputs and known exit codes.

A metadata input namespace is defined, with optional ports that are not stored in the database.

extract_bands()[source]

Determines if we should extract the band structure.

extract_dos()[source]

Determines if we should extract the density of states.

finalize()[source]

Finalize the workchain.

init_bands()[source]

Initialize the run to extract the band structure.

init_dos()[source]

Initialize the run to extract the density of states at a denser k-point grid.

init_prerun()[source]

Initialize the prerun.

init_workchain()[source]

Initialize the base workchain.

initialize()[source]

Initialize.

loop_structures()[source]

Determine if we should continue to calculate structures.

run_next_workchain()[source]

Run the next workchain.

verify_next_workchain()[source]

Inherit exit status from child workchains.

VASP NEB workchain.

class aiida_vasp.workchains.neb.VaspNEBWorkChain(*args: Any, **kwargs: Any)[source]

Bases: BaseRestartWorkChain

The NEB workchain.

Deliberately conserves most of the interface (required inputs) of the VaspNEBCalculation class, but makes it possible for a user to interact with a workchain and not a calculation.

In addition, implement restarts of calculation when the calculation is net full converged for error handling.

classmethod define(spec)[source]

Define the process specification.

handle_unconverged(node)[source]

Handle the problem where the NEB optimization is not converged.

Note that VASP could reach NSW before the actual convergence. Hence this check is necessary even for finished runs.

handle_unfinished(node)[source]

Handle the case where the calculations is not fully finished. This checks the existing of the run_stats field in the parsed per-image misc output

results()[source]

Attach the outputs specified in the output specification from the last completed process.

setup()[source]

Initialize context variables that are used during the logical flow of the BaseRestartWorkChain.

aiida_vasp.workchains.neb.get_ldau_keys(structure, mapping, utype=2, jmapping=None, felec=False)[source]

Setup LDAU mapping. In VASP, the U for each species has to be defined in the order that they appear in POSCAR. This is a helper to make sure the values of U are associated to each specie

Arguments:

structure: the structure, either StructureData or ase.Atoms is fine mapping: a dictionary in the format of {“Mn”: [d, 4]…} for U utype: the type of LDA+U, default to 2, which is the one with only one parameter jmapping: a dictionary in the format of {“Mn”: [d, 4]…} but for J felec: Wether we are dealing with f electrons, will increase lmaxmix if we are.

Returns:

dict_update: a dictionary to be used to update the raw input parameters for VASP

Relax workchain.

parameters instead of the code dependent variables.

class aiida_vasp.workchains.relax.RelaxWorkChain(*args: Any, **kwargs: Any)[source]

Bases: WorkChain

Structure relaxation workchain.

analyze_convergence()[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_positions_convergence(delta)[source]

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

check_shape_convergence(delta)[source]

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

check_volume_convergence(delta)[source]

Check the convergence of the volume, given a cutoff.

classmethod define(spec)[source]

Define the specification of the process, including its inputs, outputs and known exit codes.

A metadata input namespace is defined, with optional ports that are not stored in the database.

finalize()[source]

Finalize the workchain.

init_next_workchain()[source]

Initialize the next workchain calculation.

init_relaxed()[source]

Initialize a calculation based on a relaxed or assumed relaxed structure.

initialize()[source]

Initialize.

perform_relaxation()[source]

Check if a relaxation is to be performed.

perform_static()[source]

Check if the final static calculation is to be performed.

results()[source]

Attach the remaining output results.

run_next_workchain()[source]

Run the next workchain.

run_next_workchains()[source]
store_relaxed()[source]

Store the relaxed structure.

verify_next_workchain()[source]

Verify and inherit exit status from child workchains.

VASP workchain.

Below is a copy of the error handler logic from aiida-core.

If the process is excepted or killed, the work chain will abort. Otherwise any attached handlers will be called in order of their specified priority. If the process was failed and no handler returns a report indicating that the error was handled, it is considered an unhandled process failure and the process is relaunched. If this happens twice in a row, the work chain is aborted. In the case that at least one handler returned a report the following matrix determines the logic that is followed:

Process Handler Handler Action result report? exit code —————————————– Success yes == 0 Restart Success yes != 0 Abort Failed yes == 0 Restart Failed yes != 0 Abort

If no handler returned a report and the process finished successfully, the work chain’s work is considered done and it will move on to the next step that directly follows the while conditional, if there is one defined in the outline.

This means that for a handler:

  • No error found - just return None

  • No action taken
    • the error is not recoverable - return with a non-zero error code with do break

    • the error is not recoverable, but other handler may/maynot save it - return with a non-zero code without do break

    • the error is not recoverable, and the workchain should be aborted immediately - non-zero code + do break

  • Action taken
    • the error is fixed in full - return with a zero error code with do_break=True

    • the error is not fixed in full - return with a report with do_break=False but has a exit_code. this mean other handlers (with lower priority) must handle it and return a zero error_code.

class aiida_vasp.workchains.vasp.VaspWorkChain(*args: Any, **kwargs: Any)[source]

Bases: BaseRestartWorkChain

The VASP workchain.

Deliberately conserves most of the interface (required inputs) of the VaspCalculation class, but makes it possible for a user to interact with a workchain and not a calculation.

This is intended to be used instead of directly submitting a VaspCalculation, so that future features like automatic restarting, error checking etc. can be propagated to higher level workchains automatically by implementing them here.

Handlers are implemented to try fix common problems and improves the robustness. Individual handlers can be enabled/disabled by setting the handler_overrides input port. Additional settings may be passed under the “settings” input, which is also forwarded to the calculations. The available options are:

  • USE_WAVECAR_FOR_RESTART wether calculation restarts should use the WAVECAR. The default is True.

Usage:

from aiida.common.extendeddicts import AttributeDict
from aiida.work import submit
basevasp = WorkflowFactory('vasp.vasp')
inputs = basevasp.get_builder()
inputs = AttributeDict()
## ... set inputs
submit(basevasp, **inputs)

To see a working example, including generation of input nodes from scratch, please refer to examples/run_vasp_lean.py.

check_calc_is_finished(node)[source]

Check if the calculation has reached the end of execution.

check_electronic_converged(node)[source]

Check if the calculation has converged electronic structure.

check_ionic_converged(node)[source]

Check if the calculation has converged ionic structure.

check_misc_output(node)[source]

Check if misc output exists.

classmethod define(spec)[source]

Define the process specification.

handler_always_attach_outputs(node)[source]

Handle the case where we attach the outputs even if underlying child calculation ends up with some exit status.

handler_calculation_did_not_run(node)[source]

Handle the case where the calculation is not performed

handler_electronic_conv(node)[source]

Handle electronic convergence problem

handler_electronic_conv_alt(node)[source]

Handle electronic convergence problem

handler_ionic_conv(node)[source]

Handle ionic convergence problem

handler_ionic_conv_enhanced(node)[source]

Enhanced handling of ionic relaxation problem beyond simple restarts.

This is only used when the calculation is having difficulties reaching the convergence. This handler should be applied before the standard handler which breaks the handling cycle.

handler_misc_not_exist(node)[source]

Handle the case where misc output is not available, in which case we cannot do anything for it.

handler_unfinished_calc_generic(node)[source]

A generic handler for unfinished calculations, we attempt to restart it once.

handler_unfinished_calc_generic_alt(node)[source]

A generic handler for unfinished calculations, we attempt to restart it once.

handler_unfinished_calc_ionic(node)[source]

Handled the problem such that the calculation is not finished, e.g. did not reach the end of execution.

If WAVECAR exists, just resubmit the calculation with the restart folder.

If it is a geometry optimization, attempt to restart with output structure + WAVECAR.

handler_unfinished_calc_ionic_alt(node)[source]

Handled the problem such that the calculation is not finished, e.g. did not reach the end of execution.

If WAVECAR exists, just resubmit the calculation with the restart folder.

If it is a geometry optimization, attempt to restart with output structure + WAVECAR.

handler_vasp_critical_error(node)[source]

Check if the calculation contain any critical error.

ignore_nelm_breach_relax(node)[source]

Not a actual handler but works as a switch to bypass checks for NELM breaches in the middle of an ionic relaxation.

init_inputs()[source]

Make sure all the required inputs are there and valid, create input dictionary for calculation.

property is_noncollinear

Check if the calculation is a noncollinear one

on_except(exc_info)[source]

Handle excepted state.

on_terminated()[source]

Clean the working directories of all child calculation jobs if clean_workdir=True in the inputs and the calculation is finished without problem.

prepare_inputs()[source]

Enforce some settings for the restart folder and set parameters tags for a restart. This is called because launching the sub process.

NOTE: This method should probably be refactored to give more control on what kind of restart is needed

setup()[source]

Initialize context variables that are used during the logical flow of the BaseRestartWorkChain.

update_magmom(node=None)[source]

Update magmom from site magnetization information if available

Parameters:

node – Calculation node to be used, defaults to the last launched calculation.

verbose_report(*args, **kwargs)[source]

Send report if self.ctx.verbose is True

aiida_vasp.workchains.vasp.list_valid_objects_in_remote(remote, path='.', size_threshold=0) list[source]

List non-empty objects in the remote folder

Parameters:
  • remote – The RemoteFolder node to be inspected.

  • path – The relative path.

  • size_threshold – The size threshold to treat the object as a valide one.

Returns:

A list of valid objects in the directory.