verlet

Contents

verlet#

Generic Verlet integrator

Classes#

TemperatureStateItem

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

ConsErrTracker

A class that tracks the errors on the conserved quantity.

VerletHook

Specialized Verlet hook.

ThermostatHook

Specialized Verlet hook.

BarostatHook

Specialized Verlet hook.

NVE

Specialized Verlet hook.

VerletIntegrator

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

Module Contents#

class verlet.TemperatureStateItem(*args, **kwargs)#

Bases: IMLCV.new_yaff.iterative.StateItem

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

get_value(iterative)#
class verlet.ConsErrTracker(*args, **kwargs)#

Bases: 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.

counter: jax.Array#
ekin_m: jax.Array#
econs_m: jax.Array#
ekin_s: jax.Array#
econs_s: jax.Array#
update(ekin, econs)#
get()#
class verlet.VerletHook(*args, **kwargs)#

Bases: IMLCV.new_yaff.iterative.Hook

Specialized Verlet hook.

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

econs_correction: jax.Array#
__call__(iterative: VerletIntegrator)#
abstract init(iterative: VerletIntegrator) tuple[Self, VerletIntegrator]#
abstract pre(iterative: VerletIntegrator, **kwargs) tuple[Self, VerletIntegrator]#
abstract post(iterative: VerletIntegrator, **kwargs) tuple[Self, VerletIntegrator]#
class verlet.ThermostatHook(*args, **kwargs)#

Bases: VerletHook

Specialized Verlet hook.

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

temp: jax.Array#
abstract pre(iterative: VerletIntegrator, G1_add: jax.Array | None = None) tuple[Self, VerletIntegrator]#
abstract post(iterative: VerletIntegrator, G1_add: jax.Array | None = None) tuple[Self, VerletIntegrator]#
class verlet.BarostatHook(*args, **kwargs)#

Bases: VerletHook

Specialized Verlet hook.

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

temp: jax.Array#
press: jax.Array#
baro_ndof: int | None = None#
dim: int | None = None#
abstract pre(iterative: VerletIntegrator, chainvel0: jax.Array | None = None) tuple[Self, VerletIntegrator]#
abstract post(iterative: VerletIntegrator, chainvel0: jax.Array | None = None) tuple[Self, VerletIntegrator]#
class verlet.NVE(*args, **kwargs)#

Bases: VerletHook

Specialized Verlet hook.

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

_: dataclasses.KW_ONLY#
temp: float = 0.0#

Specialized Verlet hook.

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

econs_correction: jax.Array#
__call__(iterative)#
init(iterative: VerletIntegrator) tuple[VerletHook, VerletIntegrator]#
pre(iterative: VerletIntegrator) tuple[VerletHook, VerletIntegrator]#
post(iterative: VerletIntegrator) tuple[VerletHook, VerletIntegrator]#
class verlet.VerletIntegrator(*args, **kwargs)#

Bases: IMLCV.base.datastructures.MyPyTreeNode

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

ff: IMLCV.new_yaff.ff.YaffFF#
counter: jax.Array#
time: jax.Array#
ndof: int#
pos: jax.Array#
vel: jax.Array#
acc: jax.Array#
masses: jax.Array#
timestep: jax.Array#
ptens: jax.Array#
rvecs: jax.Array#
vtens: jax.Array#
verlet_hook: VerletHook#
delta: jax.Array#
pos_old: jax.Array#
gpos: jax.Array#
gpos_bias: jax.Array#
temp: jax.Array#
press: jax.Array#
ekin: jax.Array#
ekin_new: jax.Array#
epot: jax.Array#
etot: jax.Array#
e_bias: jax.Array#
_cons_err_tracker: ConsErrTracker | None = None#
econs: jax.Array#
cons_err: jax.Array#
rmsd_delta: jax.Array#
rmsd_gpos: jax.Array#
rmsd_gpos_bias: jax.Array#
cv: jax.Array#
other_hooks: list[IMLCV.new_yaff.iterative.Hook]#
static 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)#

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.

propagate()#
_compute_ekin()#

Auxiliary routine to compute the kinetic energy

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

compute_properties()#
finalize()#
call_hooks()#
run(nstep=None)#