main.cpp File Reference
#include <array>
#include <cstdlib>
#include <ctime>
#include <sstream>
#include <string>
#include "opt_parser.h"
#include <bond.hpp>
#include <bop.hpp>
#include <bulkTUM.hpp>
#include <cluster.hpp>
#include <franzblau.hpp>
#include <generic.hpp>
#include <mol_sys.hpp>
#include <neighbours.hpp>
#include <rdf2d.hpp>
#include <ring.hpp>
#include <seams_input.hpp>
#include <seams_output.hpp>
#include <topo_bulk.hpp>
#include <topo_one_dim.hpp>
#include <topo_two_dim.hpp>
#include <rang.hpp>
#include <sol.hpp>
#include <fmt/core.h>
#include <yaml-cpp/yaml.h>
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 57 of file main.cpp.

57  {
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 }
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 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)
cxxopts::ParseResult parse(int argc, char *argv[])
Definition: opt_parser.cpp:14
This contains a collection of points; contains information for a particular frame.
Definition: mol_sys.hpp:166