ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/Snapshot.hpp
(Generate patch)

Comparing:
trunk/src/brains/Snapshot.hpp (file contents), Revision 146 by tim, Fri Oct 22 23:09:57 2004 UTC vs.
branches/development/src/brains/Snapshot.hpp (file contents), Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright (C) 2000-2004  Object Oriented Parallel Simulation Engine (OOPSE) project
3 < *
4 < * Contact: oopse@oopse.org
5 < *
6 < * This program is free software; you can redistribute it and/or
7 < * modify it under the terms of the GNU Lesser General Public License
8 < * as published by the Free Software Foundation; either version 2.1
9 < * of the License, or (at your option) any later version.
10 < * All we ask is that proper credit is given for our work, which includes
11 < * - but is not limited to - adding the above copyright notice to the beginning
12 < * of your source code files, and to any copyright notice that you may distribute
13 < * with programs based on this work.
14 < *
15 < * This program is distributed in the hope that it will be useful,
16 < * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 < * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 < * GNU Lesser General Public License for more details.
19 < *
20 < * You should have received a copy of the GNU Lesser General Public License
21 < * along with this program; if not, write to the Free Software
22 < * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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   */
25
26 /**
27  * @file Snapshot.hpp
28  * @author tlin
29  * @date 10/20/2004
30  * @time 23:56am
31  * @version 1.0
32  */
42    
43   #ifndef BRAINS_SNAPSHOT_HPP
44   #define BRAINS_SNAPSHOT_HPP
45  
46   #include <vector>
47  
48 < #include "math/Vector3.hpp"
49 < #include "math/SquareMatrix3.hpp"
48 > #include "brains/DataStorage.hpp"
49 > #include "nonbonded/NonBondedInteraction.hpp"
50 > #include "brains/Stats.hpp"
51  
52 < using namespace std;
52 > namespace OpenMD{
53  
54 < namespace oopse{
54 >  /**
55 >   * FrameData is a structure for holding system-wide dynamic data
56 >   * about the simulation.
57 >   */
58 >  
59 >  struct FrameData {
60 >    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 >    RealType shortRangePotential; /**< short-range contributions to the potential*/
71 >    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 >    RealType electronicTemperature; /**< temperature of the electronic degrees of freedom */
84 >    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 >  };
95  
46    //forward declaration
47    class Snapshot;
48    class SnapshotManager;
96  
97 <    /**
98 <     * @struct DataStorage
99 <     * @brief
100 <     */
101 <    class DataStorage {
102 <        public:
103 <            DataStorage() {};
104 <            DataStorage(size_t size);
58 <            void resize(size_t size);
59 <            void reserve(size_t size);
60 <            
61 <        //friend Snapshot;
62 <        //friend SnapshotManager;
63 <        //private:
64 <            vector<Vector3d> position;               /** position array */
65 <            vector<Vector3d> velocity;               /** velocity array */
66 <            vector<RotMat3x3d> Amat;            /** rotation matrix array */
67 <            vector<Vector3d> angularMomentum;/** velocity array */
68 <            vector<Vector3d> ul;                /** the lab frame unit vector array*/
69 <            vector<double> zAngle;              /** z -angle array */        
70 <            vector<Vector3d> force;               /** force array */
71 <            vector<Vector3d> torque;               /** torque array */
97 >  /**
98 >   * @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 >   */
104 >  class Snapshot {
105  
106 <    };
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 >      
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 >      frameData.stressTensor = Mat3x3d(0.0);              
140 >      frameData.pressureTensor = Mat3x3d(0.0);  
141 >      frameData.systemDipole = Vector3d(0.0);            
142 >      frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
143 >    }
144  
145 <    /**
146 <     * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
147 <     * @brief Snapshot class is a repository class for storing dynamic data during
148 <     *  Simulation
149 <     * Every snapshot class will contain one DataStorage  for atoms and one DataStorage
150 <     *  for rigid bodies.
151 <     * @see SimData
152 <     */
153 <    class Snapshot {
154 <        public:
155 <            
156 <            Snapshot() {}
87 <            Snapshot(int i) {
145 >    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 <            }
158 >      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 >      frameData.stressTensor = Mat3x3d(0.0);              
179 >      frameData.pressureTensor = Mat3x3d(0.0);  
180 >      frameData.systemDipole = V3Zero;            
181 >      frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);            
182 >    }
183 >    
184 >    /** Returns the id of this Snapshot */
185 >    int getID() {
186 >      return frameData.id;
187 >    }
188  
189 <            Snapshot(const Snapshot& s);
189 >    /** Sets the id of this Snapshot */
190 >    void setID(int id) {
191 >      frameData.id = id;
192 >    }
193  
194 <            Snapshot& operator =(const Snapshot& s);
195 <            
196 <            /** Returns the id of this Snapshot */
96 <            int getID() {
97 <                return id_;
98 <            }
194 >    int getSize() {
195 >      return atomData.getSize() + rigidbodyData.getSize();
196 >    }
197  
198 <            /** Sets the id of this Snapshot */
199 <            void setID(int id) {
200 <                id_ = id;
201 <            }
198 >    /** Returns the number of atoms */
199 >    int getNumberOfAtoms() {
200 >      return atomData.getSize();
201 >    }
202  
203 <            //template<typename T>
204 <            //static typename T::ElemPointerType getArrayPointer(vector<T>& v) {
205 <            //    return v[0]->getArrayPointer();
206 <            //}
203 >    /** Returns the number of rigid bodies */
204 >    int getNumberOfRigidBodies() {
205 >      return rigidbodyData.getSize();
206 >    }
207  
208 <            static double* getArrayPointer(vector<Vector3d>& v) {
209 <                assert(v.size() > 0);
210 <                return v[0].getArrayPointer();
211 <            }
208 >    /** Returns the number of rigid bodies */
209 >    int getNumberOfCutoffGroups() {
210 >      return cgData.getSize();
211 >    }
212 >
213 >    /** Returns the H-Matrix */
214 >    Mat3x3d getHmat() {
215 >      return frameData.hmat;
216 >    }
217 >
218 >    /** Sets the H-Matrix */
219 >    void setHmat(const Mat3x3d& m);
220              
221 <            static double* getArrayPointer(vector<RotMat3x3d>& v) {
222 <                assert(v.size() > 0);
223 <                return v[0].getArrayPointer();
224 <            }
221 >    RealType getVolume() {
222 >      if (!hasVolume_) {
223 >        frameData.volume = frameData.hmat.determinant();
224 >        hasVolume_ = true;
225 >      }
226 >      return frameData.volume;
227 >    }
228 >
229 >    void setVolume(RealType volume){
230 >      hasVolume_=true;
231 >      frameData.volume = volume;
232 >    }
233 >
234 >    /** Returns the inverse H-Matrix */
235 >    Mat3x3d getInvHmat() {
236 >      return frameData.invHmat;
237 >    }
238 >
239 >    /** Wrapping the vector according to periodic boundary condition*/
240 >    void wrapVector(Vector3d& v);
241 >    /** Scaling a vector to multiples of the periodic box */
242 >    Vector3d scaleVector(Vector3d &v);
243 >
244 >
245 >    Vector3d getCOM();
246 >    Vector3d getCOMvel();
247 >    Vector3d getCOMw();
248              
249 <            static double* getArrayPointer(vector<double>& v) {
250 <                assert(v.size() > 0);
251 <                return &(v[0]);
252 <            }
249 >    RealType getTime() {
250 >      return frameData.currentTime;
251 >    }
252 >
253 >    void increaseTime(RealType dt) {
254 >      setTime(getTime() + dt);
255 >    }
256 >
257 >    void setTime(RealType time) {
258 >      frameData.currentTime =time;
259 >      //time at statData is redundant
260 >      statData[Stats::TIME] = frameData.currentTime;
261 >    }
262 >
263 >    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 >    RealType getChi() {
351 >      return frameData.chi;
352 >    }
353 >
354 >    void setChi(RealType chi) {
355 >      frameData.chi = chi;
356 >    }
357 >
358 >    RealType getIntegralOfChiDt() {
359 >      return frameData.integralOfChiDt;
360 >    }
361 >
362 >    void setIntegralOfChiDt(RealType integralOfChiDt) {
363 >      frameData.integralOfChiDt = integralOfChiDt;
364 >    }
365              
366 <            /** */
367 <            void resize(size_t size);
366 >    RealType getChiElectronic() {
367 >      return frameData.chiQ;
368 >    }
369  
370 +    void setChiElectronic(RealType chiQ) {
371 +      frameData.chiQ = chiQ;
372 +    }
373  
374 <            /** */
375 <            void reserve(size_t size);
374 >    RealType getIntegralOfChiElectronicDt() {
375 >      return frameData.integralOfChiQDt;
376 >    }
377  
378 <            DataStorage atomData;
379 <            DataStorage rigidbodyData;
378 >    void setIntegralOfChiElectronicDt(RealType integralOfChiQDt) {
379 >      frameData.integralOfChiQDt = integralOfChiQDt;
380 >    }
381  
382 <            friend class SnapshotManager;
383 <        private:
382 >    void setOrthoTolerance(RealType orthoTolerance) {
383 >      orthoTolerance_ = orthoTolerance;
384 >    }
385  
386 <            int id_; /**< identification number of the snapshot */
387 <    };
386 >    Mat3x3d getEta() {
387 >      return frameData.eta;
388 >    }
389  
390 <    typedef DataStorage* (Snapshot::*DataStoragePointer);
390 >    void setEta(const Mat3x3d& eta) {
391 >      frameData.eta = eta;
392 >    }
393 >
394 >    Mat3x3d getStressTensor() {
395 >      return frameData.stressTensor;
396 >    }
397 >        
398 >    void setStressTensor(const Mat3x3d& stressTensor) {
399 >      frameData.stressTensor = stressTensor;
400 >    }
401 >
402 >    Vector3d getConductiveHeatFlux() {
403 >      return frameData.conductiveHeatFlux;
404 >    }
405 >        
406 >    void setConductiveHeatFlux(const Vector3d& heatFlux) {
407 >      frameData.conductiveHeatFlux = heatFlux;
408 >    }
409 >
410 >    bool hasCOM() {
411 >      return hasCOM_;
412 >    }
413 >
414 >    void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) {
415 >      frameData.COM = COM;
416 >      frameData.COMvel = COMvel;
417 >      frameData.COMw = COMw;
418 >      hasCOM_ = true;
419 >    }
420 >
421 >    DataStorage atomData;
422 >    DataStorage rigidbodyData;
423 >    DataStorage cgData;
424 >    FrameData frameData;
425 >    Stats statData;
426 >
427 >  private:
428 >    RealType orthoTolerance_;
429 >    bool hasCOM_;
430 >    bool hasVolume_;    
431 >    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 >  };
442 >
443 >  typedef DataStorage (Snapshot::*DataStoragePointer);
444   }
445   #endif //BRAINS_SNAPSHOT_HPP

Comparing:
trunk/src/brains/Snapshot.hpp (property svn:keywords), Revision 146 by tim, Fri Oct 22 23:09:57 2004 UTC vs.
branches/development/src/brains/Snapshot.hpp (property svn:keywords), Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines