aiida_vasp.workchains.v2.vasp#
This file contains the VaspWorkChain class definition which uses the BaseRestartWorkChain.
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.
Module Contents#
Classes#
The VASP workchain. |
Functions#
List non-empty objects in the remote folder |
|
Validate the potential family input. |
|
Validate the entire set of inputs passed to the CalcJob constructor. |
API#
- class aiida_vasp.workchains.v2.vasp.VaspWorkChain(*args, **kwargs)[source]#
Bases:
aiida.engine.processes.workchains.restart.BaseRestartWorkChain,aiida_vasp.workchains.v2.mixins.WithBuilderUpdater,aiida_vasp.protocols.ProtocolMixinThe VASP workchain.
Error handling enriched wrapper around VaspCalculation.
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_overridesinput port. Additional settings may be passed under the “settings” input, which is also forwarded to the calculations. The available options are:USE_WAVECAR_FOR_RESTARTwether calculation restarts should use the WAVECAR. The default isTrue.
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.Initialization
Construct the instance.
- _verbose = False#
- _process_class = 'CalculationFactory(...)'#
- _algo_switching = None#
- _default_unsupported_parameters = None#
- _protocol_tag = 'vasp'#
- classmethod get_builder_from_protocol(code: aiida.orm.AbstractCode, structure: aiida.orm.StructureData, protocol=None, overrides=None, options=None, **_)[source]#
Return a builder prepopulated with inputs selected according to the chosen protocol.
- Parameters:
code – the
Codeinstance configured for theabacus.abacusplugin.structure – the
StructureDatainstance to use.protocol – protocol to use, if not specified, the default will be used.
overrides – optional dictionary of inputs to override the defaults of the protocol.
options – A dictionary of options that will be recursively set for the
metadata.optionsinput of all theCalcJobsthat are nested in this work chain.
- Returns:
a process builder instance with all inputs defined ready for launch.
- prepare_inputs() None[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
- update_magmom(node: Optional[aiida.orm.CalcJobNode] = None) None[source]#
Update magmom from site magnetization information if available
- Parameters:
node – Calculation node to be used, defaults to the last launched calculation.
- init_inputs() Optional[aiida.engine.ExitCode][source]#
Make sure all the required inputs are there and valid, create input dictionary for calculation.
- on_except(exc_info: Tuple[Any, Exception, types.TracebackType]) None[source]#
Handle excepted state.
- on_terminated() None[source]#
Clean the working directories of all child calculation jobs if clean_workdir=True in the inputs and the calculation is finished without problem.
- _get_run_status(node: aiida.orm.CalcJobNode) None[source]#
Return the run status of the calculation.
- handler_always_attach_outputs(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][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: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Handle the case where the calculation is not performed
- handler_misc_not_exist(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Handle the case where misc output is not available, in which case we cannot do anything for it.
- handler_unfinished_calc_ionic(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][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: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][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_generic_alt(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
A generic handler for unfinished calculations, we attempt to restart it once.
- handler_unfinished_calc_generic(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
A generic handler for unfinished calculations, we attempt to restart it once.
- handler_electronic_conv_alt(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Handle electronic convergence problem
- handler_electronic_conv(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Handle electronic convergence problem
- handler_ionic_conv_enhanced(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][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_ionic_conv(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Handle ionic convergence problem
- handler_vasp_critical_error(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Check if the calculation contain any critical error.
- check_misc_output(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Check if misc output exists.
- check_calc_is_finished(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Check if the calculation has reached the end of execution.
- check_electronic_converged(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Check if the calculation has converged electronic structure.
- check_ionic_converged(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Check if the calculation has converged ionic structure.
- ignore_nelm_breach_relax(node: aiida.orm.CalcJobNode) None[source]#
- Not a actual handler but works as a switch to bypass checks for NELM breaches
in the middle of an ionic relaxation.
- _calculation_sanity_checks(node: aiida.orm.CalcJobNode) Optional[aiida.engine.processes.workchains.restart.ProcessHandlerReport][source]#
Perform additional sanity checks on successfully completed calculation. This method acts invokes the ‘check’ handlers to check the calculations and abort the workchain if any problem is found. This is useful when all of the corresponding error handlers are disabled, and allow one to avoid the default behaviour of restarting the calculation one more times regardlessly with unhandled errors.
- aiida_vasp.workchains.v2.vasp.list_valid_objects_in_remote(remote: aiida.orm.RemoteData, path: str = '.', size_threshold: int = 0) List[str][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.
- aiida_vasp.workchains.v2.vasp.potential_family_validator(family: aiida.orm.Str, _) None[source]#
Validate the potential family input.
- Parameters:
faimly – The potential family to be validated.
- Raises:
ValueError – If the potential family is not valid.
- aiida_vasp.workchains.v2.vasp.validate_calc_job_custom(inputs: Any, ctx) Optional[str][source]#
Validate the entire set of inputs passed to the CalcJob constructor.
Reasons that will cause this validation to raise an InputValidationError:
No Computer has been specified, neither directly in metadata.computer nor indirectly through the Code input
The specified computer is not stored
The Computer specified in metadata.computer is not the same as that of the specified Code
No Code has been specified and no remote_folder input has been specified, i.e. this is no import run
- Returns:
string with error message in case the inputs are invalid