Loading...
Searching...
No Matches
Gen

Topics

 Ring
 

Namespaces

namespace  gen
 Small generic functions that are shared by all namespaces.

Classes

struct  gen::FracBox

Functions

double gen::radDeg (double angle)
 Inline function for converting radians->degrees.
double gen::eigenVecAngle (std::vector< double > OO, std::vector< double > OH)
 Eigen function for getting the angle (in radians) between the O–O and O-H vectors.
double gen::getAverageWithoutOutliers (std::vector< double > inpVec)
 Get the average, after excluding the outliers, using quartiles.
double gen::calcMedian (std::vector< double > *input)
 Inline generic function for calculating the median given a vector of the values.
FracBox gen::makeFracBox (const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
std::array< double, 3 > gen::fracDelta (const FracBox &b, double xi, double yi, double zi, double xj, double yj, double zj)
double gen::fracDistSq (const FracBox &b, double xi, double yi, double zi, double xj, double yj, double zj)
bool gen::smithInside (const FracBox &b, double r2)
std::array< double, 3 > gen::triclinicMinImage (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double xi, double yi, double zi, double xj, double yj, double zj)
double gen::periodicDistSq (const FracBox &b, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
 Inline generic function for obtaining the unwrapped periodic distance between two particles, whose indices (not IDs) have been given.
double gen::periodicDistSq (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
double gen::periodicDist (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
 Inline generic function for obtaining the unwrapped periodic distance between two particles, whose indices (not IDs) have been given.
void gen::batchPeriodicDistSq (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, const int *jatom, std::size_t n, double *distSq)
std::string gen::formatDumpBox (const std::vector< double > &box)
void gen::writeDumpBoxBounds (std::ostream &os, const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
std::array< double, 3 > gen::relDistFromPoint (const FracBox &b, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, double xj, double yj, double zj)
 Inline generic function for obtaining the unwrapped periodic distance between one particle and another point, whose index has been given.
std::array< double, 3 > gen::relDistFromPoint (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, double xj, double yj, double zj)
double gen::unWrappedDistFromPoint (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, const std::vector< double > &singlePoint)
double gen::distance (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
 Inline generic function for obtaining the wrapped distance between two particles WITHOUT applying PBCs, whose indices (not IDs) have been given.
std::array< double, 3 > gen::relDist (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
 Inline generic function for getting the relative unwrapped distance between two particles for each dimension.
bool gen::compareByAtomID (const molSys::Point< double > &a, const molSys::Point< double > &b)
 Inline generic function for sorting or comparing two particles, according to the atom ID when the entire Point objects have been passed.
int gen::prettyPrintYoda (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, std::string outFile)
 Generic function for printing all the struct information.
int gen::unwrappedCoordShift (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatomIndex, int jatomIndex, double *x_i, double *y_i, double *z_i, double *x_j, double *y_j, double *z_j)
 Shift particles (unwrapped coordinates).
double gen::angDistDegQuaternions (std::vector< double > quat1, std::vector< double > quat2)
std::vector< std::string > gen::tokenizer (std::string line)
 Function for tokenizing line strings into words (strings) delimited by whitespace.
std::vector< double > gen::tokenizerDouble (std::string line)
 Function for tokenizing line strings into a vector of doubles.
std::vector< int > gen::tokenizerInt (std::string line)
 Function for tokenizing line strings into a vector of ints.
bool gen::file_exists (const std::string &name)
 Function for checking if a file exists or not.
std::vector< std::complex< double > > gen::avgVector (std::vector< std::complex< double > > v, int l, int neigh)
 Calculates the complex vector, normalized by the number of nearest neighbours, of length \(2l+1\).

Variables

constexpr double gen::pi = std::numbers::pi
 Uses Boost to get the value of pi.
double gen::FracBox::lx = 0.0
double gen::FracBox::ly = 0.0
double gen::FracBox::lz = 0.0
double gen::FracBox::xy = 0.0
double gen::FracBox::xz = 0.0
double gen::FracBox::yz = 0.0
double gen::FracBox::ox = 0.0
double gen::FracBox::oy = 0.0
double gen::FracBox::oz = 0.0
double gen::FracBox::wx = 0.0
double gen::FracBox::wy = 0.0
double gen::FracBox::wz = 0.0
double gen::FracBox::halfMin = 0.0
bool gen::FracBox::triclinic = false
bool gen::FracBox::ok = false

Detailed Description

Function Documentation

◆ angDistDegQuaternions()

double gen::angDistDegQuaternions ( std::vector< double > quat1,
std::vector< double > quat2 )

Function for getting the angular distance between two quaternions. Returns the result in degrees

◆ avgVector()

std::vector< std::complex< double > > gen::avgVector ( std::vector< std::complex< double > > v,
int l,
int neigh )
inline

Calculates the complex vector, normalized by the number of nearest neighbours, of length \(2l+1\).

Parameters
[in]vThe complex vector to be normalized, of length \(2l+1\)
[in]lA free integer parameter
[in]neighThe number of nearest neighbours
Returns
length \(2l+1\), normalized by the number of nearest neighbours

Definition at line 697 of file generic.hpp.

697 {
698 if (neigh == 0) {
699 return v;
700 }
701 for (int m = 0; m < 2 * l + 1; m++) {
702 v[m] = (1.0 / static_cast<double>(neigh)) * v[m];
703 }
704
705 return v;
706}

◆ batchPeriodicDistSq()

void gen::batchPeriodicDistSq ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
const int * jatom,
std::size_t n,
double * distSq )
inline

Definition at line 426 of file generic.hpp.

428 {
429 const FracBox b = makeFracBox(yCloud);
430#ifdef SEAMS_HAS_MINIMAGE
431 if (n > 0 && b.ok && b.triclinic) {
432 mi_cell cell;
433 if (pointCloudCell(yCloud, &cell)) {
434 const auto &pi = yCloud.pts[static_cast<std::size_t>(iatom)];
435 const double p[3] = {pi.x, pi.y, pi.z};
436 std::vector<double> qs(n * 3);
437 for (std::size_t k = 0; k < n; ++k) {
438 const auto &pj = yCloud.pts[static_cast<std::size_t>(jatom[k])];
439 qs[3 * k] = pj.x;
440 qs[3 * k + 1] = pj.y;
441 qs[3 * k + 2] = pj.z;
442 }
443 if (mi_dist2_many(&cell, p, qs.data(), n, distSq) == 0) {
444 for (std::size_t k = 0; k < n; ++k) {
445 if (smithInside(b, distSq[k])) {
446 continue;
447 }
448 const double q[3] = {qs[3 * k], qs[3 * k + 1], qs[3 * k + 2]};
449 double ed[3] = {0.0, 0.0, 0.0};
450 if (mi_displacement_euclidean(&cell, q, p, ed) == 0) {
451 distSq[k] = ed[0] * ed[0] + ed[1] * ed[1] + ed[2] * ed[2];
452 }
453 }
454 return;
455 }
456 }
457 }
458#endif
459 for (std::size_t k = 0; k < n; k++) {
460 distSq[k] = periodicDistSq(b, yCloud, iatom, jatom[k]);
461 }
462}
FracBox makeFracBox(const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
Definition generic.hpp:154
constexpr double pi
Uses Boost to get the value of pi.
Definition generic.hpp:64
bool smithInside(const FracBox &b, double r2)
Definition generic.hpp:241
double periodicDistSq(const FracBox &b, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
Inline generic function for obtaining the unwrapped periodic distance between two particles,...
Definition generic.hpp:363
std::vector< S > pts
Definition mol_sys.hpp:174

◆ calcMedian()

double gen::calcMedian ( std::vector< double > * input)
inline

Inline generic function for calculating the median given a vector of the values.

Parameters
[in]yCloudThe input PointCloud, which contains the particle coordinates, simulation box lengths etc.
[in]inputThe input vector with the values
Returns
The median value

Definition at line 87 of file generic.hpp.

87 {
88 int n = (*input).size(); // Number of elements
89 double median; // Output median value
90
91 // Sort a copy (avoid mutating input)
92 std::vector<double> sorted = *input;
93 std::sort(sorted.begin(), sorted.end());
94
95 // Calculate the median
96 // For even values, the median is the average of the two middle values
97 if (n % 2 == 0) {
98 median = 0.5 * (sorted[n / 2] + sorted[n / 2 - 1]);
99 } else {
100 median = sorted[(n + 1) / 2 - 1];
101 }
102
103 return median;
104}

◆ compareByAtomID()

bool gen::compareByAtomID ( const molSys::Point< double > & a,
const molSys::Point< double > & b )
inline

Inline generic function for sorting or comparing two particles, according to the atom ID when the entire Point objects have been passed.

Parameters
[in]aThe input Point for A.
[in]bThe input Point for B.
Returns
True if the atom ID of A is less than the atom ID of B

Definition at line 620 of file generic.hpp.

621 {
622 return a.atomID < b.atomID;
623}

◆ distance()

double gen::distance ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
int jatom )
inline

Inline generic function for obtaining the wrapped distance between two particles WITHOUT applying PBCs, whose indices (not IDs) have been given.

Parameters
[in]yCloudThe input PointCloud, which contains the particle coordinates, simulation box lengths etc.
[in]iatomThe index of the \( i^{th} \) atom.
[in]jatomThe index of the \( j^{th} \) atom.
Returns
The wrapped distance.

Definition at line 575 of file generic.hpp.

576 {
577 std::array<double, 3> dr;
578 double r2 = 0.0; // Squared absolute distance
579
580 // Get x1-x2 etc
581 dr[0] = fabs(yCloud.pts[iatom].x - yCloud.pts[jatom].x);
582 dr[1] = fabs(yCloud.pts[iatom].y - yCloud.pts[jatom].y);
583 dr[2] = fabs(yCloud.pts[iatom].z - yCloud.pts[jatom].z);
584
585 // Get the squared absolute distance
586 for (int k = 0; k < 3; k++) {
587 r2 += pow(dr[k], 2.0);
588 }
589
590 return sqrt(r2);
591}

◆ eigenVecAngle()

double gen::eigenVecAngle ( std::vector< double > OO,
std::vector< double > OH )

Eigen function for getting the angle (in radians) between the O–O and O-H vectors.

◆ file_exists()

bool gen::file_exists ( const std::string & name)
inline

Function for checking if a file exists or not.

Parameters
[in]nameThe name of the file

Definition at line 684 of file generic.hpp.

684 {
685 return std::filesystem::exists(name);
686}

◆ formatDumpBox()

std::string gen::formatDumpBox ( const std::vector< double > & box)
inline

Definition at line 465 of file generic.hpp.

465 {
466 std::ostringstream oss;
467 if (box.size() >= 3) {
468 oss << box[0] << ' ' << box[1] << ' ' << box[2];
469 }
470 if (box.size() >= 6) {
471 oss << " xy " << box[3] << " xz " << box[4] << " yz " << box[5];
472 }
473 return oss.str();
474}

◆ fracDelta()

std::array< double, 3 > gen::fracDelta ( const FracBox & b,
double xi,
double yi,
double zi,
double xj,
double yj,
double zj )
inline

Definition at line 203 of file generic.hpp.

205 {
206 if (!b.triclinic) {
207 std::array<double, 3> dr = {xi - xj, yi - yj, zi - zj};
208 const double len[3] = {b.lx, b.ly, b.lz};
209 for (int k = 0; k < 3; k++) {
210 dr[static_cast<std::size_t>(k)] -=
211 len[k] * std::floor(dr[static_cast<std::size_t>(k)] / len[k] + 0.5);
212 }
213 return dr;
214 }
215 const double sz_i = (zi - b.oz) / b.lz;
216 const double sy_i = (yi - b.oy - b.yz * sz_i) / b.ly;
217 const double sx_i = (xi - b.ox - b.xy * sy_i - b.xz * sz_i) / b.lx;
218 const double sz_j = (zj - b.oz) / b.lz;
219 const double sy_j = (yj - b.oy - b.yz * sz_j) / b.ly;
220 const double sx_j = (xj - b.ox - b.xy * sy_j - b.xz * sz_j) / b.lx;
221 double dsx = sx_i - sx_j;
222 double dsy = sy_i - sy_j;
223 double dsz = sz_i - sz_j;
224 dsx -= std::round(dsx);
225 dsy -= std::round(dsy);
226 dsz -= std::round(dsz);
227 return {b.lx * dsx + b.xy * dsy + b.xz * dsz, b.ly * dsy + b.yz * dsz,
228 b.lz * dsz};
229}

◆ fracDistSq()

double gen::fracDistSq ( const FracBox & b,
double xi,
double yi,
double zi,
double xj,
double yj,
double zj )
inline

Definition at line 231 of file generic.hpp.

232 {
233 const auto dr = fracDelta(b, xi, yi, zi, xj, yj, zj);
234 return dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2];
235}
std::array< double, 3 > fracDelta(const FracBox &b, double xi, double yi, double zi, double xj, double yj, double zj)
Definition generic.hpp:203

◆ getAverageWithoutOutliers()

double gen::getAverageWithoutOutliers ( std::vector< double > inpVec)

Get the average, after excluding the outliers, using quartiles.

◆ makeFracBox()

FracBox gen::makeFracBox ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud)
inline

Definition at line 154 of file generic.hpp.

154 {
155 FracBox b;
156 const auto &box = yCloud.box;
157 const auto &boxLow = yCloud.boxLow;
158 b.ox = boxLow.size() > 0 ? boxLow[0] : 0.0;
159 b.oy = boxLow.size() > 1 ? boxLow[1] : 0.0;
160 b.oz = boxLow.size() > 2 ? boxLow[2] : 0.0;
161 if (box.size() >= 6) {
162 const double xy = box[3];
163 const double xz = box[4];
164 const double yz = box[5];
165 const double xmin = std::min(std::min(0.0, xy), std::min(xz, xy + xz));
166 const double xmax = std::max(std::max(0.0, xy), std::max(xz, xy + xz));
167 const double ymin = std::min(0.0, yz);
168 const double ymax = std::max(0.0, yz);
169 b.lx = box[0] - xmax + xmin;
170 b.ly = box[1] - ymax + ymin;
171 b.lz = box[2];
172 b.xy = xy;
173 b.xz = xz;
174 b.yz = yz;
175 b.ox -= xmin;
176 b.oy -= ymin;
177 b.triclinic = true;
178 } else if (box.size() >= 3) {
179 b.lx = box[0];
180 b.ly = box[1];
181 b.lz = box[2];
182 } else {
183 return b;
184 }
185 if (!(b.lx > 0.0 && b.ly > 0.0 && b.lz > 0.0)) {
186 return b;
187 }
188 const double bcz = b.xy * b.yz - b.ly * b.xz;
189 b.wx = b.lx * b.ly * b.lz /
190 std::sqrt(b.ly * b.lz * b.ly * b.lz + b.xy * b.lz * b.xy * b.lz +
191 bcz * bcz);
192 b.wy = b.ly * b.lz / std::sqrt(b.lz * b.lz + b.yz * b.yz);
193 b.wz = b.lz;
194 b.halfMin = 0.5 * std::min(b.wx, std::min(b.wy, b.wz));
195 b.ok = true;
196 return b;
197}
double halfMin
Definition generic.hpp:148
std::vector< T > box
Number of atoms.
Definition mol_sys.hpp:177
std::vector< T > boxLow
Periodic box lengths.
Definition mol_sys.hpp:178

◆ periodicDist()

double gen::periodicDist ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
int jatom )
inline

Inline generic function for obtaining the unwrapped periodic distance between two particles, whose indices (not IDs) have been given.

Parameters
[in]yCloudThe input PointCloud, which contains the particle coordinates, simulation box lengths etc.
[in]iatomThe index of the \( i^{th} \) atom.
[in]jatomThe index of the \( j^{th} \) atom.
Returns
The unwrapped periodic distance.

Definition at line 417 of file generic.hpp.

418 {
419 return std::sqrt(periodicDistSq(yCloud, iatom, jatom));
420}

◆ periodicDistSq() [1/2]

double gen::periodicDistSq ( const FracBox & b,
const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
int jatom )
inline

Inline generic function for obtaining the unwrapped periodic distance between two particles, whose indices (not IDs) have been given.

Parameters
[in]yCloudThe input PointCloud, which contains the particle coordinates, simulation box lengths etc.
[in]iatomThe index of the \( i^{th} \) atom.
[in]jatomThe index of the \( j^{th} \) atom.
Returns
The unwrapped periodic distance.

Definition at line 363 of file generic.hpp.

365 {
366 const auto &pi = yCloud.pts[static_cast<std::size_t>(iatom)];
367 const auto &pj = yCloud.pts[static_cast<std::size_t>(jatom)];
368 if (b.ok) {
369 const double r2 = fracDistSq(b, pi.x, pi.y, pi.z, pj.x, pj.y, pj.z);
370 if (smithInside(b, r2)) {
371 return r2;
372 }
373#ifdef SEAMS_HAS_MINIMAGE
374 double ed[3] = {0.0, 0.0, 0.0};
375 if (euclideanDelta(yCloud, pi.x, pi.y, pi.z, pj.x, pj.y, pj.z, ed)) {
376 return ed[0] * ed[0] + ed[1] * ed[1] + ed[2] * ed[2];
377 }
378#endif
379 return r2;
380 }
381 if (yCloud.box.size() >= 6) {
382 const auto dr =
383 triclinicMinImage(yCloud, pi.x, pi.y, pi.z, pj.x, pj.y, pj.z);
384 return dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2];
385 }
386 std::array<double, 3> dr;
387 double r2 = 0.0;
388 dr[0] = std::fabs(pi.x - pj.x);
389 dr[1] = std::fabs(pi.y - pj.y);
390 dr[2] = std::fabs(pi.z - pj.z);
391 for (int k = 0; k < 3; k++) {
392 dr[static_cast<std::size_t>(k)] -=
393 yCloud.box[static_cast<std::size_t>(k)] *
394 std::round(dr[static_cast<std::size_t>(k)] /
395 yCloud.box[static_cast<std::size_t>(k)]);
396 r2 += dr[static_cast<std::size_t>(k)] * dr[static_cast<std::size_t>(k)];
397 }
398 return r2;
399}
double fracDistSq(const FracBox &b, double xi, double yi, double zi, double xj, double yj, double zj)
Definition generic.hpp:231
std::array< double, 3 > triclinicMinImage(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double xi, double yi, double zi, double xj, double yj, double zj)
Definition generic.hpp:298

◆ periodicDistSq() [2/2]

double gen::periodicDistSq ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
int jatom )
inline

Definition at line 402 of file generic.hpp.

403 {
404 return periodicDistSq(makeFracBox(yCloud), yCloud, iatom, jatom);
405}

◆ prettyPrintYoda()

int gen::prettyPrintYoda ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
std::string outFile )
nodiscard

Generic function for printing all the struct information.

◆ radDeg()

double gen::radDeg ( double angle)
inline

Inline function for converting radians->degrees.

Parameters
[in]angleThe input angle, in radians
Returns
The input angle, in degrees

Definition at line 71 of file generic.hpp.

71{ return (angle * 180) / gen::pi; }

◆ relDist()

std::array< double, 3 > gen::relDist ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
int jatom )
inline

Inline generic function for getting the relative unwrapped distance between two particles for each dimension.

The indices (not IDs) of the particles have been given.

Parameters
[in]yCloudThe input PointCloud, which contains the particle coordinates, simulation box lengths etc.
[in]iatomThe index of the \( i^{th} \) atom.
[in]jatomThe index of the \( j^{th} \) atom.
Returns
The unwrapped relative distances for each dimension.

Definition at line 605 of file generic.hpp.

606 {
607 return relDistFromPoint(yCloud, iatom, yCloud.pts[jatom].x,
608 yCloud.pts[jatom].y, yCloud.pts[jatom].z);
609}
std::array< double, 3 > relDistFromPoint(const FracBox &b, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, double xj, double yj, double zj)
Inline generic function for obtaining the unwrapped periodic distance between one particle and anothe...
Definition generic.hpp:512

◆ relDistFromPoint() [1/2]

std::array< double, 3 > gen::relDistFromPoint ( const FracBox & b,
const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
double xj,
double yj,
double zj )
inline

Inline generic function for obtaining the unwrapped periodic distance between one particle and another point, whose index has been given.

Parameters
[in]bThe box of yCloud, from makeFracBox.
[in]yCloudThe input PointCloud, which contains the particle coordinates, simulation box lengths etc.
[in]iatomThe index of the \( i^{th} \) atom.
[in]xj,yj,zjThe other point.
Returns
The unwrapped periodic distance.

Definition at line 512 of file generic.hpp.

515 {
516 if (b.ok) {
517 const auto &pi = yCloud.pts[static_cast<std::size_t>(iatom)];
518 const auto dr = fracDelta(b, pi.x, pi.y, pi.z, xj, yj, zj);
519 const double r2 = dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2];
520 if (smithInside(b, r2)) {
521 return dr;
522 }
523#ifdef SEAMS_HAS_MINIMAGE
524 double ed[3] = {0.0, 0.0, 0.0};
525 if (euclideanDelta(yCloud, pi.x, pi.y, pi.z, xj, yj, zj, ed)) {
526 return {ed[0], ed[1], ed[2]};
527 }
528#endif
529 return dr;
530 }
531 if (yCloud.box.size() >= 6) {
532 return triclinicMinImage(yCloud, yCloud.pts[iatom].x, yCloud.pts[iatom].y,
533 yCloud.pts[iatom].z, xj, yj, zj);
534 }
535
536 std::array<double, 3> dr = {yCloud.pts[iatom].x - xj, yCloud.pts[iatom].y - yj,
537 yCloud.pts[iatom].z - zj};
538 for (int k = 0; k < 3; k++) {
539 if (dr[k] < -yCloud.box[k] * 0.5) {
540 dr[k] += yCloud.box[k];
541 }
542 if (dr[k] >= yCloud.box[k] * 0.5) {
543 dr[k] -= yCloud.box[k];
544 }
545 }
546 return dr;
547}

◆ relDistFromPoint() [2/2]

std::array< double, 3 > gen::relDistFromPoint ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
double xj,
double yj,
double zj )
inline

Definition at line 549 of file generic.hpp.

551 {
552 return relDistFromPoint(makeFracBox(yCloud), yCloud, iatom, xj, yj, zj);
553}

◆ smithInside()

bool gen::smithInside ( const FracBox & b,
double r2 )
inline

Definition at line 241 of file generic.hpp.

241 {
242 return b.ok && (!b.triclinic || std::sqrt(r2) + 1e-12 < b.halfMin);
243}

◆ tokenizer()

std::vector< std::string > gen::tokenizer ( std::string line)
inline

Function for tokenizing line strings into words (strings) delimited by whitespace.

This returns a vector with the words in it.

Parameters
[in]lineThe string containing the line to be tokenized

Definition at line 645 of file generic.hpp.

645 {
646 std::istringstream iss(line);
647 std::vector<std::string> tokens{std::istream_iterator<std::string>{iss},
648 std::istream_iterator<std::string>{}};
649 return tokens;
650}

◆ tokenizerDouble()

std::vector< double > gen::tokenizerDouble ( std::string line)
inline

Function for tokenizing line strings into a vector of doubles.

Parameters
[in]lineThe string containing the line to be tokenized

Definition at line 656 of file generic.hpp.

656 {
657 std::istringstream iss(line);
658 std::vector<double> tokens;
659 double number; // Each number being read in from the line
660 while (iss >> number) {
661 tokens.push_back(number);
662 }
663 return tokens;
664}

◆ tokenizerInt()

std::vector< int > gen::tokenizerInt ( std::string line)
inline

Function for tokenizing line strings into a vector of ints.

Parameters
[in]lineThe string containing the line to be tokenized

Definition at line 670 of file generic.hpp.

670 {
671 std::istringstream iss(line);
672 std::vector<int> tokens;
673 int number; // Each number being read in from the line
674 while (iss >> number) {
675 tokens.push_back(number);
676 }
677 return tokens;
678}

◆ triclinicMinImage()

std::array< double, 3 > gen::triclinicMinImage ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
double xi,
double yi,
double zi,
double xj,
double yj,
double zj )
inline

Definition at line 298 of file generic.hpp.

300 {
301 const FracBox b = makeFracBox(yCloud);
302 if (b.ok && b.triclinic) {
303 const auto dr = fracDelta(b, xi, yi, zi, xj, yj, zj);
304 const double r2 = dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2];
305 if (smithInside(b, r2)) {
306 return dr;
307 }
308#ifdef SEAMS_HAS_MINIMAGE
309 double ed[3] = {0.0, 0.0, 0.0};
310 if (euclideanDelta(yCloud, xi, yi, zi, xj, yj, zj, ed)) {
311 return {ed[0], ed[1], ed[2]};
312 }
313#endif
314 return dr;
315 }
316 const auto &box = yCloud.box;
317 const auto &boxLow = yCloud.boxLow;
318 const double xspan = box[0];
319 const double yspan = box[1];
320 const double zspan = box[2];
321 const double xlo_b = boxLow.size() > 0 ? boxLow[0] : 0.0;
322 const double ylo_b = boxLow.size() > 1 ? boxLow[1] : 0.0;
323 const double zlo_b = boxLow.size() > 2 ? boxLow[2] : 0.0;
324 const double xy = box[3];
325 const double xz = box[4];
326 const double yz = box[5];
327 const double xmin = std::min(std::min(0.0, xy), std::min(xz, xy + xz));
328 const double xmax = std::max(std::max(0.0, xy), std::max(xz, xy + xz));
329 const double ymin = std::min(0.0, yz);
330 const double ymax = std::max(0.0, yz);
331 const double lx = xspan - xmax + xmin;
332 const double ly = yspan - ymax + ymin;
333 const double lz = zspan;
334 const double ox = xlo_b - xmin;
335 const double oy = ylo_b - ymin;
336 const double oz = zlo_b;
337 const double sz_i = (zi - oz) / lz;
338 const double sy_i = (yi - oy - yz * sz_i) / ly;
339 const double sx_i = (xi - ox - xy * sy_i - xz * sz_i) / lx;
340 const double sz_j = (zj - oz) / lz;
341 const double sy_j = (yj - oy - yz * sz_j) / ly;
342 const double sx_j = (xj - ox - xy * sy_j - xz * sz_j) / lx;
343 double dsx = sx_i - sx_j;
344 double dsy = sy_i - sy_j;
345 double dsz = sz_i - sz_j;
346 dsx -= std::round(dsx);
347 dsy -= std::round(dsy);
348 dsz -= std::round(dsz);
349 return {lx * dsx + xy * dsy + xz * dsz, ly * dsy + yz * dsz, lz * dsz};
350}

◆ unwrappedCoordShift()

int gen::unwrappedCoordShift ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatomIndex,
int jatomIndex,
double * x_i,
double * y_i,
double * z_i,
double * x_j,
double * y_j,
double * z_j )
nodiscard

Shift particles (unwrapped coordinates).

◆ unWrappedDistFromPoint()

double gen::unWrappedDistFromPoint ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int iatom,
const std::vector< double > & singlePoint )
inline

Definition at line 555 of file generic.hpp.

557 {
558 const auto dr =
559 relDistFromPoint(yCloud, iatom, singlePoint[0], singlePoint[1],
560 singlePoint[2]);
561 return std::sqrt(dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2]);
562}

◆ writeDumpBoxBounds()

void gen::writeDumpBoxBounds ( std::ostream & os,
const molSys::PointCloud< molSys::Point< double >, double > & yCloud )
inline

Definition at line 477 of file generic.hpp.

479 {
480 const bool tilt = yCloud.box.size() >= 6;
481 if (tilt) {
482 os << "ITEM: BOX BOUNDS xy xz yz pp pp pp\n";
483 } else {
484 os << "ITEM: BOX BOUNDS pp pp pp\n";
485 }
486 for (int k = 0; k < 3; k++) {
487 const double lo = (static_cast<std::size_t>(k) < yCloud.boxLow.size())
488 ? yCloud.boxLow[k]
489 : 0.0;
490 const double len = (static_cast<std::size_t>(k) < yCloud.box.size())
491 ? yCloud.box[k]
492 : 0.0;
493 os << lo << ' ' << lo + len;
494 if (tilt) {
495 os << ' ' << yCloud.box[static_cast<std::size_t>(k + 3)];
496 }
497 os << '\n';
498 }
499}

Variable Documentation

◆ halfMin

double gen::FracBox::halfMin = 0.0

Definition at line 148 of file generic.hpp.

◆ lx

double gen::FracBox::lx = 0.0

Definition at line 136 of file generic.hpp.

◆ ly

double gen::FracBox::ly = 0.0

Definition at line 137 of file generic.hpp.

◆ lz

double gen::FracBox::lz = 0.0

Definition at line 138 of file generic.hpp.

◆ ok

bool gen::FracBox::ok = false

Definition at line 150 of file generic.hpp.

◆ ox

double gen::FracBox::ox = 0.0

Definition at line 142 of file generic.hpp.

◆ oy

double gen::FracBox::oy = 0.0

Definition at line 143 of file generic.hpp.

◆ oz

double gen::FracBox::oz = 0.0

Definition at line 144 of file generic.hpp.

◆ pi

double gen::pi = std::numbers::pi
constexpr

Uses Boost to get the value of pi.

Definition at line 64 of file generic.hpp.

◆ triclinic

bool gen::FracBox::triclinic = false

Definition at line 149 of file generic.hpp.

◆ wx

double gen::FracBox::wx = 0.0

Definition at line 145 of file generic.hpp.

◆ wy

double gen::FracBox::wy = 0.0

Definition at line 146 of file generic.hpp.

◆ wz

double gen::FracBox::wz = 0.0

Definition at line 147 of file generic.hpp.

◆ xy

double gen::FracBox::xy = 0.0

Definition at line 139 of file generic.hpp.

◆ xz

double gen::FracBox::xz = 0.0

Definition at line 140 of file generic.hpp.

◆ yz

double gen::FracBox::yz = 0.0

Definition at line 141 of file generic.hpp.