verlet
======

.. py:module:: verlet

.. autoapi-nested-parse::

   Generic Verlet integrator



Classes
-------

.. autoapisummary::

   verlet.TemperatureStateItem
   verlet.ConsErrTracker
   verlet.VerletHook
   verlet.ThermostatHook
   verlet.BarostatHook
   verlet.NVE
   verlet.VerletIntegrator


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

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

   Bases: :py:obj:`IMLCV.new_yaff.iterative.StateItem`


   Base class for dataclasses that should act like a JAX pytree node.


   .. py:method:: get_value(iterative)


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

   Bases: :py:obj:`IMLCV.base.datastructures.MyPyTreeNode`


   A class that tracks the errors on the conserved quantity.
   Given its superior numerical accuracy, the algorithm below
   is used to calculate the running average. Its properties are discussed
   in Donald Knuth's Art of Computer Programming, vol. 2, p. 232, 3rd edition.


   .. py:attribute:: counter
      :type:  jax.Array


   .. py:attribute:: ekin_m
      :type:  jax.Array


   .. py:attribute:: econs_m
      :type:  jax.Array


   .. py:attribute:: ekin_s
      :type:  jax.Array


   .. py:attribute:: econs_s
      :type:  jax.Array


   .. py:method:: update(ekin, econs)


   .. py:method:: get()


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

   Bases: :py:obj:`IMLCV.new_yaff.iterative.Hook`


   Specialized Verlet hook.

   This is mainly used for the implementation of thermostats and barostats.


   .. py:attribute:: econs_correction
      :type:  jax.Array


   .. py:method:: __call__(iterative: VerletIntegrator)


   .. py:method:: init(iterative: VerletIntegrator) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



   .. py:method:: pre(iterative: VerletIntegrator, **kwargs) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



   .. py:method:: post(iterative: VerletIntegrator, **kwargs) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



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

   Bases: :py:obj:`VerletHook`


   Specialized Verlet hook.

   This is mainly used for the implementation of thermostats and barostats.


   .. py:attribute:: temp
      :type:  jax.Array


   .. py:method:: pre(iterative: VerletIntegrator, G1_add: jax.Array | None = None) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



   .. py:method:: post(iterative: VerletIntegrator, G1_add: jax.Array | None = None) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



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

   Bases: :py:obj:`VerletHook`


   Specialized Verlet hook.

   This is mainly used for the implementation of thermostats and barostats.


   .. py:attribute:: temp
      :type:  jax.Array


   .. py:attribute:: press
      :type:  jax.Array


   .. py:attribute:: baro_ndof
      :type:  int | None
      :value: None



   .. py:attribute:: dim
      :type:  int | None
      :value: None



   .. py:method:: pre(iterative: VerletIntegrator, chainvel0: jax.Array | None = None) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



   .. py:method:: post(iterative: VerletIntegrator, chainvel0: jax.Array | None = None) -> tuple[Self, VerletIntegrator]
      :abstractmethod:



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

   Bases: :py:obj:`VerletHook`


   Specialized Verlet hook.

   This is mainly used for the implementation of thermostats and barostats.


   .. py:attribute:: _
      :type:  dataclasses.KW_ONLY


   .. py:attribute:: temp
      :type:  float
      :value: 0.0


      Specialized Verlet hook.

      This is mainly used for the implementation of thermostats and barostats.


   .. py:attribute:: econs_correction
      :type:  jax.Array


   .. py:method:: __call__(iterative)


   .. py:method:: init(iterative: VerletIntegrator) -> tuple[VerletHook, VerletIntegrator]


   .. py:method:: pre(iterative: VerletIntegrator) -> tuple[VerletHook, VerletIntegrator]


   .. py:method:: post(iterative: VerletIntegrator) -> tuple[VerletHook, VerletIntegrator]


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

   Bases: :py:obj:`IMLCV.base.datastructures.MyPyTreeNode`


   Base class for dataclasses that should act like a JAX pytree node.


   .. py:attribute:: ff
      :type:  IMLCV.new_yaff.ff.YaffFF


   .. py:attribute:: counter
      :type:  jax.Array


   .. py:attribute:: time
      :type:  jax.Array


   .. py:attribute:: ndof
      :type:  int


   .. py:attribute:: pos
      :type:  jax.Array


   .. py:attribute:: vel
      :type:  jax.Array


   .. py:attribute:: acc
      :type:  jax.Array


   .. py:attribute:: masses
      :type:  jax.Array


   .. py:attribute:: timestep
      :type:  jax.Array


   .. py:attribute:: ptens
      :type:  jax.Array


   .. py:attribute:: rvecs
      :type:  jax.Array


   .. py:attribute:: vtens
      :type:  jax.Array


   .. py:attribute:: verlet_hook
      :type:  VerletHook


   .. py:attribute:: delta
      :type:  jax.Array


   .. py:attribute:: pos_old
      :type:  jax.Array


   .. py:attribute:: gpos
      :type:  jax.Array


   .. py:attribute:: gpos_bias
      :type:  jax.Array


   .. py:attribute:: temp
      :type:  jax.Array


   .. py:attribute:: press
      :type:  jax.Array


   .. py:attribute:: ekin
      :type:  jax.Array


   .. py:attribute:: ekin_new
      :type:  jax.Array


   .. py:attribute:: epot
      :type:  jax.Array


   .. py:attribute:: etot
      :type:  jax.Array


   .. py:attribute:: e_bias
      :type:  jax.Array


   .. py:attribute:: _cons_err_tracker
      :type:  ConsErrTracker | None
      :value: None



   .. py:attribute:: econs
      :type:  jax.Array


   .. py:attribute:: cons_err
      :type:  jax.Array


   .. py:attribute:: rmsd_delta
      :type:  jax.Array


   .. py:attribute:: rmsd_gpos
      :type:  jax.Array


   .. py:attribute:: rmsd_gpos_bias
      :type:  jax.Array


   .. py:attribute:: cv
      :type:  jax.Array


   .. py:attribute:: other_hooks
      :type:  list[IMLCV.new_yaff.iterative.Hook]


   .. py:method:: create(ff: IMLCV.new_yaff.ff.YaffFF, other_hooks: list[IMLCV.new_yaff.iterative.Hook], timestep: float, thermostat: ThermostatHook | None = None, barostat: BarostatHook | None = None, vel0: jax.Array | None = None, temp0: float = 300.0, scalevel0: bool = True, time0: float | None = None, ndof: int | None = None, counter0: int | None = None, key=42)
      :staticmethod:


      **Arguments:**

      ff
          A ForceField instance

      **Optional arguments:**

      timestep
          The integration time step (in atomic units)

      state
          A list with state items. State items are simple objects
          that take or derive a property from the current state of the
          iterative algorithm.

      hooks
          A function (or a list of functions) that is called after every
          iterative.

      vel0
          An array with initial velocities. If not given, random
          velocities are sampled from the Maxwell-Boltzmann distribution
          corresponding to the optional arguments temp0 and scalevel0

      temp0
          The (initial) temperature for the random initial velocities

      scalevel0
          If True (the default), the random velocities are rescaled such
          that the instantaneous temperature coincides with temp0.

      time0
          The time associated with the initial state.

      ndof
          When given, this option overrides the number of degrees of
          freedom determined from internal heuristics. When ndof is not
          given, its default value depends on the thermostat used. In most
          cases it is 3*natom, except for the NHC thermostat where the
          number if internal degrees of freedom is counted. The ndof
          attribute is used to derive the temperature from the kinetic
          energy.

      counter0
          The counter value associated with the initial state.




   .. py:method:: propagate()


   .. py:method:: _compute_ekin()

      Auxiliary routine to compute the kinetic energy

      This is used internally and often also by the Verlet hooks.



   .. py:method:: compute_properties()


   .. py:method:: finalize()


   .. py:method:: call_hooks()


   .. py:method:: run(nstep=None)


