# Dynamics module¶

Module for reading and processing input files.

class sdanalysis.dynamics.Dynamics(timestep, box, position, orientation=None, molecule=None, wave_number=None, angular_resolution=360)[source]

Bases: object

Compute dynamic properties of a simulation.

Parameters
• timestep (int) – The timestep on which the configuration was taken.

• box (ndarray) – The lengths of each side of the simulation cell including any tilt factors.

• position (ndarray) – The positions of the molecules with shape (nmols, 3). Even if the simulation is only 2D, all 3 dimensions of the position need to be passed.

• orientation (Optional[ndarray]) – The orientations of all the molecules as a quaternion in the form (w, x, y, z). If no orientation is supplied then no rotational quantities are calculated.

• molecule (Optional[Molecule]) – The molecule for which to compute the dynamics quantities. This is used to compute the structural relaxation for all particles.

• wave_number (Optional[float]) – The wave number of the maximum peak in the Fourier transform of the radial distribution function. If None this is calculated from the initial configuration.

add(position, orientation=None)[source]

Update the state of the dynamics calculations by adding a Frame.

This updates the motion of the particles, comparing the positions and orientations of the current frame with the previous frame, adding the difference to the total displacement. This approach allows for tracking particles over periodic boundaries, or through larger rotations assuming that there are sufficient frames to capture the information. Each single displacement obeys the minimum image convention, so for large time intervals it is still possible to have missing information.

Parameters
add_frame(frame)[source]

Update the state of the dynamics calculations by adding a Frame.

This updates the motion of the particles, comparing the positions and orientations of the current frame with the previous frame, adding the difference to the total displacement. This approach allows for tracking particles over periodic boundaries, or through larger rotations assuming that there are sufficient frames to capture the information. Each single displacement obeys the minimum image convention, so for large time intervals it is still possible to have missing information.

Parameters

frame (Frame) – The configuration containing the current particle information.

compute_all(timestep, position, orientation=None, scattering_function=False)[source]

Compute all possible dynamics quantities.

Parameters
Return type
Returns

Mapping of the names of each dynamic quantity to their values for each particle.

Where a quantity can’t be calculated, an array of nan values will be supplied instead, allowing for continued compatibility.

compute_alpha()[source]

Compute the non-Gaussian parameter alpha for translational motion in 2D.

$\alpha = \frac{\langle \Delta r^4\rangle} {2\langle \Delta r^2 \rangle^2} -1$
Return type

float

compute_alpha_rot()[source]

Compute the non-Gaussian parameter alpha for rotational motion in 2D.

Rotational motion in 2D, is a single dimension of rotational motion, hence the use of a different divisor than translational motion.

$\alpha = \frac{\langle \Delta \theta^4\rangle} {3\langle \Delta \theta^2 \rangle^2} -1$
Return type

float

compute_displacement()[source]

Compute the translational displacement for each particle.

Return type

ndarray

compute_displacement2()[source]

Compute the squared displacement for each particle.

Return type

ndarray

compute_gamma()[source]

Calculate the second order coupling of translations and rotations.

$\gamma = \frac{\langle(\Delta r \Delta\theta)^2 \rangle} {\langle\Delta r^2\rangle\langle\Delta\theta^2\rangle} - 1$
Returns

The squared coupling of translations and rotations $$\gamma$$

Return type

float

compute_isf()[source]

Compute the intermediate scattering function.

Return type

float

compute_mean_rotation()[source]

Compute the rotation from the initial frame.

Return type

float

compute_mfd()[source]

Compute the fourth power of displacement.

Return type

float

compute_msd()[source]

Compute the mean squared displacement.

Return type

float

compute_msr()[source]

Compute the mean squared rotation from the initial frame.

Return type

float

compute_rotation()[source]

Compute the rotational motion for each particle.

Return type

ndarray

compute_rotation2()[source]

Compute the rotation from the initial frame.

Return type

ndarray

compute_rotational_relax1()[source]

Compute the first-order rotational relaxation function.

$C_1(t) = \langle \hat{\mathbf{e}}(0) \cdot \hat{\mathbf{e}}(t) \rangle$
Returns

The rotational relaxation

Return type

float

compute_rotational_relax2()[source]

Compute the second rotational relaxation function.

$C_1(t) = \langle 2(\hat{\mathbf{e}}(0) \cdot \hat{\mathbf{e}}(t))^2 - 1 \rangle$
Returns

The rotational relaxation

Return type

float

compute_struct_relax()[source]
Return type

float

compute_time_delta(timestep)[source]

Time difference between initial frame and timestep.

Return type

int

property delta_rotation
property delta_translation
property distance
Return type
classmethod from_frame(frame, molecule=None, wave_number=None)[source]

Initialise the Dynamics class from a Frame object.

There is significant overlap between the frame class and the dynamics class, so this is a convenience method to make the initialisation simpler.

Return type

Dynamics

get_molid()[source]

Molecule ids of each of the values.

class sdanalysis.dynamics.TrackedMotion(box, position, orientation)[source]

Bases: object

Keep track of the motion of a particle allowing for multiple periods.

This keeps track of the position of a particle as each frame is added, which allows for tracking the motion of a particle through multiple periods, as long as each motion takes the shortest distance.

add(position, orientation)[source]

Update the state of the dynamics calculations by adding the next values.

This updates the motion of the particles, comparing the positions and orientations of the current frame with the previous frame, adding the difference to the total displacement. This approach allows for tracking particles over periodic boundaries, or through larger rotations assuming that there are sufficient frames to capture the information. Each single displacement obeys the minimum image convention, so for large time intervals it is still possible to have missing information.

Parameters
class sdanalysis.dynamics.LastMolecularRelaxation(num_elements, threshold, irreversibility=1.0, relaxation_type=None)[source]

Bases: sdanalysis.dynamics.relaxations.MolecularRelaxation

add(timediff, distance)[source]
Return type

None

get_status()[source]
class sdanalysis.dynamics.MolecularRelaxation(num_elements, threshold, relaxation_type=None)[source]

Bases: object

Compute the relaxation of each molecule.

add(timediff, distance)[source]
Return type

None

get_status()[source]
relaxation_type = 2
class sdanalysis.dynamics.Relaxations(timestep, box, position, orientation, molecule=None, is2D=None, wave_number=None)[source]

Bases: object

add(timestep, position, orientation)[source]

Update the state of the relaxation calculations by adding a Frame.

This updates the motion of the particles, comparing the positions and orientations of the current frame with the previous frame, adding the difference to the total displacement. This approach allows for tracking particles over periodic boundaries, or through larger rotations assuming that there are sufficient frames to capture the information. Each single displacement obeys the minimum image convention, so for large time intervals it is still possible to have missing information.

Parameters
Return type

None

add_frame(frame)[source]

Update the state of the relaxation calculations by adding a Frame.

This updates the motion of the particles, comparing the positions and orientations of the current frame with the previous frame, adding the difference to the total displacement. This approach allows for tracking particles over periodic boundaries, or through larger rotations assuming that there are sufficient frames to capture the information. Each single displacement obeys the minimum image convention, so for large time intervals it is still possible to have missing information.

Parameters

frame (Frame) – The configuration containing the current particle information.

property distance
classmethod from_frame(frame, molecule=None, wave_number=None)[source]

Initialise a Relaxations class from a Frame class.

This uses the properties of the Frame class to fill the values of the Relaxations class, for which there is significant overlap.

Return type

Relaxations

get_timediff(timestep)[source]
set_mol_relax(definition)[source]
Return type

None

summary()[source]
Return type

DataFrame