3.1.14. horton/cell.h
– Unit cell code to specify periodic boundary conditions¶
Functions

long
smart_wrap
(long i, long shape, long pbc)¶ A standardized modulo operation that works across all compilers.
 Return
 i % shape if pbc is nonzero. 1 is returned otherwise.

class
Cell
¶  #include <cell.h>
3D/2D/1D periodic boundary conditions and derived quantities.
Upon construction, an object of this class acts as a readonly representation of the periodic boundary conditions. Reciprocal cell vectors, vector lengths and spacings between planes are computed immediately. All sorts of manipulations of fractional/Cartesian coordinates are supported.
Note that this implementation is specific for 3D systems, eventhough lower dimensional periodic boundary conditions are supported. In case of 1D or 2D PBC, the cell vectors are internally extended with orthogonal basis vectors to guarantee an invertible transformation between cartesian and fractional coordinates.
Public Functions

Cell
(double *_rvecs, int _nvec)¶ Construct a Cell object.
 Parameters
_rvecs
A pointer to 3*nvec doubles that represent the realspace vectors in rowmajor ordering.
_nvec
The number of cell vectors. This corresponds to the dimensionality of the periodic boundary conditions.

void
mic
(double *delta) const¶ Apply the minimum image convention to a realspace relative vector.
This is an approximate implementation that sometimes fails in very skewed cells. This is a common weakness in most implementations. For more details see: http://scicomp.stackexchange.com/questions/3107/minimumimageconventionfortriclinicunitcell
 Parameters
delta
A pointer to 3 doubles with the relative vector. It will be modified inplace.

void
to_frac
(double *cart, double *frac) const¶ Convert a realspace vector to fractional coordinates.
 Parameters
cart
A pointer to 3 doubles containing the input realspace vector.
frac
A pointer to 3 doubles in which the output is written.

void
to_cart
(double *frac, double *cart) const¶ Convert a fractional coordinates vector to realspace coordinates. This can also be interpreted as making a linear combination of realspace cell vectors.
 Parameters
frac
A pointer to 3 doubles containing the input fractional coordinates.
cart
A pointer to 3 doubles to which the output is written

void
g_lincomb
(double *coeffs, double *gvec) const¶ Construct a linear combination of reciprocal cell vectors.
 Parameters
coeffs
A pointer to 3 doubles containing the coefficients for the linear combination.
gvec
A pointer to 3 doubles to which the output is written

void
dot_rvecs
(double *cart, double *dots) const¶ Compute a dotproduct of a realspace vector with each cell vector.
 Parameters
cart
A pointer to 3 doubles containing the input fractional coordinates.
dots
A pointer to 3 doubles to which the output is written.

void
add_rvec
(double *delta, long *coeffs) const¶ Add a linear combination of cell vectors to delta.
 Parameters
delta
A pointer to 3 doubles for the realspace vector to which the linear combination is added inplace.
coeffs
A pointer to 3 doubles with the coefficients of the linear combination.

int
get_nvec
() const¶ Returns the dimensionality of the periodic boundary conditions.

double
get_volume
() const¶ Return the volume (or area or length) of the cell.

double
get_rspacing
(int i) const¶ Return the spacing between the ith realspace crystal plane

double
get_gspacing
(int i) const¶ Return the spacing between the ith reciprocal crystal plane

double
get_rlength
(int i) const¶ Return the length of the ith realspace cell vector

double
get_glength
(int i) const¶ Return the length of the ith reciprocal cell vector

void
copy_rvecs
(double *_rvecs) const¶ Write a copy of rvecs to _rvecs (3*nvec doubles)

void
copy_gvecs
(double *_gvecs) const¶ Write a copy of gvecs to _gvecs (3*nvec doubles)

void
copy_rlengths
(double *_rlengths) const¶ Write a copy of rlengths to _rlengths (nvec doubles)

void
copy_glengths
(double *_glengths) const¶ Write a copy of glengths to _glengths (nvec doubles)

void
copy_rspacings
(double *_rspacings) const¶ Write a copy of rspacings to _rspacings (nvec doubles)

void
copy_gspacings
(double *_gspacings) const¶ Write a copy of gspacings to _gspacings (nvec doubles)

void
set_ranges_rcut
(double *center, double rcut, long *ranges_begin, long *ranges_end) const¶ Get ranges of periodic images without a cutoff radius.
This function effectively defines a supercell that is guaranteed to enclose the cutoff sphere.
 Parameters
center
A pointer to three doubles that specify the center of the cutoff sphere in realspace.
rcut
The cutoff radius.
ranges_begin
A pointer to nvec longs to which the begin of each range of periodic images along a periodic boundary condition is written.
ranges_end
A pointer to nvec longs to which the end of each range of periodic images along a periodic boundary condition is written. Then end values are noninclusive as in Python ranges.
