seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
topo_bulk.hpp
Go to the documentation of this file.
1//-----------------------------------------------------------------------------------
2// d-SEAMS - Deferred Structural Elucidation Analysis for Molecular Simulations
3//
4// Copyright (c) 2018--present d-SEAMS core team
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the MIT License as published by
8// the Open Source Initiative.
9//
10// A copy of the MIT License is included in the LICENSE file of this repository.
11// You should have received a copy of the MIT License along with this program.
12// If not, see <https://opensource.org/licenses/MIT>.
13//-----------------------------------------------------------------------------------
14
15#ifndef SEAMS_TOPO_BULK_H_
16#define SEAMS_TOPO_BULK_H_
17
18#include <algorithm>
19#include <array>
20#include <cstdint>
21#include <fstream>
22#include <iostream>
23#include <iterator>
24#include <cmath>
25#include <memory>
26#include <sstream>
27#include <string>
28#include <vector>
29
30#include <cage.hpp>
31#include <mol_sys.hpp>
32#include <order_parameter.hpp>
33#include <ring.hpp>
34#include <seams_input.hpp>
35#include <seams_output.hpp>
36#include <shapeMatch.hpp>
37
42
47
48namespace ring {
49
52[[nodiscard]] int bulkPolygonRingAnalysis(
53 std::string path, const std::vector<std::vector<int>> &rings,
54 const std::vector<std::vector<int>> &nList,
55 molSys::PointCloud<molSys::Point<double>, double> &yCloud, int maxDepth,
56 int firstFrame);
57
58// DDC HC Ring functions
59
63[[nodiscard]] int topoBulkAnalysis(std::string path, const std::vector<std::vector<int>> &rings,
64 const std::vector<std::vector<int>> &nList,
66 int firstFrame, bool onlyTetrahedral = true);
67
83 std::vector<std::vector<int>> ringsContainingAtom;
86 std::vector<int> ringOff;
87 std::vector<int> ringCol;
89 [[nodiscard]] int atomCount() const {
90 return ringOff.empty() ? 0 : static_cast<int>(ringOff.size()) - 1;
91 }
92 std::vector<int> atomRank;
94 std::vector<std::array<int, 3>> ringShift;
95};
96
100[[nodiscard]] RingSearchIndex
101buildRingSearchIndex(const std::vector<std::vector<int>> &rings, int numAtoms,
102 bool withRows = true);
103
106 const std::vector<std::vector<int>> &rings,
107 const molSys::PointCloud<molSys::Point<double>, double> &yCloud);
108
112[[nodiscard]] std::vector<int>
114
119[[nodiscard]] std::vector<std::vector<int>> contractibleRings(
120 const std::vector<std::vector<int>> &rings,
121 const molSys::PointCloud<molSys::Point<double>, double> &yCloud);
122
124[[nodiscard]] std::vector<std::vector<int>> contractibleRings(
125 std::vector<std::vector<int>> &&rings,
126 const molSys::PointCloud<molSys::Point<double>, double> &yCloud);
127
133[[nodiscard]] std::vector<std::vector<int>> cageRings(
134 const std::vector<std::vector<int>> &rings,
135 const molSys::PointCloud<molSys::Point<double>, double> &yCloud,
136 double cutoff);
137
140std::vector<int> findDDC(const std::vector<std::vector<int>> &rings,
141 std::vector<strucType> &ringType,
142 const std::vector<int> &listHC,
143 std::vector<cage::Cage> &cageList);
144
153 int cages = 0;
154 int upper = -1;
155 int matching = 0;
156 int cover = 0;
157 int isolates = 0;
158 int vertices = 0;
159 int edges = 0;
160 int components = 0;
161 int dropped = 0;
162 int method = 0;
163 bool tight = false;
164 double milliseconds = 0;
165};
166
171int equatorChoiceOverflow(const struct EquatorChoice *self, int at);
172void equatorChoiceOverflowPut(struct EquatorChoice *self, int at, int value);
173
175 int ring[6]{};
176 int n = 0;
177
178 [[nodiscard]] int idAt(int k) const {
179 return k < 6 ? ring[k] : equatorChoiceOverflow(this, k - 6);
180 }
181
182 void put(int k, int value) {
183 if (k < 6) {
184 ring[k] = value;
185 return;
186 }
187 equatorChoiceOverflowPut(this, k - 6, value);
188 }
189};
190
192
196[[nodiscard]] std::vector<int>
197maximumEquators(const std::vector<EquatorChoice> &periph,
198 const std::vector<int> &order, PackingCertificate *certificate);
199
202std::vector<int> findDDC(const std::vector<std::vector<int>> &rings,
203 std::vector<strucType> &ringType,
204 const std::vector<int> &listHC,
205 std::vector<cage::Cage> &cageList,
206 const RingSearchIndex &index,
207 PackingCertificate *certificate = nullptr);
208
212std::vector<int> findMixedRings(const std::vector<std::vector<int>> &rings,
213 std::vector<strucType> &ringType,
214 std::vector<int> &listDDC,
215 std::vector<int> &listHC);
216
219std::vector<int> findHC(const std::vector<std::vector<int>> &rings,
220 std::vector<strucType> &ringType,
221 const std::vector<std::vector<int>> &nList,
222 std::vector<cage::Cage> &cageList);
223
225std::vector<int> findHC(const std::vector<std::vector<int>> &rings,
226 std::vector<strucType> &ringType,
227 const std::vector<std::vector<int>> &nList,
228 std::vector<cage::Cage> &cageList,
229 const RingSearchIndex &index);
230
233bool conditionOneDDC(const std::vector<std::vector<int>> &rings,
234 std::vector<int> &peripheralRings, int iring);
235
237bool conditionOneDDC(const std::vector<std::vector<int>> &rings,
238 std::vector<int> &peripheralRings, int iring,
239 const RingSearchIndex &index);
240
249bool equatorialConditions(const std::vector<std::vector<int>> &rings,
250 int iring, const RingSearchIndex &index,
251 std::vector<int> *peripheralUnion,
252 std::vector<int> *chosen = nullptr,
253 const std::vector<int> *rank = nullptr,
254 EquatorChoice *raw = nullptr);
255
258public:
259 void build(const std::vector<std::vector<int>> &nList);
260
261 // Row i, sorted and unique. Empty when i is outside the cloud.
262 void row(int i, const int *&begin, const int *&end) const {
263 if (static_cast<unsigned>(i) >= static_cast<unsigned>(n_) || off_.empty()) {
264 begin = nullptr;
265 end = nullptr;
266 return;
267 }
268 begin = cols_.data() + off_[static_cast<std::size_t>(i)];
269 end = cols_.data() + off_[static_cast<std::size_t>(i + 1)];
270 }
271
272 [[nodiscard]] bool operator()(int i, int j) const {
273 const int *begin = nullptr;
274 const int *end = nullptr;
275 row(i, begin, end);
276 if (begin == nullptr) {
277 return false;
278 }
279 return std::binary_search(begin, end, j);
280 }
281
282private:
283 int n_ = 0;
284 // Row i is cols_[off_[i] .. off_[i + 1]], sorted and unique.
285 std::vector<int> off_;
286 std::vector<int> cols_;
287};
288
293bool basalConditions(const std::vector<std::vector<int>> &nList,
294 const std::vector<int> &basal1,
295 const std::vector<int> &basal2);
296
298bool basalConditions(const NeighBond &bonds, const std::vector<int> &basal1,
299 const std::vector<int> &basal2);
300
303bool basalNeighbours(const std::vector<std::vector<int>> &nList,
304 std::vector<int> &triplet, int atomOne, int atomTwo);
305
308bool notNeighboursOfRing(const std::vector<std::vector<int>> &nList,
309 std::vector<int> &triplet,
310 const std::vector<int> &ring);
311
313[[nodiscard]] int findPrismatic(const std::vector<std::vector<int>> &rings, std::vector<int> &listHC,
314 std::vector<strucType> &ringType, int iring, int jring,
315 std::vector<int> &prismaticRings);
316
318[[nodiscard]] int findPrismatic(const std::vector<std::vector<int>> &rings,
319 std::vector<int> &listHC,
320 std::vector<strucType> &ringType, int iring,
321 int jring, std::vector<int> &prismaticRings,
322 const RingSearchIndex &index);
323
326[[nodiscard]] int getAtomTypesTopoBulk(const std::vector<std::vector<int>> &rings,
327 const std::vector<ring::strucType> &ringType,
328 std::vector<cage::iceType> &atomTypes);
329
331[[nodiscard]] int getStrucNumbers(const std::vector<ring::strucType> &ringType,
332 const std::vector<cage::Cage> &cageList, int &numHC, int &numDDC,
333 int &mixedRings, int &prismaticRings, int &basalRings);
334
335struct DdcSplit {
336 double order_ms = 0;
337 double equator_ms = 0;
338 double pack_ms = 0;
339 double conf_ms = 0;
340 double split_ms = 0;
341 double clique_ms = 0;
342 double match_ms = 0;
343 double search_ms = 0;
344 double write_ms = 0;
345};
346
347struct PackParts {
348 double conf_ms = 0;
349 double split_ms = 0;
350 double clique_ms = 0;
351 double match_ms = 0;
352 double search_ms = 0;
353};
354
356[[nodiscard]] PackParts lastPackParts();
357
359[[nodiscard]] DdcSplit lastDdcSplit();
360
361} // namespace ring
363
368
369namespace prism3 {
370
372[[nodiscard]] int findBulkPrisms(const std::vector<std::vector<int>> &rings,
373 std::vector<ring::strucType> &ringType,
374 const std::vector<std::vector<int>> &nList,
376 std::vector<double> &rmsdPerAtom, double heightCutoff = 8);
377
380bool basalPrismConditions(const std::vector<std::vector<int>> &nList,
381 std::vector<int> &basal1, std::vector<int> &basal2);
382
385bool relaxedPrismConditions(const std::vector<std::vector<int>> &nList,
386 std::vector<int> &basal1, std::vector<int> &basal2);
387
391 const std::vector<int> &basal1, const std::vector<int> &basal2, double heightCutoff = 8);
392} // namespace prism3
393
394
395#endif // SEAMS_TOPO_BULK_H_
File for cage types for topological network criteria.
Membership of the neighbour rows after the leading self entry.
void row(int i, const int *&begin, const int *&end) const
void build(const std::vector< std::vector< int > > &nList)
bool operator()(int i, int j) const
The main molecular system handler.
int findBulkPrisms(const std::vector< std::vector< int > > &rings, std::vector< ring::strucType > &ringType, const std::vector< std::vector< int > > &nList, molSys::PointCloud< molSys::Point< double >, double > &yCloud, std::vector< double > &rmsdPerAtom, double heightCutoff=8)
Find out which rings are prisms.
bool basalPrismConditions(const std::vector< std::vector< int > > &nList, std::vector< int > &basal1, std::vector< int > &basal2)
bool relaxedPrismConditions(const std::vector< std::vector< int > > &nList, std::vector< int > &basal1, std::vector< int > &basal2)
bool basalRingsSeparation(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &basal1, const std::vector< int > &basal2, double heightCutoff=8)
Check to see that candidate basal prisms are not really far from each other.
Topological network criteria functions.
bool equatorialConditions(const std::vector< std::vector< int > > &rings, int iring, const RingSearchIndex &index, std::vector< int > *peripheralUnion, std::vector< int > *chosen=nullptr, const std::vector< int > *rank=nullptr, EquatorChoice *raw=nullptr)
bool basalConditions(const std::vector< std::vector< int > > &nList, const std::vector< int > &basal1, const std::vector< int > &basal2)
std::vector< std::vector< int > > contractibleRings(const std::vector< std::vector< int > > &rings, const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
bool basalNeighbours(const std::vector< std::vector< int > > &nList, std::vector< int > &triplet, int atomOne, int atomTwo)
int getAtomTypesTopoBulk(const std::vector< std::vector< int > > &rings, const std::vector< ring::strucType > &ringType, std::vector< cage::iceType > &atomTypes)
int bulkPolygonRingAnalysis(std::string path, const std::vector< std::vector< int > > &rings, const std::vector< std::vector< int > > &nList, molSys::PointCloud< molSys::Point< double >, double > &yCloud, int maxDepth, int firstFrame)
std::vector< int > findDDC(const std::vector< std::vector< int > > &rings, std::vector< strucType > &ringType, const std::vector< int > &listHC, std::vector< cage::Cage > &cageList)
std::vector< int > positionRank(const molSys::PointCloud< molSys::Point< double >, double > &yCloud)
int findPrismatic(const std::vector< std::vector< int > > &rings, std::vector< int > &listHC, std::vector< strucType > &ringType, int iring, int jring, std::vector< int > &prismaticRings)
Finds the prismatic rings from basal rings iring and jring.
void releaseEquatorOverflow()
bool notNeighboursOfRing(const std::vector< std::vector< int > > &nList, std::vector< int > &triplet, const std::vector< int > &ring)
std::vector< int > findMixedRings(const std::vector< std::vector< int > > &rings, std::vector< strucType > &ringType, std::vector< int > &listDDC, std::vector< int > &listHC)
DdcSplit lastDdcSplit()
Order, equatorial test and packing from the last findDDC call.
bool conditionOneDDC(const std::vector< std::vector< int > > &rings, std::vector< int > &peripheralRings, int iring)
int equatorChoiceOverflow(const struct EquatorChoice *self, int at)
void equatorChoiceOverflowPut(struct EquatorChoice *self, int at, int value)
std::vector< std::vector< int > > cageRings(const std::vector< std::vector< int > > &rings, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff)
int getStrucNumbers(const std::vector< ring::strucType > &ringType, const std::vector< cage::Cage > &cageList, int &numHC, int &numDDC, int &mixedRings, int &prismaticRings, int &basalRings)
Determines the number of HCs, DDCs, Mixed rings, prismatic and basal rings.
RingSearchIndex buildRingSearchIndex(const std::vector< std::vector< int > > &rings, int numAtoms, bool withRows=true)
PackParts lastPackParts()
Conflict build, clique ids, matching and branch-and-bound from the last pack.
int topoBulkAnalysis(std::string path, const std::vector< std::vector< int > > &rings, const std::vector< std::vector< int > > &nList, molSys::PointCloud< molSys::Point< double >, double > &yCloud, int firstFrame, bool onlyTetrahedral=true)
std::vector< int > maximumEquators(const std::vector< EquatorChoice > &periph, const std::vector< int > &order, PackingCertificate *certificate)
std::vector< int > findHC(const std::vector< std::vector< int > > &rings, std::vector< strucType > &ringType, const std::vector< std::vector< int > > &nList, std::vector< cage::Cage > &cageList)
File containing common functions used by bulk and confined topological network critera.
File for functions that read in files).
This contains a collection of points; contains information for a particular frame.
Definition mol_sys.hpp:173
This contains per-particle information.
Definition mol_sys.hpp:152
int idAt(int k) const
void put(int k, int value)
Proof that the reported number of equatorial rings is maximum.
Inverted index from an atom to the rings that contain it.
Definition topo_bulk.hpp:82
std::vector< int > ringOff
Definition topo_bulk.hpp:86
int atomCount() const
Atoms the packed rows cover.
Definition topo_bulk.hpp:89
std::vector< std::array< int, 3 > > ringShift
Integer minimum-image winding of each ring. Empty if no box was supplied.
Definition topo_bulk.hpp:94
std::vector< int > atomRank
Definition topo_bulk.hpp:92
std::vector< std::vector< int > > ringsContainingAtom
Definition topo_bulk.hpp:83
std::vector< int > ringCol
Definition topo_bulk.hpp:87