aiida_castep.workflows package#
Submodules#
aiida_castep.workflows.bands module#
Workflow from computing the band structures
- class aiida_castep.workflows.bands.CastepBandsWorkChain(*args: Any, **kwargs: Any)[source]#
Bases:
aiida.engine.processes.workchains.workchain.WorkChain
Workchain for running bands calculation.
This workchain does the following:
Relax the structure if requested (eg. inputs passed to the relax namespace).
Optionally: Do a SCF singlepoint calculation
Do combined SCF + non-SCF calculation for bands and dos.
Inputs must be passed for the SCF calculation (dispatched to bands and DOS), others are optional.
Input for bands and dos calculations are optional. However, if they are needed, the full list of inputs must be passed. For the parameters node, one may choose to only specify those fields that need to be updated.
- __abstractmethods__ = frozenset({})#
- __module__ = 'aiida_castep.workflows.bands'#
- _abc_impl = <_abc_data object>#
- _base_wk_string = 'castep.base'#
- _relax_wk_string = 'castep.relax'#
- _task_name = 'spectral'#
- aiida_castep.workflows.bands.compose_labelled_bands(bands, kpoints)[source]#
Add additional information from the kpoints allow richer informations to be stored such as band structure labels.
- aiida_castep.workflows.bands.dos_from_bands(bands, smearing, npoints)[source]#
Compute DOS from bands
- Parameters
bands – The BandsData to be used as input.
smearing – Smearing width in eV
npoints – Number of points
- aiida_castep.workflows.bands.ensure_checkpoint(pdict)[source]#
Ensure that check/castep_bin file will be wirtten
- aiida_castep.workflows.bands.nested_update(dict_in, update_dict)[source]#
Update the dictionary - combine nested subdictionary with update as well
- aiida_castep.workflows.bands.nested_update_dict_node(dict_node, update_dict)[source]#
Utility to update a Dict node in a nested way
- aiida_castep.workflows.bands.seekpath_structure_analysis(structure, **kwargs)[source]#
Primitivize the structure with SeeKpath and generate the high symmetry k-point path through its Brillouin zone. This calcfunction will take a structure and pass it through SeeKpath to get the normalized 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. The keyword arguments can be used to specify various Seekpath parameters, such as:
with_time_reversal: True reference_distance: 0.025 recipe: ‘hpkot’ threshold: 1e-07 symprec: 1e-05 angle_tolerance: -1.0
Note that exact parameters that are available and their defaults will depend on your Seekpath version.
aiida_castep.workflows.base module#
This module contains the base workchain class which acts as the starting point of implementing more complex ones
- class aiida_castep.workflows.base.CastepBaseWorkChain(*args: Any, **kwargs: Any)[source]#
Bases:
aiida.engine.processes.workchains.workchain.WorkChain
A basic workchain for generic CASTEP calculations. We try to handle erros such as walltime exceeded or SCF not converged
- __abstractmethods__ = frozenset({})#
- __init__(*args, **kwargs)[source]#
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
- __module__ = 'aiida_castep.workflows.base'#
- _abc_impl = <_abc_data object>#
- _calculation_class#
- _context_pain_dicts = ('parameters', 'settings')#
- _error_handlers = [ErrorHandler(priority=900, method=<function _handle_scf_failure>), ErrorHandler(priority=500, method=<function _handle_walltime_limit>), ErrorHandler(priority=600, method=<function _handle_no_empty_bands>), ErrorHandler(priority=10000, method=<function _handle_stop_by_request>)]#
- _handle_calculation_failure(calculation)[source]#
Handle failure of calculation by refering to a range of handlers
- _handle_no_empty_bands(calculation)#
Handle the case where there is no empty bands
- _handle_scf_failure(calculation)#
Handle case when SCF failed
- _handle_stop_by_request(calculation)#
Handle the case when the stop flag is raised by the user
- _handle_unexpected_failure(calculation, exception=None)[source]#
The calculation has failed for an unknown reason and could not be handled. If the unexpected_failure flag is true, this is the second consecutive unexpected failure and we abort the workchain. Otherwise we restart once more.
- _handle_walltime_limit(calculation)#
Handle case when the walltime limit has reached
- _spec = <aiida.engine.processes.workchains.workchain.WorkChainSpec object>#
- _verbose = False#
- inspect_calculation()[source]#
Analyse the results of the previous calculation, return/restart/abort if necessary
- 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.
- results()[source]#
Attach the outputs specified in the output specification from the last completed calculation
- aiida_castep.workflows.base._compute_castep_gam_offset(grids)[source]#
Compute the offset need to get gamma-centred grids for a given grid specification
Note that the offset are expressed in the reciprocal cell units.
- aiida_castep.workflows.base._get_castep_output_file(calculation)[source]#
Return a list of the lines in the retrieved dot castep file
- aiida_castep.workflows.base._handle_no_empty_bands(self, calculation)[source]#
Handle the case where there is no empty bands
- aiida_castep.workflows.base._handle_scf_failure(self, calculation)[source]#
Handle case when SCF failed
aiida_castep.workflows.common module#
Common module Courtesy to aiida-quantumespresso’s WorkChain design
- class aiida_castep.workflows.common.ErrorHandler(priority, method)#
Bases:
tuple
A namedtuple to define an error handler for a
WorkChain
.The priority determines in which order the error handling methods are executed, with the higher priority being executed first. The method defines an unbound WorkChain method that takes an instance of a
CalcJobNode
as its sole argument. If the condition of the error handler is met, it should return anErrorHandlerReport
.- Parameters
priority – integer denoting the error handlers priority
method – the workchain class method
- __getnewargs__()#
Return self as a plain tuple. Used by copy and pickle.
- __module__ = 'aiida_castep.workflows.common'#
- static __new__(_cls, priority, method)#
Create new instance of ErrorHandler(priority, method)
- __repr__()#
Return a nicely formatted representation string
- __slots__ = ()#
- _asdict()#
Return a new dict which maps field names to their values.
- _field_defaults = {}#
- _fields = ('priority', 'method')#
- _fields_defaults = {}#
- classmethod _make(iterable)#
Make a new ErrorHandler object from a sequence or iterable
- _replace(**kwds)#
Return a new ErrorHandler object replacing specified fields with new values
- method#
Alias for field number 1
- priority#
Alias for field number 0
- class aiida_castep.workflows.common.ErrorHandlerReport(is_handled, do_break, exit_code)#
Bases:
tuple
- __getnewargs__()#
Return self as a plain tuple. Used by copy and pickle.
- __module__ = 'aiida_castep.workflows.common'#
- static __new__(_cls, is_handled=False, do_break=False, exit_code=ExitCode(status=0, message=None, invalidates_cache=False))#
Create new instance of ErrorHandlerReport(is_handled, do_break, exit_code)
- __repr__()#
Return a nicely formatted representation string
- __slots__ = ()#
- _asdict()#
Return a new dict which maps field names to their values.
- _field_defaults = {}#
- _fields = ('is_handled', 'do_break', 'exit_code')#
- _fields_defaults = {}#
- classmethod _make(iterable)#
Make a new ErrorHandlerReport object from a sequence or iterable
- _replace(**kwds)#
Return a new ErrorHandlerReport object replacing specified fields with new values
- do_break#
Alias for field number 1
- exit_code#
Alias for field number 2
- is_handled#
Alias for field number 0
- exception aiida_castep.workflows.common.UnexpectedCalculationFailure[source]#
Bases:
aiida.common.exceptions.AiidaException
Exception for encountering unknown errors
- __module__ = 'aiida_castep.workflows.common'#
- aiida_castep.workflows.common.register_error_handler(cls, priority)[source]#
Decorator that will turn any function in an error handler for workchain that inherits from the
BaseCastepWorkChain
. The function expects two arguments, a workchain class and a priortity. The decorator will add the function as a class method to the workchain class and add anErrorHandler
tuple to theBaseCastepWorkChain._error_handlers
attribute of the workchain. During failed calculation handling theinspect_calculation()
outline method will call the _handle_calculation_failure which will loop over all error handler in theBaseCastepWorkChain._error_handlers
, sorted with respect to the priority in reverse. If the workchain class defines aBaseCastepWorkChain._verbose
attribute and is set to True, a report message will be fired when the error handler is executed.Requirements on the function signature of error handling functions. The function to which the decorator is applied needs to take two arguments:
self: This is the instance of the workchain itself
calculation: This is the calculation that failed and needs to be investigated
The function body should usually consist of a single conditional that checks the calculation if the error that it is designed to handle is applicable. Although not required, it is advised that the function return an
ErrorHandlerReport
tuple when its conditional was met. If an error was handled it should set is_handled to True. If no other error handlers should be considered set do_break to True.- Parameters
cls – the workchain class to register the error handler with
priority – an integer that defines the order in which registered handlers will be called during the handling of a failed calculation. Higher priorities will be handled first
aiida_castep.workflows.relax module#
Module for Relaxation WorkChain
CHANGELOG:
0.1.0: Added
bypass
option to skip convergence checking. The user is still responsible to setting the correct inputs.
- class aiida_castep.workflows.relax.CastepAlterRelaxWorkChain(*args: Any, **kwargs: Any)[source]#
Bases:
aiida_castep.workflows.relax.CastepRelaxWorkChain
A relaxation workflow that alternates between fixed cell and unfixed cell This is meidate the problem in CASTEP where if the cell is partially constraints the convergence would be very slow.
To overcome this problem, the structure should be relaxed with cell constraints then restart with fixed cell and repeat.
Following fields can be used in
relax_options
- Var_cell_iter_max
Maximum iterations in variable cell relaxation, default to 10
- Fix_cell_iter_max
Maximum iterations in fixed cell relaxation, default to 20
- __abstractmethods__ = frozenset({})#
- __module__ = 'aiida_castep.workflows.relax'#
- _abc_impl = <_abc_data object>#
- _default_fix_cell_iter_max = 20#
- _default_var_cell_iter_max = 10#
- _max_meta_iterations = 11#
- class aiida_castep.workflows.relax.CastepRelaxWorkChain(*args: Any, **kwargs: Any)[source]#
Bases:
aiida.engine.processes.workchains.workchain.WorkChain
WorkChain to relax structures. Restart the relaxation calculation until the structure is fully relaxed. Each CASTEP relaxation may finish without error with not fully relaxed structure if the number of iteration is exceeded (geom_max_iter). This workchain try to restart such calculations (wrapped in CastepBaseWorkChain) until the structure is fully relaxed
relax_options
is a Dict of the options avaliable fields are:restart_mode: mode of restart, choose from
reuse
(default),structure
,continuation
.bypass: Bypass relaxation control - e.g. no checking of the convergence. Can be used for doing singlepoint calculation.
- __abstractmethods__ = frozenset({})#
- __module__ = 'aiida_castep.workflows.relax'#
- _abc_impl = <_abc_data object>#
- _max_meta_iterations = 10#
- _push_parameters(workchain)[source]#
Push the parameters for completed calculation to the current inputs
- _spec = <aiida.engine.processes.workchains.workchain.WorkChainSpec object>#
Module contents#
Sub-package of workchain and workfuctions for aiida-castep