ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/Snapshot.hpp
Revision: 1760
Committed: Thu Jun 21 19:26:46 2012 UTC (12 years, 10 months ago) by gezelter
File size: 15598 byte(s)
Log Message:
Some bugfixes (CholeskyDecomposition), more work on fluctuating charges,
migrating stats stuff into frameData

File Contents

# User Rev Content
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 tim 122 #ifndef BRAINS_SNAPSHOT_HPP
44     #define BRAINS_SNAPSHOT_HPP
45 tim 137
46     #include <vector>
47    
48 tim 155 #include "brains/DataStorage.hpp"
49 gezelter 1757 #include "nonbonded/NonBondedInteraction.hpp"
50 gezelter 246 #include "brains/Stats.hpp"
51 tim 137
52 gezelter 1390 namespace OpenMD{
53 tim 122
54 gezelter 1760 /**
55     * FrameData is a structure for holding system-wide dynamic data
56     * about the simulation.
57     */
58    
59 gezelter 1715 struct FrameData {
60 gezelter 1760 int id; /**< identification number of the snapshot */
61     RealType currentTime; /**< current time */
62     Mat3x3d hmat; /**< axes of the periodic box in matrix form */
63     Mat3x3d invHmat; /**< the inverse of the Hmat matrix */
64     bool orthoRhombic; /**< is this an orthorhombic periodic box? */
65     RealType volume; /**< total volume of this frame */
66     RealType pressure; /**< pressure of this frame */
67     RealType totalEnergy; /**< total energy of this frame */
68     RealType kineticEnergy; /**< kinetic energy of this frame */
69     RealType potentialEnergy; /**< potential energy of this frame */
70 gezelter 1757 RealType shortRangePotential; /**< short-range contributions to the potential*/
71 gezelter 1760 RealType longRangePotential; /**< long-range contributions to the potential */
72     RealType bondPotential; /**< bonded contribution to the potential */
73     RealType bendPotential; /**< angle-bending contribution to the potential */
74     RealType torsionPotential; /**< dihedral (torsion angle) contribution to the potential */
75     RealType inversionPotential; /**< inversion (planarity) contribution to the potential */
76     potVec lrPotentials; /**< breakdown of long-range potentials by family */
77     potVec excludedPotentials; /**< breakdown of excluded potentials by family */
78     RealType restraintPotential; /**< potential energy of restraints */
79     RealType rawPotential; /**< unrestrained potential energy (when restraints are applied) */
80     RealType temperature; /**< temperature of this frame */
81     RealType chi; /**< thermostat velocity */
82     RealType integralOfChiDt; /**< thermostat position */
83 gezelter 1715 RealType electronicTemperature; /**< temperature of the electronic degrees of freedom */
84 gezelter 1760 RealType chiQ; /**< fluctuating charge thermostat velocity */
85     RealType integralOfChiQDt; /**< fluctuating charge thermostat position */
86     Mat3x3d eta; /**< barostat matrix */
87     Vector3d COM; /**< location of system center of mass */
88     Vector3d COMvel; /**< system center of mass velocity */
89     Vector3d COMw; /**< system center of mass angular velocity */
90     Mat3x3d stressTensor; /**< stress tensor */
91     Mat3x3d pressureTensor; /**< pressure tensor */
92     Vector3d systemDipole; /**< total system dipole moment */
93     Vector3d conductiveHeatFlux; /**< heat flux vector (conductive only) */
94 gezelter 1715 };
95    
96    
97 gezelter 507 /**
98 gezelter 1760 * @class Snapshot
99     * @brief The Snapshot class is a repository storing dynamic data during a
100     * Simulation. Every Snapshot contains FrameData (for global information)
101     * as well as DataStorage (one for Atoms, one for RigidBodies, and one for
102     * CutoffGroups).
103 gezelter 507 */
104     class Snapshot {
105 gezelter 1760
106     public:
107     Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups) :
108     atomData(nAtoms), rigidbodyData(nRigidbodies),
109     cgData(nCutoffGroups, DataStorage::dslPosition),
110     orthoTolerance_(1e-6), hasCOM_(false), hasVolume_(false),
111     hasShortRangePotential_(false),
112     hasBondPotential_(false), hasBendPotential_(false),
113     hasTorsionPotential_(false), hasInversionPotential_(false),
114     hasLongRangePotential_(false), hasLongRangePotentialFamilies_(false),
115     hasRestraintPotential_(false), hasRawPotential_(false),
116     hasExcludedPotentials_(false)
117     {
118 gezelter 1715
119     frameData.id = -1;
120     frameData.currentTime = 0;
121     frameData.hmat = Mat3x3d(0.0);
122     frameData.invHmat = Mat3x3d(0.0);
123     frameData.orthoRhombic = false;
124     frameData.volume = 0.0;
125     frameData.pressure = 0.0;
126     frameData.totalEnergy = 0.0;
127     frameData.kineticEnergy = 0.0;
128     frameData.potentialEnergy = 0.0;
129     frameData.temperature = 0.0;
130     frameData.chi = 0.0;
131     frameData.integralOfChiDt = 0.0;
132     frameData.electronicTemperature = 0.0;
133     frameData.chiQ = 0.0;
134     frameData.integralOfChiQDt = 0.0;
135     frameData.eta = Mat3x3d(0.0);
136     frameData.COM = V3Zero;
137     frameData.COMvel = V3Zero;
138     frameData.COMw = V3Zero;
139 gezelter 1723 frameData.stressTensor = Mat3x3d(0.0);
140 gezelter 1715 frameData.pressureTensor = Mat3x3d(0.0);
141 gezelter 1744 frameData.systemDipole = Vector3d(0.0);
142     frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
143 gezelter 507 }
144 tim 137
145 gezelter 1760 Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, int storageLayout) :
146     atomData(nAtoms, storageLayout),
147     rigidbodyData(nRigidbodies, storageLayout),
148     cgData(nCutoffGroups, DataStorage::dslPosition),
149     orthoTolerance_(1e-6), hasCOM_(false), hasVolume_(false),
150     hasShortRangePotential_(false),
151     hasBondPotential_(false), hasBendPotential_(false),
152     hasTorsionPotential_(false), hasInversionPotential_(false),
153     hasLongRangePotential_(false), hasLongRangePotentialFamilies_(false),
154     hasRestraintPotential_(false), hasRawPotential_(false),
155     hasExcludedPotentials_(false)
156     {
157    
158 gezelter 1715 frameData.id = -1;
159     frameData.currentTime = 0;
160     frameData.hmat = Mat3x3d(0.0);
161     frameData.invHmat = Mat3x3d(0.0);
162     frameData.orthoRhombic = false;
163     frameData.volume = 0.0;
164     frameData.pressure = 0.0;
165     frameData.totalEnergy = 0.0;
166     frameData.kineticEnergy = 0.0;
167     frameData.potentialEnergy = 0.0;
168     frameData.temperature = 0.0;
169     frameData.chi = 0.0;
170     frameData.integralOfChiDt = 0.0;
171     frameData.electronicTemperature = 0.0;
172     frameData.chiQ = 0.0;
173     frameData.integralOfChiQDt = 0.0;
174     frameData.eta = Mat3x3d(0.0);
175     frameData.COM = V3Zero;
176     frameData.COMvel = V3Zero;
177     frameData.COMw = V3Zero;
178 gezelter 1723 frameData.stressTensor = Mat3x3d(0.0);
179 gezelter 1715 frameData.pressureTensor = Mat3x3d(0.0);
180     frameData.systemDipole = V3Zero;
181 gezelter 1744 frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
182 gezelter 1540 }
183    
184 gezelter 507 /** Returns the id of this Snapshot */
185     int getID() {
186 gezelter 1715 return frameData.id;
187 gezelter 507 }
188 tim 137
189 gezelter 507 /** Sets the id of this Snapshot */
190     void setID(int id) {
191 gezelter 1715 frameData.id = id;
192 gezelter 507 }
193 tim 137
194 gezelter 507 int getSize() {
195     return atomData.getSize() + rigidbodyData.getSize();
196     }
197 tim 152
198 gezelter 507 /** Returns the number of atoms */
199     int getNumberOfAtoms() {
200     return atomData.getSize();
201     }
202 tim 152
203 gezelter 507 /** Returns the number of rigid bodies */
204     int getNumberOfRigidBodies() {
205     return rigidbodyData.getSize();
206     }
207 tim 152
208 gezelter 1544 /** Returns the number of rigid bodies */
209     int getNumberOfCutoffGroups() {
210     return cgData.getSize();
211     }
212    
213 gezelter 507 /** Returns the H-Matrix */
214     Mat3x3d getHmat() {
215 gezelter 1715 return frameData.hmat;
216 gezelter 507 }
217 tim 152
218 gezelter 507 /** Sets the H-Matrix */
219     void setHmat(const Mat3x3d& m);
220 gezelter 246
221 tim 963 RealType getVolume() {
222 gezelter 1760 if (!hasVolume_) {
223     frameData.volume = frameData.hmat.determinant();
224     hasVolume_ = true;
225 chuckv 1302 }
226 gezelter 1760 return frameData.volume;
227 gezelter 507 }
228 tim 152
229 chuckv 1302 void setVolume(RealType volume){
230     hasVolume_=true;
231 gezelter 1715 frameData.volume = volume;
232 chuckv 1302 }
233    
234 gezelter 507 /** Returns the inverse H-Matrix */
235     Mat3x3d getInvHmat() {
236 gezelter 1715 return frameData.invHmat;
237 gezelter 507 }
238 tim 152
239 gezelter 507 /** Wrapping the vector according to periodic boundary condition*/
240     void wrapVector(Vector3d& v);
241 gezelter 1562 /** Scaling a vector to multiples of the periodic box */
242     Vector3d scaleVector(Vector3d &v);
243    
244    
245 gezelter 1104 Vector3d getCOM();
246     Vector3d getCOMvel();
247     Vector3d getCOMw();
248 gezelter 246
249 tim 963 RealType getTime() {
250 gezelter 1715 return frameData.currentTime;
251 gezelter 507 }
252 tim 152
253 tim 963 void increaseTime(RealType dt) {
254 gezelter 507 setTime(getTime() + dt);
255     }
256 tim 152
257 tim 963 void setTime(RealType time) {
258 gezelter 1715 frameData.currentTime =time;
259 gezelter 507 //time at statData is redundant
260 gezelter 1715 statData[Stats::TIME] = frameData.currentTime;
261 gezelter 507 }
262 tim 152
263 gezelter 1760 void setShortRangePotential(RealType srp) {
264     frameData.shortRangePotential = srp;
265     hasShortRangePotential_ = true;
266     statData[Stats::SHORT_RANGE_POTENTIAL] = frameData.shortRangePotential;
267     }
268    
269     RealType getShortRangePotential() {
270     return frameData.shortRangePotential;
271     }
272    
273     void setBondPotential(RealType bp) {
274     frameData.bondPotential = bp;
275     hasBondPotential_ = true;
276     statData[Stats::BOND_POTENTIAL] = frameData.bondPotential;
277     }
278    
279     void setBendPotential(RealType bp) {
280     frameData.bendPotential = bp;
281     hasBendPotential_ = true;
282     statData[Stats::BEND_POTENTIAL] = frameData.bendPotential;
283     }
284    
285     void setTorsionPotential(RealType tp) {
286     frameData.torsionPotential = tp;
287     hasTorsionPotential_ = true;
288     statData[Stats::DIHEDRAL_POTENTIAL] = frameData.torsionPotential;
289     }
290    
291     void setInversionPotential(RealType ip) {
292     frameData.inversionPotential = ip;
293     hasInversionPotential_ = true;
294     statData[Stats::INVERSION_POTENTIAL] = frameData.inversionPotential;
295     }
296    
297     void setLongRangePotential(RealType lrp) {
298     frameData.longRangePotential = lrp;
299     hasLongRangePotential_ = true;
300     statData[Stats::LONG_RANGE_POTENTIAL] = frameData.longRangePotential;
301     }
302    
303     RealType getLongRangePotential() {
304     return frameData.longRangePotential;
305     }
306    
307     void setLongRangePotentialFamilies(potVec lrPot) {
308     frameData.lrPotentials = lrPot;
309     hasLongRangePotentialFamilies_ = true;
310     statData[Stats::VANDERWAALS_POTENTIAL] = frameData.lrPotentials[VANDERWAALS_FAMILY];
311     statData[Stats::ELECTROSTATIC_POTENTIAL] = frameData.lrPotentials[ELECTROSTATIC_FAMILY];
312     statData[Stats::METALLIC_POTENTIAL] = frameData.lrPotentials[METALLIC_FAMILY];
313     statData[Stats::HYDROGENBONDING_POTENTIAL] = frameData.lrPotentials[HYDROGENBONDING_FAMILY];
314     }
315    
316     potVec getLongRangePotentials() {
317     return frameData.lrPotentials;
318     }
319    
320     void setExcludedPotentials(potVec exPot) {
321     frameData.excludedPotentials = exPot;
322     hasExcludedPotentials_ = true;
323     }
324    
325     potVec getExcludedPotentials() {
326     return frameData.excludedPotentials;
327     }
328    
329    
330     void setRestraintPotential(RealType rp) {
331     frameData.restraintPotential = rp;
332     hasRestraintPotential_ = true;
333     statData[Stats::RESTRAINT_POTENTIAL] = frameData.restraintPotential;
334     }
335    
336     RealType getRestraintPotential() {
337     return frameData.restraintPotential;
338     }
339    
340     void setRawPotential(RealType rp) {
341     frameData.rawPotential = rp;
342     hasRawPotential_ = true;
343     statData[Stats::RAW_POTENTIAL] = frameData.rawPotential;
344     }
345    
346     RealType getRawPotential() {
347     return frameData.rawPotential;
348     }
349    
350 tim 963 RealType getChi() {
351 gezelter 1715 return frameData.chi;
352 gezelter 507 }
353 gezelter 246
354 tim 963 void setChi(RealType chi) {
355 gezelter 1715 frameData.chi = chi;
356 gezelter 507 }
357 gezelter 246
358 tim 963 RealType getIntegralOfChiDt() {
359 gezelter 1715 return frameData.integralOfChiDt;
360 gezelter 507 }
361 gezelter 246
362 tim 963 void setIntegralOfChiDt(RealType integralOfChiDt) {
363 gezelter 1715 frameData.integralOfChiDt = integralOfChiDt;
364 gezelter 507 }
365 gezelter 246
366 gezelter 1715 RealType getChiElectronic() {
367     return frameData.chiQ;
368     }
369 gezelter 1021
370 gezelter 1715 void setChiElectronic(RealType chiQ) {
371     frameData.chiQ = chiQ;
372     }
373    
374     RealType getIntegralOfChiElectronicDt() {
375     return frameData.integralOfChiQDt;
376     }
377    
378     void setIntegralOfChiElectronicDt(RealType integralOfChiQDt) {
379     frameData.integralOfChiQDt = integralOfChiQDt;
380     }
381    
382 gezelter 1021 void setOrthoTolerance(RealType orthoTolerance) {
383     orthoTolerance_ = orthoTolerance;
384     }
385    
386 gezelter 507 Mat3x3d getEta() {
387 gezelter 1715 return frameData.eta;
388 gezelter 507 }
389 gezelter 246
390 gezelter 507 void setEta(const Mat3x3d& eta) {
391 gezelter 1715 frameData.eta = eta;
392 gezelter 507 }
393 gezelter 1104
394 gezelter 1723 Mat3x3d getStressTensor() {
395     return frameData.stressTensor;
396 gezelter 1709 }
397    
398 gezelter 1723 void setStressTensor(const Mat3x3d& stressTensor) {
399     frameData.stressTensor = stressTensor;
400 gezelter 1709 }
401    
402 gezelter 1723 Vector3d getConductiveHeatFlux() {
403     return frameData.conductiveHeatFlux;
404     }
405    
406     void setConductiveHeatFlux(const Vector3d& heatFlux) {
407     frameData.conductiveHeatFlux = heatFlux;
408     }
409    
410 gezelter 1104 bool hasCOM() {
411     return hasCOM_;
412     }
413    
414     void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) {
415 gezelter 1715 frameData.COM = COM;
416     frameData.COMvel = COMvel;
417     frameData.COMw = COMw;
418 gezelter 1104 hasCOM_ = true;
419     }
420 gezelter 1540
421 gezelter 507 DataStorage atomData;
422     DataStorage rigidbodyData;
423 gezelter 1540 DataStorage cgData;
424 gezelter 1715 FrameData frameData;
425 gezelter 1541 Stats statData;
426 gezelter 1540
427 gezelter 507 private:
428 gezelter 1021 RealType orthoTolerance_;
429 gezelter 1104 bool hasCOM_;
430 gezelter 1715 bool hasVolume_;
431 gezelter 1760 bool hasShortRangePotential_;
432     bool hasBondPotential_;
433     bool hasBendPotential_;
434     bool hasTorsionPotential_;
435     bool hasInversionPotential_;
436     bool hasLongRangePotential_;
437     bool hasLongRangePotentialFamilies_;
438     bool hasRestraintPotential_;
439     bool hasRawPotential_;
440     bool hasExcludedPotentials_;
441 gezelter 507 };
442 tim 122
443 gezelter 507 typedef DataStorage (Snapshot::*DataStoragePointer);
444 tim 122 }
445     #endif //BRAINS_SNAPSHOT_HPP

Properties

Name Value
svn:keywords Author Id Revision Date