seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
bop.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_BOP_H_
16#define SEAMS_BOP_H_
17
18#include <array>
19#include <cmath>
20#include <complex>
21#include <string>
22#include <vector>
23
24#ifdef SEAMS_HAS_MPI
25#include <mpi.h>
26#endif
27#include <generic.hpp>
28#include <mol_sys.hpp>
29#include <neighbours.hpp>
30#include <seams_output.hpp>
31
35
40
136
137namespace chill {
138
139// 2*l+1 length complex vector
147struct YlmAtom {
148 std::vector<std::complex<double>> ylm;
149};
150
151// Vector of 2*l+1 averaged over 4 nearest neighbours
168struct QlmAtom {
169 std::vector<YlmAtom> ptq; // Averaged over neighbours
170};
171
186
193inline molSys::bond_type classifyBond(double cij, const BondClassifier &rule,
194 bool closed = true) {
195 const bool staggered = closed ? cij <= rule.staggeredMax : cij < rule.staggeredMax;
196 if (staggered) {
198 }
199 const bool eclipsed =
200 closed ? (cij >= rule.eclipsedMin && cij <= rule.eclipsedMax)
201 : (cij > rule.eclipsedMin && cij < rule.eclipsedMax);
202 if (eclipsed) {
204 }
206}
207
210[[nodiscard]] BondClassifier chillRule();
211
215
219[[nodiscard]] BondClassifier bondClassifier(const std::string &name);
220
223void registerBondClassifier(const std::string &name,
224 const BondClassifier &rule);
225
227[[nodiscard]] std::vector<std::string> bondClassifierNames();
228
233 const std::vector<std::vector<int>> &nList,
234 const BondClassifier &rule, bool isSlice = false);
235
240 const std::vector<std::vector<int>> &nList,
241 const BondClassifier &rule, bool isSlice, bool closed);
242
245 const std::vector<int> &offsets, const std::vector<int> &cols,
246 const BondClassifier &rule, bool isSlice = false);
247
253 const std::vector<int> &offsets, const std::vector<int> &cols,
254 bool keepBonds = true);
255
262 const std::vector<int> &offsets, const std::vector<int> &cols);
263
268 const std::vector<int> &offsets, const std::vector<int> &cols);
269
273struct BondOrder {
274 int keepMax = 0;
275 std::vector<double> q;
276 std::vector<double> norm;
277 std::vector<int> nkeep;
278 std::vector<int> chosen;
279 std::vector<std::vector<int>> rows;
280};
281
283 const std::vector<std::vector<int>> &nList, const BondClassifier &rule,
284 BondOrder &order, const std::vector<char> *which, bool fresh = true);
285
290 const BondOrder &order, const BondClassifier &rule, bool isSlice,
291 const std::vector<char> *which, bool closed = true);
292
293#ifdef SEAMS_HAS_MPI
299void distributedChillPlus(molSys::PointCloud<molSys::Point<double>, double> &full,
300 double cutoff, BondClassifier rule, bool neighbourTest,
301 MPI_Comm comm, bool closed = true);
302#endif
303
319void
321 const std::vector<std::vector<int>> &nList, bool isSlice = false,
322 int coordinationNumber = 4);
323
331void
333 const std::vector<std::vector<int>> &nList, bool isSlice = false);
334
335// Classifies each atom according to the CHILL algorithm
348void
350 const std::vector<std::vector<int>> &nList, std::string path,
351 int firstFrame, bool isSlice = false,
352 std::string outputFileName = "chill.txt");
353
358void
360 const std::vector<std::vector<int>> &nList, bool isSlice = false,
361 int coordinationNumber = 4);
362
364void
366 const std::vector<std::vector<int>> &nList, bool isSlice,
367 int coordinationNumber, bool closedBounds);
368
373 molSys::PointCloud<molSys::Point<double>, double> &yCloud, double cutoff,
374 int typeI);
375
382 molSys::PointCloud<molSys::Point<double>, double> &yCloud, double cutoff,
383 int typeI, std::vector<double> &q4, std::vector<double> &q6,
384 std::vector<double> &q4bar, std::vector<double> &q6bar);
385
395 molSys::PointCloud<molSys::Point<double>, double> &yCloud, double cutoff,
396 int typeI);
397
400void
402 const std::vector<std::vector<int>> &nList, std::string path,
403 int firstFrame, bool isSlice = false,
404 std::string outputFileName = "chillPlus.txt");
405
407void
409 const std::vector<std::vector<int>> &nList, std::string path,
410 int firstFrame, bool isSlice, std::string outputFileName,
411 bool neighbourTest);
412
415void
418 const std::vector<std::vector<int>> &nList, bool isSlice = false);
419
423void
426 const std::vector<std::vector<int>> &nList, bool isSlice,
427 bool neighbourTest);
428
434 const std::vector<int> &types);
435
438std::vector<double>
440 const std::vector<std::vector<int>> &nList, bool isSlice = false);
441
446void
448 std::vector<double> &q6);
449
451[[nodiscard]] int printIceType(molSys::PointCloud<molSys::Point<double>, double> &yCloud,
452 std::string path, int firstFrame, bool isSlice = false,
453 std::string outputFileName = "superChill.txt");
454
459 const std::vector<std::vector<int>> &nList, int iatom,
460 int num_staggrd, int num_eclipsd, bool chillPlus = false);
461
463[[nodiscard]] int numStaggered(molSys::PointCloud<molSys::Point<double>, double> &yCloud,
464 const std::vector<std::vector<int>> &nList, int jatom);
465
474 std::vector<double> ql;
475 std::vector<double> qlBar;
476 std::vector<double> wl;
477};
478
488[[nodiscard]] SteinhardtQl
490 const std::vector<std::vector<int>> &nList, int orderL);
491
500 const molSys::PointCloud<molSys::Point<double>, double> &yCloud,
501 double cutoff, int orderL, int typeI, bool average, bool invariants = false);
502
508 double list = 0.0;
509 double ql = 0.0;
510 bool set = false;
511};
513
518 const molSys::PointCloud<molSys::Point<double>, double> &yCloud, double cutoff,
519 int typeI, std::vector<double> &q4, std::vector<double> &q6);
520
525[[nodiscard]] bool steinhardtQ4Q6Cutoff(
526 const molSys::PointCloud<molSys::Point<double>, double> &yCloud,
527 double cutoff, int typeI, bool average, SteinhardtQl &q4, SteinhardtQl &q6);
528
534 const molSys::PointCloud<molSys::Point<double>, double> &yCloud, int k,
535 double candidateCutoff, int typeI, int orderL);
536
540void setSteinhardtAtomSplit(bool split);
541
544 double rebuildMs = 0;
545 double computeMs = 0;
546 double exchangeMs = 0;
547 double reduceMs = 0;
548};
549
552
554inline int steinhardtQlmWidth(int orderL) { return 2 * (2 * orderL + 1); }
555
558 const std::vector<std::vector<int>> &nList, int orderL,
559 std::vector<double> &qlm, const std::vector<char> *which);
560
563 const std::vector<std::vector<int>> &nList, int orderL,
564 const std::vector<double> &qlm, std::vector<double> &ql,
565 std::vector<double> &qlBar, const std::vector<char> *which);
566
567#ifdef SEAMS_HAS_MPI
570SteinhardtQl distributedSteinhardt(
571 const molSys::PointCloud<molSys::Point<double>, double> &full, double cutoff,
572 int orderL, MPI_Comm comm);
573#endif
574
575} // namespace chill
576
588namespace sph {
589
590// 7 is for Q3, orderL=3
591
592std::vector<std::complex<double>>
593spheriHarmo(int orderL, std::array<double, 2> radialCoord);
594
596void spheriHarmoInto(int orderL, std::array<double, 2> radialCoord,
597 std::vector<std::complex<double>> &out);
598
599std::array<double, 2> radialCoord(std::array<double, 3> cartCoord);
600
602std::vector<std::complex<double>>
603lookupTableQ3Vec(std::array<double, 2> angles);
604
606std::complex<double> lookupTableQ3(int m, std::array<double, 2> angles);
607
609std::vector<std::complex<double>>
610lookupTableQ4Vec(std::array<double, 2> angles);
611
613std::complex<double> lookupTableQ4(int m, std::array<double, 2> angles);
614
616std::vector<std::complex<double>>
617lookupTableQ6Vec(std::array<double, 2> angles);
618
620std::vector<std::complex<double>>
621lookupTableQ8Vec(std::array<double, 2> angles);
622
624std::complex<double> lookupTableQ8(int m, std::array<double, 2> angles);
625
627std::complex<double> lookupTableQ6(int m, std::array<double, 2> angles);
628
629} // namespace sph
630
632#endif // SEAMS_BOP_H_
File for containing generic or common functions.
The main molecular system handler.
CHILL and CHILL+ structure classification.
Definition bop.hpp:137
void getCorrelPlus(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, bool isSlice=false, int coordinationNumber=4)
void getIceTypePlusNoPrint(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, bool isSlice=false)
bool chillPlusSymbolicPrefilter(molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, int typeI)
bool q4q6ChillPlus(molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, int typeI, std::vector< double > &q4, std::vector< double > &q6, std::vector< double > &q4bar, std::vector< double > &q6bar)
int printIceType(molSys::PointCloud< molSys::Point< double >, double > &yCloud, std::string path, int firstFrame, bool isSlice=false, std::string outputFileName="superChill.txt")
Prints out the iceType for a particular frame onto the terminal.
BondClassifier chillRule()
QlCutoffStages & lastQlCutoffStages()
SteinhardtQl steinhardtQlCutoff(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, int orderL, int typeI, bool average, bool invariants=false)
bool steinhardtQ4Q6Cutoff(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, int typeI, bool average, SteinhardtQl &q4, SteinhardtQl &q6)
void getCorrel(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, bool isSlice=false, int coordinationNumber=4)
Function for getting the bond order correlations (or in some treatments) according to the CHILL alg...
bool localCutoffQ4Q6(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, int typeI, std::vector< double > &q4, std::vector< double > &q6)
AnalysisPhases lastSteinhardtPhases()
void writeSteinhardtQlm(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, int orderL, std::vector< double > &qlm, const std::vector< char > *which)
q_lm for atoms which selects. Other atoms are left zero.
int chillFromCsr(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &offsets, const std::vector< int > &cols)
std::vector< std::string > bondClassifierNames()
Names of every registered rule set.
void getIceTypeNoPrint(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, bool isSlice=false)
Function that classifies every particle's molSys::atom_state_type ice type, according to the CHILL al...
void classifyBonds(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, const BondClassifier &rule, bool isSlice=false)
int chillPlusFromCsr(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &offsets, const std::vector< int > &cols, bool keepBonds=true)
void clearIceTypesExcept(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &types)
void setSteinhardtAtomSplit(bool split)
void readSteinhardtQl(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, int orderL, const std::vector< double > &qlm, std::vector< double > &ql, std::vector< double > &qlBar, const std::vector< char > *which)
ql and qlBar for atoms which selects, reading q_lm of their neighbours.
void getIceType(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, std::string path, int firstFrame, bool isSlice=false, std::string outputFileName="chill.txt")
Function that classifies every particle's molSys::atom_state_type ice type, according to the CHILL al...
bool isInterfacial(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, int iatom, int num_staggrd, int num_eclipsd, bool chillPlus=false)
AnalysisPhases lastChillPhases()
std::vector< double > getq6(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, bool isSlice=false)
int chillPlusOvitoFromCsr(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &offsets, const std::vector< int > &cols)
bool chillPlusPublishedCutoff(molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, int typeI)
void reclassifyWater(molSys::PointCloud< molSys::Point< double >, double > &yCloud, std::vector< double > &q6)
void bondOrder(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, const BondClassifier &rule, BondOrder &order, const std::vector< char > *which, bool fresh=true)
int numStaggered(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, int jatom)
Finds the number of staggered bonds for a given atom of index jatom.
SteinhardtQl steinhardtQlMutual(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, int typeI, int orderL)
BondClassifier chillPlusRule()
BondClassifier bondClassifier(const std::string &name)
void classifyBondsCsr(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &offsets, const std::vector< int > &cols, const BondClassifier &rule, bool isSlice=false)
CHILL/CHILL+ bonds from a CSR of cloud indices.
int steinhardtQlmWidth(int orderL)
Width of one atom's interleaved q_lm: real, imaginary, m = -l..l.
Definition bop.hpp:554
SteinhardtQl steinhardtQl(const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, int orderL)
void correlFromOrder(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const BondOrder &order, const BondClassifier &rule, bool isSlice, const std::vector< char > *which, bool closed=true)
ChillPlusResult chillPlus(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList)
void getIceTypePlus(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList, std::string path, int firstFrame, bool isSlice=false, std::string outputFileName="chillPlus.txt")
molSys::bond_type classifyBond(double cij, const BondClassifier &rule, bool closed=true)
Definition bop.hpp:193
void registerBondClassifier(const std::string &name, const BondClassifier &rule)
@ eclipsed
The bond is an eclipsed bond.
Definition mol_sys.hpp:69
@ out_of_range
The bond cannot be classified as either staggered or eclipsed.
Definition mol_sys.hpp:69
@ staggered
The bond is a staggered bond, according to the or value.
Definition mol_sys.hpp:69
Functions used for spherical harmonics.
Definition bop.hpp:588
std::vector< std::complex< double > > lookupTableQ6Vec(std::array< double, 2 > angles)
Lookup table for Q6.
std::vector< std::complex< double > > lookupTableQ3Vec(std::array< double, 2 > angles)
Lookup table for Q3.
std::vector< std::complex< double > > lookupTableQ4Vec(std::array< double, 2 > angles)
Lookup table for Q4.
std::array< double, 2 > radialCoord(std::array< double, 3 > cartCoord)
void spheriHarmoInto(int orderL, std::array< double, 2 > radialCoord, std::vector< std::complex< double > > &out)
Fill out with Y_lm, m = -l .. +l. Reuses out capacity.
std::complex< double > lookupTableQ6(int m, std::array< double, 2 > angles)
Lookup table for Q6 (m=0 to m=12).
std::vector< std::complex< double > > spheriHarmo(int orderL, std::array< double, 2 > radialCoord)
std::complex< double > lookupTableQ8(int m, std::array< double, 2 > angles)
Lookup table for Q8 (m=0 to m=16).
std::complex< double > lookupTableQ3(int m, std::array< double, 2 > angles)
Lookup table for Q3 (m=0 to m=6).
std::vector< std::complex< double > > lookupTableQ8Vec(std::array< double, 2 > angles)
Lookup table for Q8.
std::complex< double > lookupTableQ4(int m, std::array< double, 2 > angles)
Lookup table for Q4 (m=0 to m=8).
Header file for neighbour list generation.
Rebuild, local kernel, halo exchange, and the write-back to the frame.
Definition bop.hpp:543
One rule set for classifying bond correlations .
Definition bop.hpp:179
double eclipsedMin
Inclusive staggered edge, c_ij <= staggeredMax.
Definition bop.hpp:181
int coordinationNumber
Inclusive upper edge of the eclipsed band.
Definition bop.hpp:183
double eclipsedMax
Inclusive lower edge of the eclipsed band.
Definition bop.hpp:182
std::vector< int > chosen
Definition bop.hpp:278
std::vector< double > q
Definition bop.hpp:275
std::vector< int > nkeep
squared norm of q, with the m != 0 factor
Definition bop.hpp:277
std::vector< std::vector< int > > rows
keepMax > 0, local indices, -1 empty
Definition bop.hpp:279
std::vector< double > norm
atom-major, 7 channels
Definition bop.hpp:276
This is the local orientational bond order parameter , of length .
Definition bop.hpp:168
std::vector< YlmAtom > ptq
Definition bop.hpp:169
Per-particle Steinhardt order parameters of a single degree .
Definition bop.hpp:473
std::vector< double > ql
Definition bop.hpp:474
std::vector< double > wl
Averaged .
Definition bop.hpp:476
std::vector< double > qlBar
Local .
Definition bop.hpp:475
This contains a complex vector of length .
Definition bop.hpp:147
std::vector< std::complex< double > > ylm
Definition bop.hpp:148
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