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 1715 by gezelter, Tue May 22 21:55:31 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 tau;              /**< stress tensor */
83 >    Mat3x3d pressureTensor;   /**< pressure tensor */
84 >    Vector3d systemDipole;    /**< total system dipole moment */
85 >  };
86  
46    //forward declaration
47    class Snapshot;
48    class SnapshotManager;
87  
88 <    /**
89 <     * @struct DataStorage
90 <     * @brief
91 <     */
92 <    class DataStorage {
93 <        public:
94 <            DataStorage() {};
95 <            DataStorage(size_t size);
96 <            void resize(size_t size);
59 <            void reserve(size_t size);
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 <        //friend Snapshot;
99 <        //friend SnapshotManager;
100 <        //private:
101 <            vector<Vector3d> position;               /** position array */
102 <            vector<Vector3d> velocity;               /** velocity array */
103 <            vector<RotMat3x3d> Amat;            /** rotation matrix array */
104 <            vector<Vector3d> angularMomentum;/** velocity array */
105 <            vector<Vector3d> ul;                /** the lab frame unit vector array*/
106 <            vector<double> zAngle;              /** z -angle array */        
107 <            vector<Vector3d> force;               /** force array */
108 <            vector<Vector3d> torque;               /** torque array */
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 <    };
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 <    /**
167 <     * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
168 <     * @brief Snapshot class is a repository class for storing dynamic data during
169 <     *  Simulation
170 <     * Every snapshot class will contain one DataStorage  for atoms and one DataStorage
171 <     *  for rigid bodies.
172 <     * @see SimData
173 <     */
174 <    class Snapshot {
175 <        public:
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 <            Snapshot() {}
199 <            Snapshot(int i) {
198 >    RealType getVolume() {
199 >      if (hasVolume_){
200 >        return frameData.volume;
201 >      }else{
202 >        return frameData.hmat.determinant();
203 >      }
204 >    }
205  
206 <            }
206 >    void setVolume(RealType volume){
207 >      hasVolume_=true;
208 >      frameData.volume = volume;
209 >    }
210  
211 <            Snapshot(const Snapshot& s);
211 >    /** Returns the inverse H-Matrix */
212 >    Mat3x3d getInvHmat() {
213 >      return frameData.invHmat;
214 >    }
215  
216 <            Snapshot& operator =(const Snapshot& s);
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 <            /** Returns the id of this Snapshot */
227 <            int getID() {
228 <                return id_;
98 <            }
226 >    RealType getTime() {
227 >      return frameData.currentTime;
228 >    }
229  
230 <            /** Sets the id of this Snapshot */
231 <            void setID(int id) {
232 <                id_ = id;
103 <            }
230 >    void increaseTime(RealType dt) {
231 >      setTime(getTime() + dt);
232 >    }
233  
234 <            //template<typename T>
235 <            //static typename T::ElemPointerType getArrayPointer(vector<T>& v) {
236 <            //    return v[0]->getArrayPointer();
237 <            //}
234 >    void setTime(RealType time) {
235 >      frameData.currentTime =time;
236 >      //time at statData is redundant
237 >      statData[Stats::TIME] = frameData.currentTime;
238 >    }
239  
240 <            static double* getArrayPointer(vector<Vector3d>& v) {
241 <                assert(v.size() > 0);
242 <                return v[0].getArrayPointer();
243 <            }
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 <            static double* getArrayPointer(vector<RotMat3x3d>& v) {
257 <                assert(v.size() > 0);
258 <                return v[0].getArrayPointer();
259 <            }
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              
120            static double* getArrayPointer(vector<double>& v) {
121                assert(v.size() > 0);
122                return &(v[0]);
123            }
124            
125            /** */
126            void resize(size_t size);
272  
273 +    void setOrthoTolerance(RealType orthoTolerance) {
274 +      orthoTolerance_ = orthoTolerance;
275 +    }
276  
277 <            /** */
278 <            void reserve(size_t size);
277 >    Mat3x3d getEta() {
278 >      return frameData.eta;
279 >    }
280  
281 <            DataStorage atomData;
282 <            DataStorage rigidbodyData;
281 >    void setEta(const Mat3x3d& eta) {
282 >      frameData.eta = eta;
283 >    }
284  
285 <            friend class SnapshotManager;
286 <        private:
285 >    Mat3x3d getTau() {
286 >      return frameData.tau;
287 >    }
288 >        
289 >    void setTau(const Mat3x3d& tau) {
290 >      frameData.tau = tau;
291 >    }
292  
293 <            int id_; /**< identification number of the snapshot */
294 <    };
293 >    bool hasCOM() {
294 >      return hasCOM_;
295 >    }
296  
297 <    typedef DataStorage* (Snapshot::*DataStoragePointer);
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

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 1715 by gezelter, Tue May 22 21:55:31 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines