OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Snapshot.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#ifndef BRAINS_SNAPSHOT_HPP
46#define BRAINS_SNAPSHOT_HPP
47
48#include <vector>
49
50#include "brains/DataStorage.hpp"
51#include "brains/Stats.hpp"
52#include "nonbonded/NonBondedInteraction.hpp"
53
54using namespace std;
55namespace OpenMD {
56
57 struct SPFData {
58 Vector3d pos {V3Zero};
59 RealType lambda {0.0};
60 int globalID {-1};
61 };
62
63 /**
64 * FrameData is a structure for holding system-wide dynamic data
65 * about the simulation.
66 */
67 struct FrameData {
68 int id; /**< identification number of the snapshot */
69 RealType currentTime; /**< current time */
70 Mat3x3d hmat; /**< axes of the periodic box in matrix form */
71 Mat3x3d invHmat; /**< the inverse of the Hmat matrix */
72 Mat3x3d bBox; /**< axes of a bounding box in matrix form */
73 Mat3x3d invBbox; /**< the inverse of the bounding box */
74 bool usePBC; /**< are we using a periodic box? */
75 bool orthoRhombic; /**< is this an orthorhombic periodic box? */
76 RealType totalEnergy; /**< total energy of this frame */
77 RealType
78 translationalKinetic; /**< translational kinetic energy of this frame */
79 RealType rotationalKinetic; /**< rotational kinetic energy of this frame */
80 RealType electronicKinetic; /**< electronic kinetic energy of this frame */
81 RealType kineticEnergy; /**< kinetic energy of this frame */
82 RealType potentialEnergy; /**< potential energy of this frame */
83 RealType
84 shortRangePotential; /**< short-range contributions to the potential*/
85 RealType
86 longRangePotential; /**< long-range contributions to the potential */
87 RealType reciprocalPotential; /**< reciprocal-space contributions to the
88 potential */
89 RealType
90 surfacePotential; /**< surface-term contributions to the potential */
91 RealType bondPotential; /**< bonded contribution to the potential */
92 RealType bendPotential; /**< angle-bending contribution to the potential */
93 RealType torsionPotential; /**< dihedral (torsion angle) contribution to the
94 potential */
95 RealType inversionPotential; /**< inversion (planarity) contribution to the
96 potential */
97 potVec lrPotentials; /**< breakdown of long-range potentials by family */
98 RealType selfPotential; /**< potential energy of self interactions */
99 potVec selfPotentials; /**< breakdown of self interactions by family */
100 RealType
101 excludedPotential; /**< potential energy excluded from atomic forces */
102 potVec
103 excludedPotentials; /**< breakdown of excluded potentials by family */
104 RealType restraintPotential; /**< potential energy of restraints */
105 RealType rawPotential; /**< unrestrained potential energy (when restraints
106 are applied) */
107 potVec selectionPotentials; /**< potential of selected stuntDoubles */
108 RealType xyArea; /**< XY area of this frame */
109 RealType xzArea; /**< XZ area of this frame */
110 RealType yzArea; /**< YZ area of this frame */
111 RealType volume; /**< total volume of this frame */
112 RealType pressure; /**< pressure of this frame */
113 RealType temperature; /**< temperature of this frame */
114 pair<RealType, RealType> thermostat; /**< thermostat variables */
115 RealType electronicTemperature; /**< temperature of the electronic degrees
116 of freedom */
117 RealType netCharge; /**< total net charge in the system */
118 RealType chargeMomentum; /**< total charge momentum in the system */
119 pair<RealType, RealType>
120 electronicThermostat; /**< thermostat variables for electronic degrees
121 of freedom */
122 Mat3x3d barostat; /**< barostat matrix */
123 Vector3d COM; /**< location of system center of mass */
124 Vector3d COMvel; /**< system center of mass velocity */
125 Vector3d COMw; /**< system center of mass angular velocity */
126 Mat3x3d inertiaTensor; /**< inertia tensor for entire system */
127 RealType gyrationalVolume; /**< gyrational volume for entire system */
128 RealType hullVolume; /**< hull volume for entire system */
129 Mat3x3d virialTensor; /**< virial tensor */
130 Mat3x3d pressureTensor; /**< pressure tensor */
131 Vector3d systemDipole; /**< total system dipole moment */
132 Mat3x3d systemQuadrupole; /**< total system quadrupole moment */
133 Vector3d conductiveHeatFlux; /**< heat flux vector (conductive only) */
134 Vector3d convectiveHeatFlux; /**< heat flux vector (convective only) */
135 RealType conservedQuantity; /**< anything conserved by the integrator */
136 std::shared_ptr<SPFData> spfData {
137 nullptr}; /**< parameters for restarting an SPF simulation */
138 };
139
140 /**
141 * @class Snapshot
142 * @brief The Snapshot class is a repository storing dynamic data during a
143 * Simulation. Every Snapshot contains FrameData (for global information)
144 * as well as DataStorage (one for Atoms, one for RigidBodies, and one for
145 * CutoffGroups).
146 */
147 class Snapshot {
148 public:
149 Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, bool usePBC);
150 Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
151 int atomStorageLayout, int rigidBodyStorageLayout,
152 int cutoffGroupStorageLayout, bool usePBC);
153 /** Returns the id of this Snapshot */
154 int getID();
155 /** Sets the id of this Snapshot */
156 void setID(int id);
157
158 /** sets the state of the computed properties to false */
160
161 int getSize();
162 /** Returns the number of atoms */
163 int getNumberOfAtoms();
164 /** Returns the number of rigid bodies */
166 /** Returns the number of rigid bodies */
168 /** Returns the number of bytes in a FrameData structure */
169 static int getFrameDataSize();
170
171 /** Returns the H-Matrix */
173 /** Sets the H-Matrix */
174 void setHmat(const Mat3x3d& m);
175 /** Returns the inverse H-Matrix */
177
178 /** Returns the Bounding Box */
180 /** Sets the Bounding Box */
181 void setBoundingBox(const Mat3x3d& m);
182 /** Returns the inverse Bounding Box*/
184
185 RealType getVolume();
186 RealType getXYarea();
187 RealType getXZarea();
188 RealType getYZarea();
189 void setVolume(const RealType vol);
190
191 /** Wrapping the vector according to periodic boundary condition*/
192 void wrapVector(Vector3d& v);
193
194 /** Scaling a vector to multiples of the periodic box */
196
197 void setCOM(const Vector3d& com);
198 void setCOMvel(const Vector3d& comVel);
199 void setCOMw(const Vector3d& comw);
200
201 Vector3d getCOM();
202 Vector3d getCOMvel();
203 Vector3d getCOMw();
204
205 RealType getTime();
206 void increaseTime(const RealType dt);
207 void setTime(const RealType time);
208
209 void setBondPotential(const RealType bp);
210 void setBendPotential(const RealType bp);
211 void setTorsionPotential(const RealType tp);
212 void setInversionPotential(const RealType ip);
213 RealType getBondPotential();
214 RealType getBendPotential();
215 RealType getTorsionPotential();
216 RealType getInversionPotential();
217
218 RealType getShortRangePotential();
219
220 void setLongRangePotentials(const potVec lrPot);
221 RealType getLongRangePotential();
222 potVec getLongRangePotentials();
223
224 void setReciprocalPotential(const RealType rp);
225 RealType getReciprocalPotential();
226
227 void setSurfacePotential(const RealType sp);
228 RealType getSurfacePotential();
229
230 void setSelfPotentials(const potVec sp);
231 RealType getSelfPotential();
232 potVec getSelfPotentials();
233
234 void setExcludedPotentials(const potVec exPot);
235 potVec getExcludedPotentials();
236 RealType getExcludedPotential();
237
238 void setRestraintPotential(const RealType rp);
239 RealType getRestraintPotential();
240
241 void setRawPotential(const RealType rp);
242 RealType getRawPotential();
243
244 void setSelectionPotentials(const potVec selPot);
245 potVec getSelectionPotentials();
246
247 RealType getPotentialEnergy();
248 void setPotentialEnergy(const RealType pe);
249 RealType getKineticEnergy();
250 RealType getTranslationalKineticEnergy();
251 RealType getRotationalKineticEnergy();
252 RealType getElectronicKineticEnergy();
253 void setKineticEnergy(const RealType ke);
254 void setTranslationalKineticEnergy(const RealType tke);
255 void setRotationalKineticEnergy(const RealType rke);
256 void setElectronicKineticEnergy(const RealType eke);
257 RealType getTotalEnergy();
258 void setTotalEnergy(const RealType te);
259 RealType getConservedQuantity();
260 void setConservedQuantity(const RealType cq);
261 RealType getTemperature();
262 void setTemperature(const RealType temp);
263 RealType getElectronicTemperature();
264 void setElectronicTemperature(const RealType eTemp);
265 RealType getNetCharge();
266 void setNetCharge(const RealType nChg);
267 RealType getChargeMomentum();
268 void setChargeMomentum(const RealType cMom);
269
270 RealType getPressure();
271 void setPressure(const RealType pressure);
272
273 Mat3x3d getPressureTensor();
274 void setPressureTensor(const Mat3x3d& pressureTensor);
275
276 Mat3x3d getVirialTensor();
277 void setVirialTensor(const Mat3x3d& virialTensor);
278
279 Vector3d getConductiveHeatFlux();
280 void setConductiveHeatFlux(const Vector3d& chf);
281
282 Vector3d getConvectiveHeatFlux();
283 void setConvectiveHeatFlux(const Vector3d& chf);
284
285 Vector3d getHeatFlux();
286
287 Vector3d getSystemDipole();
288 void setSystemDipole(const Vector3d& bd);
289
290 Mat3x3d getSystemQuadrupole();
291 void setSystemQuadrupole(const Mat3x3d& bq);
292
293 pair<RealType, RealType> getThermostat();
294 void setThermostat(const pair<RealType, RealType>& thermostat);
295
296 pair<RealType, RealType> getElectronicThermostat();
297 void setElectronicThermostat(const pair<RealType, RealType>& eThermostat);
298
299 Mat3x3d getBarostat();
300 void setBarostat(const Mat3x3d& barostat);
301
302 std::shared_ptr<SPFData> getSPFData();
303 void setSPFData(std::shared_ptr<SPFData> data);
304
305 Mat3x3d getInertiaTensor();
306 void setInertiaTensor(const Mat3x3d& inertiaTensor);
307
308 RealType getGyrationalVolume();
309 void setGyrationalVolume(const RealType gv);
310
311 RealType getHullVolume();
312 void setHullVolume(const RealType hv);
313
314 void setOrthoTolerance(RealType orthoTolerance);
315
316 DataStorage atomData;
317 DataStorage rigidbodyData;
318 DataStorage cgData;
319 FrameData frameData;
320
321 bool hasTotalEnergy;
322 bool hasTranslationalKineticEnergy;
323 bool hasRotationalKineticEnergy;
324 bool hasElectronicKineticEnergy;
325 bool hasKineticEnergy;
326 bool hasShortRangePotential;
327 bool hasLongRangePotential;
328 bool hasExcludedPotential;
329 bool hasSelfPotential;
330 bool hasPotentialEnergy;
331 bool hasXYarea;
332 bool hasXZarea;
333 bool hasYZarea;
334 bool hasVolume;
335 bool hasPressure;
336 bool hasTemperature;
337 bool hasElectronicTemperature;
338 bool hasNetCharge;
339 bool hasChargeMomentum;
340 bool hasCOM;
341 bool hasCOMvel;
342 bool hasCOMw;
343 bool hasPressureTensor;
344 bool hasSystemDipole;
345 bool hasSystemQuadrupole;
346 bool hasConvectiveHeatFlux;
347 bool hasInertiaTensor;
348 bool hasGyrationalVolume;
349 bool hasHullVolume;
350 bool hasBoundingBox;
351
352 private:
353 RealType orthoTolerance_;
354 };
355
356 typedef DataStorage(Snapshot::*DataStoragePointer);
357
358 // translation from typedef into using:
359 // using DataStoragePointer = DataStorage Snapshot::*;
360} // namespace OpenMD
361
362#endif // BRAINS_SNAPSHOT_HPP
The Snapshot class is a repository storing dynamic data during a Simulation.
Definition Snapshot.hpp:147
Vector3d scaleVector(Vector3d &v)
Scaling a vector to multiples of the periodic box.
Definition Snapshot.cpp:358
Mat3x3d getHmat()
Returns the H-Matrix.
Definition Snapshot.cpp:214
Mat3x3d getInvHmat()
Returns the inverse H-Matrix.
Definition Snapshot.cpp:278
void clearDerivedProperties()
sets the state of the computed properties to false
Definition Snapshot.cpp:135
void setHmat(const Mat3x3d &m)
Sets the H-Matrix.
Definition Snapshot.cpp:217
Mat3x3d getBoundingBox()
Returns the Bounding Box.
Definition Snapshot.cpp:281
int getNumberOfAtoms()
Returns the number of atoms.
Definition Snapshot.cpp:202
int getNumberOfRigidBodies()
Returns the number of rigid bodies.
Definition Snapshot.cpp:205
void setID(int id)
Sets the id of this Snapshot.
Definition Snapshot.cpp:195
Mat3x3d getInvBoundingBox()
Returns the inverse Bounding Box.
Definition Snapshot.cpp:291
void setBoundingBox(const Mat3x3d &m)
Sets the Bounding Box.
Definition Snapshot.cpp:284
static int getFrameDataSize()
Returns the number of bytes in a FrameData structure.
Definition Snapshot.cpp:211
void wrapVector(Vector3d &v)
Wrapping the vector according to periodic boundary condition.
Definition Snapshot.cpp:337
int getNumberOfCutoffGroups()
Returns the number of rigid bodies.
Definition Snapshot.cpp:208
int getID()
Returns the id of this Snapshot.
Definition Snapshot.cpp:192
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
FrameData is a structure for holding system-wide dynamic data about the simulation.
Definition Snapshot.hpp:67
RealType xyArea
XY area of this frame.
Definition Snapshot.hpp:108
RealType totalEnergy
total energy of this frame
Definition Snapshot.hpp:76
pair< RealType, RealType > electronicThermostat
thermostat variables for electronic degrees of freedom
Definition Snapshot.hpp:120
RealType yzArea
YZ area of this frame.
Definition Snapshot.hpp:110
RealType excludedPotential
potential energy excluded from atomic forces
Definition Snapshot.hpp:101
Vector3d COMvel
system center of mass velocity
Definition Snapshot.hpp:124
bool orthoRhombic
is this an orthorhombic periodic box?
Definition Snapshot.hpp:75
int id
identification number of the snapshot
Definition Snapshot.hpp:68
Mat3x3d systemQuadrupole
total system quadrupole moment
Definition Snapshot.hpp:132
Mat3x3d invHmat
the inverse of the Hmat matrix
Definition Snapshot.hpp:71
Vector3d COM
location of system center of mass
Definition Snapshot.hpp:123
Mat3x3d inertiaTensor
inertia tensor for entire system
Definition Snapshot.hpp:126
RealType reciprocalPotential
reciprocal-space contributions to the potential
Definition Snapshot.hpp:87
RealType temperature
temperature of this frame
Definition Snapshot.hpp:113
potVec lrPotentials
breakdown of long-range potentials by family
Definition Snapshot.hpp:97
RealType conservedQuantity
anything conserved by the integrator
Definition Snapshot.hpp:135
Vector3d systemDipole
total system dipole moment
Definition Snapshot.hpp:131
RealType chargeMomentum
total charge momentum in the system
Definition Snapshot.hpp:118
Vector3d COMw
system center of mass angular velocity
Definition Snapshot.hpp:125
Mat3x3d bBox
axes of a bounding box in matrix form
Definition Snapshot.hpp:72
RealType xzArea
XZ area of this frame.
Definition Snapshot.hpp:109
RealType rotationalKinetic
rotational kinetic energy of this frame
Definition Snapshot.hpp:79
RealType electronicKinetic
electronic kinetic energy of this frame
Definition Snapshot.hpp:80
RealType bondPotential
bonded contribution to the potential
Definition Snapshot.hpp:91
RealType rawPotential
unrestrained potential energy (when restraints are applied)
Definition Snapshot.hpp:105
RealType kineticEnergy
kinetic energy of this frame
Definition Snapshot.hpp:81
RealType volume
total volume of this frame
Definition Snapshot.hpp:111
RealType electronicTemperature
temperature of the electronic degrees of freedom
Definition Snapshot.hpp:115
RealType gyrationalVolume
gyrational volume for entire system
Definition Snapshot.hpp:127
RealType shortRangePotential
short-range contributions to the potential
Definition Snapshot.hpp:84
RealType restraintPotential
potential energy of restraints
Definition Snapshot.hpp:104
Vector3d convectiveHeatFlux
heat flux vector (convective only)
Definition Snapshot.hpp:134
Mat3x3d barostat
barostat matrix
Definition Snapshot.hpp:122
RealType netCharge
total net charge in the system
Definition Snapshot.hpp:117
RealType translationalKinetic
translational kinetic energy of this frame
Definition Snapshot.hpp:78
RealType potentialEnergy
potential energy of this frame
Definition Snapshot.hpp:82
bool usePBC
are we using a periodic box?
Definition Snapshot.hpp:74
potVec selfPotentials
breakdown of self interactions by family
Definition Snapshot.hpp:99
RealType bendPotential
angle-bending contribution to the potential
Definition Snapshot.hpp:92
potVec excludedPotentials
breakdown of excluded potentials by family
Definition Snapshot.hpp:103
RealType torsionPotential
dihedral (torsion angle) contribution to the potential
Definition Snapshot.hpp:93
RealType pressure
pressure of this frame
Definition Snapshot.hpp:112
Mat3x3d virialTensor
virial tensor
Definition Snapshot.hpp:129
RealType hullVolume
hull volume for entire system
Definition Snapshot.hpp:128
RealType surfacePotential
surface-term contributions to the potential
Definition Snapshot.hpp:90
Mat3x3d hmat
axes of the periodic box in matrix form
Definition Snapshot.hpp:70
pair< RealType, RealType > thermostat
thermostat variables
Definition Snapshot.hpp:114
RealType inversionPotential
inversion (planarity) contribution to the potential
Definition Snapshot.hpp:95
potVec selectionPotentials
potential of selected stuntDoubles
Definition Snapshot.hpp:107
RealType selfPotential
potential energy of self interactions
Definition Snapshot.hpp:98
std::shared_ptr< SPFData > spfData
parameters for restarting an SPF simulation
Definition Snapshot.hpp:136
Mat3x3d pressureTensor
pressure tensor
Definition Snapshot.hpp:130
RealType longRangePotential
long-range contributions to the potential
Definition Snapshot.hpp:86
Mat3x3d invBbox
the inverse of the bounding box
Definition Snapshot.hpp:73
RealType currentTime
current time
Definition Snapshot.hpp:69
Vector3d conductiveHeatFlux
heat flux vector (conductive only)
Definition Snapshot.hpp:133