| 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 |
|
#ifndef BRAINS_SNAPSHOT_HPP |
| 44 |
|
#define BRAINS_SNAPSHOT_HPP |
| 45 |
|
|
| 46 |
|
#include <vector> |
| 47 |
|
|
| 48 |
< |
#include "math/Vector3.hpp" |
| 49 |
< |
#include "math/SquareMatrix3.hpp" |
| 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 |
< |
namespace oopse{ |
| 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 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 |
> |
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 |
|
|
| 46 |
– |
enum DataStorageLayout { |
| 47 |
– |
dslPosition = 1, |
| 48 |
– |
dslVelocity = 2, |
| 49 |
– |
dslAMat = 4, |
| 50 |
– |
dslAngularMomentum = 8, |
| 51 |
– |
dslUnitVector = 16, |
| 52 |
– |
dslZAngle = 32, |
| 53 |
– |
dslForce = 64, |
| 54 |
– |
dslTorque = 128 |
| 55 |
– |
}; |
| 56 |
– |
//forward declaration |
| 57 |
– |
class Snapshot; |
| 58 |
– |
class SnapshotManager; |
| 59 |
– |
class StuntDouble; |
| 60 |
– |
|
| 61 |
– |
/** |
| 62 |
– |
* @class DataStorage |
| 63 |
– |
* @brief |
| 64 |
– |
* @warning do not try to insert element into (or ease element from) private member data |
| 65 |
– |
* of DataStorage directly. |
| 66 |
– |
*/ |
| 67 |
– |
class DataStorage { |
| 68 |
– |
public: |
| 69 |
– |
DataStorage() {}; |
| 70 |
– |
DataStorage(size_t size); |
| 103 |
|
|
| 104 |
< |
int size(); |
| 105 |
< |
void resize(size_t size); |
| 106 |
< |
void reserve(size_t size); |
| 107 |
< |
|
| 108 |
< |
friend class Snapshot; |
| 109 |
< |
friend class StuntDouble; |
| 110 |
< |
private: |
| 111 |
< |
vector<Vector3d> position; /** position array */ |
| 80 |
< |
vector<Vector3d> velocity; /** velocity array */ |
| 81 |
< |
vector<RotMat3x3d> aMat; /** rotation matrix array */ |
| 82 |
< |
vector<Vector3d> angularMomentum;/** velocity array */ |
| 83 |
< |
vector<Vector3d> unitVector; /** the lab frame unit vector array*/ |
| 84 |
< |
vector<double> zAngle; /** z -angle array */ |
| 85 |
< |
vector<Vector3d> force; /** force array */ |
| 86 |
< |
vector<Vector3d> torque; /** torque array */ |
| 104 |
> |
/** |
| 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 { |
| 112 |
|
|
| 113 |
< |
}; |
| 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(); |
| 118 |
> |
/** Sets the id of this Snapshot */ |
| 119 |
> |
void setID(int id); |
| 120 |
|
|
| 121 |
< |
/** |
| 122 |
< |
* @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" |
| 92 |
< |
* @brief Snapshot class is a repository class for storing dynamic data during |
| 93 |
< |
* Simulation |
| 94 |
< |
* Every snapshot class will contain one DataStorage for atoms and one DataStorage |
| 95 |
< |
* for rigid bodies. |
| 96 |
< |
* @see SimData |
| 97 |
< |
*/ |
| 98 |
< |
class Snapshot { |
| 99 |
< |
public: |
| 100 |
< |
|
| 101 |
< |
Snapshot(int nAtoms, int nRigidbodies) { |
| 102 |
< |
atomData.resize(nAtoms); |
| 103 |
< |
rigidbodyData.resize(nRigidbodies); |
| 104 |
< |
} |
| 121 |
> |
/** sets the state of the computed properties to false */ |
| 122 |
> |
void clearDerivedProperties(); |
| 123 |
|
|
| 124 |
< |
Snapshot(const Snapshot& s); |
| 124 |
> |
int getSize(); |
| 125 |
> |
/** Returns the number of atoms */ |
| 126 |
> |
int getNumberOfAtoms(); |
| 127 |
> |
/** Returns the number of rigid bodies */ |
| 128 |
> |
int getNumberOfRigidBodies(); |
| 129 |
> |
/** Returns the number of rigid bodies */ |
| 130 |
> |
int getNumberOfCutoffGroups(); |
| 131 |
|
|
| 132 |
< |
Snapshot& operator =(const Snapshot& s); |
| 132 |
> |
/** Returns the H-Matrix */ |
| 133 |
> |
Mat3x3d getHmat(); |
| 134 |
> |
/** Sets the H-Matrix */ |
| 135 |
> |
void setHmat(const Mat3x3d& m); |
| 136 |
> |
/** Returns the inverse H-Matrix */ |
| 137 |
> |
Mat3x3d getInvHmat(); |
| 138 |
|
|
| 139 |
< |
/** Returns the id of this Snapshot */ |
| 140 |
< |
int getID() { |
| 141 |
< |
return id_; |
| 113 |
< |
} |
| 139 |
> |
RealType getVolume(); |
| 140 |
> |
RealType getXYarea(); |
| 141 |
> |
void setVolume(const RealType vol); |
| 142 |
|
|
| 143 |
< |
/** Sets the id of this Snapshot */ |
| 144 |
< |
void setID(int id) { |
| 117 |
< |
id_ = id; |
| 118 |
< |
} |
| 143 |
> |
/** Wrapping the vector according to periodic boundary condition*/ |
| 144 |
> |
void wrapVector(Vector3d& v); |
| 145 |
|
|
| 146 |
< |
//template<typename T> |
| 147 |
< |
//static typename T::ElemPointerType getArrayPointer(vector<T>& v) { |
| 122 |
< |
// return v[0]->getArrayPointer(); |
| 123 |
< |
//} |
| 146 |
> |
/** Scaling a vector to multiples of the periodic box */ |
| 147 |
> |
Vector3d scaleVector(Vector3d &v); |
| 148 |
|
|
| 149 |
< |
static double* getArrayPointer(vector<Vector3d>& v) { |
| 150 |
< |
assert(v.size() > 0); |
| 151 |
< |
return v[0].getArrayPointer(); |
| 152 |
< |
} |
| 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 |
< |
static double* getArrayPointer(vector<RotMat3x3d>& v) { |
| 158 |
< |
assert(v.size() > 0); |
| 159 |
< |
return v[0].getArrayPointer(); |
| 133 |
< |
} |
| 134 |
< |
|
| 135 |
< |
static double* getArrayPointer(vector<double>& v) { |
| 136 |
< |
assert(v.size() > 0); |
| 137 |
< |
return &(v[0]); |
| 138 |
< |
} |
| 157 |
> |
RealType getTime(); |
| 158 |
> |
void increaseTime(const RealType dt); |
| 159 |
> |
void setTime(const RealType time); |
| 160 |
|
|
| 161 |
< |
int getSize() { |
| 162 |
< |
return atomData.size() + rigidbodyData.size(); |
| 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 |
> |
RealType getShortRangePotential(); |
| 171 |
> |
|
| 172 |
> |
void setLongRangePotential(const potVec lrPot); |
| 173 |
> |
RealType getLongRangePotential(); |
| 174 |
> |
potVec getLongRangePotentials(); |
| 175 |
> |
|
| 176 |
> |
void setExcludedPotentials(const potVec exPot); |
| 177 |
> |
potVec getExcludedPotentials(); |
| 178 |
> |
|
| 179 |
> |
void setRestraintPotential(const RealType rp); |
| 180 |
> |
RealType getRestraintPotential(); |
| 181 |
> |
|
| 182 |
> |
void setRawPotential(const RealType rp); |
| 183 |
> |
RealType getRawPotential(); |
| 184 |
> |
|
| 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 |
> |
Mat3x3d getPressureTensor(); |
| 204 |
> |
void setPressureTensor(const Mat3x3d& pressureTensor); |
| 205 |
> |
|
| 206 |
> |
Mat3x3d getStressTensor(); |
| 207 |
> |
void setStressTensor(const Mat3x3d& stressTensor); |
| 208 |
> |
|
| 209 |
> |
Vector3d getConductiveHeatFlux(); |
| 210 |
> |
void setConductiveHeatFlux(const Vector3d& chf); |
| 211 |
> |
|
| 212 |
> |
Vector3d getConvectiveHeatFlux(); |
| 213 |
> |
void setConvectiveHeatFlux(const Vector3d& chf); |
| 214 |
> |
|
| 215 |
> |
Vector3d getHeatFlux(); |
| 216 |
> |
|
| 217 |
> |
Vector3d getSystemDipole(); |
| 218 |
> |
void setSystemDipole(const Vector3d& bd); |
| 219 |
> |
|
| 220 |
> |
pair<RealType, RealType> getThermostat(); |
| 221 |
> |
void setThermostat(const pair<RealType, RealType>& thermostat); |
| 222 |
> |
|
| 223 |
> |
pair<RealType, RealType> getElectronicThermostat(); |
| 224 |
> |
void setElectronicThermostat(const pair<RealType, RealType>& eThermostat); |
| 225 |
|
|
| 226 |
< |
int getSizeOfAtoms() { |
| 227 |
< |
return atomData.size(); |
| 146 |
< |
} |
| 147 |
< |
|
| 148 |
< |
int getSizeOfRigidBodies() { |
| 149 |
< |
return rigidbodyData.size(); |
| 150 |
< |
} |
| 151 |
< |
|
| 152 |
< |
DataStorage atomData; |
| 153 |
< |
DataStorage rigidbodyData; |
| 226 |
> |
Mat3x3d getBarostat(); |
| 227 |
> |
void setBarostat(const Mat3x3d& barostat); |
| 228 |
|
|
| 229 |
< |
friend class StuntDouble; |
| 230 |
< |
private: |
| 229 |
> |
Mat3x3d getInertiaTensor(); |
| 230 |
> |
void setInertiaTensor(const Mat3x3d& inertiaTensor); |
| 231 |
|
|
| 232 |
< |
int id_; /**< identification number of the snapshot */ |
| 233 |
< |
}; |
| 232 |
> |
RealType getGyrationalVolume(); |
| 233 |
> |
void setGyrationalVolume(const RealType gv); |
| 234 |
|
|
| 235 |
< |
typedef DataStorage (Snapshot::*DataStoragePointer); |
| 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; |
| 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 |
> |
|
| 271 |
> |
}; |
| 272 |
> |
|
| 273 |
> |
typedef DataStorage (Snapshot::*DataStoragePointer); |
| 274 |
|
} |
| 275 |
|
#endif //BRAINS_SNAPSHOT_HPP |