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

Comparing branches/development/src/brains/Snapshot.hpp (file contents):
Revision 1757 by gezelter, Tue Jun 19 02:11:07 2012 UTC vs.
Revision 1858 by gezelter, Wed Apr 3 21:32:13 2013 UTC

# Line 35 | Line 35
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).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (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  
43   #ifndef BRAINS_SNAPSHOT_HPP
44   #define BRAINS_SNAPSHOT_HPP
45  
# Line 57 | Line 49
49   #include "nonbonded/NonBondedInteraction.hpp"
50   #include "brains/Stats.hpp"
51  
52 + using namespace std;
53   namespace OpenMD{
54  
55 +  /**
56 +   * FrameData is a structure for holding system-wide dynamic data
57 +   * about the simulation.
58 +   */
59 +  
60    struct FrameData {
61 <    int id;                   /**< identification number of the snapshot */
62 <    RealType currentTime;     /**< current time */
63 <    Mat3x3d hmat;             /**< axes of the periodic box in matrix form */
64 <    Mat3x3d invHmat;          /**< the inverse of the Hmat matrix */
65 <    bool orthoRhombic;        /**< is this an orthorhombic periodic box? */
66 <    RealType volume;          /**< total volume of this frame */
67 <    RealType pressure;        /**< pressure of this frame */
68 <    RealType totalEnergy;     /**< total energy of this frame */
69 <    RealType kineticEnergy;   /**< kinetic energy of this frame */
70 <    RealType potentialEnergy; /**< potential energy of this frame */
61 >    int id;                       /**< identification number of the snapshot */
62 >    RealType currentTime;         /**< current time */
63 >    Mat3x3d  hmat;                /**< axes of the periodic box in matrix form */
64 >    Mat3x3d  invHmat;             /**< the inverse of the Hmat matrix */
65 >    Mat3x3d  bBox;                /**< axes of a bounding box in matrix form */
66 >    Mat3x3d  invBbox;             /**< the inverse of the bounding box */
67 >    bool     orthoRhombic;        /**< is this an orthorhombic periodic box? */
68 >    RealType totalEnergy;         /**< total energy of this frame */
69 >    RealType translationalKinetic; /**< translational kinetic energy of this frame */
70 >    RealType rotationalKinetic;   /**< rotational kinetic energy of this frame */
71 >    RealType kineticEnergy;       /**< kinetic energy of this frame */
72 >    RealType potentialEnergy;     /**< potential energy of this frame */
73      RealType shortRangePotential; /**< short-range contributions to the potential*/
74 <    RealType longRangePotential; /**< long-range contributions to the potential */
75 <    RealType bondPotential;   /**< bonded contribution to the potential */
76 <    RealType bendPotential;   /**< angle-bending contribution to the potential */
77 <    RealType torsionPotential; /**< dihedral (torsion angle) contribution to the potential */
78 <    RealType inversionPotential; /**< inversion (planarity) contribution to the potential */
79 <    potVec   lrPotentials;    /**< breakdown of long-range potentials by family */
80 <    RealType temperature;     /**< temperature of this frame */
81 <    RealType chi;             /**< thermostat velocity */
82 <    RealType integralOfChiDt; /**< the actual thermostat */
74 >    RealType longRangePotential;  /**< long-range contributions to the potential */
75 >    RealType bondPotential;       /**< bonded contribution to the potential */
76 >    RealType bendPotential;       /**< angle-bending contribution to the potential */
77 >    RealType torsionPotential;    /**< dihedral (torsion angle) contribution to the potential */
78 >    RealType inversionPotential;  /**< inversion (planarity) contribution to the potential */
79 >    potVec   lrPotentials;        /**< breakdown of long-range potentials by family */
80 >    potVec   excludedPotentials;  /**< breakdown of excluded potentials by family */
81 >    RealType restraintPotential;  /**< potential energy of restraints */
82 >    RealType rawPotential;        /**< unrestrained potential energy (when restraints are applied) */
83 >    RealType xyArea;              /**< XY area of this frame */
84 >    RealType volume;              /**< total volume of this frame */
85 >    RealType pressure;            /**< pressure of this frame */
86 >    RealType temperature;         /**< temperature of this frame */
87 >    pair<RealType, RealType> thermostat;    /**< thermostat variables */
88      RealType electronicTemperature; /**< temperature of the electronic degrees of freedom */
89 <    RealType chiQ;            /**< fluctuating charge thermostat velocity */
90 <    RealType integralOfChiQDt; /**< the actual fluctuating charge thermostat */
91 <    Mat3x3d eta;              /**< barostat matrix */
92 <    Vector3d COM;             /**< location of center of mass */
93 <    Vector3d COMvel;          /**< system center of mass velocity */
94 <    Vector3d COMw;            /**< system center of mass angular velocity */
95 <    Mat3x3d stressTensor;     /**< stress tensor */
96 <    Mat3x3d pressureTensor;   /**< pressure tensor */
97 <    Vector3d systemDipole;    /**< total system dipole moment */
98 <    Vector3d conductiveHeatFlux; /**< heat flux vector (conductive only) */
89 >    pair<RealType, RealType> electronicThermostat; /**< thermostat variables for electronic degrees of freedom */
90 >    Mat3x3d  barostat;            /**< barostat matrix */
91 >    Vector3d COM;                 /**< location of system center of mass */
92 >    Vector3d COMvel;              /**< system center of mass velocity */
93 >    Vector3d COMw;                /**< system center of mass angular velocity */
94 >    Mat3x3d  inertiaTensor;       /**< inertia tensor for entire system */
95 >    RealType gyrationalVolume;    /**< gyrational volume for entire system */
96 >    RealType hullVolume;          /**< hull volume for entire system */
97 >    Mat3x3d  stressTensor;        /**< stress tensor */
98 >    Mat3x3d  pressureTensor;      /**< pressure tensor */
99 >    Vector3d systemDipole;        /**< total system dipole moment */
100 >    Vector3d conductiveHeatFlux;  /**< heat flux vector (conductive only) */
101 >    Vector3d convectiveHeatFlux;  /**< heat flux vector (convective only) */
102 >    RealType conservedQuantity;   /**< anything conserved by the integrator */
103    };
104  
105  
106    /**
107 <   * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
108 <   * @brief Snapshot class is a repository class for storing dynamic data during
109 <   *  Simulation
110 <   * Every snapshot class will contain one DataStorage for atoms and one DataStorage
111 <   *  for rigid bodies.
107 >   * @class Snapshot
108 >   * @brief The Snapshot class is a repository storing dynamic data during a
109 >   * Simulation.  Every Snapshot contains FrameData (for global information)
110 >   * as well as DataStorage (one for Atoms, one for RigidBodies, and one for
111 >   * CutoffGroups).
112     */
113    class Snapshot {
105  public:
106            
107    Snapshot(int nAtoms, int nRigidbodies,
108             int nCutoffGroups) : atomData(nAtoms),
109                                  rigidbodyData(nRigidbodies),
110                                  cgData(nCutoffGroups, DataStorage::dslPosition),
111                                  orthoTolerance_(1e-6), hasCOM_(false), hasVolume_(false){
112      
113      frameData.id = -1;                  
114      frameData.currentTime = 0;    
115      frameData.hmat = Mat3x3d(0.0);            
116      frameData.invHmat = Mat3x3d(0.0);          
117      frameData.orthoRhombic = false;        
118      frameData.volume = 0.0;          
119      frameData.pressure = 0.0;        
120      frameData.totalEnergy = 0.0;    
121      frameData.kineticEnergy = 0.0;  
122      frameData.potentialEnergy = 0.0;
123      frameData.temperature = 0.0;    
124      frameData.chi = 0.0;            
125      frameData.integralOfChiDt = 0.0;
126      frameData.electronicTemperature = 0.0;
127      frameData.chiQ = 0.0;            
128      frameData.integralOfChiQDt = 0.0;
129      frameData.eta = Mat3x3d(0.0);              
130      frameData.COM = V3Zero;            
131      frameData.COMvel = V3Zero;          
132      frameData.COMw = V3Zero;            
133      frameData.stressTensor = Mat3x3d(0.0);              
134      frameData.pressureTensor = Mat3x3d(0.0);  
135      frameData.systemDipole = Vector3d(0.0);            
136      frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
137    }
114  
115 <    Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
116 <             int storageLayout) : atomData(nAtoms, storageLayout),
117 <                                  rigidbodyData(nRigidbodies, storageLayout),
142 <                                  cgData(nCutoffGroups, DataStorage::dslPosition),
143 <                                  orthoTolerance_(1e-6),
144 <                                  hasCOM_(false),
145 <                                  hasVolume_(false) {
146 <      frameData.id = -1;                  
147 <      frameData.currentTime = 0;    
148 <      frameData.hmat = Mat3x3d(0.0);            
149 <      frameData.invHmat = Mat3x3d(0.0);          
150 <      frameData.orthoRhombic = false;        
151 <      frameData.volume = 0.0;          
152 <      frameData.pressure = 0.0;        
153 <      frameData.totalEnergy = 0.0;    
154 <      frameData.kineticEnergy = 0.0;  
155 <      frameData.potentialEnergy = 0.0;
156 <      frameData.temperature = 0.0;    
157 <      frameData.chi = 0.0;            
158 <      frameData.integralOfChiDt = 0.0;
159 <      frameData.electronicTemperature = 0.0;
160 <      frameData.chiQ = 0.0;            
161 <      frameData.integralOfChiQDt = 0.0;
162 <      frameData.eta = Mat3x3d(0.0);              
163 <      frameData.COM = V3Zero;            
164 <      frameData.COMvel = V3Zero;          
165 <      frameData.COMw = V3Zero;            
166 <      frameData.stressTensor = Mat3x3d(0.0);              
167 <      frameData.pressureTensor = Mat3x3d(0.0);  
168 <      frameData.systemDipole = V3Zero;            
169 <      frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);            
170 <    }
171 <    
115 >  public:            
116 >    Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups);
117 >    Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, int storageLayout);    
118      /** Returns the id of this Snapshot */
119 <    int getID() {
174 <      return frameData.id;
175 <    }
176 <
119 >    int      getID();
120      /** Sets the id of this Snapshot */
121 <    void setID(int id) {
179 <      frameData.id = id;
180 <    }
121 >    void     setID(int id);
122  
123 <    int getSize() {
124 <      return atomData.getSize() + rigidbodyData.getSize();
184 <    }
123 >    /** sets the state of the computed properties to false */
124 >    void     clearDerivedProperties();
125  
126 +    int      getSize();
127      /** Returns the number of atoms */
128 <    int getNumberOfAtoms() {
188 <      return atomData.getSize();
189 <    }
190 <
128 >    int      getNumberOfAtoms();
129      /** Returns the number of rigid bodies */
130 <    int getNumberOfRigidBodies() {
193 <      return rigidbodyData.getSize();
194 <    }
195 <
130 >    int      getNumberOfRigidBodies();
131      /** Returns the number of rigid bodies */
132 <    int getNumberOfCutoffGroups() {
198 <      return cgData.getSize();
199 <    }
132 >    int      getNumberOfCutoffGroups();
133  
134      /** Returns the H-Matrix */
135 <    Mat3x3d getHmat() {
203 <      return frameData.hmat;
204 <    }
205 <
135 >    Mat3x3d  getHmat();
136      /** Sets the H-Matrix */
137 <    void setHmat(const Mat3x3d& m);
138 <            
139 <    RealType getVolume() {
210 <      if (hasVolume_){
211 <        return frameData.volume;
212 <      }else{
213 <        return frameData.hmat.determinant();
214 <      }
215 <    }
137 >    void     setHmat(const Mat3x3d& m);
138 >    /** Returns the inverse H-Matrix */
139 >    Mat3x3d  getInvHmat();
140  
141 <    void setVolume(RealType volume){
142 <      hasVolume_=true;
143 <      frameData.volume = volume;
144 <    }
141 >    /** Returns the Bounding Box */
142 >    Mat3x3d  getBoundingBox();
143 >    /** Sets the Bounding Box */
144 >    void     setBoundingBox(const Mat3x3d& m);
145 >    /** Returns the inverse Bounding Box*/
146 >    Mat3x3d  getInvBoundingBox();
147 >            
148 >    RealType getVolume();
149 >    RealType getXYarea();
150 >    void     setVolume(const RealType vol);
151  
222    /** Returns the inverse H-Matrix */
223    Mat3x3d getInvHmat() {
224      return frameData.invHmat;
225    }
226
152      /** Wrapping the vector according to periodic boundary condition*/
153 <    void wrapVector(Vector3d& v);
153 >    void     wrapVector(Vector3d& v);
154 >
155      /** Scaling a vector to multiples of the periodic box */
156      Vector3d scaleVector(Vector3d &v);
157  
158 +    void     setCOM(const Vector3d &com);
159 +    void     setCOMvel(const Vector3d &comVel);
160 +    void     setCOMw(const Vector3d &comw);
161  
162      Vector3d getCOM();
163      Vector3d getCOMvel();
164      Vector3d getCOMw();
165              
166 <    RealType getTime() {
167 <      return frameData.currentTime;
168 <    }
166 >    RealType getTime();
167 >    void     increaseTime(const RealType dt);
168 >    void     setTime(const RealType time);
169  
170 <    void increaseTime(RealType dt) {
171 <      setTime(getTime() + dt);
172 <    }
170 >    void     setBondPotential(const RealType bp);
171 >    void     setBendPotential(const RealType bp);
172 >    void     setTorsionPotential(const RealType tp);
173 >    void     setInversionPotential(const RealType ip);
174 >    RealType getBondPotential();
175 >    RealType getBendPotential();
176 >    RealType getTorsionPotential();
177 >    RealType getInversionPotential();
178  
179 <    void setTime(RealType time) {
246 <      frameData.currentTime =time;
247 <      //time at statData is redundant
248 <      statData[Stats::TIME] = frameData.currentTime;
249 <    }
179 >    RealType getShortRangePotential();
180  
181 <    RealType getChi() {
182 <      return frameData.chi;
183 <    }
181 >    void     setLongRangePotential(const potVec lrPot);
182 >    RealType getLongRangePotential();
183 >    potVec   getLongRangePotentials();
184  
185 <    void setChi(RealType chi) {
186 <      frameData.chi = chi;
187 <    }
185 >    void     setExcludedPotentials(const potVec exPot);
186 >    potVec   getExcludedPotentials();
187 >  
188 >    void     setRestraintPotential(const RealType rp);
189 >    RealType getRestraintPotential();
190  
191 <    RealType getIntegralOfChiDt() {
192 <      return frameData.integralOfChiDt;
261 <    }
191 >    void     setRawPotential(const RealType rp);
192 >    RealType getRawPotential();
193  
194 <    void setIntegralOfChiDt(RealType integralOfChiDt) {
195 <      frameData.integralOfChiDt = integralOfChiDt;
196 <    }
197 <            
198 <    RealType getChiElectronic() {
199 <      return frameData.chiQ;
200 <    }
194 >    RealType getPotentialEnergy();
195 >    RealType getKineticEnergy();
196 >    RealType getTranslationalKineticEnergy();
197 >    RealType getRotationalKineticEnergy();
198 >    void     setKineticEnergy(const RealType ke);
199 >    void     setTranslationalKineticEnergy(const RealType tke);
200 >    void     setRotationalKineticEnergy(const RealType rke);
201 >    RealType getTotalEnergy();
202 >    void     setTotalEnergy(const RealType te);
203 >    RealType getConservedQuantity();
204 >    void     setConservedQuantity(const RealType cq);
205 >    RealType getTemperature();
206 >    void     setTemperature(const RealType temp);
207 >    RealType getElectronicTemperature();
208 >    void     setElectronicTemperature(const RealType eTemp);
209 >    RealType getPressure();
210 >    void     setPressure(const RealType pressure);
211  
212 <    void setChiElectronic(RealType chiQ) {
213 <      frameData.chiQ = chiQ;
273 <    }
212 >    Mat3x3d  getPressureTensor();
213 >    void     setPressureTensor(const Mat3x3d& pressureTensor);
214  
215 <    RealType getIntegralOfChiElectronicDt() {
216 <      return frameData.integralOfChiQDt;
277 <    }
215 >    Mat3x3d  getStressTensor();
216 >    void     setStressTensor(const Mat3x3d& stressTensor);
217  
218 <    void setIntegralOfChiElectronicDt(RealType integralOfChiQDt) {
219 <      frameData.integralOfChiQDt = integralOfChiQDt;
281 <    }
282 <            
218 >    Vector3d getConductiveHeatFlux();
219 >    void     setConductiveHeatFlux(const Vector3d& chf);
220  
221 <    void setOrthoTolerance(RealType orthoTolerance) {
222 <      orthoTolerance_ = orthoTolerance;
286 <    }
221 >    Vector3d getConvectiveHeatFlux();
222 >    void     setConvectiveHeatFlux(const Vector3d& chf);
223  
224 <    Mat3x3d getEta() {
225 <      return frameData.eta;
226 <    }
224 >    Vector3d getHeatFlux();
225 >    
226 >    Vector3d getSystemDipole();
227 >    void     setSystemDipole(const Vector3d& bd);
228  
229 <    void setEta(const Mat3x3d& eta) {
230 <      frameData.eta = eta;
294 <    }
229 >    pair<RealType, RealType> getThermostat();
230 >    void setThermostat(const pair<RealType, RealType>& thermostat);
231  
232 <    Mat3x3d getStressTensor() {
233 <      return frameData.stressTensor;
234 <    }
235 <        
236 <    void setStressTensor(const Mat3x3d& stressTensor) {
301 <      frameData.stressTensor = stressTensor;
302 <    }
232 >    pair<RealType, RealType> getElectronicThermostat();
233 >    void setElectronicThermostat(const pair<RealType, RealType>& eThermostat);
234 >            
235 >    Mat3x3d  getBarostat();
236 >    void     setBarostat(const Mat3x3d& barostat);
237  
238 <    Vector3d getConductiveHeatFlux() {
239 <      return frameData.conductiveHeatFlux;
306 <    }
307 <        
308 <    void setConductiveHeatFlux(const Vector3d& heatFlux) {
309 <      frameData.conductiveHeatFlux = heatFlux;
310 <    }
238 >    Mat3x3d  getInertiaTensor();
239 >    void     setInertiaTensor(const Mat3x3d& inertiaTensor);
240  
241 <    bool hasCOM() {
242 <      return hasCOM_;
314 <    }
241 >    RealType getGyrationalVolume();
242 >    void     setGyrationalVolume(const RealType gv);
243  
244 <    void setCOMprops(const Vector3d& COM, const Vector3d& COMvel, const Vector3d& COMw) {
245 <      frameData.COM = COM;
246 <      frameData.COMvel = COMvel;
247 <      frameData.COMw = COMw;
320 <      hasCOM_ = true;
321 <    }
244 >    RealType getHullVolume();
245 >    void     setHullVolume(const RealType hv);
246 >    
247 >    void     setOrthoTolerance(RealType orthoTolerance);
248  
249      DataStorage atomData;
250      DataStorage rigidbodyData;
251      DataStorage cgData;
252 <    FrameData frameData;
327 <    Stats statData;
252 >    FrameData   frameData;
253  
254 +    bool hasTotalEnergy;        
255 +    bool hasTranslationalKineticEnergy;    
256 +    bool hasRotationalKineticEnergy;    
257 +    bool hasKineticEnergy;    
258 +    bool hasShortRangePotential;
259 +    bool hasLongRangePotential;
260 +    bool hasPotentialEnergy;    
261 +    bool hasXYarea;
262 +    bool hasVolume;        
263 +    bool hasPressure;      
264 +    bool hasTemperature;    
265 +    bool hasElectronicTemperature;
266 +    bool hasCOM;            
267 +    bool hasCOMvel;
268 +    bool hasCOMw;
269 +    bool hasPressureTensor;    
270 +    bool hasSystemDipole;    
271 +    bool hasConvectiveHeatFlux;
272 +    bool hasInertiaTensor;
273 +    bool hasGyrationalVolume;
274 +    bool hasHullVolume;
275 +    bool hasConservedQuantity;
276 +    bool hasBoundingBox;
277 +
278    private:
279      RealType orthoTolerance_;
280 <    bool hasCOM_;
332 <    bool hasVolume_;    
280 >    
281    };
282  
283    typedef DataStorage (Snapshot::*DataStoragePointer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines