1 |
gezelter |
507 |
/* |
2 |
gezelter |
246 |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
tim |
122 |
* |
4 |
gezelter |
246 |
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
|
* redistribute this software in source and binary code form, provided |
7 |
|
|
* that the following conditions are met: |
8 |
|
|
* |
9 |
gezelter |
1390 |
* 1. Redistributions of source code must retain the above copyright |
10 |
gezelter |
246 |
* notice, this list of conditions and the following disclaimer. |
11 |
|
|
* |
12 |
gezelter |
1390 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
gezelter |
246 |
* notice, this list of conditions and the following disclaimer in the |
14 |
|
|
* documentation and/or other materials provided with the |
15 |
|
|
* distribution. |
16 |
|
|
* |
17 |
|
|
* This software is provided "AS IS," without a warranty of any |
18 |
|
|
* kind. All express or implied conditions, representations and |
19 |
|
|
* warranties, including any implied warranty of merchantability, |
20 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
21 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
22 |
|
|
* be liable for any damages suffered by licensee as a result of |
23 |
|
|
* using, modifying or distributing the software or its |
24 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
25 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
26 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
27 |
|
|
* damages, however caused and regardless of the theory of liability, |
28 |
|
|
* arising out of the use of or inability to use software, even if the |
29 |
|
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
|
* such damages. |
31 |
gezelter |
1390 |
* |
32 |
|
|
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
|
|
* research, please cite the appropriate papers when you publish your |
34 |
|
|
* work. Good starting points are: |
35 |
|
|
* |
36 |
|
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
gezelter |
1665 |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
|
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
tim |
122 |
*/ |
42 |
gezelter |
246 |
|
43 |
gezelter |
507 |
/** |
44 |
|
|
* @file Snapshot.hpp |
45 |
|
|
* @author tlin |
46 |
|
|
* @date 10/20/2004 |
47 |
|
|
* @time 23:56am |
48 |
|
|
* @version 1.0 |
49 |
|
|
*/ |
50 |
tim |
146 |
|
51 |
tim |
122 |
#ifndef BRAINS_SNAPSHOT_HPP |
52 |
|
|
#define BRAINS_SNAPSHOT_HPP |
53 |
tim |
137 |
|
54 |
|
|
#include <vector> |
55 |
|
|
|
56 |
tim |
155 |
#include "brains/DataStorage.hpp" |
57 |
gezelter |
1757 |
#include "nonbonded/NonBondedInteraction.hpp" |
58 |
gezelter |
246 |
#include "brains/Stats.hpp" |
59 |
tim |
137 |
|
60 |
gezelter |
1390 |
namespace OpenMD{ |
61 |
tim |
122 |
|
62 |
gezelter |
1715 |
struct FrameData { |
63 |
|
|
int id; /**< identification number of the snapshot */ |
64 |
|
|
RealType currentTime; /**< current time */ |
65 |
|
|
Mat3x3d hmat; /**< axes of the periodic box in matrix form */ |
66 |
|
|
Mat3x3d invHmat; /**< the inverse of the Hmat matrix */ |
67 |
|
|
bool orthoRhombic; /**< is this an orthorhombic periodic box? */ |
68 |
|
|
RealType volume; /**< total volume of this frame */ |
69 |
|
|
RealType pressure; /**< pressure of this frame */ |
70 |
|
|
RealType totalEnergy; /**< total energy of this frame */ |
71 |
|
|
RealType kineticEnergy; /**< kinetic energy of this frame */ |
72 |
|
|
RealType potentialEnergy; /**< potential energy of this frame */ |
73 |
gezelter |
1757 |
RealType shortRangePotential; /**< short-range contributions to the potential*/ |
74 |
|
|
RealType longRangePotential; /**< long-range contributions to the potential */ |
75 |
|
|
RealType bondPotential; /**< bonded contribution to the potential */ |
76 |
|
|
RealType bendPotential; /**< angle-bending contribution to the potential */ |
77 |
|
|
RealType torsionPotential; /**< dihedral (torsion angle) contribution to the potential */ |
78 |
|
|
RealType inversionPotential; /**< inversion (planarity) contribution to the potential */ |
79 |
|
|
potVec lrPotentials; /**< breakdown of long-range potentials by family */ |
80 |
gezelter |
1715 |
RealType temperature; /**< temperature of this frame */ |
81 |
|
|
RealType chi; /**< thermostat velocity */ |
82 |
|
|
RealType integralOfChiDt; /**< the actual thermostat */ |
83 |
|
|
RealType electronicTemperature; /**< temperature of the electronic degrees of freedom */ |
84 |
|
|
RealType chiQ; /**< fluctuating charge thermostat velocity */ |
85 |
|
|
RealType integralOfChiQDt; /**< the actual fluctuating charge thermostat */ |
86 |
|
|
Mat3x3d eta; /**< barostat matrix */ |
87 |
|
|
Vector3d COM; /**< location of center of mass */ |
88 |
|
|
Vector3d COMvel; /**< system center of mass velocity */ |
89 |
|
|
Vector3d COMw; /**< system center of mass angular velocity */ |
90 |
gezelter |
1723 |
Mat3x3d stressTensor; /**< stress tensor */ |
91 |
gezelter |
1715 |
Mat3x3d pressureTensor; /**< pressure tensor */ |
92 |
|
|
Vector3d systemDipole; /**< total system dipole moment */ |
93 |
gezelter |
1723 |
Vector3d conductiveHeatFlux; /**< heat flux vector (conductive only) */ |
94 |
gezelter |
1715 |
}; |
95 |
|
|
|
96 |
|
|
|
97 |
gezelter |
507 |
/** |
98 |
|
|
* @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" |
99 |
|
|
* @brief Snapshot class is a repository class for storing dynamic data during |
100 |
|
|
* Simulation |
101 |
gezelter |
1540 |
* Every snapshot class will contain one DataStorage for atoms and one DataStorage |
102 |
gezelter |
507 |
* for rigid bodies. |
103 |
|
|
*/ |
104 |
|
|
class Snapshot { |
105 |
|
|
public: |
106 |
tim |
146 |
|
107 |
gezelter |
1540 |
Snapshot(int nAtoms, int nRigidbodies, |
108 |
|
|
int nCutoffGroups) : atomData(nAtoms), |
109 |
|
|
rigidbodyData(nRigidbodies), |
110 |
gezelter |
1715 |
cgData(nCutoffGroups, DataStorage::dslPosition), |
111 |
|
|
orthoTolerance_(1e-6), hasCOM_(false), hasVolume_(false){ |
112 |
|
|
|
113 |
|
|
frameData.id = -1; |
114 |
|
|
frameData.currentTime = 0; |
115 |
|
|
frameData.hmat = Mat3x3d(0.0); |
116 |
|
|
frameData.invHmat = Mat3x3d(0.0); |
117 |
|
|
frameData.orthoRhombic = false; |
118 |
|
|
frameData.volume = 0.0; |
119 |
|
|
frameData.pressure = 0.0; |
120 |
|
|
frameData.totalEnergy = 0.0; |
121 |
|
|
frameData.kineticEnergy = 0.0; |
122 |
|
|
frameData.potentialEnergy = 0.0; |
123 |
|
|
frameData.temperature = 0.0; |
124 |
|
|
frameData.chi = 0.0; |
125 |
|
|
frameData.integralOfChiDt = 0.0; |
126 |
|
|
frameData.electronicTemperature = 0.0; |
127 |
|
|
frameData.chiQ = 0.0; |
128 |
|
|
frameData.integralOfChiQDt = 0.0; |
129 |
|
|
frameData.eta = Mat3x3d(0.0); |
130 |
|
|
frameData.COM = V3Zero; |
131 |
|
|
frameData.COMvel = V3Zero; |
132 |
|
|
frameData.COMw = V3Zero; |
133 |
gezelter |
1723 |
frameData.stressTensor = Mat3x3d(0.0); |
134 |
gezelter |
1715 |
frameData.pressureTensor = Mat3x3d(0.0); |
135 |
gezelter |
1744 |
frameData.systemDipole = Vector3d(0.0); |
136 |
|
|
frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0); |
137 |
gezelter |
507 |
} |
138 |
tim |
137 |
|
139 |
gezelter |
1540 |
Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, |
140 |
|
|
int storageLayout) : atomData(nAtoms, storageLayout), |
141 |
|
|
rigidbodyData(nRigidbodies, storageLayout), |
142 |
|
|
cgData(nCutoffGroups, DataStorage::dslPosition), |
143 |
gezelter |
1715 |
orthoTolerance_(1e-6), |
144 |
|
|
hasCOM_(false), |
145 |
gezelter |
1708 |
hasVolume_(false) { |
146 |
gezelter |
1715 |
frameData.id = -1; |
147 |
|
|
frameData.currentTime = 0; |
148 |
|
|
frameData.hmat = Mat3x3d(0.0); |
149 |
|
|
frameData.invHmat = Mat3x3d(0.0); |
150 |
|
|
frameData.orthoRhombic = false; |
151 |
|
|
frameData.volume = 0.0; |
152 |
|
|
frameData.pressure = 0.0; |
153 |
|
|
frameData.totalEnergy = 0.0; |
154 |
|
|
frameData.kineticEnergy = 0.0; |
155 |
|
|
frameData.potentialEnergy = 0.0; |
156 |
|
|
frameData.temperature = 0.0; |
157 |
|
|
frameData.chi = 0.0; |
158 |
|
|
frameData.integralOfChiDt = 0.0; |
159 |
|
|
frameData.electronicTemperature = 0.0; |
160 |
|
|
frameData.chiQ = 0.0; |
161 |
|
|
frameData.integralOfChiQDt = 0.0; |
162 |
|
|
frameData.eta = Mat3x3d(0.0); |
163 |
|
|
frameData.COM = V3Zero; |
164 |
|
|
frameData.COMvel = V3Zero; |
165 |
|
|
frameData.COMw = V3Zero; |
166 |
gezelter |
1723 |
frameData.stressTensor = Mat3x3d(0.0); |
167 |
gezelter |
1715 |
frameData.pressureTensor = Mat3x3d(0.0); |
168 |
|
|
frameData.systemDipole = V3Zero; |
169 |
gezelter |
1744 |
frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0); |
170 |
gezelter |
1540 |
} |
171 |
|
|
|
172 |
gezelter |
507 |
/** Returns the id of this Snapshot */ |
173 |
|
|
int getID() { |
174 |
gezelter |
1715 |
return frameData.id; |
175 |
gezelter |
507 |
} |
176 |
tim |
137 |
|
177 |
gezelter |
507 |
/** Sets the id of this Snapshot */ |
178 |
|
|
void setID(int id) { |
179 |
gezelter |
1715 |
frameData.id = id; |
180 |
gezelter |
507 |
} |
181 |
tim |
137 |
|
182 |
gezelter |
507 |
int getSize() { |
183 |
|
|
return atomData.getSize() + rigidbodyData.getSize(); |
184 |
|
|
} |
185 |
tim |
152 |
|
186 |
gezelter |
507 |
/** Returns the number of atoms */ |
187 |
|
|
int getNumberOfAtoms() { |
188 |
|
|
return atomData.getSize(); |
189 |
|
|
} |
190 |
tim |
152 |
|
191 |
gezelter |
507 |
/** Returns the number of rigid bodies */ |
192 |
|
|
int getNumberOfRigidBodies() { |
193 |
|
|
return rigidbodyData.getSize(); |
194 |
|
|
} |
195 |
tim |
152 |
|
196 |
gezelter |
1544 |
/** Returns the number of rigid bodies */ |
197 |
|
|
int getNumberOfCutoffGroups() { |
198 |
|
|
return cgData.getSize(); |
199 |
|
|
} |
200 |
|
|
|
201 |
gezelter |
507 |
/** Returns the H-Matrix */ |
202 |
|
|
Mat3x3d getHmat() { |
203 |
gezelter |
1715 |
return frameData.hmat; |
204 |
gezelter |
507 |
} |
205 |
tim |
152 |
|
206 |
gezelter |
507 |
/** Sets the H-Matrix */ |
207 |
|
|
void setHmat(const Mat3x3d& m); |
208 |
gezelter |
246 |
|
209 |
tim |
963 |
RealType getVolume() { |
210 |
chuckv |
1302 |
if (hasVolume_){ |
211 |
gezelter |
1715 |
return frameData.volume; |
212 |
chuckv |
1302 |
}else{ |
213 |
gezelter |
1715 |
return frameData.hmat.determinant(); |
214 |
chuckv |
1302 |
} |
215 |
gezelter |
507 |
} |
216 |
tim |
152 |
|
217 |
chuckv |
1302 |
void setVolume(RealType volume){ |
218 |
|
|
hasVolume_=true; |
219 |
gezelter |
1715 |
frameData.volume = volume; |
220 |
chuckv |
1302 |
} |
221 |
|
|
|
222 |
gezelter |
507 |
/** Returns the inverse H-Matrix */ |
223 |
|
|
Mat3x3d getInvHmat() { |
224 |
gezelter |
1715 |
return frameData.invHmat; |
225 |
gezelter |
507 |
} |
226 |
tim |
152 |
|
227 |
gezelter |
507 |
/** Wrapping the vector according to periodic boundary condition*/ |
228 |
|
|
void wrapVector(Vector3d& v); |
229 |
gezelter |
1562 |
/** Scaling a vector to multiples of the periodic box */ |
230 |
|
|
Vector3d scaleVector(Vector3d &v); |
231 |
|
|
|
232 |
|
|
|
233 |
gezelter |
1104 |
Vector3d getCOM(); |
234 |
|
|
Vector3d getCOMvel(); |
235 |
|
|
Vector3d getCOMw(); |
236 |
gezelter |
246 |
|
237 |
tim |
963 |
RealType getTime() { |
238 |
gezelter |
1715 |
return frameData.currentTime; |
239 |
gezelter |
507 |
} |
240 |
tim |
152 |
|
241 |
tim |
963 |
void increaseTime(RealType dt) { |
242 |
gezelter |
507 |
setTime(getTime() + dt); |
243 |
|
|
} |
244 |
tim |
152 |
|
245 |
tim |
963 |
void setTime(RealType time) { |
246 |
gezelter |
1715 |
frameData.currentTime =time; |
247 |
gezelter |
507 |
//time at statData is redundant |
248 |
gezelter |
1715 |
statData[Stats::TIME] = frameData.currentTime; |
249 |
gezelter |
507 |
} |
250 |
tim |
152 |
|
251 |
tim |
963 |
RealType getChi() { |
252 |
gezelter |
1715 |
return frameData.chi; |
253 |
gezelter |
507 |
} |
254 |
gezelter |
246 |
|
255 |
tim |
963 |
void setChi(RealType chi) { |
256 |
gezelter |
1715 |
frameData.chi = chi; |
257 |
gezelter |
507 |
} |
258 |
gezelter |
246 |
|
259 |
tim |
963 |
RealType getIntegralOfChiDt() { |
260 |
gezelter |
1715 |
return frameData.integralOfChiDt; |
261 |
gezelter |
507 |
} |
262 |
gezelter |
246 |
|
263 |
tim |
963 |
void setIntegralOfChiDt(RealType integralOfChiDt) { |
264 |
gezelter |
1715 |
frameData.integralOfChiDt = integralOfChiDt; |
265 |
gezelter |
507 |
} |
266 |
gezelter |
246 |
|
267 |
gezelter |
1715 |
RealType getChiElectronic() { |
268 |
|
|
return frameData.chiQ; |
269 |
|
|
} |
270 |
gezelter |
1021 |
|
271 |
gezelter |
1715 |
void setChiElectronic(RealType chiQ) { |
272 |
|
|
frameData.chiQ = chiQ; |
273 |
|
|
} |
274 |
|
|
|
275 |
|
|
RealType getIntegralOfChiElectronicDt() { |
276 |
|
|
return frameData.integralOfChiQDt; |
277 |
|
|
} |
278 |
|
|
|
279 |
|
|
void setIntegralOfChiElectronicDt(RealType integralOfChiQDt) { |
280 |
|
|
frameData.integralOfChiQDt = integralOfChiQDt; |
281 |
|
|
} |
282 |
|
|
|
283 |
|
|
|
284 |
gezelter |
1021 |
void setOrthoTolerance(RealType orthoTolerance) { |
285 |
|
|
orthoTolerance_ = orthoTolerance; |
286 |
|
|
} |
287 |
|
|
|
288 |
gezelter |
507 |
Mat3x3d getEta() { |
289 |
gezelter |
1715 |
return frameData.eta; |
290 |
gezelter |
507 |
} |
291 |
gezelter |
246 |
|
292 |
gezelter |
507 |
void setEta(const Mat3x3d& eta) { |
293 |
gezelter |
1715 |
frameData.eta = eta; |
294 |
gezelter |
507 |
} |
295 |
gezelter |
1104 |
|
296 |
gezelter |
1723 |
Mat3x3d getStressTensor() { |
297 |
|
|
return frameData.stressTensor; |
298 |
gezelter |
1709 |
} |
299 |
|
|
|
300 |
gezelter |
1723 |
void setStressTensor(const Mat3x3d& stressTensor) { |
301 |
|
|
frameData.stressTensor = stressTensor; |
302 |
gezelter |
1709 |
} |
303 |
|
|
|
304 |
gezelter |
1723 |
Vector3d getConductiveHeatFlux() { |
305 |
|
|
return frameData.conductiveHeatFlux; |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
void setConductiveHeatFlux(const Vector3d& heatFlux) { |
309 |
|
|
frameData.conductiveHeatFlux = heatFlux; |
310 |
|
|
} |
311 |
|
|
|
312 |
gezelter |
1104 |
bool hasCOM() { |
313 |
|
|
return hasCOM_; |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) { |
317 |
gezelter |
1715 |
frameData.COM = COM; |
318 |
|
|
frameData.COMvel = COMvel; |
319 |
|
|
frameData.COMw = COMw; |
320 |
gezelter |
1104 |
hasCOM_ = true; |
321 |
|
|
} |
322 |
gezelter |
1540 |
|
323 |
gezelter |
507 |
DataStorage atomData; |
324 |
|
|
DataStorage rigidbodyData; |
325 |
gezelter |
1540 |
DataStorage cgData; |
326 |
gezelter |
1715 |
FrameData frameData; |
327 |
gezelter |
1541 |
Stats statData; |
328 |
gezelter |
1540 |
|
329 |
gezelter |
507 |
private: |
330 |
gezelter |
1021 |
RealType orthoTolerance_; |
331 |
gezelter |
1104 |
bool hasCOM_; |
332 |
gezelter |
1715 |
bool hasVolume_; |
333 |
gezelter |
507 |
}; |
334 |
tim |
122 |
|
335 |
gezelter |
507 |
typedef DataStorage (Snapshot::*DataStoragePointer); |
336 |
tim |
122 |
} |
337 |
|
|
#endif //BRAINS_SNAPSHOT_HPP |