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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines