Analysis Functions¶
In addition to being able to read in trajectories and index files, some basic
analysis functions are included in the API. These are not intended to be
exhaustive of all possible analytical tools. Instead, this is a simple framework
the analyst can use in writing his own programs. All of these are currently
found in gmxcpp/Utils.h
, except for the clustering routines, which are found
in gmxcpp/Clusters.h
.
Bond vector¶
-
coordinates
bond_vector
(coordinates atom1, coordinates atom2, triclinicbox box)¶ Gets the bond vector between to atoms.
- Return
- bond vector
- Parameters
atom1
-First atom in bond
atom2
-Second atom in bond
box
-Simulation box
Bond angle¶
-
double
bond_angle
(coordinates atom1, coordinates atom2, coordinates atom3, triclinicbox box)¶ Calculates the angle between two bonds.
The central atom should be the middle input.
- Return
- bond angle in radians
- Parameters
atom1
-First atom in angle
atom2
-Second atom in angle
atom3
-Third atom in angle
box
-Simulation box
Center a group of atoms around a point¶
-
void
do_center_group
(vector<coordinates> &atom, coordinates center, triclinicbox box)¶ Centers a group of atoms.
Centers a group of atoms around a specified point, removing the periodic effects. Note that this only works for a cubic box for the moment.
- Parameters
atom
-Group of atoms to be transformed.
center
-The point around which to center the atoms.
box
-The simulation box.
Center of mass¶
-
group
center_of_mass
Functions
-
coordinates
center_of_mass
(vector<coordinates> atom, vector<double> mass)¶ Gets the center of mass of a group of atoms.
Gets the center of mass of a group of atoms. The masses must match up with the atoms specified. Note that this version does NOT take into account the periodic boundary.
- Return
- The center of mass.
- Parameters
atom
-The positions of the atoms.
mass
-The masses of the atoms.
-
coordinates
center_of_mass
(vector<coordinates> atom, vector<double> mass, triclinicbox box)¶ Gets the center of mass of a group of atoms.
Gets the center of mass of a group of atoms. The masses must match up with the atoms specified. Note that this version DOES take into account the periodic boundary by centering the group around the geometric center first before the calculation. Note this only works for a cubic box at the moment!
- Return
- The center of mass.
- Parameters
mass
-The masses of the atoms.
atom
-The positions of the atoms.
box
-The simulation box.
-
coordinates
Clustering¶
-
class
Clusters
¶ Class containing clustering functions.
This class is used for clustering molecules based off of a cutoff distance between the various atomic sites on each molecule in question. Before clustering can be performed, the object must be constructed. Then “do_clustering” can be called for each frame one desires to cluster together. Initially each molecule is in its own cluster of size one. After performing the clustering routine one can get which molecules are part of a cluster, get the cluster for which a molecule belongs, and get the size of the cluster. The functions are only appropriate for clustering molecules of the same type.
Public Functions
-
Clusters
(int mol_n, int atoms_per_mol)¶ Constructor for a Clusters object.
- Parameters
mol_n
-Total number of molecules that are going to be processed.
atoms_per_mol
-Number of atoms in each molecule that are going to be processed.
-
void
do_clustering
(int frame, Trajectory &traj, double rcut2)¶ Perform clustering on all molecules in xtc file.
This version performs clustering on all molecules in the Trajectory object. This is useful when, say, only the solutes are in the trajectory file that was read in. After this function is called one can get information on the clusters using the getters in this class.
- Parameters
frame
-The frame number to do clustering on.
traj
-The trajectory object with the molecules
rcut2
-The cutoff length squared for determining if molecules are in the same cluster. The cutoff is measured between atomic sites on each molecule. If any two sites are within the cutoff the two molecules are in the same cluster.
-
void
do_clustering
(int frame, Trajectory &traj, string group, double rcut2)¶ Perform clustering on a specific index group.
<<<<<<< HEAD
- Parameters
frame
-The frame number to do clustering on.
traj
-The trajectory object with the molecules <<<<<<< HEAD group The index group to do clustering on.
This version only performs the clustering routine on a specific index group. After this function is called one can get information on the clusters using the getters in this class.
- Parameters
group
-The index group to do clustering on.
rcut2
-The cutoff length squared for determining if molecules are in the same cluster. The cutoff is measured between atomic sites on each molecule. If any two sites are within the cutoff the two molecules are in the same cluster.
-
int
get_size
(int clust)¶ Get the size of the cluster.
This return the number of molecules in a cluster given the cluster number. This should only be performed after ‘do_clustering’ has been done for the frame. Otherwise each cluster will be of size one. After doing ‘do_clustering’ several clusters will be of size zero, since initially each molecule is in it’s own cluster.
- Return
- The cluster size, indicating the number of molecules in a cluster.
- Parameters
clust
-The cluster number.
-
int
get_index
(int mol)¶ Get the cluster number given a molecule.
This should only be called after performing ‘do_clustering’ for a frame. Initially each molecule will be in its own cluster.
- Return
- The cluster number to which the molecule belongs.
- Parameters
mol
-The number indicating the molecule of interest, corresponding to the order in the trajectory object.
-
vector<int>
get_mol_numbers
(int clust)¶ Find out which molecules belong to a cluster.
- Return
- A vector of numbers indicating which molecules are part of this cluster.
- Parameters
clust
-The cluster number.
-
Cross product¶
-
coordinates
cross
(coordinates a, coordinates b)¶ Calculates the cross product.
Gets the cross product between vectors a and b and returns it.
- Return
- The resultant vector of the cross of a and b.
- Parameters
a
-First vector to be crossed.
b
-Second vector to be crossed.
Dihedral angle¶
-
double
dihedral_angle
(coordinates atom1, coordinates atom2, coordinates atom3, coordinates atom4, triclinicbox box)¶ Calculates the torsion / dihedral angle from four atoms’ positions.
Source: Blondel and Karplus, J. Comp. Chem., Vol. 17, No. 9, 1 132-1 141 (1 996). Note that it returns in radians and that the atoms should be in order along their connections.
- Return
- dihedral angle in radians
- Parameters
atom1
-First atom in angle
atom2
-Second atom in angle
atom3
-Third atom in angle
atom4
-Fourth atom in angle
box
-Simulation box
Distance¶
Warning
doxygenfunction: Unable to resolve multiple matches for function “distance” with arguments () in doxygen xml output for project “project0” from directory: ./doxyxml. Potential matches:
- double distance(coordinates, coordinates, triclinicbox) - double distance(coordinates, coordinates)
Distance squared¶
Warning
doxygenfunction: Unable to resolve multiple matches for function “distance2” with arguments () in doxygen xml output for project “project0” from directory: ./doxyxml. Potential matches:
- double distance2(coordinates, coordinates) - double distance2(coordinates, coordinates, triclinicbox)
Dot product¶
-
double
dot
(coordinates a, coordinates b)¶ Calculates the dot product between two vectors.
- Return
- Dot product of a and b
- Parameters
a
-First vector in dot product
b
-Second vector in dot product
Geometric center¶
-
coordinates
center_of_geometry
(vector<coordinates> atom, triclinicbox box)¶ Gets the geometric of a group of atoms.
Gets the gemetric of a group of atoms, taking into account the periodic boundary condition. *
- Return
- Geometric center.
- Parameters
atom
-The positions of the atoms. Note this only works for a cubic box at the moment.
atom
-The positions of the atoms.
box
-The simulation box.
Periodic boundary condition¶
-
coordinates
pbc
(coordinates a, triclinicbox box)¶ Adjusts for periodic boundary condition.
User passes a vector, most likely a vector pointing from one atom to another in the simulation. This function adjusts the vector such that if it is longer than 1/2 the box size it accounts for the periodic boundary.
- Return
- Vector after pbc accounted for.
- Parameters
a
-Vector to be passed.
box
-The box dimensions.
Random point on sphere¶
-
group
gen_sphere_point
Functions
-
coordinates
gen_sphere_point
(coordinates center, double r)¶ Generates a random point on a sphere.
- Return
- The coordinates of the random point.
- Parameters
center
-The center of the sphere.
r
-The radius of the sphere.
-
coordinates
gen_sphere_point
(double r)¶ Generates a random point on a sphere at the origin.
- Return
- The coordinates of the random point.
- Parameters
r
-The radius of the sphere.
-
coordinates
gen_sphere_point
()¶ Generates a random point on a unit sphere at the origin.
- Return
- The coordinates of the random point.
-
coordinates
Surface area¶
-
double
get_surf_area
(vector<coordinates> sites, double r, double rand_n, triclinicbox box)¶ Gets the surface area of a group of atoms.
Gets the surface area of a group of atoms (could be a molecule) defined by vector of coordinates. Randomly generated points on a sphere of radius r are used at each site in order to get an acceptance ratio. The surface area contributed from each site is simply the surface area of a sphere multiplied by the acceptance ratio for that site. The total surface area is the sum of the surface areas for each site.
- Parameters
sites
-The coordinates of sites in the group / molecule. For example, the carbons in an alkane.
r
-The radius to be used in determining the surface area. For example, to determine the SASA use the appropriate radius.
rand_n
-The number of randomly generated points to be used for each site.
box
-The box dimensions for the frame in question.