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
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 from ionic part, initializing optional parts correctly.
Compute kinetic energy from ion velocity.
Compute temperature from kinetic energy KE.
Acceleration due to ionic forces.
Collect the masses of all ions as an n_ions x 1 tensor.
get_pressure
Compute total stress tensor including ion velocity contributions.
report
run
save_checkpoint
Save self and all children in hierarchy to cp_path.
Thermal velocity distribution at T, randomized with seed.
Attributes
Number of degrees of freedom in the dynamics.
System being optimized currently
n_ions x 1 for bcast)
stepper
Communictaor over which forces consistent
Time step
Number of MD steps
Thermostat/barostat method
Random seed for initial velocities
Initial temperature / temperature set point
Stress set point (used only if lattice.movable)
Whether lattice change is isotropic (NPT, vs.
Thermostat damping time
Barostat damping time
Characteristic bulk modulus for Berendsen barostat
Damping rate for Langevin thermostat
Whether to drag atomic components of wavefunctions
Current pressure (available if lattice.compute_stress)
Current temperature
Current kinetic energy
Current stress including kinetic contributions
Utility to save trajectory data
Callback from report
Starting iteration number (when continuing from checkpoint)
child_names
Names of attributes with child objects.
variant_name
Version of children having variants (if any)
- 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
- 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)
- t_damp_P: float
Barostat damping time
- t_damp_T: float
Thermostat damping time
- thermostat: Thermostat
Thermostat/barostat method