:py:mod:`aiida_lammps.workflows.base`
=====================================

.. py:module:: aiida_lammps.workflows.base

.. autoapi-nested-parse::

   Workchain to run a LAMMPS calculation with automated error handling and restarts.



Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   aiida_lammps.workflows.base.LammpsBaseWorkChain




.. py:class:: LammpsBaseWorkChain(*args, **kwargs)


   Bases: :py:obj:`aiida.engine.BaseRestartWorkChain`

   Base workchain for calculations using LAMMPS

   .. py:attribute:: _process_class

      

   .. py:method:: define(spec)
      :classmethod:

      Define the process specification.


   .. py:method:: setup()

      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.


   .. py:method:: report_error_handled(calculation, action)

      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.
      :param calculation: the failed calculation node
      :param action: a string message with the action taken


   .. py:method:: _check_restart_in_remote(calculation)

      Check if the remote folder of a previous calculation contains a restartfile

      :param calculation: node from the previous calculation
      :return: latest restartfile found or None


   .. py:method:: set_restart_type(restart_type, calculation)

      Set the parameters to run the restart calculation

      Depending on the type of restart several variables of the input parameters
      will be changed to try to ensure that the calculation can resume from
      the last stored structure

      :param restart_type: type of the restart approach to be used
      :param calculation: node from the previous calculation


   .. py:method:: handle_unrecoverable_failure(calculation)

      Handle calculations with unrecoverable errors.

      Checks if the calculation ended with an exit status below 400 if so
      abort the work chain.


   .. py:method:: handle_out_of_walltime(calculation)

      Handle calculations where the walltime was reached.

      The handler will try to find a configuration to restart from with the
      following priority

      1. Use a stored restart file in the repository from the previous calculation.
      2. Use a restartfile found in the remote folder from the previous calculation.
      3. Use the structure from the last step of the trajectory from the previous calculation.
      4. Restart from scratch


   .. py:method:: handle_minimization_not_converged(calculation)

      Handle calculations where the minimization did not converge

      The handler will try to find a configuration to restart from with the
      following priority

      1. Use a stored restart file in the repository from the previous calculation.
      2. Use a restartfile found in the remote folder from the previous calculation.
      3. Use the structure from the last step of the trajectory from the previous calculation.

      This handler should never start from restart as at least the trajectory
      should always exist, if the calculation finished successfully.



