main.cpp
Go to the documentation of this file.
1 //
3 // d-SEAMS molecular dynamics analysis engine code
4 // Copyright (C) <2018-present> Amrita Goswami, Rohit Goswami
5 // amrita16thaug646[at]gmail.com, r95g10[at]gmail.com
6 
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <https://www.gnu.org/licenses/>.
19 //
21 
22 // Standard Library
23 #include <array>
24 #include <cstdlib>
25 #include <ctime>
26 #include <sstream>
27 #include <string>
28 
29 // Internal Libraries
30 #include "opt_parser.h"
31 
32 // Newer pointCloud
33 #include <bond.hpp>
34 #include <bop.hpp>
35 #include <bulkTUM.hpp>
36 #include <cluster.hpp>
37 #include <franzblau.hpp>
38 #include <generic.hpp>
39 #include <mol_sys.hpp>
40 #include <neighbours.hpp>
41 #include <rdf2d.hpp>
42 #include <ring.hpp>
43 #include <seams_input.hpp>
44 #include <seams_output.hpp>
45 #include <topo_bulk.hpp>
46 #include <topo_one_dim.hpp>
47 #include <topo_two_dim.hpp>
48 
49 // Externally bundled-input libraries
50 // #include <cxxopts.hpp>
51 #include <rang.hpp>
52 #include <sol.hpp>
53 
54 #include <fmt/core.h>
55 #include <yaml-cpp/yaml.h>
56 
57 int main(int argc, char *argv[]) {
58  // Parse Things
59  auto result = parse(argc, argv);
60  auto &arguments = result.arguments();
61  // Initialize yaml config
62  YAML::Node config = YAML::LoadFile(result["c"].as<std::string>());
63  // This is a dummy used to figure out the order of options (cmd > yml)
64  std::string script, tFile;
65  // Initialize Lua
66  sol::state lua;
67  // Use all libraries
68  lua.open_libraries();
69  // Get the trajectory string
70  if (config["trajectory"]) {
71  tFile = config["trajectory"].as<std::string>();
72  } // end of getting the trajectory
73  // Get variable file string
74  std::string vars = config["variables"].as<std::string>();
75  // --------------------------------------
76  // Structure determination block for TWO-DIMENSIONAL ICE
77  if (config["topoTwoDim"]["use"].as<bool>()) {
78  // Use the variables script
79  lua.script_file(vars);
80  // -----------------
81  // Variables which must be declared in C++
82  //
83  // Newer pointCloud (rescloud -> ice structure, solcloud -> largest cluster)
85  // Some neighbor lists
86  std::vector<std::vector<int>> nList, hbnList;
87  // For the list of all rings (of all sizes)
88  std::vector<std::vector<int>> ringsAllSizes;
90  // RDF stuff
91  std::vector<double> rdfValues; // RDF vector
92  // -----------------
93  // This section basically only registers functions and handles the rest in
94  // lua Use the functions defined here
95  auto lscript = lua.get<std::string>("functionScript");
96  // Transfer variables to lua
97  lua["doBOP"] = config["bulk"]["use"].as<bool>();
98  lua["topoOneDim"] = config["topoOneDim"]["use"].as<bool>();
99  lua["topoTwoDim"] = config["topoTwoDim"]["use"].as<bool>();
100  lua["topoBulk"] = config["bulk"]["use"].as<bool>();
101  //
102  lua["nList"] = &nList;
103  lua["hbnList"] = &hbnList;
104  lua["resCloud"] = &resCloud;
105  lua["trajectory"] = tFile;
106  // Confined ice stuff
107  lua["ringsAllSizes"] = &rings;
108  // RDF stuff
109  lua["rdf"] = &rdfValues;
110  // -----------------
111  // Register functions
112  //
113  // Writing stuff
114  // Generic requirements
115  lua.set_function("readFrameOnlyOne", sinp::readLammpsTrjreduced);
116  lua.set_function("neighborList", nneigh::neighListO);
117  // -----------------
118  // Topological Network Method Specific Functions
119  // Generic requirements (read in only inside the slice)
120  lua.set_function("getHbondNetwork", bond::populateHbonds);
121  lua.set_function("bondNetworkByIndex", nneigh::neighbourListByIndex);
122  // -----------------
123  // Primitive rings
124  lua.set_function("getPrimitiveRings", primitive::ringNetwork);
125  // -----------------
126  // Quasi-two-dimensional ice
127  lua.set_function("ringAnalysis", ring::polygonRingAnalysis);
128  // --------------------------
129  // RDF functions
130  lua.set_function("calcRDF", rdf2::rdf2Danalysis_AA);
131  // --------------------------
132  // Use the script
133  lua.script_file(lscript);
134  // --------------------------
135 
136  } // end of two-dimensional ice block
137  // --------------------------------------
138  // Structure determination block for ONE-DIMENSIONAL ICE
139  if (config["topoOneDim"]["use"].as<bool>()) {
140  // Use the script
141  lua.script_file(vars);
142  // -----------------
143  // Variables which must be declared in C++
144  //
145  // Newer pointCloud (rescloud -> ice structure, solcloud -> largest cluster)
147  // Some neighbor
148  std::vector<std::vector<int>> nList, hbnList;
149  // For the list of all rings (of all sizes)
150  std::vector<std::vector<int>> ringsAllSizes;
152  int atomID;
153  // -----------------
154  // This section basically only registers functions and handles the rest in
155  // lua Use the functions defined here
156  auto lscript = lua.get<std::string>("functionScript");
157  // Transfer variables to lua
158  lua["doBOP"] = config["bulk"]["use"].as<bool>();
159  lua["topoOneDim"] = config["topoOneDim"]["use"].as<bool>();
160  lua["topoTwoDim"] = config["topoTwoDim"]["use"].as<bool>();
161  lua["topoBulk"] = config["bulk"]["use"].as<bool>();
162  //
163  lua["nList"] = &nList;
164  lua["hbnList"] = &hbnList;
165  lua["resCloud"] = &resCloud;
166  lua["trajectory"] = tFile;
167  // Confined ice stuff
168  lua["ringsAllSizes"] = &rings;
169  lua["lowestAtomID"] = &atomID;
170  // Register functions
171  //
172  // Writing stuff
173  // Generic requirements
174  lua.set_function("readFrameOnlyOne", sinp::readLammpsTrjreduced);
175  lua.set_function("neighborList", nneigh::neighListO);
176  // -----------------
177  // Topological Network Method Specific Functions
178  // Generic requirements (read in only inside the slice)
179  lua.set_function("getHbondNetwork", bond::populateHbonds);
180  lua.set_function("bondNetworkByIndex", nneigh::neighbourListByIndex);
181  // -----------------
182  // Primitive rings
183  lua.set_function("getPrimitiveRings", primitive::ringNetwork);
184  // -----------------
185  // Quasi-one-dimensional ice
186  lua.set_function("prismAnalysis", ring::prismAnalysis);
187  // --------------------------
188  // Use the script
189  lua.script_file(lscript);
190  // --------------------------
191 
192  } // end of one-dimensional ice block
193  // --------------------------------------
194  // Ice Structure Determination for BULK ICE
195  if (config["bulk"]["use"].as<bool>()) {
196  // Use the variables script
197  lua.script_file(vars);
198  // Variables which must be declared in C++
199  //
200  // Newer pointCloud (rescloud -> ice structure, solcloud -> largest
201  molSys::PointCloud<molSys::Point<double>, double> resCloud, solCloud;
202  // Some neighbor
204  hbnList; // Neighbour lists (by cutoff and hydrogen-bonded neighbour
205  // lists)
207  iceList; // Neighbour list for the largest ice cluster
208  // For averaged q6
209  std::vector<double> avgQ6;
210  // For the list of all rings (of all sizes)
211  std::vector<std::vector<int>> ringsAllSizes;
213  // -----------------
214  // Variables defined in C++ specific to confined systems
215 
216  // This section basically only registers functions and handles the rest in
217  // lua lua Use the functions defined here
218  auto lscript = lua.get<std::string>("functionScript");
219  // Transfer variables to lua
220  lua["doBOP"] = config["bulk"]["bondOrderParameters"].as<bool>();
221  lua["topoOneDim"] = config["topoOneDim"]["use"].as<bool>();
222  lua["topoTwoDim"] = config["topoTwoDim"]["use"].as<bool>();
223  lua["topoBulk"] = config["bulk"]["topologicalNetworkCriterion"].as<bool>();
224  //
225  lua["nList"] = &nList;
226  lua["hbnList"] = &hbnList;
227  lua["iceNeighbourList"] = &iceList;
228  lua["resCloud"] = &resCloud;
229  lua["clusterCloud"] = &solCloud;
230  lua["avgQ6"] = &avgQ6;
231  lua["trajectory"] = tFile;
232  // Confined ice stuff
233  lua["ringsAllSizes"] = &rings;
234  // Register functions
235  //
236  // Writing stuff
237  lua.set_function("writeDump", sout::writeDump);
238  lua.set_function("writeHistogram", sout::writeHisto);
239  // Generic requirements
240  lua.set_function("readFrame", sinp::readLammpsTrjO);
241  lua.set_function("neighborList", nneigh::neighListO);
242  // CHILL+ and modifications
243  lua.set_function("chillPlus_cij", chill::getCorrelPlus);
244  lua.set_function("chillPlus_iceType", chill::getIceTypePlus);
245  // CHILL functions
246  lua.set_function("chill_cij", chill::getCorrel);
247  lua.set_function("chill_iceType", chill::getIceType);
248  // Reclassify using q6
249  lua.set_function("averageQ6", chill::getq6);
250  lua.set_function("modifyChill", chill::reclassifyWater);
251  lua.set_function("percentage_Ice", chill::printIceType);
252  // Largest ice cluster
253  lua.set_function("clusterAnalysis", clump::clusterAnalysis);
254  lua.set_function("recenterCluster", clump::recenterClusterCloud);
255  // -----------------
256  // Topological Network Methods
257  // Generic requirements (read in only inside the slice)
258  lua.set_function("readFrameOnlyOne", sinp::readLammpsTrjreduced);
259  lua.set_function("getHbondNetwork", bond::populateHbonds);
260  lua.set_function("bondNetworkByIndex", nneigh::neighbourListByIndex);
261  // -----------------
262  // Primitive rings
263  lua.set_function("getPrimitiveRings", primitive::ringNetwork);
264  // -----------------
265  // Bulk ice, using the topological network criterion
266  lua.set_function("bulkTopologicalNetworkCriterion", ring::topoBulkAnalysis);
267  // --------------------------
268  // Bulk ice, using the TUM (Topological Unit Matching Criterion). No need to
269  // use bulkTopologicalNetworkCriterion if you use this function
270  lua.set_function("bulkTopoUnitMatching", tum3::topoUnitMatchingBulk);
271  // --------------------------
272  // Use the script
273  lua.script_file(lscript);
274  // --------------------------
275 
276  } // end of bulk ice structure determination block
277  // --------------------------------------
278 
279  std::cout << rang::style::bold
280  << fmt::format("Welcome to the Black Parade.\nYou ran:-\n")
281  << rang::style::reset
282  << fmt::format("\nBulk Ice Analysis: {}",
283  config["bulk"]["use"].as<bool>())
284  << fmt::format("\nQuasi-one-dimensional Ice Analysis: {}",
285  config["topoOneDim"]["use"].as<bool>())
286  << fmt::format("\nQuasi-two-dimensional Ice Analysis: {}",
287  config["topoTwoDim"]["use"].as<bool>())
288  << "\n";
289 
290  return 0;
291 }
File for bond-related analyses (hydrogen bonds, bonded atoms for data file write-outs etc....
File for the bond order parameter analysis.
File containing functions used specific to bulk topological unit matching (TUM) criterion.
File for the bond order parameter analysis.
File for generating shortest-path rings according to the Franzblau algorithm.
File for containing generic or common functions.
std::vector< std::vector< int > > populateHbonds(std::string filename, molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, int targetFrame, int Htype)
Definition: bond.cpp:170
std::vector< double > getq6(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, bool isSlice=false)
Definition: bop.cpp:864
molSys::PointCloud< molSys::Point< double >, double > getCorrelPlus(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, bool isSlice=false)
Gets c_ij and then classifies bond types according to the CHILL+ algorithm.
Definition: bop.cpp:598
molSys::PointCloud< molSys::Point< double >, double > getIceTypePlus(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::string path, int firstFrame, bool isSlice=false, std::string outputFileName="chillPlus.txt")
Classifies each atom according to the CHILL+ algorithm.
Definition: bop.cpp:751
molSys::PointCloud< molSys::Point< double >, double > getCorrel(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, bool isSlice=false)
Definition: bop.cpp:295
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.
Definition: bop.cpp:1056
molSys::PointCloud< molSys::Point< double >, double > reclassifyWater(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< double > *q6)
Definition: bop.cpp:1007
molSys::PointCloud< molSys::Point< double >, double > getIceType(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::string path, int firstFrame, bool isSlice=false, std::string outputFileName="chill.txt")
Classifies each atom according to the CHILL algorithm.
Definition: bop.cpp:501
int recenterClusterCloud(molSys::PointCloud< molSys::Point< double >, double > *iceCloud, std::vector< std::vector< int >> nList)
Recenters the coordinates of a pointCloud.
Definition: cluster.cpp:394
int clusterAnalysis(std::string path, molSys::PointCloud< molSys::Point< double >, double > *iceCloud, molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< std::vector< int >> &iceNeighbourList, double cutoff, int firstFrame, std::string bopAnalysis="q6")
Definition: cluster.cpp:308
std::vector< std::vector< int > > neighListO(double rcutoff, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int typeI)
Definition: neighbours.cpp:114
std::vector< std::vector< int > > neighbourListByIndex(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList)
Definition: neighbours.cpp:337
std::vector< std::vector< int > > ringNetwork(std::vector< std::vector< int >> nList, int maxDepth)
Definition: franzblau.cpp:28
int topoBulkAnalysis(std::string path, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int firstFrame, bool onlyTetrahedral=true)
Definition: topo_bulk.cpp:48
int rdf2Danalysis_AA(std::string path, std::vector< double > *rdfValues, molSys::PointCloud< molSys::Point< double >, double > *yCloud, double cutoff, double binwidth, int firstFrame, int finalFrame)
Definition: rdf2d.cpp:41
int prismAnalysis(std::string path, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int maxDepth, int *atomID, int firstFrame, int currentFrame, bool doShapeMatching=false)
int topoUnitMatchingBulk(std::string path, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int firstFrame, bool printClusters, bool onlyTetrahedral)
Definition: bulkTUM.cpp:48
int polygonRingAnalysis(std::string path, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int maxDepth, double sheetArea, int firstFrame)
molSys::PointCloud< molSys::Point< double >, double > readLammpsTrjreduced(std::string filename, int targetFrame, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int typeI, 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})
molSys::PointCloud< molSys::Point< double >, double > readLammpsTrjO(std::string filename, int targetFrame, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int typeO, 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})
int main(int argc, char *argv[])
Definition: main.cpp:57
The main molecular system handler.
int writeDump(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::string path, std::string outFile)
Generic function for writing out to a dump file.
int writeHisto(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< double > avgQ6)
Header file for neighbour list generation.
cxxopts::ParseResult parse(int argc, char *argv[])
Definition: opt_parser.cpp:14
File containing functions used to calculate the in-plane radial distribution functions.
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:166
File containing functions used specific to bulk topological network critera.
File containing functions used specific to quasi-one-dimensional topological network critera (the pri...