Loading...
Searching...
No Matches
eonc::pbc Namespace Reference

Functions

AtomMatrix apply (const AtomMatrix &diff, const Matrix3d &cell, const Matrix3d &cellInverse)
AtomMatrix applyLegacy (const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse)
AtomMatrix applyPositions (const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse, PbcConvention convention)
VectorXd applyV (const VectorXd &diffVector, const Matrix3d &cell, const Matrix3d &cellInverse)

Function Documentation

◆ apply()

AtomMatrix eonc::pbc::apply ( const AtomMatrix & diff,
const Matrix3d & cell,
const Matrix3d & cellInverse )
inline

Definition at line 42 of file Matter.h.

43 {
44 // Transform to fractional coordinates, wrap to [-0.5, 0.5), transform back.
45 // Uses floor(x + 0.5) instead of double-fmod: single x86 vroundsd instruction
46 // vs expensive fmod library call. Vectorized via Eigen .array() operations.
47 AtomMatrix frac = diff * cellInverse;
48 frac.array() -= (frac.array() + 0.5).floor();
49 return frac * cell;
50}
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37

◆ applyLegacy()

AtomMatrix eonc::pbc::applyLegacy ( const AtomMatrix & coords,
const Matrix3d & cell,
const Matrix3d & cellInverse )
inline

Definition at line 54 of file Matter.h.

55 {
56 AtomMatrix frac = coords * cellInverse;
57 for (int i = 0; i < frac.rows(); i++) {
58 for (int j = 0; j < 3; j++) {
59 frac(i, j) = std::fmod(frac(i, j) + 1.0, 1.0);
60 }
61 }
62 return frac * cell;
63}

◆ applyPositions()

AtomMatrix eonc::pbc::applyPositions ( const AtomMatrix & coords,
const Matrix3d & cell,
const Matrix3d & cellInverse,
PbcConvention convention )
inline

Definition at line 66 of file Matter.h.

68 {
69 if (convention == PbcConvention::MinimumImage) {
70 return apply(coords, cell, cellInverse);
71 }
72 return applyLegacy(coords, cell, cellInverse);
73}
AtomMatrix apply(const AtomMatrix &diff, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:42
AtomMatrix applyLegacy(const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:54

◆ applyV()

VectorXd eonc::pbc::applyV ( const VectorXd & diffVector,
const Matrix3d & cell,
const Matrix3d & cellInverse )
inline

Definition at line 75 of file Matter.h.

76 {
77 AtomMatrix pbcMatrix =
78 apply(AtomMatrix::Map(diffVector.data(), diffVector.size() / 3, 3), cell,
79 cellInverse);
80 return VectorXd(VectorXd::Map(pbcMatrix.data(), diffVector.size()));
81}