parmed.geometry module¶

This module contains the functionality for carrying out geometrical calculations for molecules and molecular systems

Author: Jason Swails Contributors:

Copyright (C) 2014 - 2015 Jason Swails

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.

`parmed.geometry.``angle`(a1, a2, a3)[source]

Computes the cartesian angle between three atoms. Ignores periodic boundary conditions.

Parameters
a1, a2, a3Atom or collection of 3 coordinates

The three atoms between whom the angle should be calculated (with a2 being the central atoms)

Returns
angfloat

The angle between the vectors a1-a2 and a2-a3 in degrees

Raises
TypeError if a1, a2, or a3 are not Atom or iterable
ValueError if a1, a2, or a3 are iterable, but do not have exactly 3 items

Notes

This is done in pure Python, so it should not be used for large numbers of distance calculations. For that, use numpy-vectorized routines and the numpy coordinate arrays

`parmed.geometry.``box_lengths_and_angles_to_vectors`(a, b, c, alpha, beta, gamma)[source]

This function takes the lengths of the unit cell vectors and the angles between them and returns 3 unit cell vectors satisfying those dimensions

Parameters

Length of the first unit cell vector

bdouble (or length Quantity)

Length of the second unit cell vector

cdouble (or length Quantity)

Length of the third unit cell vector

Angle between vectors b and c

Angle between vectors a and c

Angle between vectors a and b

Returns
list Quantity, list Quantity, list Quantity

The 3, 3-element vectors as quantities with dimension length

Notes

The unit cell lengths are assumed to be Angstroms if no explicit unit is given. The angles are assumed to be degrees

`parmed.geometry.``box_vectors_to_lengths_and_angles`(a, b, c)[source]

This function takes the lengths of the unit cell vectors and the angles between them and returns 3 unit cell vectors satisfying those dimensions

Parameters
acollection of 3 floats (or length Quantity)

The first unit cell vector

bcollection of 3 floats (or length Quantity)

The second unit cell vector

ccollection of 3 floats (or length Quantity)

The third unit cell vector

Returns
(a, b, c), (alpha, beta, gamma)

Two tuples, the first is the 3 unit cell vector lengths as length-dimension Quantity objects and the second is the set of angles between the unit cell vectors as angle-dimension Quantity objects

Notes

The unit cell lengths are assumed to be Angstroms if no explicit unit is given.

`parmed.geometry.``center_of_mass`(coordinates, masses)[source]

Compute the center of mass of a group of coordinates.

Parameters
coordinatesnumpy.ndarray

Coordinate array

massesnumpy.ndarray

Array of masses

Returns
COM

np.ndarray of shape (3,) identifying the cartesian center of mass

Notes

This method requires that the parameters be passed in as numpy arrays. AttributeError’s will ensue if this is not the case. Also, coordinates must be able to be reshaped to (len(masses), 3), or ValueError’s will ensue

`parmed.geometry.``dihedral`(a1, a2, a3, a4)[source]

Computes the angle between three vectors made up of four points (all three vectors share one point with one other vector)

Parameters
a1, a2, a3, a4Atom or collection of 4 coordinates

The four atoms between whom the torsion angle should be calculated (with a1 and a4 being the two end-point atoms not shared between two vectors)

Returns
dihedfloat

The measured dihedral between the 4 points in degrees

`parmed.geometry.``distance2`(a1, a2)[source]

Computes the cartesian distance between two atoms. Ignores periodic boundary conditions.

Parameters
a1, a2Atom or collection of 3 coordinates

The two atoms between whom the distance should be calculated

Returns
d2float

The square of the distance between the two atoms

Raises
TypeError if a1 or a2 are not Atom or iterable
ValueError if a1 or a2 are iterable, but do not have exactly 3 items

Notes

This is done in pure Python, so it should not be used for large numbers of distance calculations. For that, use numpy-vectorized routines and the numpy coordinate arrays

`parmed.geometry.``reduce_box_vectors`(a, b, c)[source]

This function puts three unit cell vectors in a reduced form where a is “mostly” in x, b is “mostly” in y, and c is “mostly” in z. This form is necessary for some programs (notably OpenMM and Gromacs)

Parameters
a3-element collection of float

First unit cell vector

b3-element collection of float

Second unit cell vector

c3-element collection of float

Third unit cell vector

Returns
red_a, red_b, red_cVec3, Vec3, Vec3

The reduced unit cell vectors in units of angstroms

Notes

The implementation here is taken from the OpenMM Python application layer written by Peter Eastman