3.1.2. horton.cext
– C++ extensions¶
-
class
horton.cext.
Cell
¶ 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
()¶ Add a linear combination of real cell vectors,
r
, todelta
in-place
-
dot_rvecs
()¶ Return the corresponding dot product with the rvecs
-
from_hdf5
()¶ Construct a Cell object from data in an HDF5 group
-
from_parameters
()¶ 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
()¶ Return a linear combination of reciprocal cell vectors
-
get_glength
()¶ Get the length of the i-the reciprocal cell vector.
-
get_gspacing
()¶ Get the spacing between the i-the reciprocal cell planes.
-
get_ranges_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
()¶ Get the length of the i-the real-space cell vector.
-
get_rspacing
()¶ Get the spacing between the i-the real-space cell planes.
-
mic
()¶ Apply the minimum image convention to delta in-place
-
select_inside
()¶ Select the indexes of periodic images inside a cutoff sphere
Arguments:
- origin
- The origin of a supercell.
- center
- The center of the cutoff sphere.
- rcut
- The cutoff radius.
- ranges_begin, ranges_end
- As obtained with
horton.cext.Cell.get_ranges_rcut()
. - shape
- The shape of the supercell
- indexes
- A sufficiently large output array. The number of rows is the
product of the lengths of the ranges specified by ranges_begin
and ranges_end. The number of columns equals
nvec
.
-
to_cart
()¶ Return the corresponding Cartesian coordinates
-
to_frac
()¶ Return the corresponding fractional coordinates
-
to_hdf5
()¶ 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
()¶ Returned a standardize modulo operation i % shape if pbc is nonzero, -1 otherwise.
-
horton.cext.
fill_cartesian_polynomials
()¶ 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
()¶ 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
()¶ 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
()¶ 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
()¶ 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.