waterEntropy.maths package¶
Submodules¶
waterEntropy.maths.transformations module¶
Functions for transforming atomic positions and forces
- waterEntropy.maths.transformations.MOI(CoM: ndarray, positions: ndarray, masses: list)[source]¶
Use this function to calculate moment of inertia for cases where the mass list will contain masses of UAs rather than individual atoms and the postions will be those for the UAs only (excluding the H atoms coordinates).
- Parameters:
CoM – a (3,) array of the chosen center of mass
positions – a (N,3) array of point positions
masses – a (N,) list of point masses
- waterEntropy.maths.transformations.get_UA_masses(molecule)[source]¶
For a given molecule, return a list of masses of UAs (combination of the heavy atoms + bonded hydrogen atoms. This list is used to get the moment of inertia tensor for molecules larger than one UA
- Parameters:
molecule – mdanalysis instance of molecule
- waterEntropy.maths.transformations.get_axes(molecule, molecule_scale: str)[source]¶
From a selection of atoms, get the ordered principal axes (3,3) and the ordered moment of inertia axes (3,) for that selection of atoms
- Parameters:
molecule – mdanalysis instance of molecule
molecule_scale – the length scale of molecule
- waterEntropy.maths.transformations.get_bonded_axes(system, atom, dimensions)[source]¶
For a given united atom, find how to select bonded atoms to get the axes for rotating forces around. Few cases for choosing united atom axes:
X -- H = bonded to one or more light atom X -- R = bonded to one heavy atom R -- X -- H = bonded to one heavy and one light atom R1 -- X -- R2 = bonded to two heavy atoms R1 -- X -- R2 = bonded to more than two heavy atoms | R3
Note that axis2 is calculated by taking the cross product between axis1 and the vector chosen for each case, dependent on bonding:
case1: if all the bonded atoms are hydrogens, then just use the moment of inertia as all the axes.
case2: no axes required to rotate forces.
case3: use XR vector as axis1, vector XH to calculate axis2
case4: use vector XR1 as axis1, and XR2 to calculate axis2
case5: get the sum of all XR normalised vectors as axis1, then use vector R1R2 to calculate axis2
- waterEntropy.maths.transformations.get_covariance_matrix(ft: ndarray, halve=0.5)[source]¶
Get the outer product of the mass weighted forces or torques (ft) and half values if halve=True
- Parameters:
ft – (3,) array of either mass weighted forces or torques
halve – Boolean to set weather covariance matrix should be halved (i.e. divide by \(2^2\))
- waterEntropy.maths.transformations.get_custom_PI_MOI(molecule, custom_rotation_axes, center_of_mass, dimensions)[source]¶
Get MOI tensor (PIaxes) and center point coordinates (custom_MI_axis) for UA level, where eigenvalues and vectors are not used. Note, positions and masses are provided separately as some cases require using the positions of heavy atoms only, but the masses of all atoms for a given selection of atoms.
- Parameters:
coords – MDAnalysis instance of molecule
custom_rotation_axes – (3,3) arrray of rotation axes
center_of_mass – (3,) center of mass for collection of atoms N
masses – (N,) list of masses for collection of atoms, note this should be the same length as coords. If there are no hydrogens in the coords array, then the masses of these should be added to the heavy atom
dimensions – (3,) array of system box dimensions.
- waterEntropy.maths.transformations.get_custom_axes(a: ndarray, b_list: list, c: ndarray, dimensions: ndarray)[source]¶
For atoms a, b_list and c, calculate the axis to rotate forces around:
axis1: use the normalised vector ab as axis1. If there is more than one bonded heavy atom (HA), average over all the normalised vectors calculated from b_list and use this as axis1). b_list contains all the bonded heavy atom coordinates.
axis2: use cross product of normalised vector ac and axis1 as axis2. If there are more than two bonded heavy atoms, then use normalised vector b[0]c to cross product with axis1, this gives the axis perpendicular to axis1.
axis3: the cross product of axis1 and axis2, which is perpendicular to axis1 and axis2.
- Parameters:
a – central united-atom coordinates (3,)
b_list – list of heavy bonded atom positions (3,N)
c – atom coordinates of either a second heavy atom or a hydrogen atom if there are no other bonded heavy atoms in b_list (where N=1 in b_list) (3,)
dimensions – dimensions of the simulation box (3,)
a 1 = norm_ab / \ 2 = |_ norm_ab and norm_ac (use bc if more than 2 HAs) / \ 3 = |_ 1 and 2 b c
- waterEntropy.maths.transformations.get_flipped_axes(positions, custom_axes, center_of_mass, dimensions)[source]¶
For a given set of custom axes, ensure the axes are pointing in the correct direction wrt the heavy atom position and the chosen center of mass.
- waterEntropy.maths.transformations.get_mass_weighted_forces(molecule, rotation_axes: ndarray)[source]¶
For a given set of atoms, sum their forces and rotate these summed forces using the rotation axes (3,3)
- Parameters:
molecule – mdanalysis instance of molecule
rotation_axes – a (3,3) array to rotate forces along
- waterEntropy.maths.transformations.get_rotated_sum_forces(molecule, rotation_axes: ndarray)[source]¶
Rotated the forces for a given seletion of atoms along a particular rotation axes (3,3)
- Parameters:
molecule – mdanalysis instance of molecule
rotation_axes – a (3,3) array to rotate forces along
- waterEntropy.maths.transformations.get_torques(molecule, center_of_mass: ndarray, rotation_axes: ndarray, MI_axis: ndarray)[source]¶
For a selection of atoms, use their positions and forces to get the torque (3,) for that selection of atoms. The positions are first translated to the center of mass, then the translated positions and forces are rotated to align with the chosen rotation axes. Lastly the torque is calculated from the cross product of the transformed positions and forces, which is subsequently divided by the sqaure root of the moment of inertia axis.
- Parameters:
coords – mdanalysis instance of atoms selected for positions
forces – mdanalysis instance of atoms selected for forces
center_of_mass – a (3,) array of the chosen center of mass
rotation_axes – a (3,3) array to rotate forces along
MI_axis – a (3,) array for the moment of inertia axis center
waterEntropy.maths.trig module¶
Functions for common trigonometric calculations
- waterEntropy.maths.trig.get_angle(a: ndarray, b: ndarray, c: ndarray, dimensions: ndarray)[source]¶
Get the angle between three atoms, taking into account PBC.
- Parameters:
a – (3,) array of atom cooordinates
b – (3,) array of atom cooordinates
c – (3,) array of atom cooordinates
dimensions – (3,) array of system box dimensions.
- waterEntropy.maths.trig.get_distance(a: ndarray, b: ndarray, dimensions: ndarray)[source]¶
Calculates distance and accounts for PBCs.
- Parameters:
a – (3,) array of atom cooordinates
b – (3,) array of atom cooordinates
dimensions – (3,) array of system box dimensions.
- waterEntropy.maths.trig.get_neighbourlist(atom: ndarray, neighbours, dimensions: ndarray, max_cutoff=9000000000.0)[source]¶
Use MDAnalysis to get distances between an atom and neighbours within a given cutoff. Each atom index pair sorted by distance are outputted.
- Parameters:
atom – (3,) array of an atom coordinates.
neighbours – MDAnalysis array of heavy atoms in the system, not the atom itself and not bonded to the atom.
dimensions – (6,) array of system box dimensions.
max_cutoff – set the maximum cutoff value for finding neighbour distances
- waterEntropy.maths.trig.get_shell_neighbour_selection(shell, donator, system, heavy_atoms=True, max_cutoff=10)[source]¶
get shell neighbours ordered by ascending distance, this is used for finding possible hydrogen bonding neighbours.
- Parameters:
shell – the instance for class waterEntropy.neighbours.RAD.RAD containing coordination shell neighbours
donator – the mdanalysis object for the donator
system – mdanalysis instance of all atoms in current frame
heavy_atoms – consider heavy atoms in a shell as neighbours
- Max_cutoff:
set the maximum cutoff value for finding neighbours
- waterEntropy.maths.trig.get_sorted_neighbours(i_idx: int, system, max_cutoff=10)[source]¶
For a given atom, find neighbouring united atoms from closest to furthest within a given cutoff.
- Parameters:
i_idx – idx of atom i
system – mdanalysis instance of atoms in a frame
max_cutoff – set the maximum cutoff value for finding neighbours
Module contents¶
waterEntropy: calculate water entropy near heterogeneous interfaces