qimpy.dft.geometry.Dynamics

class Dynamics(*, comm, dt, n_steps, thermostat=None, seed=1234, T0=298.0 K, P0=1.0 bar, stress0=None, t_damp_T=50.0 fs, t_damp_P=100.0 fs, drag_wavefunctions=True, save_history=True, report_callback=None, checkpoint_in=(None, ''))

Bases: TreeNode

Molecular dynamics of ions and/or lattice. Whether lattice changes is controlled by lattice.movable.

Parameters:
  • comm (Comm) –

  • dt (float) –

  • n_steps (int) –

  • thermostat (Thermostat) –

  • seed (int) –

  • T0 (float) –

  • P0 (UnitOrFloat) –

  • stress0 (Tensor) –

  • t_damp_T (float) –

  • t_damp_P (float) –

  • drag_wavefunctions (bool) –

  • save_history (bool) –

  • report_callback (Callable[[Dynamics, int], None] | None) –

  • checkpoint_in (CheckpointPath) –

__init__(*, comm, dt, n_steps, thermostat=None, seed=1234, T0=298.0 K, P0=1.0 bar, stress0=None, t_damp_T=50.0 fs, t_damp_P=100.0 fs, drag_wavefunctions=True, save_history=True, report_callback=None, checkpoint_in=(None, ''))

Specify molecular dynamics parameters.

Parameters:
  • dt (float) – [Input file] Time step.

  • n_steps (int) – [Input file] Number of MD steps.

  • thermostat (Thermostat | dict | str | None) – [Input file] Thermostat/barostat method. Specify name of thermostat eg. ‘nose-hoover’ if using default options for that thermostat method, and dictionary of parameters if not.

  • seed (int) – [Input file] Random seed for initial velocities.

  • T0 (Unit | float) – [Input file] Initial temperature / temperature set point.

  • P0 (Unit | float) – [Input file] Pressure set point for NPT, if lattice.movable is True. Note that this is overridden by stress0, if that is specified.

  • stress0 (ndarray | Tensor | None) – [Input file] Stress set point for N-stress-T, if lattice.movable is True. If specified and lattice.movable, strain tensor will fluctuate during dynamics, instead of only volume in NPT mode. (Set to None and specify P0 instead for NPT mode.)

  • t_damp_T (Unit | float) – [Input file] Thermostat damping time.

  • t_damp_P (Unit | float) – [Input file] Barostat damping time.

  • drag_wavefunctions (bool) – [Input file] Whether to drag atomic components of wavefunctions.

  • save_history (bool) – [Input file] Whether to save history along the trajectory. Saved quantities include positions, forces, velocities, temperature, pressure, potential and total stress (if available), and lattice (if movable).

  • report_callback (Callable[[Dynamics, int], None] | None) – Optional function to call at each step during report. Use this to perform additional reporting / data collection. The functional will be called as report_callback(dynamics, i_iter).

  • comm (Comm) –

  • checkpoint_in (CheckpointPath) –

Return type:

None

Methods

__init__

Specify molecular dynamics parameters.

add_child

Construct child object self.`attr_name` of type cls.

add_child_one_of

Invoke add_child on one of several child options in args.

create_gradient

Create gradient from ionic part, initializing optional parts correctly.

get_KE

Compute kinetic energy from ion velocity.

get_T

Compute temperature from kinetic energy KE.

get_acceleration

Acceleration due to ionic forces.

get_masses

Collect the masses of all ions as an n_ions x 1 tensor.

get_pressure

get_stress

Compute total stress tensor including ion velocity contributions.

report

run

save_checkpoint

Save self and all children in hierarchy to cp_path.

thermal_velocities

Thermal velocity distribution at T, randomized with seed.

Attributes

nDOF

Number of degrees of freedom in the dynamics.

system

System being optimized currently

masses

n_ions x 1 for bcast)

stepper

comm

Communictaor over which forces consistent

dt

Time step

n_steps

Number of MD steps

thermostat

Thermostat/barostat method

seed

Random seed for initial velocities

T0

Initial temperature / temperature set point

stress0

Stress set point (used only if lattice.movable)

isotropic

Whether lattice change is isotropic (NPT, vs.

t_damp_T

Thermostat damping time

t_damp_P

Barostat damping time

B0

Characteristic bulk modulus for Berendsen barostat

langevin_gamma

Damping rate for Langevin thermostat

drag_wavefunctions

Whether to drag atomic components of wavefunctions

P

Current pressure (available if lattice.compute_stress)

T

Current temperature

KE

Current kinetic energy

stress

Current stress including kinetic contributions

history

Utility to save trajectory data

report_callback

Callback from report

i_iter_start

Starting iteration number (when continuing from checkpoint)

child_names

Names of attributes with child objects.

create_gradient(ions)

Create gradient from ionic part, initializing optional parts correctly.

Parameters:

ions (Tensor) –

Return type:

Gradient

get_KE(velocity)

Compute kinetic energy from ion velocity.

Parameters:

velocity (Tensor) –

Return type:

float

get_T(KE)

Compute temperature from kinetic energy KE.

Parameters:

KE (float) –

Return type:

float

get_acceleration()

Acceleration due to ionic forces.

Return type:

Gradient

static get_masses(ions)

Collect the masses of all ions as an n_ions x 1 tensor.

Parameters:

ions (Ions) –

Return type:

Tensor

get_stress(velocity)

Compute total stress tensor including ion velocity contributions.

Parameters:

velocity (Tensor) –

Return type:

Tensor | None

thermal_velocities(T, seed)

Thermal velocity distribution at T, randomized with seed.

Parameters:
  • T (float) –

  • seed (int) –

Return type:

Tensor

B0: float

Characteristic bulk modulus for Berendsen barostat

KE: float

Current kinetic energy

P: float | None

Current pressure (available if lattice.compute_stress)

T: float

Current temperature

T0: float

Initial temperature / temperature set point

comm: Comm

Communictaor over which forces consistent

drag_wavefunctions: bool

Whether to drag atomic components of wavefunctions

dt: float

Time step

history: History | None

Utility to save trajectory data

i_iter_start: int

Starting iteration number (when continuing from checkpoint)

isotropic: bool

Whether lattice change is isotropic (NPT, vs. N-stress-T mode)

langevin_gamma: float

Damping rate for Langevin thermostat

masses: Tensor

n_ions x 1 for bcast)

Type:

Mass of each ion in system (Dim

property nDOF: int

Number of degrees of freedom in the dynamics.

n_steps: int

Number of MD steps

report_callback: Callable[[Dynamics, int], None] | None

Callback from report

seed: int

Random seed for initial velocities

stress: Tensor | None

Current stress including kinetic contributions

stress0: Tensor

Stress set point (used only if lattice.movable)

system: System

System being optimized currently

t_damp_P: float

Barostat damping time

t_damp_T: float

Thermostat damping time

thermostat: Thermostat

Thermostat/barostat method