wepy.util.util module¶
Miscellaneous functions needed by wepy.
- wepy.util.util.traj_box_vectors_to_lengths_angles(traj_box_vectors)[source]¶
Convert box vectors for multiple ‘frames’ (a ‘trajectory’) to box lengths and angles.
- Parameters:
traj_box_vectors (arraylike of float of shape (n_frames, n_dims, n_dims)) – Box vector matrices (x, y, z) for a trajectory of frames.
- Returns:
traj_box_lengths (arraylike of float of shape (n_frames, n_dims)) – The lengths of the box for each frame
traj_box_angles (arraylike of float of shape (n_frames, n_dims)) – The angles of the box vectors to normal for each frame in degrees.
- wepy.util.util.box_vectors_to_lengths_angles(box_vectors)[source]¶
Convert box vectors for a single ‘frame’ to lengths and angles.
- Parameters:
box_vectors (arraylike of float of shape (n_dims, n_dims)) – Box vector matrices (x, y, z) for a single frame.
- Returns:
box_lengths (arraylike of float of shape (n_dims,)) – The lengths of the box
box_angles (arraylike of float of shape (n_dims,)) – The angles of the box vectors to normal in degrees.
- wepy.util.util.lengths_and_angles_to_box_vectors(a_length, b_length, c_length, alpha, beta, gamma)[source]¶
Convert from the lengths/angles of the unit cell to the box vectors (Bravais vectors). The angles should be in degrees.
- Parameters:
a_length (scalar or np.ndarray) – length of Bravais unit vector a
b_length (scalar or np.ndarray) – length of Bravais unit vector b
c_length (scalar or np.ndarray) – length of Bravais unit vector c
alpha (scalar or np.ndarray) – angle between vectors b and c, in degrees.
beta (scalar or np.ndarray) – angle between vectors c and a, in degrees.
gamma (scalar or np.ndarray) – angle between vectors a and b, in degrees.
- Returns:
a (np.ndarray) – If the inputs are scalar, the vectors will one dimesninoal (length 3). If the inputs are one dimension, shape=(n_frames, ), then the output will be (n_frames, 3)
b (np.ndarray) – If the inputs are scalar, the vectors will one dimesninoal (length 3). If the inputs are one dimension, shape=(n_frames, ), then the output will be (n_frames, 3)
c (np.ndarray) – If the inputs are scalar, the vectors will one dimesninoal (length 3). If the inputs are one dimension, shape=(n_frames, ), then the output will be (n_frames, 3)
Examples
Notes
This code is adapted from gyroid, which is licensed under the BSD http://pythonhosted.org/gyroid/_modules/gyroid/unitcell.html >>> import numpy as np >>> result = lengths_and_angles_to_box_vectors(1, 1, 1, 90.0, 90.0, 90.0)