Numerical Utilities#

Numerical interpolation and geometry utilities.

tmol.numeric.Angles#

alias of Tensor

class tmol.numeric.BSplineInterpolation(coeffs: Tensor, n_interp_dims: int)[source]#

Bases: object

Class for performing bspline interpolation with periodic boundary conditions.

Construct an instance of this class using the from_coordinates function, handing it a (possibly stacked) table of coordinates that should be interpolated by the splines, the degree of the spline that should be constructed, and (optionally) the number of dimensions in the coordinates tensor that are “indexing dimensions” and not interpolation dimensions. The indexing dimensions should appear as the most significant dimensions and the interpolating dimensions should appear as the least significant dimensions.

Once constructed, the interpolate method can be given a tensor of coordinates X (and if the original coordinate tensor had indexing dimensions, a tensor of indices Y) to produce a tensor of interpolated values.

classmethod from_coordinates(coords: Tensor)[source]#

Construct a BSplineInterpolation instance from the input coordinates (i.e. the data to be interpolated)

This code handles splines of 2-4 dimensions

interpolate(X: Tensor) Tensor[source]#

B-spline interpolation function

X should be a two dimensional tensor of size [ n_points, n_dims ] the result will be a one dimensional tensor of size [ n_points ].

n_points represents the number of points in the n-dimensional space that is being interpolated (n-dimensional == n_interp_dims-dimensional). The result returned by this is the interpolated value for each of the input points.

tmol.numeric.Coord64Array#

alias of Tensor

tmol.numeric.coord_dihedrals(a: Tensor[slice(None, None, None), 3], b: Tensor[slice(None, None, None), 3], c: Tensor[slice(None, None, None), 3], d: Tensor[slice(None, None, None), 3]) Tensor[source]#

Dihedral angle in [-pi, pi] over the planes defined by {a, b, c} & {b, c, d}.

Calculate dihedral angle from four coordinate locations, using the “standard” torsion angle definition of two planes defined by the points {a, b, c} and {b, c, d}. For a four-atom bond definition, this corrosponds to rotation about the b-c bond.