quippy.DynamicalSystem – run molecular dynamics simulation

class quippy.DynamicalSystem(atoms[, velocity, acceleration, constraints, rigidbodies])

A DynamicalSystem object stores the dynamical state of a molecular dynamics simulation. It has methods to integrate the equations of motion using the Velocity-Verlet algorithm.

A DynamicalSystem is constructed from an Atoms object atoms. The initial velocities and accelerations can optionally be specificed as (3,atoms.n) arrays. The constraints and rigidbodies arguments can be used to specify the number of constraints and rigid bodies respectively (the default is zero in both cases).

Attributes:

atoms

Atoms object used to store all dynamical variables. Important properties include:

pos
Real vector. Positions of atoms.
velo
Real vector. Velocity of each atom.
acc
Real vector. Acceleration of each atom.
avgpos
Real vector. Time-averaged position of each atom.
oldpos
Real vector. Position of each atom at previous time step.
mass
Real scalar. Atomic masses.
travel
Integer vector. Travel across the periodic boundary conditions.
move_mask
Integer scalar. Mask used to fix atoms. Defaults to 1 for all atoms.
damp_mask
Integer salar. Mask to select atoms for damping. Defaults to 1 for all atoms.
thermostat_mask
Integer scalar. Mask to select which thermostat to use for each atom. Defaults to 1 for all atoms.
avg_ke
Real scalar. Time-averaged kinetic energy of each atom.
avg_temp

Time-averaged temperature

avg_time

Averaging time, in fs

cur_temp

Current temperature

dw

Increment of work done this time step

epot

Total potential energy

ext_energy

Extended energy

initialised
n

Number of atoms

nconstraints

Number of constraints

ndof

Number of degrees of freedom

nrigid

Number of rigid bodies

nsteps

Number of integration steps

random_seed

RNG seed, used by ‘ds_save_state’ and ‘ds_restore_state’ only.

t

Time

thermostat_dw

Increment of work done by thermostat

thermostat_work

Total work done by thermostat

work

Total work done

Important DynamicalSystem methods are listed below:

add_atoms(z[mass, p, v, a, t, data])

Equivalent of Atoms.add_atoms(), but also amends the number of degrees of freedom correctly.

remove_atoms(remove_list)

Equivalent of Atoms.remove_atoms(), but also amends the number of degrees of freedom correctly.

add_heat(heat, ekin)

Add or remove heat from the system by scaling the atomic velocities.

add_thermostat(type_bn, t[, gamma, q, tau, p])

Add a new thermostat to this DynamicalSystem. type_bn should be one of 0 (no thermostat), 1 (Langevin), 2 (Nose-Hoover), 3 (Nose-Hoover-Langevin) or 4 (Langevin NPT). t is the target temperature. q is the Nose-Hoover coupling constant. Only one of tau or gamma should be given. p is the external pressure for the case of Langevin NPT.

advance_verlet1(dt[, virial])

Advance the velocities by half the time-step dt and the positions by a full time-step. A typical MD loop should resemble the following code. See the Potentials and DynamicalSystems section of the quippy tutorial for more details.

ds.atoms.calc_connect()
for n in range(n_steps):
   ds.advance_verlet1(dt)
   pot.calc(ds.atoms, force=True, energy=True)
   ds.advance_verlet2(dt, ds.atoms.force)
   ds.print_status(epot=ds.atoms.energy)
   if n % connect_interval == 0:
      ds.atoms.calc_connect()
advance_verlet2(dt, f[, virial])

Advances the velocities by the second half time-step.

advance_verlet(dt, f[, virial])

Equivalent to advance_verlet2() followed by advance_verlet1(). This allows a simple MD loop:

for n in range(n_steps):
    pot.calc(ds.atoms, force=True, energy=True)
    ds.advance_verlet(dt, ds.atoms.force)
    ds.print_status(epot=ds.atoms.energy)
    if n % connect_interval == 0:
       ds.atoms.calc_connect()
angular_momentum([origin, indices])

Return the angular momentum of all the atoms in this DynamicalSystem, defined by

\mathbf{L} = \sum_{i} \mathbf{r_i} \times \mathbf{v_i}

Optionally the origin can be specified, or only specific atoms in the list indices can be included.

centre_of_mass_velo([index_list])

Return the velocity of the center of mass, optionally including only the atoms in index_list.

centre_of_mass_acc([index_list])

Return the acceleration of the center of mass, optionally including only the atoms in index_list.

enable_damping(damp_time)

Enable damping, with damping time set to damp_time. Only atoms flagged in the damp_mask property will be affected.

disable_damping()

Disable damping for this DynamicalSystem.

kinetic_energy()

Return the total kinetic energy E_k = \sum_{i} \frac{1}{2} m v^2

momentum([indices])

Return the total momentum \mathbf{p} = \sum_i \mathbf{m_i} \mathbf{v_i}. Optionally only include the contribution of a subset of atoms in the array indices.

print_status([label, epot, instantaneous])

Print a status line showing the current time, temperature, the mean temperature the total energy and the total momentum for this DynamicalSystem. If present, the optional label parameter should be a one character label for the log lines and is printed in the first column of the output. epot should be the potential energy if this is available. instantaneous has the same meaning as in temperature().

rescale_velo(temp[, mass_weighted, zero_l])

Rescale the atomic velocities to temperature temp. If the current temperature is zero, we first randomise the velocities. If mass_weighted is true, then the velocites are weighted by 1/sqrt{m}. Linear momentum is zeroed automatically. If zero_l is true then the angular momentum is also zeroed.

run(pot[, dt, n_steps, save_interval, connect_interval, args_str])

Generator to return snapshots from a trajectory. For each step, forces are evaluated using the Potential pot and the DynamicalSystem is advanced by a time dt (default 1 fs). n_steps (default 10 steps) are carried out in total, with the generator yielding a result every save_interval steps. The connectivity is recalculated every connect_interval steps. args_str can be used to supply extra arguments to Potential.calc().

temperature(this[, region, include_all, instantaneous])

Return the temperature, assuming each degree of freedom contributes \frac{1}{2}kT. By default only moving and thermostatted atoms are included — this can be overriden by setting include_all to true. region can be used to restrict the calculation to a particular thermostat region. instantaneous controls whether the calculation should be carried out using the current values of the velocities and masses, or whether to return the value at the last Verlet step (the latter is the default).

zero_momentum([indices])

Change velocities to those that the system would have in the zero momentum frame. Optionalally zero the total momentum of a subset of atoms, specified by indices.

Previous topic

quippy.Potential – evaluate interatomic potentials

Next topic

atomeye – Interface to AtomEye viewer

This Page