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 1723 by gezelter, Thu May 24 20:59:54 2012 UTC vs.
Revision 1764 by gezelter, Tue Jul 3 18:32:27 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines