Gyration analysis code
For source code refer to github repository
Module documentation
Module to calculate gyaration and inertial information from coordinates.
Currently only .xyz file input is supported.
To use:
1) import the module in your python script with (script must be in same directory as this file)
import get_gyr as gyr
2) read .xyz file
molecule = gyr.GyrationMolecule("./molecules/water.xyz")
3) call appropriate variable, e.g.
print("Relative shape anisotropy is: ", molecule.Rel_anis)
for detailed information see test_gyr.py script
Classes
GyrationMolecule
Class containing gyration/inertia information for given molecule
Attributes:
Name | Type | Description |
---|---|---|
Rx2 |
float |
Radius of gyration squared in first principal direction |
Ry2 |
float |
Radius of gyration squared in second principal direction |
Rz2 |
float |
Radius of gyration squared in third principal direction |
Rg |
float |
Radius of gyration for molecule |
Rel_anis |
float |
Relative shape anisotropy, 0 for perfectly spherical arangement 1 for perfectly linear arangement |
Ix |
float |
Moment of inertia in first principal direction |
Iy |
float |
Moment of inertia in first principal direction |
Iz |
float |
Moment of inertia in first principal direction |
Methods
__init__(self, fname, flag_xyz=1, flag_periodic=0)
special
Calculate gyration properties from given file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fname |
str |
Filename of coordinates, xyz file or simple list of coordinates |
required |
flag_xyz |
int |
1 if using xyz file, 0 if using simple list of coordinates |
1 |
flag_periodic |
int |
1 if using periodic system (not yet supported) |
0 |
Source code in Gyration-from-coordinates/get_gyr.py
def __init__(self, fname: str, flag_xyz: int=1, flag_periodic: int=0):
"""Calculate gyration properties from given file
Arguments:
fname: Filename of coordinates, xyz file or simple list of coordinates
flag_xyz: 1 if using xyz file, 0 if using simple list of coordinates
flag_periodic: 1 if using periodic system (not yet supported)
"""
if flag_xyz:
self.name = fname.split('.xyz')[0]
# Gyration parameters
self.__coords = self.__xyz_to_coords(fname)
self.Rx2, self.Ry2, self.Rz2, = self.__calc_evals_gyr(self.__coords)
self.Rg = np.sqrt(self.Rx2 + self.Ry2 + self.Rz2)
self.Rel_anis = (1.5 * (self.Rx2**2 + self.Ry2**2 + self.Rz2**2)
/ (self.Rx2 + self.Ry2 + self.Rz2)**2 - 0.5)
# Inertia parametrs
self.Ix, self.Iy, self.Iz, = self.__calc_evals_inertia(self.__coords)
else:
print("Not yet implemented")
quit()