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 152 by tim, Tue Oct 26 17:28:53 2004 UTC vs.
branches/development/src/brains/Snapshot.hpp (file contents), Revision 1723 by gezelter, Thu May 24 20:59:54 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 + /**
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 "math/Vector3.hpp"
57 < #include "math/SquareMatrix3.hpp"
56 > #include "brains/DataStorage.hpp"
57 > #include "brains/Stats.hpp"
58  
59 < using namespace std;
59 > namespace OpenMD{
60  
61 < namespace oopse{
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 stressTensor;     /**< stress tensor */
83 >    Mat3x3d pressureTensor;   /**< pressure tensor */
84 >    Vector3d systemDipole;    /**< total system dipole moment */
85 >    Vector3d conductiveHeatFlux; /**< heat flux vector (conductive only) */
86 >  };
87  
88  
89 <    //forward declaration
90 <    class Snapshot;
91 <    class SnapshotManager;
92 <    class StuntDouble;
89 >  /**
90 >   * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
91 >   * @brief Snapshot class is a repository class for storing dynamic data during
92 >   *  Simulation
93 >   * Every snapshot class will contain one DataStorage for atoms and one DataStorage
94 >   *  for rigid bodies.
95 >   */
96 >  class Snapshot {
97 >  public:
98 >            
99 >    Snapshot(int nAtoms, int nRigidbodies,
100 >             int nCutoffGroups) : atomData(nAtoms),
101 >                                  rigidbodyData(nRigidbodies),
102 >                                  cgData(nCutoffGroups, DataStorage::dslPosition),
103 >                                  orthoTolerance_(1e-6), hasCOM_(false), hasVolume_(false){
104 >      
105 >      frameData.id = -1;                  
106 >      frameData.currentTime = 0;    
107 >      frameData.hmat = Mat3x3d(0.0);            
108 >      frameData.invHmat = Mat3x3d(0.0);          
109 >      frameData.orthoRhombic = false;        
110 >      frameData.volume = 0.0;          
111 >      frameData.pressure = 0.0;        
112 >      frameData.totalEnergy = 0.0;    
113 >      frameData.kineticEnergy = 0.0;  
114 >      frameData.potentialEnergy = 0.0;
115 >      frameData.temperature = 0.0;    
116 >      frameData.chi = 0.0;            
117 >      frameData.integralOfChiDt = 0.0;
118 >      frameData.electronicTemperature = 0.0;
119 >      frameData.chiQ = 0.0;            
120 >      frameData.integralOfChiQDt = 0.0;
121 >      frameData.eta = Mat3x3d(0.0);              
122 >      frameData.COM = V3Zero;            
123 >      frameData.COMvel = V3Zero;          
124 >      frameData.COMw = V3Zero;            
125 >      frameData.stressTensor = Mat3x3d(0.0);              
126 >      frameData.pressureTensor = Mat3x3d(0.0);  
127 >      frameData.systemDipole = V3Zero;            
128 >      frameData.conductiveHeatFlux = V3Zero;            
129 >    }
130 >
131 >    Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
132 >             int storageLayout) : atomData(nAtoms, storageLayout),
133 >                                  rigidbodyData(nRigidbodies, storageLayout),
134 >                                  cgData(nCutoffGroups, DataStorage::dslPosition),
135 >                                  orthoTolerance_(1e-6),
136 >                                  hasCOM_(false),
137 >                                  hasVolume_(false) {
138 >      frameData.id = -1;                  
139 >      frameData.currentTime = 0;    
140 >      frameData.hmat = Mat3x3d(0.0);            
141 >      frameData.invHmat = Mat3x3d(0.0);          
142 >      frameData.orthoRhombic = false;        
143 >      frameData.volume = 0.0;          
144 >      frameData.pressure = 0.0;        
145 >      frameData.totalEnergy = 0.0;    
146 >      frameData.kineticEnergy = 0.0;  
147 >      frameData.potentialEnergy = 0.0;
148 >      frameData.temperature = 0.0;    
149 >      frameData.chi = 0.0;            
150 >      frameData.integralOfChiDt = 0.0;
151 >      frameData.electronicTemperature = 0.0;
152 >      frameData.chiQ = 0.0;            
153 >      frameData.integralOfChiQDt = 0.0;
154 >      frameData.eta = Mat3x3d(0.0);              
155 >      frameData.COM = V3Zero;            
156 >      frameData.COMvel = V3Zero;          
157 >      frameData.COMw = V3Zero;            
158 >      frameData.stressTensor = Mat3x3d(0.0);              
159 >      frameData.pressureTensor = Mat3x3d(0.0);  
160 >      frameData.systemDipole = V3Zero;            
161 >      frameData.conductiveHeatFlux = V3Zero;            
162 >    }
163      
164 <    /**
165 <     * @class DataStorage
166 <     * @warning do not try to insert element into (or ease element from) private member data
167 <     * of DataStorage directly.
56 <     */
57 <    class DataStorage {
58 <        public:
164 >    /** Returns the id of this Snapshot */
165 >    int getID() {
166 >      return frameData.id;
167 >    }
168  
169 <            enum{
170 <                slPosition = 1,
171 <                slVelocity = 2,
172 <                slAmat = 4,
64 <                slAngularMomentum = 8,
65 <                slUnitVector = 16,
66 <                slZAngle = 32,
67 <                slForce = 64,
68 <                slTorque = 128
69 <            };
70 <            
71 <            DataStorage(int size);
169 >    /** Sets the id of this Snapshot */
170 >    void setID(int id) {
171 >      frameData.id = id;
172 >    }
173  
174 <            /** return the size of this DataStorage */
175 <            int size();
176 <            void resize(int size);
76 <            void reserve(int size);
174 >    int getSize() {
175 >      return atomData.getSize() + rigidbodyData.getSize();
176 >    }
177  
178 <            void move(int source, int num, int target);
179 <            int getStorageLayout();
180 <            void setStorageLayout(int layout);
178 >    /** Returns the number of atoms */
179 >    int getNumberOfAtoms() {
180 >      return atomData.getSize();
181 >    }
182  
183 <            double *getArrayPointer(int );
183 >    /** Returns the number of rigid bodies */
184 >    int getNumberOfRigidBodies() {
185 >      return rigidbodyData.getSize();
186 >    }
187  
188 <            friend class StuntDouble;
188 >    /** Returns the number of rigid bodies */
189 >    int getNumberOfCutoffGroups() {
190 >      return cgData.getSize();
191 >    }
192  
193 <        private:
194 <            int size_;
195 <            int storageLayout_;
196 <            vector<Vector3d> position;               /** position array */
90 <            vector<Vector3d> velocity;               /** velocity array */
91 <            vector<RotMat3x3d> aMat;            /** rotation matrix array */
92 <            vector<Vector3d> angularMomentum;/** velocity array */
93 <            vector<Vector3d> unitVector;                /** the lab frame unit vector array*/
94 <            vector<double> zAngle;              /** z -angle array */        
95 <            vector<Vector3d> force;               /** force array */
96 <            vector<Vector3d> torque;               /** torque array */
97 <    };
193 >    /** Returns the H-Matrix */
194 >    Mat3x3d getHmat() {
195 >      return frameData.hmat;
196 >    }
197  
198 <    /**
199 <     * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
101 <     * @brief Snapshot class is a repository class for storing dynamic data during
102 <     *  Simulation
103 <     * Every snapshot class will contain one DataStorage  for atoms and one DataStorage
104 <     *  for rigid bodies.
105 <     * @see SimData
106 <     */
107 <    class Snapshot {
108 <        public:
198 >    /** Sets the H-Matrix */
199 >    void setHmat(const Mat3x3d& m);
200              
201 <            Snapshot(int nAtoms, int nRigidbodies) {
202 <                atomData.resize(nAtoms);
203 <                rigidbodyData.resize(nRigidbodies);
204 <            }
201 >    RealType getVolume() {
202 >      if (hasVolume_){
203 >        return frameData.volume;
204 >      }else{
205 >        return frameData.hmat.determinant();
206 >      }
207 >    }
208  
209 <            Snapshot(const Snapshot& s);
209 >    void setVolume(RealType volume){
210 >      hasVolume_=true;
211 >      frameData.volume = volume;
212 >    }
213  
214 <            Snapshot& operator =(const Snapshot& s);
215 <            
216 <            /** Returns the id of this Snapshot */
217 <            int getID() {
121 <                return id_;
122 <            }
214 >    /** Returns the inverse H-Matrix */
215 >    Mat3x3d getInvHmat() {
216 >      return frameData.invHmat;
217 >    }
218  
219 <            /** Sets the id of this Snapshot */
220 <            void setID(int id) {
221 <                id_ = id;
222 <            }
219 >    /** Wrapping the vector according to periodic boundary condition*/
220 >    void wrapVector(Vector3d& v);
221 >    /** Scaling a vector to multiples of the periodic box */
222 >    Vector3d scaleVector(Vector3d &v);
223  
129            //template<typename T>
130            //static typename T::ElemPointerType getArrayPointer(vector<T>& v) {
131            //    return v[0]->getArrayPointer();
132            //}
224  
225 <            int getSize() {
226 <                return atomData.size() + rigidbodyData.size();
227 <            }
225 >    Vector3d getCOM();
226 >    Vector3d getCOMvel();
227 >    Vector3d getCOMw();
228 >            
229 >    RealType getTime() {
230 >      return frameData.currentTime;
231 >    }
232  
233 <            /** Returns the number of atoms */
234 <            int getNumberOfAtoms() {
235 <                return atomData.size();
141 <            }
233 >    void increaseTime(RealType dt) {
234 >      setTime(getTime() + dt);
235 >    }
236  
237 <            /** Returns the number of rigid bodies */
238 <            int getNumberOfRigidBodies() {
239 <                return rigidbodyData.size();
240 <            }
237 >    void setTime(RealType time) {
238 >      frameData.currentTime =time;
239 >      //time at statData is redundant
240 >      statData[Stats::TIME] = frameData.currentTime;
241 >    }
242  
243 <            /** Returns the H-Matrix */
244 <            Mat3x3d getHmat() {
245 <                return hmat_;
151 <            }
243 >    RealType getChi() {
244 >      return frameData.chi;
245 >    }
246  
247 <            /** Sets the H-Matrix */
248 <            void setHamt(const Mat3x3d& m) {
249 <                hmat_ = m;
156 <                invHmat_ = hmat_.inverse();
157 <            }
247 >    void setChi(RealType chi) {
248 >      frameData.chi = chi;
249 >    }
250  
251 <            /** Returns the inverse H-Matrix */
252 <            Mat3x3d getInvHmat() {
253 <                return invHmat_
162 <            }
251 >    RealType getIntegralOfChiDt() {
252 >      return frameData.integralOfChiDt;
253 >    }
254  
255 <            double getTimeStamp() {
256 <                return timeStamp_;
257 <            }
255 >    void setIntegralOfChiDt(RealType integralOfChiDt) {
256 >      frameData.integralOfChiDt = integralOfChiDt;
257 >    }
258 >            
259 >    RealType getChiElectronic() {
260 >      return frameData.chiQ;
261 >    }
262  
263 <            void setTimeStamp(double timeStamp) {
264 <                timeStamp_ =timeStamp;
265 <            }
263 >    void setChiElectronic(RealType chiQ) {
264 >      frameData.chiQ = chiQ;
265 >    }
266  
267 +    RealType getIntegralOfChiElectronicDt() {
268 +      return frameData.integralOfChiQDt;
269 +    }
270  
271 <            DataStorage atomData;
272 <            DataStorage rigidbodyData;
271 >    void setIntegralOfChiElectronicDt(RealType integralOfChiQDt) {
272 >      frameData.integralOfChiQDt = integralOfChiQDt;
273 >    }
274              
176            friend class StuntDouble;
177            
178        private:
179            double timeStamp_;
180            Mat3x3d hmat_;
181            Mat3x3d invHmat_;
182            int id_; /**< identification number of the snapshot */
183    };
275  
276 <    typedef DataStorage (Snapshot::*DataStoragePointer);
276 >    void setOrthoTolerance(RealType orthoTolerance) {
277 >      orthoTolerance_ = orthoTolerance;
278 >    }
279 >
280 >    Mat3x3d getEta() {
281 >      return frameData.eta;
282 >    }
283 >
284 >    void setEta(const Mat3x3d& eta) {
285 >      frameData.eta = eta;
286 >    }
287 >
288 >    Mat3x3d getStressTensor() {
289 >      return frameData.stressTensor;
290 >    }
291 >        
292 >    void setStressTensor(const Mat3x3d& stressTensor) {
293 >      frameData.stressTensor = stressTensor;
294 >    }
295 >
296 >    Vector3d getConductiveHeatFlux() {
297 >      return frameData.conductiveHeatFlux;
298 >    }
299 >        
300 >    void setConductiveHeatFlux(const Vector3d& heatFlux) {
301 >      frameData.conductiveHeatFlux = heatFlux;
302 >    }
303 >
304 >    bool hasCOM() {
305 >      return hasCOM_;
306 >    }
307 >
308 >    void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) {
309 >      frameData.COM = COM;
310 >      frameData.COMvel = COMvel;
311 >      frameData.COMw = COMw;
312 >      hasCOM_ = true;
313 >    }
314 >
315 >    DataStorage atomData;
316 >    DataStorage rigidbodyData;
317 >    DataStorage cgData;
318 >    FrameData frameData;
319 >    Stats statData;
320 >
321 >  private:
322 >    RealType orthoTolerance_;
323 >    bool hasCOM_;
324 >    bool hasVolume_;    
325 >  };
326 >
327 >  typedef DataStorage (Snapshot::*DataStoragePointer);
328   }
329   #endif //BRAINS_SNAPSHOT_HPP

Comparing:
trunk/src/brains/Snapshot.hpp (property svn:keywords), Revision 152 by tim, Tue Oct 26 17:28:53 2004 UTC vs.
branches/development/src/brains/Snapshot.hpp (property svn:keywords), Revision 1723 by gezelter, Thu May 24 20:59:54 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines