seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
gen Namespace Reference

Small generic functions that are shared by all namespaces. More...

Namespaces

namespace  mic

Classes

struct  FracBox

Functions

double radDeg (double angle)
 Inline function for converting radians->degrees.
double 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 getAverageWithoutOutliers (std::vector< double > inpVec)
 Get the average, after excluding the outliers, using quartiles.
double calcMedian (std::vector< double > *input)
 Inline generic function for calculating the median given a vector of the values.
FracBox makeFracBox (const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
std::array< double, 3 > fracDelta (const FracBox &b, double xi, double yi, double zi, double xj, double yj, double zj)
double fracDistSq (const FracBox &b, double xi, double yi, double zi, double xj, double yj, double zj)
bool smithInside (const FracBox &b, double r2)
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)
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, whose indices (not IDs) have been given.
double periodicDistSq (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, int jatom)
double 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 batchPeriodicDistSq (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, const int *jatom, std::size_t n, double *distSq)
std::string formatDumpBox (const std::vector< double > &box)
void writeDumpBoxBounds (std::ostream &os, const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
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 another point, whose index has been given.
std::array< double, 3 > relDistFromPoint (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, double xj, double yj, double zj)
double unWrappedDistFromPoint (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int iatom, const std::vector< double > &singlePoint)
double 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 > 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.
std::array< double, 3 > unwrappedXYZ (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int origin, int atom)
bool 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 prettyPrintYoda (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, std::string outFile)
 Generic function for printing all the struct information.
int 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 angDistDegQuaternions (std::vector< double > quat1, std::vector< double > quat2)
std::vector< std::string > tokenizer (std::string line)
 Function for tokenizing line strings into words (strings) delimited by whitespace.
std::vector< double > tokenizerDouble (std::string line)
 Function for tokenizing line strings into a vector of doubles.
std::vector< int > tokenizerInt (std::string line)
 Function for tokenizing line strings into a vector of ints.
bool file_exists (const std::string &name)
 Function for checking if a file exists or not.
std::vector< std::complex< double > > 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\).
molSys::PointCloud< molSys::Point< double >, double > getPointCloudOneAtomType (molSys::PointCloud< molSys::Point< double >, double > &yCloud, molSys::PointCloud< molSys::Point< double >, double > &outCloud, int atomTypeI, bool isSlice=false, std::array< double, 3 > coordLow=std::array< double, 3 >{0, 0, 0}, std::array< double, 3 > coordHigh=std::array< double, 3 >{0, 0, 0})
void moleculesInSingleSlice (molSys::PointCloud< molSys::Point< double >, double > &yCloud, bool clearPreviousSliceSelection=true, std::array< double, 3 > coordLow=std::array< double, 3 >{0, 0, 0}, std::array< double, 3 > coordHigh=std::array< double, 3 >{0, 0, 0})
void atomsInSingleSlice (molSys::PointCloud< molSys::Point< double >, double > &yCloud, bool clearPreviousSliceSelection=true, std::array< double, 3 > coordLow=std::array< double, 3 >{0, 0, 0}, std::array< double, 3 > coordHigh=std::array< double, 3 >{0, 0, 0})
void setAtomsWithSameMolID (molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::unordered_multimap< int, int > &molIDAtomIDmap, int molID, bool inSliceValue=true)

Variables

constexpr double pi = std::numbers::pi
 Uses Boost to get the value of pi.

Detailed Description

Small generic functions that are shared by all namespaces.

These are general functions (eg. for finding the periodic distance) which are required by several namespaces.

Changelog

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

◆ atomsInSingleSlice()

void gen::atomsInSingleSlice ( molSys::PointCloud< molSys::Point< double >, double > & yCloud,
bool clearPreviousSliceSelection = true,
std::array< double, 3 > coordLow = std::array< double, 3 >{0, 0, 0},
std::array< double, 3 > coordHigh = std::array< double, 3 >{0, 0, 0} )

Given a pointCloud set the inSlice bool for every atom, if the atoms are inside the specified (single) region. Does not handle atoms in molecules straddling the boundary

◆ 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 720 of file generic.hpp.

720 {
721 if (neigh == 0) {
722 return v;
723 }
724 for (int m = 0; m < 2 * l + 1; m++) {
725 v[static_cast<std::size_t>(m)] = (1.0 / static_cast<double>(neigh)) * v[static_cast<std::size_t>(m)];
726 }
727
728 return v;
729}

◆ 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 435 of file generic.hpp.

437 {
438 const FracBox b = makeFracBox(yCloud);
439#ifdef SEAMS_HAS_MINIMAGE
440 if (n > 0 && b.ok && b.triclinic) {
441 mi_cell cell;
442 if (pointCloudCell(yCloud, &cell)) {
443 const auto &atom = yCloud.pts[static_cast<std::size_t>(iatom)];
444 const double p[3] = {atom.x, atom.y, atom.z};
445 std::vector<double> qs(n * 3);
446 for (std::size_t k = 0; k < n; ++k) {
447 const auto &pj = yCloud.pts[static_cast<std::size_t>(jatom[k])];
448 qs[3 * k] = pj.x;
449 qs[3 * k + 1] = pj.y;
450 qs[3 * k + 2] = pj.z;
451 }
452 if (mi_dist2_many(&cell, p, qs.data(), n, distSq) == 0) {
453 for (std::size_t k = 0; k < n; ++k) {
454 if (smithInside(b, distSq[k])) {
455 continue;
456 }
457 const double q[3] = {qs[3 * k], qs[3 * k + 1], qs[3 * k + 2]};
458 double ed[3] = {0.0, 0.0, 0.0};
459 if (mi_displacement_euclidean(&cell, q, p, ed) == 0) {
460 distSq[k] = ed[0] * ed[0] + ed[1] * ed[1] + ed[2] * ed[2];
461 }
462 }
463 return;
464 }
465 }
466 }
467#endif
468 for (std::size_t k = 0; k < n; k++) {
469 distSq[k] = periodicDistSq(b, yCloud, iatom, jatom[k]);
470 }
471}
FracBox makeFracBox(const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
Definition generic.hpp:156
bool smithInside(const FracBox &b, double r2)
Definition generic.hpp:243
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:365
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 89 of file generic.hpp.

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

◆ 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 643 of file generic.hpp.

644 {
645 return a.atomID < b.atomID;
646}

◆ 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 587 of file generic.hpp.

588 {
589 std::array<double, 3> dr;
590 double r2 = 0.0; // Squared absolute distance
591
592 // Get x1-x2 etc
593 dr[0] = fabs(yCloud.pts[static_cast<std::size_t>(iatom)].x - yCloud.pts[static_cast<std::size_t>(jatom)].x);
594 dr[1] = fabs(yCloud.pts[static_cast<std::size_t>(iatom)].y - yCloud.pts[static_cast<std::size_t>(jatom)].y);
595 dr[2] = fabs(yCloud.pts[static_cast<std::size_t>(iatom)].z - yCloud.pts[static_cast<std::size_t>(jatom)].z);
596
597 // Get the squared absolute distance
598 for (int k = 0; k < 3; k++) {
599 r2 += pow(dr[static_cast<std::size_t>(k)], 2.0);
600 }
601
602 return sqrt(r2);
603}

◆ 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 707 of file generic.hpp.

707 {
708 return std::filesystem::exists(name);
709}

◆ formatDumpBox()

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

Definition at line 474 of file generic.hpp.

474 {
475 std::ostringstream oss;
476 if (box.size() >= 3) {
477 oss << box[0] << ' ' << box[1] << ' ' << box[2];
478 }
479 if (box.size() >= 6) {
480 oss << " xy " << box[3] << " xz " << box[4] << " yz " << box[5];
481 }
482 return oss.str();
483}

◆ 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 205 of file generic.hpp.

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

◆ fracDistSq()

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

Definition at line 233 of file generic.hpp.

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

◆ getAverageWithoutOutliers()

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

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

◆ getPointCloudOneAtomType()

molSys::PointCloud< molSys::Point< double >, double > gen::getPointCloudOneAtomType ( molSys::PointCloud< molSys::Point< double >, double > & yCloud,
molSys::PointCloud< molSys::Point< double >, double > & outCloud,
int atomTypeI,
bool isSlice = false,
std::array< double, 3 > coordLow = std::array< double, 3 >{0, 0, 0},
std::array< double, 3 > coordHigh = std::array< double, 3 >{0, 0, 0} )

Given a pointCloud containing certain atom types, this returns a pointCloud containing atoms of only the desired type

◆ makeFracBox()

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

Definition at line 156 of file generic.hpp.

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

◆ moleculesInSingleSlice()

void gen::moleculesInSingleSlice ( molSys::PointCloud< molSys::Point< double >, double > & yCloud,
bool clearPreviousSliceSelection = true,
std::array< double, 3 > coordLow = std::array< double, 3 >{0, 0, 0},
std::array< double, 3 > coordHigh = std::array< double, 3 >{0, 0, 0} )

Given a pointCloud set the inSlice bool for every atom, if the molecules are inside the specified (single) region. If even one atom of a molecule is inside the region, then all atoms of that molecule will be inside the region (irrespective of type)

◆ 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 426 of file generic.hpp.

427 {
428 return std::sqrt(periodicDistSq(yCloud, iatom, jatom));
429}

◆ 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 365 of file generic.hpp.

367 {
368 const auto &atom = yCloud.pts[static_cast<std::size_t>(iatom)];
369 const auto &pj = yCloud.pts[static_cast<std::size_t>(jatom)];
370 if (b.ok) {
371 const auto wrapped = fracDelta(b, atom.x, atom.y, atom.z, pj.x, pj.y, pj.z);
372 const double r2 =
373 wrapped[0] * wrapped[0] + wrapped[1] * wrapped[1] + wrapped[2] * wrapped[2];
374 if (smithInside(b, r2)) {
375 return r2;
376 }
377#ifdef SEAMS_HAS_MINIMAGE
378 double ed[3] = {0.0, 0.0, 0.0};
379 if (euclideanDelta(yCloud, atom.x, atom.y, atom.z, pj.x, pj.y, pj.z, ed)) {
380 return ed[0] * ed[0] + ed[1] * ed[1] + ed[2] * ed[2];
381 }
382 return r2;
383#else
384 const std::array<double, 3> raw = {atom.x - pj.x, atom.y - pj.y, atom.z - pj.z};
385 const auto euc = mic::euclideanIfShorter(b.lx, b.ly, b.lz, b.xy, b.xz, b.yz,
386 raw, wrapped);
387 return euc[0] * euc[0] + euc[1] * euc[1] + euc[2] * euc[2];
388#endif
389 }
390 if (yCloud.box.size() >= 6) {
391 const auto dr =
392 triclinicMinImage(yCloud, atom.x, atom.y, atom.z, pj.x, pj.y, pj.z);
393 return dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2];
394 }
395 std::array<double, 3> dr;
396 double r2 = 0.0;
397 dr[0] = std::fabs(atom.x - pj.x);
398 dr[1] = std::fabs(atom.y - pj.y);
399 dr[2] = std::fabs(atom.z - pj.z);
400 for (int k = 0; k < 3; k++) {
401 dr[static_cast<std::size_t>(k)] -=
402 yCloud.box[static_cast<std::size_t>(k)] *
403 std::round(dr[static_cast<std::size_t>(k)] /
404 yCloud.box[static_cast<std::size_t>(k)]);
405 r2 += dr[static_cast<std::size_t>(k)] * dr[static_cast<std::size_t>(k)];
406 }
407 return r2;
408}
std::array< double, 3 > euclideanIfShorter(double lx, double ly, double lz, double xy, double xz, double yz, const std::array< double, 3 > &raw, const std::array< double, 3 > &wrapped)
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:300

◆ periodicDistSq() [2/2]

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

Definition at line 411 of file generic.hpp.

412 {
413 return periodicDistSq(makeFracBox(yCloud), yCloud, iatom, jatom);
414}

◆ 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 73 of file generic.hpp.

73{ return (angle * 180) / gen::pi; }
constexpr double pi
Uses Boost to get the value of pi.
Definition generic.hpp:66

◆ 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 617 of file generic.hpp.

618 {
619 return relDistFromPoint(yCloud, iatom, yCloud.pts[static_cast<std::size_t>(jatom)].x,
620 yCloud.pts[static_cast<std::size_t>(jatom)].y, yCloud.pts[static_cast<std::size_t>(jatom)].z);
621}
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:521

◆ 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 521 of file generic.hpp.

524 {
525 if (b.ok) {
526 const auto &atom = yCloud.pts[static_cast<std::size_t>(iatom)];
527 const auto dr = fracDelta(b, atom.x, atom.y, atom.z, xj, yj, zj);
528 const double r2 = dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2];
529 if (smithInside(b, r2)) {
530 return dr;
531 }
532#ifdef SEAMS_HAS_MINIMAGE
533 double ed[3] = {0.0, 0.0, 0.0};
534 if (euclideanDelta(yCloud, atom.x, atom.y, atom.z, xj, yj, zj, ed)) {
535 return {ed[0], ed[1], ed[2]};
536 }
537 return dr;
538#else
539 const std::array<double, 3> raw = {atom.x - xj, atom.y - yj, atom.z - zj};
540 return mic::euclideanIfShorter(b.lx, b.ly, b.lz, b.xy, b.xz, b.yz, raw, dr);
541#endif
542 }
543 if (yCloud.box.size() >= 6) {
544 return triclinicMinImage(yCloud, yCloud.pts[static_cast<std::size_t>(iatom)].x, yCloud.pts[static_cast<std::size_t>(iatom)].y,
545 yCloud.pts[static_cast<std::size_t>(iatom)].z, xj, yj, zj);
546 }
547
548 std::array<double, 3> dr = {yCloud.pts[static_cast<std::size_t>(iatom)].x - xj, yCloud.pts[static_cast<std::size_t>(iatom)].y - yj,
549 yCloud.pts[static_cast<std::size_t>(iatom)].z - zj};
550 for (int k = 0; k < 3; k++) {
551 if (dr[static_cast<std::size_t>(k)] < -yCloud.box[static_cast<std::size_t>(k)] * 0.5) {
552 dr[static_cast<std::size_t>(k)] += yCloud.box[static_cast<std::size_t>(k)];
553 }
554 if (dr[static_cast<std::size_t>(k)] >= yCloud.box[static_cast<std::size_t>(k)] * 0.5) {
555 dr[static_cast<std::size_t>(k)] -= yCloud.box[static_cast<std::size_t>(k)];
556 }
557 }
558 return dr;
559}

◆ 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 561 of file generic.hpp.

563 {
564 return relDistFromPoint(makeFracBox(yCloud), yCloud, iatom, xj, yj, zj);
565}

◆ setAtomsWithSameMolID()

void gen::setAtomsWithSameMolID ( molSys::PointCloud< molSys::Point< double >, double > & yCloud,
const std::unordered_multimap< int, int > & molIDAtomIDmap,
int molID,
bool inSliceValue = true )

Given a particular molecule ID and a pointCloud set the inSlice bool for all atoms, with that molecule ID

◆ smithInside()

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

Definition at line 243 of file generic.hpp.

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

◆ 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 668 of file generic.hpp.

668 {
669 std::istringstream iss(line);
670 std::vector<std::string> tokens{std::istream_iterator<std::string>{iss},
671 std::istream_iterator<std::string>{}};
672 return tokens;
673}

◆ 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 679 of file generic.hpp.

679 {
680 std::istringstream iss(line);
681 std::vector<double> tokens;
682 double number; // Each number being read in from the line
683 while (iss >> number) {
684 tokens.push_back(number);
685 }
686 return tokens;
687}

◆ 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 693 of file generic.hpp.

693 {
694 std::istringstream iss(line);
695 std::vector<int> tokens;
696 int number; // Each number being read in from the line
697 while (iss >> number) {
698 tokens.push_back(number);
699 }
700 return tokens;
701}

◆ 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 300 of file generic.hpp.

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

◆ 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 567 of file generic.hpp.

569 {
570 const auto dr =
571 relDistFromPoint(yCloud, iatom, singlePoint[0], singlePoint[1],
572 singlePoint[2]);
573 return std::sqrt(dr[0] * dr[0] + dr[1] * dr[1] + dr[2] * dr[2]);
574}

◆ unwrappedXYZ()

std::array< double, 3 > gen::unwrappedXYZ ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
int origin,
int atom )
inline

Definition at line 626 of file generic.hpp.

628 {
629 const auto dr = relDist(yCloud, origin, atom);
630 const auto &o = yCloud.pts[static_cast<std::size_t>(origin)];
631 return {o.x - dr[0], o.y - dr[1], o.z - dr[2]};
632}
std::array< double, 3 > 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 di...
Definition generic.hpp:617

◆ writeDumpBoxBounds()

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

Definition at line 486 of file generic.hpp.

488 {
489 const bool tilt = yCloud.box.size() >= 6;
490 if (tilt) {
491 os << "ITEM: BOX BOUNDS xy xz yz pp pp pp\n";
492 } else {
493 os << "ITEM: BOX BOUNDS pp pp pp\n";
494 }
495 for (int k = 0; k < 3; k++) {
496 const double lo = (static_cast<std::size_t>(k) < yCloud.boxLow.size())
497 ? yCloud.boxLow[static_cast<std::size_t>(k)]
498 : 0.0;
499 const double len = (static_cast<std::size_t>(k) < yCloud.box.size())
500 ? yCloud.box[static_cast<std::size_t>(k)]
501 : 0.0;
502 os << lo << ' ' << lo + len;
503 if (tilt) {
504 os << ' ' << yCloud.box[static_cast<std::size_t>(k + 3)];
505 }
506 os << '\n';
507 }
508}

Variable Documentation

◆ pi

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

Uses Boost to get the value of pi.

Definition at line 66 of file generic.hpp.