Loading...
Searching...
No Matches
gpr::geometry::PairBox Class Reference

#include <gpr/auxiliary/MinImage.h>

Public Member Functions

 PairBox ()=default
 PairBox (const double cell[9])
 PairBox (const std::array< double, 9 > &cell)
 PairBox (const double cell[9], const std::array< bool, 3 > &periodic)
void reset (const double cell[9])
bool periodic () const noexcept
 Some axis is periodic.
const std::array< bool, 3 > & periodicAxes () const noexcept
 The periodic axes, a, b, c.
void displacement (const double p[3], const double q[3], double dr[3]) const
 Displacement from p to q. Cartesian q - p when the cell is zero.
Eigen::Vector3d displacement (const Eigen::Vector3d &p, const Eigen::Vector3d &q) const
double dist2 (const Eigen::Vector3d &p, const Eigen::Vector3d &q) const

Detailed Description

Pair displacement through the LODE minimage mi_* C ABI.

A zero cell keeps the Cartesian difference q - p and never calls mi_*. A cell with three nonzero rows builds one mi_cell (ASE row-major) and every displacement is the nearest Euclidean lattice image. A cell with one or two zero rows is periodic along its nonzero rows only (a slab or a wire): an mi_pbc_cell takes the nearest image over the lattice of those rows and none along the open axes. Distances and derivatives use that same displacement. The 25 A vacuum box stays off this path at the load and overlay sites (cellIsMicLattice), not inside PairBox.

Definition at line 156 of file MinImage.h.

Constructor & Destructor Documentation

◆ PairBox() [1/4]

gpr::geometry::PairBox::PairBox ( )
default

◆ PairBox() [2/4]

gpr::geometry::PairBox::PairBox ( const double cell[9])
inlineexplicit

Definition at line 160 of file MinImage.h.

161 {
162 reset(cell);
163 }
void reset(const double cell[9])
Definition MinImage.h:180

◆ PairBox() [3/4]

gpr::geometry::PairBox::PairBox ( const std::array< double, 9 > & cell)
inlineexplicit

Definition at line 165 of file MinImage.h.

166 {
167 reset(cell.data());
168 }

◆ PairBox() [4/4]

gpr::geometry::PairBox::PairBox ( const double cell[9],
const std::array< bool, 3 > & periodic )
inline

Periodic along the axes of periodic only; the rows of the open axes are ignored.

Definition at line 172 of file MinImage.h.

173 {
174 double rows[9];
175 std::copy(cell, cell + 9, rows);
176 zeroOpenAxes(rows, periodic);
177 reset(rows);
178 }
bool periodic() const noexcept
Some axis is periodic.
Definition MinImage.h:198
void zeroOpenAxes(double cell[9], const std::array< bool, 3 > &periodic) noexcept
Definition MinImage.h:136

Member Function Documentation

◆ displacement() [1/2]

void gpr::geometry::PairBox::displacement ( const double p[3],
const double q[3],
double dr[3] ) const
inline

Displacement from p to q. Cartesian q - p when the cell is zero.

Definition at line 210 of file MinImage.h.

211 {
212 if (!periodic_) {
213 dr[0] = q[0] - p[0];
214 dr[1] = q[1] - p[1];
215 dr[2] = q[2] - p[2];
216 return;
217 }
218 if (!partial_) {
219 if (minimage_displacement_euclidean(&box_, p, q, dr) != 0)
220 throwLastError("minimage: displacement failed");
221 return;
222 }
223 if (minimage_displacement_euclidean_pbc(&partial_box_, p, q, dr) != 0)
224 throwLastError("minimage: displacement failed");
225 }

◆ displacement() [2/2]

Eigen::Vector3d gpr::geometry::PairBox::displacement ( const Eigen::Vector3d & p,
const Eigen::Vector3d & q ) const
inlinenodiscard

Definition at line 227 of file MinImage.h.

229 {
230 Eigen::Vector3d dr;
231 displacement(p.data(), q.data(), dr.data());
232 return dr;
233 }
void displacement(const double p[3], const double q[3], double dr[3]) const
Displacement from p to q. Cartesian q - p when the cell is zero.
Definition MinImage.h:210

◆ dist2()

double gpr::geometry::PairBox::dist2 ( const Eigen::Vector3d & p,
const Eigen::Vector3d & q ) const
inlinenodiscard

Definition at line 235 of file MinImage.h.

237 {
238 if (!periodic_) return (q - p).squaredNorm();
239 return displacement(p, q).squaredNorm();
240 }

◆ periodic()

bool gpr::geometry::PairBox::periodic ( ) const
inlinenodiscardnoexcept

Some axis is periodic.

Definition at line 198 of file MinImage.h.

199 {
200 return periodic_;
201 }

◆ periodicAxes()

const std::array< bool, 3 > & gpr::geometry::PairBox::periodicAxes ( ) const
inlinenodiscardnoexcept

The periodic axes, a, b, c.

Definition at line 204 of file MinImage.h.

205 {
206 return axes_;
207 }

◆ reset()

void gpr::geometry::PairBox::reset ( const double cell[9])
inline

Definition at line 180 of file MinImage.h.

181 {
182 axes_ = cellPeriodicAxes(cell);
183 periodic_ = axes_[0] || axes_[1] || axes_[2];
184 partial_ = periodic_ && !(axes_[0] && axes_[1] && axes_[2]);
185 if (!periodic_) return;
186 if (!partial_) {
187 if (minimage_cell_from_ase(cell, nullptr, &box_) != 0)
188 throwLastError("minimage: cell_from_ase failed");
189 return;
190 }
191 const int mask[3] = {axes_[0] ? 1 : 0, axes_[1] ? 1 : 0,
192 axes_[2] ? 1 : 0};
193 if (minimage_pbc_cell_from_ase(cell, mask, nullptr, &partial_box_) != 0)
194 throwLastError("minimage: pbc_cell_from_ase failed");
195 }
std::array< bool, 3 > cellPeriodicAxes(const double cell[9]) noexcept
Definition MinImage.h:93

The documentation for this class was generated from the following file: