ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/Snapshot.hpp
Revision: 1715
Committed: Tue May 22 21:55:31 2012 UTC (12 years, 11 months ago) by gezelter
File size: 10571 byte(s)
Log Message:
Adding more support structure for Fluctuating Charges.

File Contents

# Content
1 /*
2 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 *
4 * 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 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * 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 *
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 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 */
42
43 /**
44 * @file Snapshot.hpp
45 * @author tlin
46 * @date 10/20/2004
47 * @time 23:56am
48 * @version 1.0
49 */
50
51 #ifndef BRAINS_SNAPSHOT_HPP
52 #define BRAINS_SNAPSHOT_HPP
53
54 #include <vector>
55
56 #include "brains/DataStorage.hpp"
57 #include "brains/Stats.hpp"
58
59 namespace OpenMD{
60
61 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 /**
89 * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
90 * @brief Snapshot class is a repository class for storing dynamic data during
91 * Simulation
92 * Every snapshot class will contain one DataStorage for atoms and one DataStorage
93 * for rigid bodies.
94 */
95 class Snapshot {
96 public:
97
98 Snapshot(int nAtoms, int nRigidbodies,
99 int nCutoffGroups) : atomData(nAtoms),
100 rigidbodyData(nRigidbodies),
101 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 }
128
129 Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
130 int storageLayout) : atomData(nAtoms, storageLayout),
131 rigidbodyData(nRigidbodies, storageLayout),
132 cgData(nCutoffGroups, DataStorage::dslPosition),
133 orthoTolerance_(1e-6),
134 hasCOM_(false),
135 hasVolume_(false) {
136 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 }
160
161 /** Returns the id of this Snapshot */
162 int getID() {
163 return frameData.id;
164 }
165
166 /** Sets the id of this Snapshot */
167 void setID(int id) {
168 frameData.id = id;
169 }
170
171 int getSize() {
172 return atomData.getSize() + rigidbodyData.getSize();
173 }
174
175 /** Returns the number of atoms */
176 int getNumberOfAtoms() {
177 return atomData.getSize();
178 }
179
180 /** Returns the number of rigid bodies */
181 int getNumberOfRigidBodies() {
182 return rigidbodyData.getSize();
183 }
184
185 /** Returns the number of rigid bodies */
186 int getNumberOfCutoffGroups() {
187 return cgData.getSize();
188 }
189
190 /** Returns the H-Matrix */
191 Mat3x3d getHmat() {
192 return frameData.hmat;
193 }
194
195 /** Sets the H-Matrix */
196 void setHmat(const Mat3x3d& m);
197
198 RealType getVolume() {
199 if (hasVolume_){
200 return frameData.volume;
201 }else{
202 return frameData.hmat.determinant();
203 }
204 }
205
206 void setVolume(RealType volume){
207 hasVolume_=true;
208 frameData.volume = volume;
209 }
210
211 /** Returns the inverse H-Matrix */
212 Mat3x3d getInvHmat() {
213 return frameData.invHmat;
214 }
215
216 /** Wrapping the vector according to periodic boundary condition*/
217 void wrapVector(Vector3d& v);
218 /** Scaling a vector to multiples of the periodic box */
219 Vector3d scaleVector(Vector3d &v);
220
221
222 Vector3d getCOM();
223 Vector3d getCOMvel();
224 Vector3d getCOMw();
225
226 RealType getTime() {
227 return frameData.currentTime;
228 }
229
230 void increaseTime(RealType dt) {
231 setTime(getTime() + dt);
232 }
233
234 void setTime(RealType time) {
235 frameData.currentTime =time;
236 //time at statData is redundant
237 statData[Stats::TIME] = frameData.currentTime;
238 }
239
240 RealType getChi() {
241 return frameData.chi;
242 }
243
244 void setChi(RealType chi) {
245 frameData.chi = chi;
246 }
247
248 RealType getIntegralOfChiDt() {
249 return frameData.integralOfChiDt;
250 }
251
252 void setIntegralOfChiDt(RealType integralOfChiDt) {
253 frameData.integralOfChiDt = integralOfChiDt;
254 }
255
256 RealType getChiElectronic() {
257 return frameData.chiQ;
258 }
259
260 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 void setOrthoTolerance(RealType orthoTolerance) {
274 orthoTolerance_ = orthoTolerance;
275 }
276
277 Mat3x3d getEta() {
278 return frameData.eta;
279 }
280
281 void setEta(const Mat3x3d& eta) {
282 frameData.eta = eta;
283 }
284
285 Mat3x3d getTau() {
286 return frameData.tau;
287 }
288
289 void setTau(const Mat3x3d& tau) {
290 frameData.tau = tau;
291 }
292
293 bool hasCOM() {
294 return hasCOM_;
295 }
296
297 void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) {
298 frameData.COM = COM;
299 frameData.COMvel = COMvel;
300 frameData.COMw = COMw;
301 hasCOM_ = true;
302 }
303
304 DataStorage atomData;
305 DataStorage rigidbodyData;
306 DataStorage cgData;
307 FrameData frameData;
308 Stats statData;
309
310 private:
311 RealType orthoTolerance_;
312 bool hasCOM_;
313 bool hasVolume_;
314 };
315
316 typedef DataStorage (Snapshot::*DataStoragePointer);
317 }
318 #endif //BRAINS_SNAPSHOT_HPP

Properties

Name Value
svn:keywords Author Id Revision Date