aiida_quantumespresso.workflows.pw.base#

Workchain to run a Quantum ESPRESSO pw.x calculation with automated error handling and restarts.

Module Contents#

Classes#

PwBaseWorkChain

Workchain to run a Quantum ESPRESSO pw.x calculation with automated error handling and restarts.

Attributes#

PwCalculation

SsspFamily

PseudoDojoFamily

CutoffsPseudoPotentialFamily

aiida_quantumespresso.workflows.pw.base.PwCalculation[source]#
aiida_quantumespresso.workflows.pw.base.SsspFamily[source]#
aiida_quantumespresso.workflows.pw.base.PseudoDojoFamily[source]#
aiida_quantumespresso.workflows.pw.base.CutoffsPseudoPotentialFamily[source]#
class aiida_quantumespresso.workflows.pw.base.PwBaseWorkChain(*args, **kwargs)[source]#

Bases: aiida_quantumespresso.workflows.protocols.utils.ProtocolMixin, aiida.engine.BaseRestartWorkChain

Workchain to run a Quantum ESPRESSO pw.x calculation with automated error handling and restarts.

_process_class[source]#
defaults[source]#
classmethod define(spec)[source]#

Define the process specification.

classmethod get_protocol_filepath()[source]#

Return pathlib.Path to the .yaml file that defines the protocols.

classmethod get_builder_from_protocol(code, structure, protocol=None, overrides=None, electronic_type=ElectronicType.METAL, spin_type=SpinType.NONE, initial_magnetic_moments=None, options=None, **_)[source]#

Return a builder prepopulated with inputs selected according to the chosen protocol.

Parameters:
  • code – the Code instance configured for the quantumespresso.pw plugin.

  • structure – the StructureData instance 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.

  • electronic_type – indicate the electronic character of the system through ElectronicType instance.

  • spin_type – indicate the spin polarization type to use through a SpinType instance.

  • initial_magnetic_moments – optional dictionary that maps the initial magnetic moment of each kind to a desired value for a spin polarized calculation. Note that in case the starting_magnetization is also provided in the overrides, this takes precedence over the values provided here. In case neither is provided and spin_type == SpinType.COLLINEAR, an initial guess for the magnetic moments is used.

  • 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.

setup()[source]#

Call the setup of the BaseRestartWorkChain and create the inputs dictionary in self.ctx.inputs.

This self.ctx.inputs dictionary will be used by the BaseRestartWorkChain to submit the calculations in the internal loop.

The parameters and settings input Dict nodes are converted into a regular dictionary and the default namelists for the parameters are set to empty dictionaries if not specified.

validate_kpoints()[source]#

Validate the inputs related to k-points.

Either an explicit KpointsData with given mesh/path, or a desired k-points distance should be specified. In the case of the latter, the KpointsData will be constructed for the input StructureData using the create_kpoints_from_distance calculation function.

set_restart_type(restart_type, parent_folder=None)[source]#

Set the restart type for the next iteration.

prepare_process()[source]#

Prepare the inputs for the next calculation.

report_error_handled(calculation, action)[source]#

Report an action taken for a calculation that has failed.

This should be called in a registered error handler if its condition is met and an action was taken.

Parameters:
  • calculation – the failed calculation node

  • action – a string message with the action taken

sanity_check_insufficient_bands(calculation)[source]#

Perform a sanity check on the band occupations of a successfully converged calculation.

Verify that the occupation of the last band is below a certain threshold, unless occupations was explicitly set to fixed in the input parameters. If this is violated, the calculation used too few bands and cannot be trusted. The number of bands is increased and the calculation is restarted, using the charge density from the previous calculation.

handle_unrecoverable_failure(calculation)[source]#

Handle calculations with an exit status below 400 which are unrecoverable, so abort the work chain.

handle_known_unrecoverable_failure(calculation)[source]#

Handle calculations with an exit status that correspond to a known failure mode that are unrecoverable.

These failures may always be unrecoverable or at some point a handler may be devised.

handle_diagonalization_errors(calculation)[source]#

Handle known issues related to the diagonalization.

We use the following strategy. When a diagonalization algorithm fails, we try using an other one still not used. Conjugate gradient (CG) is kept as last option, as it is the slowest among the available ones, but on the contrary it is the most stable as well, thus kept as last resort.

Once the error handler has tried all diagonalization options, abort.

handle_out_of_walltime(calculation)[source]#

Handle ERROR_OUT_OF_WALLTIME exit code.

In this case the calculation shut down neatly and we can simply restart. We consider two cases:

  1. If the structure is unchanged, we do a full restart.

  2. If the structure has changed during the calculation, we restart from scratch.

handle_ionic_interrupted_partial_trajectory(calculation)[source]#

Handle ERROR_IONIC_INTERRUPTED_PARTIAL_TRAJECTORY exit code.

In this case the calculation got interrupted during an ionic optimization due to a problem that is likely transient, so we can restart from the last output structure. Note that since the job got interrupted the charge density and wave functions are likely corrupt so those cannot be used in the restart.

handle_vcrelax_converged_except_final_scf(calculation)[source]#

Handle ERROR_IONIC_CONVERGENCE_REACHED_EXCEPT_IN_FINAL_SCF exit code.

Convergence reached in vc-relax except thresholds exceeded in final scf: consider as converged.

handle_relax_recoverable_ionic_convergence_bfgs_history_error(calculation)[source]#

Handle failure of the ionic minimization algorithm (BFGS).

When BFGS history fails, this can mean two things: the structure is close to the global minimum, but the moves the algorithm wants to do are smaller than trust_radius_min, or the structure is close to a local minimum (hard to detect). For the first, we restart with lowered trust_radius_min. For the first case, one can lower the trust radius; for the second one, one can exploit a different algorithm, e.g. damp (and damp-w for vc-relax).

handle_relax_recoverable_ionic_convergence_error(calculation)[source]#

Handle various exit codes for recoverable relax calculations with failed ionic convergence.

These exit codes signify that the ionic convergence thresholds were not met, but the output structure is usable, so the solution is to simply restart from scratch but from the output structure.

handle_vcrelax_recoverable_fft_significant_volume_contraction_error(calculation)[source]#

Handle exit code for recoverable vc-relax calculations with significant volume contraction.

This exit code appears when a cell relaxation produces a significant volume scaling (contraction or expansion). This means the pseudopotentials tables must be recalculated. This parameter is controlled by CELL.cell_factor. The solution, as suggested by the QuantumESPRESSO error itself, is to restart with an increased cell_factor. We then start from scratch using the last output structure and we double the cell factor.

handle_relax_recoverable_electronic_convergence_error(calculation)[source]#

Handle various exit codes for recoverable relax calculations with failed electronic convergence.

These exit codes signify that the electronic convergence thresholds were not met, but the output structure is usable, so the solution is to simply restart from scratch but from the output structure and with a reduced mixing_beta.

handle_electronic_convergence_not_reached(calculation)[source]#

Handle ERROR_ELECTRONIC_CONVERGENCE_NOT_REACHED error.

Decrease the mixing beta and fully restart from the previous calculation.

handle_electronic_convergence_warning(calculation)[source]#

Handle WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED: consider finished.