3.1.2. horton.cext – C++ extensions

class horton.cext.Cell(ndarray rvecs=None)

Bases: object

Representation of periodic boundary conditions.

0, 1, 2 and 3 dimensional systems are supported. The cell vectors don’t need to be orthogonal.

add_rvec(self, ndarray delta, ndarray r)

Add a linear combination of real cell vectors, r, to delta in-place

dot_rvecs(self, ndarray cart)

Return the corresponding dot product with the rvecs

from_hdf5(type cls, grp)

Construct a Cell object from data in an HDF5 group

from_parameters(type cls, lengths, angles)

Construct a cell with the given parameters

The a vector is always parallel with the x-axis and they point in the same direction. The b vector is always in the xy plane and points towards the positive y-direction. The c vector points towards the positive z-direction.

The number of elements in the lengths and angles arrays determines the number of cell vectors. There are four cases:

  • len(lengths) == 0 and len(angles) == 0: 0 rvecs
  • len(lengths) == 1 and len(angles) == 0: 1 rvecs
  • len(lengths) == 2 and len(angles) == 1: 2 rvecs
  • len(lengths) == 3 and len(angles) == 3: 3 rvecs
g_lincomb(self, ndarray coeffs)

Return a linear combination of reciprocal cell vectors

get_glength(self, int i)

Get the length of the i-the reciprocal cell vector.

get_gspacing(self, int i)

Get the spacing between the i-the reciprocal cell planes.

get_ranges_rcut(self, ndarray center, double rcut)

Return the integer ranges for linear combinations of cell vectors.

Arguments:

center
The origin of the cutoff sphere
rcut
A cutoff radius

The returned ranges span the linear combination of cell vectors that can be added to delta to obtain all periodic images within the cutoff sphere.

get_rlength(self, int i)

Get the length of the i-the real-space cell vector.

get_rspacing(self, int i)

Get the spacing between the i-the real-space cell planes.

mic(self, ndarray delta)

Apply the minimum image convention to delta in-place

to_cart(self, ndarray frac)

Return the corresponding Cartesian coordinates

to_frac(self, ndarray cart)

Return the corresponding fractional coordinates

to_hdf5(self, grp)

Write the cell object to an HDF5 group

glengths

The lengths of the reciprocal-space vectors.

gspacings

The (orthogonal) spacing between opposite sides of the reciprocal-space unit cell.

gvecs

The reciporcal-space cell vectors, layed out as rows.

nvec

The number of cell vectors

parameters

The cell parameters (lengths and angles)

rlengths

The lengths of the real-space vectors.

rspacings

The (orthogonal) spacing between opposite sides of the real-space unit cell.

rvecs

The real-space cell vectors, layed out as rows.

volume

The generalized volume of the unit cell (length, area or volume)

horton.cext.smart_wrap(long i, long shape, long pbc)

Returned a standardize modulo operation i % shape if pbc is nonzero, -1 otherwise.

horton.cext.fill_cartesian_polynomials(ndarray output, long lmax)

Fill the output vector with cartesian polynomials

Arguments:

output
A double precision numpy array where the first three values are x, y and z coordinates.
lmax
The maximum angular momentum to compute.

The polynomials are stored according to the conventions set in get_cartesian_powers.

Returns:

The index of the first element of the array that contains the polynomials of the outermost shell.

horton.cext.fill_pure_polynomials(ndarray output, long lmax)

Fill the output vector with pure polynomials

Arguments:

output
This can either be a double precission Numpy vector or 2D array. In the first case, the first three values are z, x, and y coordinates. In the second case, the first three columns contain z, x and y coordinates.
lmax
The maximum angular momentum to compute.

Returns:

The index of the first element of the array that contains the polynomials of the outermost shell.

horton.cext.fill_radial_polynomials(ndarray output, long lmax)

Fill the output vector with radial polynomials

Arguments:

output
A double precision numpy array where the first element is the radius
lmax
The maximum angular momentum to compute.

All elements after the first will be filled up with increasing powers of the first element, up to lmax.

horton.cext.compute_grid_nucpot(ndarray coordinates, ndarray charges, ndarray points, ndarray output)

Compute the potential due to a set of (nuclear) point charges

coordinates
A (N, 3) float numpy array with Cartesian coordinates of the atoms.
charges
A (N,) numpy vector with the atomic charges.
points
An (M, 3) array with grid points where the potential must be computed.
output
An (M,) output array in which the potential is stored.
horton.cext.compute_nucnuc(ndarray coordinates, ndarray charges)

Compute interaction energy of the nuclei

Arguments:

coordinates
A (N, 3) float numpy array with Cartesian coordinates of the atoms.
charges
A (N,) numpy vector with the atomic charges.