order_parameter.cpp
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 #include <order_parameter.hpp>
16 
33  molSys::PointCloud<molSys::Point<double>, double> *yCloud, int nPrisms,
34  double avgPrismHeight) {
35  //
36  double hPercent; // Normalized height percent
37  double nanoTubeHeight; // Height of the SWCT
38  double numberMax; // Maximum number possible, given the average prism height
39 
40  // ---------------------------------------
41  // Calculate the height of the SWCT
42  // This is the longest dimension of the simulation box
43  nanoTubeHeight = *max_element(yCloud->box.begin(), yCloud->box.end());
44  // ---------------------------------------
45  // Calculate the maximum possible height, given the average prism height
46  // and the height of the nanotube
47  numberMax = nanoTubeHeight / avgPrismHeight;
48  // ---------------------------------------
49  // Calculate the normalized height percentage
50  hPercent = nPrisms / numberMax * 100.0;
51 
52  return hPercent;
53 }
54 
72  std::vector<std::vector<int>> rings, double sheetArea) {
73  //
74  double areaXY, areaXZ, areaYZ; // Total coverage area
75  std::vector<double> singleAreas; // Area of single rings
76 
77  // ---------------------------------------
78  // Initialization
79  areaXY = 0.0;
80  areaXZ = 0.0;
81  areaYZ = 0.0;
82  // ---------------------------------------
83  // Loop through all the rings
84  for (int iring = 0; iring < rings.size(); iring++) {
85  // Get the coverage area for the current ring
86  singleAreas = topoparam::projAreaSingleRing(yCloud, rings[iring]);
87  // Add these to the total coverage area
88  areaXY += singleAreas[0];
89  areaXZ += singleAreas[1];
90  areaYZ += singleAreas[2];
91  } // end of loop through all the rings
92  // ---------------------------------------
93  // Normalize the coverage area by the sheet area
94  areaXY = areaXY / sheetArea * 100.0;
95  areaXZ = areaXZ / sheetArea * 100.0;
96  areaYZ = areaYZ / sheetArea * 100.0;
97 
98  return {areaXY, areaXZ, areaYZ};
99 }
100 
106  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
108  //
109  int iatomIndex, jatomIndex; // Atom indices of the i^th and j^th atoms
110  int ringSize = ring.size(); // Number of nodes in the ring
111  double areaXY, areaXZ, areaYZ;
112  double x_iatom, y_iatom, z_iatom; // Coordinates of iatom
113  double x_jatom, y_jatom, z_jatom; // Coordinates of jatom
114  // ----------------------------------------
115  // Calculate projected area onto the XY, YZ and XZ planes for basal1
116 
117  // Init the projected area
118  areaXY = 0.0;
119  areaXZ = 0.0;
120  areaYZ = 0.0;
121 
122  jatomIndex = ring[0];
123 
124  // All points except the first pair
125  for (int k = 1; k < ringSize; k++) {
126  iatomIndex = ring[k]; // Current vertex
127 
128  // --------------------------------------------------------------------
129  // SHIFT PARTICLES TEMPORARILY (IN CASE OF UNWRAPPED COORDINATES)
130  gen::unwrappedCoordShift(yCloud, iatomIndex, jatomIndex, &x_iatom, &y_iatom,
131  &z_iatom, &x_jatom, &y_jatom, &z_jatom);
132  // --------------------------------------------------------------------
133 
134  // Add to the polygon area
135  // ------
136  // XY plane
137  areaXY += (x_jatom + x_iatom) * (y_jatom - y_iatom);
138  // ------
139  // XZ plane
140  areaXZ += (x_jatom + x_iatom) * (z_jatom - z_iatom);
141  // ------
142  // YZ plane
143  areaYZ += (y_jatom + y_iatom) * (z_jatom - z_iatom);
144  // ------
145  jatomIndex = iatomIndex;
146  }
147 
148  // Closure point
149  iatomIndex = ring[0];
150  // Unwrapped coordinates needed
151  gen::unwrappedCoordShift(yCloud, iatomIndex, jatomIndex, &x_iatom, &y_iatom,
152  &z_iatom, &x_jatom, &y_jatom, &z_jatom);
153  // ------
154  // XY plane
155  areaXY += (x_jatom + x_iatom) * (y_jatom - y_iatom);
156  // ------
157  // XZ plane
158  areaXZ += (x_jatom + x_iatom) * (z_jatom - z_iatom);
159  // ------
160  // YZ plane
161  areaYZ += (y_jatom + y_iatom) * (z_jatom - z_iatom);
162  // ------
163  // The actual projected area is half of this
164  areaXY *= 0.5;
165  areaXZ *= 0.5;
166  areaYZ *= 0.5;
167 
168  // Absolute area
169  areaXY = fabs(areaXY);
170  areaXZ = fabs(areaXZ);
171  areaYZ = fabs(areaYZ);
172 
173  return {areaXY, areaYZ, areaXZ};
174 }
int unwrappedCoordShift(molSys::PointCloud< molSys::Point< double >, double > *yCloud, int iatomIndex, int jatomIndex, double *x_i, double *y_i, double *z_i, double *x_j, double *y_j, double *z_j)
Shift particles (unwrapped coordinates)
Definition: generic.cpp:71
Topological network criteria functions.
Definition: ring.hpp:64
std::vector< double > projAreaSingleRing(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< int > ring)
Calculates the projected area on the XY, YZ and XZ planes.
double normHeightPercent(molSys::PointCloud< molSys::Point< double >, double > *yCloud, int nPrisms, double avgPrismHeight)
std::vector< double > calcCoverageArea(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> rings, double sheetArea)
This contains a collection of points; contains information for a particular frame.
Definition: mol_sys.hpp:170
This contains per-particle information.
Definition: mol_sys.hpp:149