| 1 | gezelter | 507 | /* | 
| 2 | gezelter | 246 | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 | tim | 122 | * | 
| 4 | gezelter | 246 | * 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 | gezelter | 1390 | * 1. Redistributions of source code must retain the above copyright | 
| 10 | gezelter | 246 | *    notice, this list of conditions and the following disclaimer. | 
| 11 |  |  | * | 
| 12 | gezelter | 1390 | * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 | gezelter | 246 | *    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 | gezelter | 1390 | * | 
| 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 | gezelter | 1879 | * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). | 
| 39 | gezelter | 1782 | * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 |  |  | * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 | tim | 122 | */ | 
| 42 | gezelter | 246 |  | 
| 43 | tim | 122 | #ifndef BRAINS_SNAPSHOT_HPP | 
| 44 |  |  | #define BRAINS_SNAPSHOT_HPP | 
| 45 | tim | 137 |  | 
| 46 |  |  | #include <vector> | 
| 47 |  |  |  | 
| 48 | tim | 155 | #include "brains/DataStorage.hpp" | 
| 49 | gezelter | 1782 | #include "nonbonded/NonBondedInteraction.hpp" | 
| 50 | gezelter | 246 | #include "brains/Stats.hpp" | 
| 51 | tim | 137 |  | 
| 52 | gezelter | 1782 | using namespace std; | 
| 53 | gezelter | 1390 | namespace OpenMD{ | 
| 54 | tim | 122 |  | 
| 55 | gezelter | 507 | /** | 
| 56 | gezelter | 1782 | * FrameData is a structure for holding system-wide dynamic data | 
| 57 |  |  | * about the simulation. | 
| 58 | gezelter | 507 | */ | 
| 59 | gezelter | 1782 |  | 
| 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 | gezelter | 1879 | Mat3x3d  bBox;                /**< axes of a bounding box in matrix form */ | 
| 66 |  |  | Mat3x3d  invBbox;             /**< the inverse of the bounding box */ | 
| 67 | gezelter | 1782 | 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 | gezelter | 1925 | RealType reciprocalPotential; /**< reciprocal-space contributions to the potential */ | 
| 76 | gezelter | 1782 | RealType bondPotential;       /**< bonded contribution to the potential */ | 
| 77 |  |  | RealType bendPotential;       /**< angle-bending contribution to the potential */ | 
| 78 |  |  | RealType torsionPotential;    /**< dihedral (torsion angle) contribution to the potential */ | 
| 79 |  |  | RealType inversionPotential;  /**< inversion (planarity) contribution to the potential */ | 
| 80 |  |  | potVec   lrPotentials;        /**< breakdown of long-range potentials by family */ | 
| 81 |  |  | potVec   excludedPotentials;  /**< breakdown of excluded potentials by family */ | 
| 82 |  |  | RealType restraintPotential;  /**< potential energy of restraints */ | 
| 83 |  |  | RealType rawPotential;        /**< unrestrained potential energy (when restraints are applied) */ | 
| 84 |  |  | RealType xyArea;              /**< XY area of this frame */ | 
| 85 |  |  | RealType volume;              /**< total volume of this frame */ | 
| 86 |  |  | RealType pressure;            /**< pressure of this frame */ | 
| 87 |  |  | RealType temperature;         /**< temperature of this frame */ | 
| 88 |  |  | pair<RealType, RealType> thermostat;    /**< thermostat variables */ | 
| 89 |  |  | RealType electronicTemperature; /**< temperature of the electronic degrees of freedom */ | 
| 90 |  |  | pair<RealType, RealType> electronicThermostat; /**< thermostat variables for electronic degrees of freedom */ | 
| 91 |  |  | Mat3x3d  barostat;            /**< barostat matrix */ | 
| 92 |  |  | Vector3d COM;                 /**< location of system center of mass */ | 
| 93 |  |  | Vector3d COMvel;              /**< system center of mass velocity */ | 
| 94 |  |  | Vector3d COMw;                /**< system center of mass angular velocity */ | 
| 95 |  |  | Mat3x3d  inertiaTensor;       /**< inertia tensor for entire system */ | 
| 96 |  |  | RealType gyrationalVolume;    /**< gyrational volume for entire system */ | 
| 97 |  |  | RealType hullVolume;          /**< hull volume for entire system */ | 
| 98 |  |  | Mat3x3d  stressTensor;        /**< stress tensor */ | 
| 99 |  |  | Mat3x3d  pressureTensor;      /**< pressure tensor */ | 
| 100 |  |  | Vector3d systemDipole;        /**< total system dipole moment */ | 
| 101 | gezelter | 2022 | Mat3x3d  systemQuadrupole;    /**< total system quadrupole moment */ | 
| 102 | gezelter | 1782 | Vector3d conductiveHeatFlux;  /**< heat flux vector (conductive only) */ | 
| 103 |  |  | Vector3d convectiveHeatFlux;  /**< heat flux vector (convective only) */ | 
| 104 |  |  | RealType conservedQuantity;   /**< anything conserved by the integrator */ | 
| 105 |  |  | }; | 
| 106 | gezelter | 246 |  | 
| 107 | tim | 137 |  | 
| 108 | gezelter | 1782 | /** | 
| 109 |  |  | * @class Snapshot | 
| 110 |  |  | * @brief The Snapshot class is a repository storing dynamic data during a | 
| 111 |  |  | * Simulation.  Every Snapshot contains FrameData (for global information) | 
| 112 |  |  | * as well as DataStorage (one for Atoms, one for RigidBodies, and one for | 
| 113 |  |  | * CutoffGroups). | 
| 114 |  |  | */ | 
| 115 |  |  | class Snapshot { | 
| 116 | tim | 316 |  | 
| 117 | gezelter | 1782 | public: | 
| 118 |  |  | Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups); | 
| 119 |  |  | Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, int storageLayout); | 
| 120 | gezelter | 507 | /** Returns the id of this Snapshot */ | 
| 121 | gezelter | 1782 | int      getID(); | 
| 122 | gezelter | 507 | /** Sets the id of this Snapshot */ | 
| 123 | gezelter | 1782 | void     setID(int id); | 
| 124 | tim | 137 |  | 
| 125 | gezelter | 1782 | /** sets the state of the computed properties to false */ | 
| 126 |  |  | void     clearDerivedProperties(); | 
| 127 | tim | 152 |  | 
| 128 | gezelter | 1782 | int      getSize(); | 
| 129 | gezelter | 507 | /** Returns the number of atoms */ | 
| 130 | gezelter | 1782 | int      getNumberOfAtoms(); | 
| 131 | gezelter | 507 | /** Returns the number of rigid bodies */ | 
| 132 | gezelter | 1782 | int      getNumberOfRigidBodies(); | 
| 133 |  |  | /** Returns the number of rigid bodies */ | 
| 134 |  |  | int      getNumberOfCutoffGroups(); | 
| 135 | gezelter | 1966 | /** Returns the number of bytes in a FrameData structure */ | 
| 136 |  |  | static int getFrameDataSize(); | 
| 137 | tim | 152 |  | 
| 138 | gezelter | 507 | /** Returns the H-Matrix */ | 
| 139 | gezelter | 1782 | Mat3x3d  getHmat(); | 
| 140 | gezelter | 507 | /** Sets the H-Matrix */ | 
| 141 | gezelter | 1782 | void     setHmat(const Mat3x3d& m); | 
| 142 |  |  | /** Returns the inverse H-Matrix */ | 
| 143 |  |  | Mat3x3d  getInvHmat(); | 
| 144 | gezelter | 1879 |  | 
| 145 |  |  | /** Returns the Bounding Box */ | 
| 146 |  |  | Mat3x3d  getBoundingBox(); | 
| 147 |  |  | /** Sets the Bounding Box */ | 
| 148 |  |  | void     setBoundingBox(const Mat3x3d& m); | 
| 149 |  |  | /** Returns the inverse Bounding Box*/ | 
| 150 |  |  | Mat3x3d  getInvBoundingBox(); | 
| 151 | gezelter | 246 |  | 
| 152 | gezelter | 1782 | RealType getVolume(); | 
| 153 |  |  | RealType getXYarea(); | 
| 154 |  |  | void     setVolume(const RealType vol); | 
| 155 | tim | 152 |  | 
| 156 | gezelter | 1782 | /** Wrapping the vector according to periodic boundary condition*/ | 
| 157 |  |  | void     wrapVector(Vector3d& v); | 
| 158 | chuckv | 1302 |  | 
| 159 | gezelter | 1782 | /** Scaling a vector to multiples of the periodic box */ | 
| 160 |  |  | Vector3d scaleVector(Vector3d &v); | 
| 161 | tim | 152 |  | 
| 162 | gezelter | 1782 | void     setCOM(const Vector3d &com); | 
| 163 |  |  | void     setCOMvel(const Vector3d &comVel); | 
| 164 |  |  | void     setCOMw(const Vector3d &comw); | 
| 165 |  |  |  | 
| 166 | gezelter | 1104 | Vector3d getCOM(); | 
| 167 |  |  | Vector3d getCOMvel(); | 
| 168 |  |  | Vector3d getCOMw(); | 
| 169 | gezelter | 246 |  | 
| 170 | gezelter | 1782 | RealType getTime(); | 
| 171 |  |  | void     increaseTime(const RealType dt); | 
| 172 |  |  | void     setTime(const RealType time); | 
| 173 | tim | 152 |  | 
| 174 | gezelter | 1782 | void     setBondPotential(const RealType bp); | 
| 175 |  |  | void     setBendPotential(const RealType bp); | 
| 176 |  |  | void     setTorsionPotential(const RealType tp); | 
| 177 |  |  | void     setInversionPotential(const RealType ip); | 
| 178 |  |  | RealType getBondPotential(); | 
| 179 |  |  | RealType getBendPotential(); | 
| 180 |  |  | RealType getTorsionPotential(); | 
| 181 |  |  | RealType getInversionPotential(); | 
| 182 | tim | 152 |  | 
| 183 | gezelter | 1782 | RealType getShortRangePotential(); | 
| 184 | tim | 152 |  | 
| 185 | gezelter | 1782 | void     setLongRangePotential(const potVec lrPot); | 
| 186 |  |  | RealType getLongRangePotential(); | 
| 187 |  |  | potVec   getLongRangePotentials(); | 
| 188 | gezelter | 246 |  | 
| 189 | gezelter | 1925 | void     setReciprocalPotential(const RealType rp); | 
| 190 |  |  | RealType getReciprocalPotential(); | 
| 191 |  |  |  | 
| 192 | gezelter | 1782 | void     setExcludedPotentials(const potVec exPot); | 
| 193 |  |  | potVec   getExcludedPotentials(); | 
| 194 |  |  |  | 
| 195 |  |  | void     setRestraintPotential(const RealType rp); | 
| 196 |  |  | RealType getRestraintPotential(); | 
| 197 | gezelter | 246 |  | 
| 198 | gezelter | 1782 | void     setRawPotential(const RealType rp); | 
| 199 |  |  | RealType getRawPotential(); | 
| 200 | gezelter | 246 |  | 
| 201 | gezelter | 1782 | RealType getPotentialEnergy(); | 
| 202 |  |  | RealType getKineticEnergy(); | 
| 203 |  |  | RealType getTranslationalKineticEnergy(); | 
| 204 |  |  | RealType getRotationalKineticEnergy(); | 
| 205 |  |  | void     setKineticEnergy(const RealType ke); | 
| 206 |  |  | void     setTranslationalKineticEnergy(const RealType tke); | 
| 207 |  |  | void     setRotationalKineticEnergy(const RealType rke); | 
| 208 |  |  | RealType getTotalEnergy(); | 
| 209 |  |  | void     setTotalEnergy(const RealType te); | 
| 210 |  |  | RealType getConservedQuantity(); | 
| 211 |  |  | void     setConservedQuantity(const RealType cq); | 
| 212 |  |  | RealType getTemperature(); | 
| 213 |  |  | void     setTemperature(const RealType temp); | 
| 214 |  |  | RealType getElectronicTemperature(); | 
| 215 |  |  | void     setElectronicTemperature(const RealType eTemp); | 
| 216 |  |  | RealType getPressure(); | 
| 217 |  |  | void     setPressure(const RealType pressure); | 
| 218 |  |  |  | 
| 219 |  |  | Mat3x3d  getPressureTensor(); | 
| 220 |  |  | void     setPressureTensor(const Mat3x3d& pressureTensor); | 
| 221 |  |  |  | 
| 222 |  |  | Mat3x3d  getStressTensor(); | 
| 223 |  |  | void     setStressTensor(const Mat3x3d& stressTensor); | 
| 224 |  |  |  | 
| 225 |  |  | Vector3d getConductiveHeatFlux(); | 
| 226 |  |  | void     setConductiveHeatFlux(const Vector3d& chf); | 
| 227 |  |  |  | 
| 228 |  |  | Vector3d getConvectiveHeatFlux(); | 
| 229 |  |  | void     setConvectiveHeatFlux(const Vector3d& chf); | 
| 230 |  |  |  | 
| 231 |  |  | Vector3d getHeatFlux(); | 
| 232 |  |  |  | 
| 233 |  |  | Vector3d getSystemDipole(); | 
| 234 |  |  | void     setSystemDipole(const Vector3d& bd); | 
| 235 |  |  |  | 
| 236 | gezelter | 2022 | Mat3x3d  getSystemQuadrupole(); | 
| 237 |  |  | void     setSystemQuadrupole(const Mat3x3d& bq); | 
| 238 |  |  |  | 
| 239 | gezelter | 1782 | pair<RealType, RealType> getThermostat(); | 
| 240 |  |  | void setThermostat(const pair<RealType, RealType>& thermostat); | 
| 241 |  |  |  | 
| 242 |  |  | pair<RealType, RealType> getElectronicThermostat(); | 
| 243 |  |  | void setElectronicThermostat(const pair<RealType, RealType>& eThermostat); | 
| 244 | gezelter | 246 |  | 
| 245 | gezelter | 1782 | Mat3x3d  getBarostat(); | 
| 246 |  |  | void     setBarostat(const Mat3x3d& barostat); | 
| 247 | gezelter | 1021 |  | 
| 248 | gezelter | 1782 | Mat3x3d  getInertiaTensor(); | 
| 249 |  |  | void     setInertiaTensor(const Mat3x3d& inertiaTensor); | 
| 250 | gezelter | 1021 |  | 
| 251 | gezelter | 1782 | RealType getGyrationalVolume(); | 
| 252 |  |  | void     setGyrationalVolume(const RealType gv); | 
| 253 | gezelter | 246 |  | 
| 254 | gezelter | 1782 | RealType getHullVolume(); | 
| 255 |  |  | void     setHullVolume(const RealType hv); | 
| 256 |  |  |  | 
| 257 |  |  | void     setOrthoTolerance(RealType orthoTolerance); | 
| 258 | gezelter | 1104 |  | 
| 259 | gezelter | 507 | DataStorage atomData; | 
| 260 |  |  | DataStorage rigidbodyData; | 
| 261 | gezelter | 1782 | DataStorage cgData; | 
| 262 |  |  | FrameData   frameData; | 
| 263 |  |  |  | 
| 264 |  |  | bool hasTotalEnergy; | 
| 265 |  |  | bool hasTranslationalKineticEnergy; | 
| 266 |  |  | bool hasRotationalKineticEnergy; | 
| 267 |  |  | bool hasKineticEnergy; | 
| 268 |  |  | bool hasShortRangePotential; | 
| 269 |  |  | bool hasLongRangePotential; | 
| 270 |  |  | bool hasPotentialEnergy; | 
| 271 |  |  | bool hasXYarea; | 
| 272 |  |  | bool hasVolume; | 
| 273 |  |  | bool hasPressure; | 
| 274 |  |  | bool hasTemperature; | 
| 275 |  |  | bool hasElectronicTemperature; | 
| 276 |  |  | bool hasCOM; | 
| 277 |  |  | bool hasCOMvel; | 
| 278 |  |  | bool hasCOMw; | 
| 279 |  |  | bool hasPressureTensor; | 
| 280 | gezelter | 2022 | bool hasSystemDipole; | 
| 281 |  |  | bool hasSystemQuadrupole; | 
| 282 | gezelter | 1782 | bool hasConvectiveHeatFlux; | 
| 283 |  |  | bool hasInertiaTensor; | 
| 284 |  |  | bool hasGyrationalVolume; | 
| 285 |  |  | bool hasHullVolume; | 
| 286 |  |  | bool hasConservedQuantity; | 
| 287 | gezelter | 1879 | bool hasBoundingBox; | 
| 288 | gezelter | 1782 |  | 
| 289 | gezelter | 507 | private: | 
| 290 | gezelter | 1021 | RealType orthoTolerance_; | 
| 291 | gezelter | 1782 |  | 
| 292 | gezelter | 507 | }; | 
| 293 | tim | 122 |  | 
| 294 | gezelter | 507 | typedef DataStorage (Snapshot::*DataStoragePointer); | 
| 295 | tim | 122 | } | 
| 296 |  |  | #endif //BRAINS_SNAPSHOT_HPP |