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

Functions

long cnaEpiCenter (const Matter *matter, double neighborCutoff)
long minCoordinatedEpiCenter (const Matter *matter, double neighborCutoff)
long lastAtom (const Matter *matter)
long randomFreeAtomEpiCenter (const Matter *matter)
long listedAtomEpiCenter (const Matter *matter, const std::vector< long > &atomList)
void cna (long *cna, const Matter *matter, double neighborCutoff)
void coordination (long *coordinationVal, const Matter *matter, double neighborCutoff)
void coordinationLessOrEqual (bool *result, long coordinationMaxVal, const Matter *matter, double neighborCutoff)
long minCoordination (const Matter *matter, double neighborCutoff)

Variables

const char DISP_LOAD [] = "load"
const char DISP_NOT_FCC_OR_HCP [] = "not_fcc_hcp_coordinated"
const char DISP_MIN_COORDINATED [] = "least_coordinated"
const char DISP_LAST_ATOM [] = "last_atom"
const char DISP_RANDOM [] = "random"
const char DISP_LISTED_ATOMS [] = "listed_atoms"

Function Documentation

◆ cna()

void eonc::EpiCenters::cna ( long * cna,
const Matter * matter,
double neighborCutoff )

Definition at line 114 of file EpiCenters.cpp.

115 {
116 long nAtoms = matter->numberOfAtoms();
117 std::vector<int> nFCC(nAtoms, 0);
118 std::vector<int> nHCP(nAtoms, 0);
119 std::vector<std::vector<int>> neighborLists(nAtoms);
120
121 for (long i = 0; i < nAtoms - 1; i++) {
122 for (long j = i + 1; j < nAtoms; j++) {
123 double diffR = matter->distance(i, j);
124 if (diffR < neighborCutoff) {
125 neighborLists[i].push_back(static_cast<int>(j));
126 neighborLists[j].push_back(static_cast<int>(i));
127 }
128 }
129 }
130
131 for (long a2 = 0; a2 < nAtoms; a2++) {
132 const auto &nbs2 = neighborLists[a2];
133 for (size_t n2 = 0; n2 < nbs2.size(); n2++) {
134 int a1 = nbs2[n2];
135 if (a1 < a2) {
136 std::vector<int> common;
137 const auto &nbs1 = neighborLists[a1];
138 for (size_t n1 = 0; n1 < nbs1.size(); n1++) {
139 int a3 = nbs1[n1];
140 for (size_t m2 = 0; m2 < nbs2.size(); m2++) {
141 if (a3 == nbs2[m2])
142 common.push_back(a3);
143 }
144 }
145 if (common.size() == 4) {
146 int nBonds = 0;
147 int bondsSum = 0;
148 for (int j2 = 1; j2 < 4; j2++) {
149 const auto &nbs = neighborLists[common[j2]];
150 for (int j1 = 0; j1 < j2; j1++) {
151 for (size_t n = 0; n < nbs.size(); n++) {
152 if (common[j1] == nbs[n]) {
153 nBonds++;
154 bondsSum += j1 + j2;
155 break;
156 }
157 }
158 }
159 }
160 if (nBonds == 2) {
161 if (bondsSum == 6) {
162 nFCC[a1]++;
163 nFCC[a2]++;
164 } else {
165 nHCP[a1]++;
166 nHCP[a2]++;
167 }
168 }
169 }
170 }
171 }
172 }
173 // 0: fcc (421), 1: hcp (422), 2: other
174 for (long i = 0; i < nAtoms; i++) {
175 if (neighborLists[i].size() == 12) {
176 if (nFCC[i] == 12)
177 cna[i] = 0;
178 else if (nFCC[i] == 6 && nHCP[i] == 6)
179 cna[i] = 1;
180 else
181 cna[i] = 2;
182 } else {
183 cna[i] = 2;
184 }
185 }
186}
double distance(long index1, long index2) const
Definition Matter.cpp:360
long int numberOfAtoms() const
Definition Matter.cpp:209
void cna(long *cna, const Matter *matter, double neighborCutoff)

◆ cnaEpiCenter()

long eonc::EpiCenters::cnaEpiCenter ( const Matter * matter,
double neighborCutoff )

Definition at line 22 of file EpiCenters.cpp.

23 {
24 long nAtoms = matter->numberOfAtoms();
25 std::vector<long> cnaList(nAtoms);
26 long indexEpiCenter = -2;
27
28 cna(cnaList.data(), matter, neighborCutoff);
29
30 // Count atoms that are not FCC or HCP and are free to move
31 long count = 0;
32 for (long i = 0; i < nAtoms; i++) {
33 if (cnaList[i] == 2 && !matter->getFixed(i))
34 count++;
35 }
36 // Pick a random atom being both free and not FCC or HCP coordinated
37 long pick = static_cast<long>(randomDouble(count)) + 1;
38 for (long i = 0; i < nAtoms; i++) {
39 if (cnaList[i] == 2 && !matter->getFixed(i)) {
40 pick--;
41 if (!pick) {
42 indexEpiCenter = i;
43 break;
44 }
45 }
46 }
47
48 assert(indexEpiCenter > -1 && indexEpiCenter < nAtoms);
49 return indexEpiCenter;
50}
int getFixed(long int atom) const
1 if every Cartesian axis of the atom is fixed, else 0.
Definition Matter.cpp:402
double randomDouble()

◆ coordination()

void eonc::EpiCenters::coordination ( long * coordinationVal,
const Matter * matter,
double neighborCutoff )

Definition at line 188 of file EpiCenters.cpp.

189 {
190 long nAtoms = matter->numberOfAtoms();
191 for (long i = 0; i < nAtoms; i++)
192 coordinationVal[i] = 0;
193
194 for (long i = 0; i < nAtoms - 1; i++) {
195 for (long j = i + 1; j < nAtoms; j++) {
196 double diffR = matter->distance(i, j);
197 if (diffR < neighborCutoff) {
198 coordinationVal[i]++;
199 coordinationVal[j]++;
200 }
201 }
202 }
203}

◆ coordinationLessOrEqual()

void eonc::EpiCenters::coordinationLessOrEqual ( bool * result,
long coordinationMaxVal,
const Matter * matter,
double neighborCutoff )

Definition at line 205 of file EpiCenters.cpp.

208 {
209 long nAtoms = matter->numberOfAtoms();
210 std::vector<long> coordinationVal(nAtoms);
211
212 coordination(coordinationVal.data(), matter, neighborCutoff);
213
214 for (long i = 0; i < nAtoms; i++) {
215 result[i] =
216 (coordinationVal[i] <= coordinationMaxVal) && !matter->getFixed(i);
217 }
218}
void coordination(long *coordinationVal, const Matter *matter, double neighborCutoff)

◆ lastAtom()

long eonc::EpiCenters::lastAtom ( const Matter * matter)

Definition at line 86 of file EpiCenters.cpp.

86 {
87 long nAtoms = matter->numberOfAtoms();
88 long indexEpiCenter = nAtoms - 1;
89 assert(indexEpiCenter > -1 && indexEpiCenter < nAtoms);
90 return indexEpiCenter;
91}

◆ listedAtomEpiCenter()

long eonc::EpiCenters::listedAtomEpiCenter ( const Matter * matter,
const std::vector< long > & atomList )

Definition at line 220 of file EpiCenters.cpp.

221 {
222 long nAtoms = matter->numberOfAtoms();
223 // Filter to only free atoms from the provided list
224 std::vector<long> freeAtoms;
225 for (long idx : atomList) {
226 if (idx >= 0 && idx < nAtoms && !matter->getFixed(idx)) {
227 freeAtoms.push_back(idx);
228 }
229 }
230 assert(!freeAtoms.empty());
231 long pick =
232 static_cast<long>(randomDouble(static_cast<long>(freeAtoms.size() - 1)));
233 return freeAtoms[pick];
234}

◆ minCoordinatedEpiCenter()

long eonc::EpiCenters::minCoordinatedEpiCenter ( const Matter * matter,
double neighborCutoff )

Definition at line 52 of file EpiCenters.cpp.

53 {
54 long nAtoms = matter->numberOfAtoms();
55 // Can't use vector<bool> (.data() is deleted), use unique_ptr<bool[]>
56 auto minCoordinatedList = std::make_unique<bool[]>(nAtoms);
57 long indexEpiCenter = -2;
58
59 long minCoordinationVal = minCoordination(matter, neighborCutoff);
60 coordinationLessOrEqual(minCoordinatedList.get(), minCoordinationVal, matter,
61 neighborCutoff);
62
63 // Count all atoms that are minimally coordinated and free to move
64 long count = 0;
65 for (long i = 0; i < nAtoms; i++) {
66 if (minCoordinatedList[i] && !matter->getFixed(i))
67 count++;
68 }
69 // Pick a random atom that is free and minimally coordinated
70 long pick = static_cast<long>(randomDouble(count));
71 for (long i = 0; i < nAtoms; i++) {
72 if (minCoordinatedList[i] && !matter->getFixed(i)) {
73 if (!pick) {
74 indexEpiCenter = i;
75 break;
76 } else {
77 pick--;
78 }
79 }
80 }
81
82 assert(indexEpiCenter > -1 && indexEpiCenter < nAtoms);
83 return indexEpiCenter;
84}
long minCoordination(const Matter *matter, double neighborCutoff)
void coordinationLessOrEqual(bool *result, long coordinationMaxVal, const Matter *matter, double neighborCutoff)

◆ minCoordination()

long eonc::EpiCenters::minCoordination ( const Matter * matter,
double neighborCutoff )

Definition at line 236 of file EpiCenters.cpp.

237 {
238 long nAtoms = matter->numberOfAtoms();
239 std::vector<long> coordinationVal(nAtoms);
240
241 coordination(coordinationVal.data(), matter, neighborCutoff);
242
243 long minVal = LONG_MAX;
244 for (long i = 0; i < nAtoms; i++) {
245 if (coordinationVal[i] < minVal && !matter->getFixed(i)) {
246 minVal = coordinationVal[i];
247 }
248 }
249 return minVal;
250}

◆ randomFreeAtomEpiCenter()

long eonc::EpiCenters::randomFreeAtomEpiCenter ( const Matter * matter)

Definition at line 93 of file EpiCenters.cpp.

93 {
94 long nAtoms = matter->numberOfAtoms();
95 long indexEpiCenter = -2;
96
97 long freeCount = matter->numberOfFreeAtoms() - 1;
98 long pick = static_cast<long>(randomDouble(freeCount));
99
100 for (long i = 0; i < nAtoms; i++) {
101 if (!matter->getFixed(i)) {
102 if (!pick) {
103 indexEpiCenter = i;
104 break;
105 } else {
106 pick--;
107 }
108 }
109 }
110 assert(indexEpiCenter > -1 && indexEpiCenter < nAtoms);
111 return indexEpiCenter;
112}
long int numberOfFreeAtoms() const
Definition Matter.cpp:475

Variable Documentation

◆ DISP_LAST_ATOM

const char eonc::EpiCenters::DISP_LAST_ATOM[] = "last_atom"

Definition at line 23 of file EpiCenters.h.

◆ DISP_LISTED_ATOMS

const char eonc::EpiCenters::DISP_LISTED_ATOMS[] = "listed_atoms"

Definition at line 25 of file EpiCenters.h.

◆ DISP_LOAD

const char eonc::EpiCenters::DISP_LOAD[] = "load"

Definition at line 20 of file EpiCenters.h.

◆ DISP_MIN_COORDINATED

const char eonc::EpiCenters::DISP_MIN_COORDINATED[] = "least_coordinated"

Definition at line 22 of file EpiCenters.h.

◆ DISP_NOT_FCC_OR_HCP

const char eonc::EpiCenters::DISP_NOT_FCC_OR_HCP[] = "not_fcc_hcp_coordinated"

Definition at line 21 of file EpiCenters.h.

◆ DISP_RANDOM

const char eonc::EpiCenters::DISP_RANDOM[] = "random"

Definition at line 24 of file EpiCenters.h.