seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
shell_hot.hpp
Go to the documentation of this file.
1#ifndef SEAMS_SHELL_HOT_H_
2#define SEAMS_SHELL_HOT_H_
3
4// Hot path of the ice classifier. No Eigen types: this header is safe to
5// compile with AVX2, which faults when it is mixed with Eigen's allocators.
6//
7// Copyright (c) d-SEAMS developers
8// SPDX-License-Identifier: MIT
9
10namespace symm {
11
12// One ideal shell, three templates. first[k][a] is the a-th tetrahedron
13// vertex of template k, relative to the center. arm[k][a] is the three
14// second-shell atoms on that bond, ordered by azimuth.
15struct CanonShell {
16 double first[3][4][3];
17 double second[3][12][3];
18 int parent[3][12];
19 int arm[3][4][3];
20 int nArm[3][4];
21 double pts[3][17][3];
22};
23
24// Seventeen oxygens: the center, the tetrahedron, and the twelve outer atoms.
25struct Shell17 {
26 double p[17][3];
27};
28
29// First-shell prefilter. It is not the crystal decision: that is the
30// second-shell fingerprint and the scale-free fit. On TIP4P/2005 at its
31// melting point a quench-majority crystal has tetrahedral-order 5th
32// percentile 0.87 and the liquid median is 0.80, so 0.85 lets the thermal
33// crystal reach the second shell and still sits above the liquid median.
34// 0.94 is the floor of a quenched mW crystal and cuts that thermal body.
35inline constexpr double kThermalQ = 0.85;
36// Ratio of the longest to the shortest of the four nearest bonds. The
37// same crystal's 95th percentile is 1.17.
38inline constexpr double kThermalBondRatio = 1.20;
39
40// xyz is n by 3, row major. lat rows are the cell edges. kind[i] is written
41// as ice Ih (0), ice Ic (1), ice Isd (2), or -1.
42// x, y, z are length n. Column-major coordinates, no interleaving copy.
43// openFace completes a short second shell on a bonded neighbour that has
44// fewer than four bonds. A full coordination shell is never padded. Off
45// by default, which keeps the labels the shell match gave before.
46void classifyPrepared(const double *x, const double *y, const double *z, int n,
47 const double lat[3][3], const CanonShell &canon, double gate, int *kind,
48 double thermalQ = kThermalQ, double bondRatio = kThermalBondRatio,
49 bool openFace = false);
50
51// Common-neighbour signatures of one atom's twelve second neighbours, given
52// relative to the atom: 1 for twelve (4,2,1), 0 for six (4,2,1) and six
53// (4,2,2), 3 or 4 for a mostly cubic or mostly hexagonal shell with eight
54// good signatures, -2 for at least `ambiguous` good ones, -1 otherwise.
55int diamondCna(const double *sx, const double *sy, const double *sz, int ambiguous,
56 int *n421 = nullptr, int *n422 = nullptr, int *nGood = nullptr);
57
58// True when the AVX2 build of shell_classify.cpp is linked in, the CPU
59// reports AVX2 and FMA, and seams::cpu::allowSimdKernels has not turned it
60// off. classifyPrepared and diamondCna call symm::avx2 only then, and
61// symm::generic otherwise.
63
64// The two builds of shell_classify.cpp. Call them through the functions
65// above; symm::avx2 exists only where avx2Kernels() can be true.
66namespace generic {
67void classifyPrepared(const double *x, const double *y, const double *z, int n,
68 const double lat[3][3], const CanonShell &canon, double gate, int *kind,
69 double thermalQ, double bondRatio, bool openFace);
70int diamondCna(const double *sx, const double *sy, const double *sz, int ambiguous, int *n421,
71 int *n422, int *nGood);
72} // namespace generic
73
74namespace avx2 {
75void classifyPrepared(const double *x, const double *y, const double *z, int n,
76 const double lat[3][3], const CanonShell &canon, double gate, int *kind,
77 double thermalQ, double bondRatio, bool openFace);
78int diamondCna(const double *sx, const double *sy, const double *sz, int ambiguous, int *n421,
79 int *n422, int *nGood);
80} // namespace avx2
81
82} // namespace symm
83
84#endif
int diamondCna(const double *sx, const double *sy, const double *sz, int ambiguous, int *n421, int *n422, int *nGood)
void classifyPrepared(const double *x, const double *y, const double *z, int n, const double lat[3][3], const CanonShell &canon, double gate, int *kind, double thermalQ, double bondRatio, bool openFace)
void classifyPrepared(const double *x, const double *y, const double *z, int n, const double lat[3][3], const CanonShell &canon, double gate, int *kind, double thermalQ, double bondRatio, bool openFace)
int diamondCna(const double *sx, const double *sy, const double *sz, int ambiguous, int *n421, int *n422, int *nGood)
constexpr double kThermalQ
Definition shell_hot.hpp:35
void classifyPrepared(const double *x, const double *y, const double *z, int n, const double lat[3][3], const CanonShell &canon, double gate, int *kind, double thermalQ=kThermalQ, double bondRatio=kThermalBondRatio, bool openFace=false)
constexpr double kThermalBondRatio
Definition shell_hot.hpp:38
bool avx2Kernels()
int diamondCna(const double *sx, const double *sy, const double *sz, int ambiguous, int *n421=nullptr, int *n422=nullptr, int *nGood=nullptr)
double pts[3][17][3]
Definition shell_hot.hpp:21
double first[3][4][3]
Definition shell_hot.hpp:16
int parent[3][12]
Definition shell_hot.hpp:18
int arm[3][4][3]
Definition shell_hot.hpp:19
double second[3][12][3]
Definition shell_hot.hpp:17
double p[17][3]
Definition shell_hot.hpp:26