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 |
246 |
#include "brains/Stats.hpp" |
58 |
tim |
137 |
|
59 |
gezelter |
1390 |
namespace OpenMD{ |
60 |
tim |
122 |
|
61 |
gezelter |
1715 |
struct FrameData { |
62 |
|
|
int id; /**< identification number of the snapshot */ |
63 |
|
|
RealType currentTime; /**< current time */ |
64 |
|
|
Mat3x3d hmat; /**< axes of the periodic box in matrix form */ |
65 |
|
|
Mat3x3d invHmat; /**< the inverse of the Hmat matrix */ |
66 |
|
|
bool orthoRhombic; /**< is this an orthorhombic periodic box? */ |
67 |
|
|
RealType volume; /**< total volume of this frame */ |
68 |
|
|
RealType pressure; /**< pressure of this frame */ |
69 |
|
|
RealType totalEnergy; /**< total energy of this frame */ |
70 |
|
|
RealType kineticEnergy; /**< kinetic energy of this frame */ |
71 |
|
|
RealType potentialEnergy; /**< potential energy of this frame */ |
72 |
|
|
RealType temperature; /**< temperature of this frame */ |
73 |
|
|
RealType chi; /**< thermostat velocity */ |
74 |
|
|
RealType integralOfChiDt; /**< the actual thermostat */ |
75 |
|
|
RealType electronicTemperature; /**< temperature of the electronic degrees of freedom */ |
76 |
|
|
RealType chiQ; /**< fluctuating charge thermostat velocity */ |
77 |
|
|
RealType integralOfChiQDt; /**< the actual fluctuating charge thermostat */ |
78 |
|
|
Mat3x3d eta; /**< barostat matrix */ |
79 |
|
|
Vector3d COM; /**< location of center of mass */ |
80 |
|
|
Vector3d COMvel; /**< system center of mass velocity */ |
81 |
|
|
Vector3d COMw; /**< system center of mass angular velocity */ |
82 |
|
|
Mat3x3d tau; /**< stress tensor */ |
83 |
|
|
Mat3x3d pressureTensor; /**< pressure tensor */ |
84 |
|
|
Vector3d systemDipole; /**< total system dipole moment */ |
85 |
|
|
}; |
86 |
|
|
|
87 |
|
|
|
88 |
gezelter |
507 |
/** |
89 |
|
|
* @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" |
90 |
|
|
* @brief Snapshot class is a repository class for storing dynamic data during |
91 |
|
|
* Simulation |
92 |
gezelter |
1540 |
* Every snapshot class will contain one DataStorage for atoms and one DataStorage |
93 |
gezelter |
507 |
* for rigid bodies. |
94 |
|
|
*/ |
95 |
|
|
class Snapshot { |
96 |
|
|
public: |
97 |
tim |
146 |
|
98 |
gezelter |
1540 |
Snapshot(int nAtoms, int nRigidbodies, |
99 |
|
|
int nCutoffGroups) : atomData(nAtoms), |
100 |
|
|
rigidbodyData(nRigidbodies), |
101 |
gezelter |
1715 |
cgData(nCutoffGroups, DataStorage::dslPosition), |
102 |
|
|
orthoTolerance_(1e-6), hasCOM_(false), hasVolume_(false){ |
103 |
|
|
|
104 |
|
|
frameData.id = -1; |
105 |
|
|
frameData.currentTime = 0; |
106 |
|
|
frameData.hmat = Mat3x3d(0.0); |
107 |
|
|
frameData.invHmat = Mat3x3d(0.0); |
108 |
|
|
frameData.orthoRhombic = false; |
109 |
|
|
frameData.volume = 0.0; |
110 |
|
|
frameData.pressure = 0.0; |
111 |
|
|
frameData.totalEnergy = 0.0; |
112 |
|
|
frameData.kineticEnergy = 0.0; |
113 |
|
|
frameData.potentialEnergy = 0.0; |
114 |
|
|
frameData.temperature = 0.0; |
115 |
|
|
frameData.chi = 0.0; |
116 |
|
|
frameData.integralOfChiDt = 0.0; |
117 |
|
|
frameData.electronicTemperature = 0.0; |
118 |
|
|
frameData.chiQ = 0.0; |
119 |
|
|
frameData.integralOfChiQDt = 0.0; |
120 |
|
|
frameData.eta = Mat3x3d(0.0); |
121 |
|
|
frameData.COM = V3Zero; |
122 |
|
|
frameData.COMvel = V3Zero; |
123 |
|
|
frameData.COMw = V3Zero; |
124 |
|
|
frameData.tau = Mat3x3d(0.0); |
125 |
|
|
frameData.pressureTensor = Mat3x3d(0.0); |
126 |
|
|
frameData.systemDipole = V3Zero; |
127 |
gezelter |
507 |
} |
128 |
tim |
137 |
|
129 |
gezelter |
1540 |
Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, |
130 |
|
|
int storageLayout) : atomData(nAtoms, storageLayout), |
131 |
|
|
rigidbodyData(nRigidbodies, storageLayout), |
132 |
|
|
cgData(nCutoffGroups, DataStorage::dslPosition), |
133 |
gezelter |
1715 |
orthoTolerance_(1e-6), |
134 |
|
|
hasCOM_(false), |
135 |
gezelter |
1708 |
hasVolume_(false) { |
136 |
gezelter |
1715 |
frameData.id = -1; |
137 |
|
|
frameData.currentTime = 0; |
138 |
|
|
frameData.hmat = Mat3x3d(0.0); |
139 |
|
|
frameData.invHmat = Mat3x3d(0.0); |
140 |
|
|
frameData.orthoRhombic = false; |
141 |
|
|
frameData.volume = 0.0; |
142 |
|
|
frameData.pressure = 0.0; |
143 |
|
|
frameData.totalEnergy = 0.0; |
144 |
|
|
frameData.kineticEnergy = 0.0; |
145 |
|
|
frameData.potentialEnergy = 0.0; |
146 |
|
|
frameData.temperature = 0.0; |
147 |
|
|
frameData.chi = 0.0; |
148 |
|
|
frameData.integralOfChiDt = 0.0; |
149 |
|
|
frameData.electronicTemperature = 0.0; |
150 |
|
|
frameData.chiQ = 0.0; |
151 |
|
|
frameData.integralOfChiQDt = 0.0; |
152 |
|
|
frameData.eta = Mat3x3d(0.0); |
153 |
|
|
frameData.COM = V3Zero; |
154 |
|
|
frameData.COMvel = V3Zero; |
155 |
|
|
frameData.COMw = V3Zero; |
156 |
|
|
frameData.tau = Mat3x3d(0.0); |
157 |
|
|
frameData.pressureTensor = Mat3x3d(0.0); |
158 |
|
|
frameData.systemDipole = V3Zero; |
159 |
gezelter |
1540 |
} |
160 |
|
|
|
161 |
gezelter |
507 |
/** Returns the id of this Snapshot */ |
162 |
|
|
int getID() { |
163 |
gezelter |
1715 |
return frameData.id; |
164 |
gezelter |
507 |
} |
165 |
tim |
137 |
|
166 |
gezelter |
507 |
/** Sets the id of this Snapshot */ |
167 |
|
|
void setID(int id) { |
168 |
gezelter |
1715 |
frameData.id = id; |
169 |
gezelter |
507 |
} |
170 |
tim |
137 |
|
171 |
gezelter |
507 |
int getSize() { |
172 |
|
|
return atomData.getSize() + rigidbodyData.getSize(); |
173 |
|
|
} |
174 |
tim |
152 |
|
175 |
gezelter |
507 |
/** Returns the number of atoms */ |
176 |
|
|
int getNumberOfAtoms() { |
177 |
|
|
return atomData.getSize(); |
178 |
|
|
} |
179 |
tim |
152 |
|
180 |
gezelter |
507 |
/** Returns the number of rigid bodies */ |
181 |
|
|
int getNumberOfRigidBodies() { |
182 |
|
|
return rigidbodyData.getSize(); |
183 |
|
|
} |
184 |
tim |
152 |
|
185 |
gezelter |
1544 |
/** Returns the number of rigid bodies */ |
186 |
|
|
int getNumberOfCutoffGroups() { |
187 |
|
|
return cgData.getSize(); |
188 |
|
|
} |
189 |
|
|
|
190 |
gezelter |
507 |
/** Returns the H-Matrix */ |
191 |
|
|
Mat3x3d getHmat() { |
192 |
gezelter |
1715 |
return frameData.hmat; |
193 |
gezelter |
507 |
} |
194 |
tim |
152 |
|
195 |
gezelter |
507 |
/** Sets the H-Matrix */ |
196 |
|
|
void setHmat(const Mat3x3d& m); |
197 |
gezelter |
246 |
|
198 |
tim |
963 |
RealType getVolume() { |
199 |
chuckv |
1302 |
if (hasVolume_){ |
200 |
gezelter |
1715 |
return frameData.volume; |
201 |
chuckv |
1302 |
}else{ |
202 |
gezelter |
1715 |
return frameData.hmat.determinant(); |
203 |
chuckv |
1302 |
} |
204 |
gezelter |
507 |
} |
205 |
tim |
152 |
|
206 |
chuckv |
1302 |
void setVolume(RealType volume){ |
207 |
|
|
hasVolume_=true; |
208 |
gezelter |
1715 |
frameData.volume = volume; |
209 |
chuckv |
1302 |
} |
210 |
|
|
|
211 |
gezelter |
507 |
/** Returns the inverse H-Matrix */ |
212 |
|
|
Mat3x3d getInvHmat() { |
213 |
gezelter |
1715 |
return frameData.invHmat; |
214 |
gezelter |
507 |
} |
215 |
tim |
152 |
|
216 |
gezelter |
507 |
/** Wrapping the vector according to periodic boundary condition*/ |
217 |
|
|
void wrapVector(Vector3d& v); |
218 |
gezelter |
1562 |
/** Scaling a vector to multiples of the periodic box */ |
219 |
|
|
Vector3d scaleVector(Vector3d &v); |
220 |
|
|
|
221 |
|
|
|
222 |
gezelter |
1104 |
Vector3d getCOM(); |
223 |
|
|
Vector3d getCOMvel(); |
224 |
|
|
Vector3d getCOMw(); |
225 |
gezelter |
246 |
|
226 |
tim |
963 |
RealType getTime() { |
227 |
gezelter |
1715 |
return frameData.currentTime; |
228 |
gezelter |
507 |
} |
229 |
tim |
152 |
|
230 |
tim |
963 |
void increaseTime(RealType dt) { |
231 |
gezelter |
507 |
setTime(getTime() + dt); |
232 |
|
|
} |
233 |
tim |
152 |
|
234 |
tim |
963 |
void setTime(RealType time) { |
235 |
gezelter |
1715 |
frameData.currentTime =time; |
236 |
gezelter |
507 |
//time at statData is redundant |
237 |
gezelter |
1715 |
statData[Stats::TIME] = frameData.currentTime; |
238 |
gezelter |
507 |
} |
239 |
tim |
152 |
|
240 |
tim |
963 |
RealType getChi() { |
241 |
gezelter |
1715 |
return frameData.chi; |
242 |
gezelter |
507 |
} |
243 |
gezelter |
246 |
|
244 |
tim |
963 |
void setChi(RealType chi) { |
245 |
gezelter |
1715 |
frameData.chi = chi; |
246 |
gezelter |
507 |
} |
247 |
gezelter |
246 |
|
248 |
tim |
963 |
RealType getIntegralOfChiDt() { |
249 |
gezelter |
1715 |
return frameData.integralOfChiDt; |
250 |
gezelter |
507 |
} |
251 |
gezelter |
246 |
|
252 |
tim |
963 |
void setIntegralOfChiDt(RealType integralOfChiDt) { |
253 |
gezelter |
1715 |
frameData.integralOfChiDt = integralOfChiDt; |
254 |
gezelter |
507 |
} |
255 |
gezelter |
246 |
|
256 |
gezelter |
1715 |
RealType getChiElectronic() { |
257 |
|
|
return frameData.chiQ; |
258 |
|
|
} |
259 |
gezelter |
1021 |
|
260 |
gezelter |
1715 |
void setChiElectronic(RealType chiQ) { |
261 |
|
|
frameData.chiQ = chiQ; |
262 |
|
|
} |
263 |
|
|
|
264 |
|
|
RealType getIntegralOfChiElectronicDt() { |
265 |
|
|
return frameData.integralOfChiQDt; |
266 |
|
|
} |
267 |
|
|
|
268 |
|
|
void setIntegralOfChiElectronicDt(RealType integralOfChiQDt) { |
269 |
|
|
frameData.integralOfChiQDt = integralOfChiQDt; |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
|
273 |
gezelter |
1021 |
void setOrthoTolerance(RealType orthoTolerance) { |
274 |
|
|
orthoTolerance_ = orthoTolerance; |
275 |
|
|
} |
276 |
|
|
|
277 |
gezelter |
507 |
Mat3x3d getEta() { |
278 |
gezelter |
1715 |
return frameData.eta; |
279 |
gezelter |
507 |
} |
280 |
gezelter |
246 |
|
281 |
gezelter |
507 |
void setEta(const Mat3x3d& eta) { |
282 |
gezelter |
1715 |
frameData.eta = eta; |
283 |
gezelter |
507 |
} |
284 |
gezelter |
1104 |
|
285 |
gezelter |
1709 |
Mat3x3d getTau() { |
286 |
gezelter |
1715 |
return frameData.tau; |
287 |
gezelter |
1709 |
} |
288 |
|
|
|
289 |
|
|
void setTau(const Mat3x3d& tau) { |
290 |
gezelter |
1715 |
frameData.tau = tau; |
291 |
gezelter |
1709 |
} |
292 |
|
|
|
293 |
gezelter |
1104 |
bool hasCOM() { |
294 |
|
|
return hasCOM_; |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) { |
298 |
gezelter |
1715 |
frameData.COM = COM; |
299 |
|
|
frameData.COMvel = COMvel; |
300 |
|
|
frameData.COMw = COMw; |
301 |
gezelter |
1104 |
hasCOM_ = true; |
302 |
|
|
} |
303 |
gezelter |
1540 |
|
304 |
gezelter |
507 |
DataStorage atomData; |
305 |
|
|
DataStorage rigidbodyData; |
306 |
gezelter |
1540 |
DataStorage cgData; |
307 |
gezelter |
1715 |
FrameData frameData; |
308 |
gezelter |
1541 |
Stats statData; |
309 |
gezelter |
1540 |
|
310 |
gezelter |
507 |
private: |
311 |
gezelter |
1021 |
RealType orthoTolerance_; |
312 |
gezelter |
1104 |
bool hasCOM_; |
313 |
gezelter |
1715 |
bool hasVolume_; |
314 |
gezelter |
507 |
}; |
315 |
tim |
122 |
|
316 |
gezelter |
507 |
typedef DataStorage (Snapshot::*DataStoragePointer); |
317 |
tim |
122 |
} |
318 |
|
|
#endif //BRAINS_SNAPSHOT_HPP |