Util module

A collection of utility functions.

class sdanalysis.util.Variables(temperature, pressure, crystal, iteration_id)[source]

Bases: tuple

property crystal

Alias for field number 2

classmethod from_filename(fname)[source]

Create a Variables instance taking information from a path.

This extracts the information about the value of variables used within a simulation trajectory from the filename. This is expecting the information in a specific format, where values are separated by the dash character -.

Parameters

fname (Union[str, Path]) – The full path of the filename from which to extract the information.

Warning

This is expecting the full name of the file, including the extension. Should there not be an extension on the filename, values could be stripped giving undefined behaviour.

Return type

Variables

property iteration_id

Alias for field number 3

property pressure

Alias for field number 1

property temperature

Alias for field number 0

sdanalysis.util.create_freud_box(box, is_2D=True)[source]

Convert an array of box values to a box for use with freud functions

The freud package has a special type for the description of the simulation cell, the Box class. This is a function to take an array of lengths and tilts to simplify the creation of the Box class for use with freud.

Return type

Box

sdanalysis.util.get_filename_vars(fname)[source]

Extract variables information from a filename.

This extracts the information about the value of variables used within a simulation trajectory from the filename. This is expecting the information in a specific format, where values are separated by the dash character -.

Parameters

fname (Union[str, Path]) – The full path of the filename from which to extract the information.

Warning

This is expecting the full name of the file, including the extension. Should there not be an extension on the filename, values could be stripped giving undefined behaviour.

Return type

Variables

sdanalysis.util.orientation2positions(mol, position, orientation)[source]
Return type

ndarray

sdanalysis.util.parse_directory(directory, glob)[source]
Return type

Dict[str, Dict]

sdanalysis.util.quaternion2z(quaternion)[source]

Convert a rotation about the z axis to a quaternion.

This is a helper for 2D simulations, taking the rotation of a particle about the z axis and converting it to a quaternion. The input angle theta is assumed to be in radians.

Return type

ndarray

sdanalysis.util.quaternion_angle(quaternion)[source]
Return type

ndarray

sdanalysis.util.quaternion_rotation(initial, final)[source]
sdanalysis.util.rotate_vectors(quaternion, vector)[source]
sdanalysis.util.set_filename_vars(fname, sim_params)[source]

Set the variables of the simulations params according to the filename.

Return type

None

sdanalysis.util.z2quaternion(theta)[source]

Convert a rotation about the z axis to a quaternion.

This is a helper for 2D simulations, taking the rotation of a particle about the z axis and converting it to a quaternion. The input angle theta is assumed to be in radians.

Return type

ndarray

sdanalysis.util.zero_quaternion(num)[source]