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

Warning

doxygenfunction: Unable to resolve multiple matches for function “bond_vector” with arguments (coordinates, coordinates, triclinicbox)) in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml. Potential matches:

- coordinates bond_vector(coordinates, coordinates, cubicbox)
- coordinates bond_vector(coordinates, coordinates, triclinicbox)

Bond angle

Warning

doxygenfunction: Unable to resolve multiple matches for function “bond_angle” with arguments (coordinates, coordinates, triclinicbox)) in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml. Potential matches:

- double bond_angle(coordinates, coordinates, coordinates, cubicbox)
- double bond_angle(coordinates, coordinates, coordinates, triclinicbox)

Center a group of atoms around a point

Warning

doxygenfunction: Unable to resolve multiple matches for function “do_center_group” with arguments () in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml. Potential matches:

- void do_center_group(vector<coordinates>&, coordinates, cubicbox)
- void do_center_group(vector<coordinates>&, coordinates, triclinicbox)
- void do_center_group(vector<coordinates>&, cubicbox&)

Center of mass

Warning

doxygengroup: Cannot find namespace “center_of_mass” in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml

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.

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
  • frame: The frame number to do clustering on.
  • traj: The trajectory object with the molecules
  • group: The index group to do clustering on.
  • 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 (coordinates, coordinates, triclinicbox)) in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml. Potential matches:

- double distance(coordinates, coordinates)
- double distance(coordinates, coordinates, triclinicbox)

Distance squared

Warning

doxygenfunction: Unable to resolve multiple matches for function “distance2” with arguments (coordinates, coordinates, triclinicbox)) in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml. Potential matches:

- __m256 distance2(coordinates8, coordinates8, cubicbox8)
- __m256 distance2(coordinates8, coordinates8, cubicbox_m256)
- double distance2(coordinates, coordinates)
- double distance2(coordinates, coordinates, cubicbox)
- double distance2(coordinates, coordinates, triclinicbox)

Dot product

Warning

doxygenfunction: Unable to resolve multiple matches for function “dot” with arguments (coordinates, coordinates)) in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml. Potential matches:

- double dot(coordinates)
- double dot(coordinates, coordinates)

Geometric center

coordinates center_of_geometry(vector<coordinates> &atom, cubicbox &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 (can be either triclinicbox or cubicbox).

Random points in a box

Warning

doxygengroup: Cannot find namespace “gen_rand_box_points” in doxygen xml output for project “libgmxcpp” from directory: ./doxyxml

Random point on sphere

coordinates gen_sphere_point()

Generates a random point on a unit sphere at the origin.

Return
The coordinates of the random point.

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.

Vector magnitude

double magnitude(coordinates x)

Calculates the magnitude of a vector.

Return
Magnitude
Parameters
  • x: Vector for which magnitude is desired

Volume of Box

double volume(triclinicbox box)

Calculates the volume of simulation box.

Return
Volume of box
Parameters
  • box: Box dimensions