OpenMD 3.2
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 following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48#ifndef BRAINS_SNAPSHOT_HPP
49#define BRAINS_SNAPSHOT_HPP
50
51#include <vector>
52
53#include "brains/DataStorage.hpp"
54#include "brains/Stats.hpp"
55#include "nonbonded/NonBondedInteraction.hpp"
56
57using namespace std;
58namespace OpenMD {
59
60 /**
61 * Storage specific to the SPF-RNEMD method that allows for a new simulation
62 * to pick up where an old one left off.
63 *
64 * \note used primarily in a \c std::shared_ptr
65 */
66 struct SPFData {
67 Vector3d pos {V3Zero}; /**< location to place a selected molecule */
68 RealType lambda {0.0}; /**< how much of the molecule has been transferred */
69 int globalID {-1}; /**< which molecule have we selected */
70
71 /**
72 * Reset member variables to their defaults. Prefer this to resetting a
73 * \c std::shared_ptr<SPFData> or allocating/deallocating more memory.
74 */
75 void clear() {
76 pos = V3Zero;
77 lambda = 0.0;
78 globalID = -1;
79 }
80 };
81
82 /**
83 * FrameData is a structure for holding system-wide dynamic data
84 * about the simulation.
85 */
86 struct FrameData {
87 int id; /**< identification number of the snapshot */
88 RealType currentTime; /**< current time */
89 Mat3x3d hmat; /**< axes of the periodic box in matrix form */
90 Mat3x3d invHmat; /**< the inverse of the Hmat matrix */
91 Mat3x3d bBox; /**< axes of a bounding box in matrix form */
92 Mat3x3d invBbox; /**< the inverse of the bounding box */
93 bool usePBC; /**< are we using a periodic box? */
94 bool orthoRhombic; /**< is this an orthorhombic periodic box? */
95 RealType totalEnergy; /**< total energy of this frame */
96 RealType
97 translationalKinetic; /**< translational kinetic energy of this frame */
98 RealType rotationalKinetic; /**< rotational kinetic energy of this frame */
99 RealType electronicKinetic; /**< electronic kinetic energy of this frame */
100 RealType kineticEnergy; /**< kinetic energy of this frame */
101 RealType potentialEnergy; /**< potential energy of this frame */
102 RealType
103 shortRangePotential; /**< short-range contributions to the potential*/
104 RealType
105 longRangePotential; /**< long-range contributions to the potential */
106 RealType reciprocalPotential; /**< reciprocal-space contributions to the
107 potential */
108 RealType
109 surfacePotential; /**< surface-term contributions to the potential */
110 RealType bondPotential; /**< bonded contribution to the potential */
111 RealType bendPotential; /**< angle-bending contribution to the potential */
112 RealType torsionPotential; /**< dihedral (torsion angle) contribution to the
113 potential */
114 RealType inversionPotential; /**< inversion (planarity) contribution to the
115 potential */
116 potVec lrPotentials; /**< breakdown of long-range potentials by family */
117 RealType selfPotential; /**< potential energy of self interactions */
118 potVec selfPotentials; /**< breakdown of self interactions by family */
119 RealType
120 excludedPotential; /**< potential energy excluded from atomic forces */
121 potVec
122 excludedPotentials; /**< breakdown of excluded potentials by family */
123 RealType restraintPotential; /**< potential energy of restraints */
124 RealType rawPotential; /**< unrestrained potential energy (when restraints
125 are applied) */
126 potVec selectionPotentials; /**< potential of selected stuntDoubles */
127 RealType xyArea; /**< XY area of this frame */
128 RealType xzArea; /**< XZ area of this frame */
129 RealType yzArea; /**< YZ area of this frame */
130 RealType volume; /**< total volume of this frame */
131 RealType pressure; /**< pressure of this frame */
132 RealType temperature; /**< temperature of this frame */
133 pair<RealType, RealType> thermostat; /**< thermostat variables */
134 RealType electronicTemperature; /**< temperature of the electronic degrees
135 of freedom */
136 RealType netCharge; /**< total net charge in the system */
137 RealType chargeMomentum; /**< total charge momentum in the system */
138 pair<RealType, RealType>
139 electronicThermostat; /**< thermostat variables for electronic degrees
140 of freedom */
141 Mat3x3d barostat; /**< barostat matrix */
142 Vector3d COM; /**< location of system center of mass */
143 Vector3d COMvel; /**< system center of mass velocity */
144 Vector3d COMw; /**< system center of mass angular velocity */
145 Mat3x3d inertiaTensor; /**< inertia tensor for entire system */
146 RealType gyrationalVolume; /**< gyrational volume for entire system */
147 RealType hullVolume; /**< hull volume for entire system */
148 Mat3x3d virialTensor; /**< virial tensor */
149 Mat3x3d pressureTensor; /**< pressure tensor */
150 Vector3d systemDipole; /**< total system dipole moment */
151 Mat3x3d systemQuadrupole; /**< total system quadrupole moment */
152 Vector3d conductiveHeatFlux; /**< heat flux vector (conductive only) */
153 Vector3d convectiveHeatFlux; /**< heat flux vector (convective only) */
154 RealType conservedQuantity; /**< anything conserved by the integrator */
155 std::shared_ptr<SPFData> spfData {
156 nullptr}; /**< parameters for restarting an SPF simulation */
157 };
158
159 /**
160 * @class Snapshot
161 * @brief The Snapshot class is a repository storing dynamic data during a
162 * Simulation. Every Snapshot contains FrameData (for global information)
163 * as well as DataStorage (one for Atoms, one for RigidBodies, and one for
164 * CutoffGroups).
165 */
166 class Snapshot {
167 public:
168 Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups, bool usePBC);
169 Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
170 int atomStorageLayout, int rigidBodyStorageLayout,
171 int cutoffGroupStorageLayout, bool usePBC);
172 /** Returns the id of this Snapshot */
173 int getID();
174 /** Sets the id of this Snapshot */
175 void setID(int id);
176
177 /** sets the state of the computed properties to false */
179
180 int getSize();
181 /** Returns the number of atoms */
182 int getNumberOfAtoms();
183 /** Returns the number of rigid bodies */
185 /** Returns the number of rigid bodies */
187 /** Returns the number of bytes in a FrameData structure */
188 static int getFrameDataSize();
189
190 /** Returns the H-Matrix */
191 Mat3x3d getHmat();
192 /** Sets the H-Matrix */
193 void setHmat(const Mat3x3d& m);
194 /** Returns the inverse H-Matrix */
195 Mat3x3d getInvHmat();
196
197 /** Returns the Bounding Box */
198 Mat3x3d getBoundingBox();
199 /** Sets the Bounding Box */
200 void setBoundingBox(const Mat3x3d& m);
201 /** Returns the inverse Bounding Box*/
202 Mat3x3d getInvBoundingBox();
203
204 RealType getVolume();
205 RealType getXYarea();
206 RealType getXZarea();
207 RealType getYZarea();
208 void setVolume(const RealType vol);
209
210 /** Wrapping the vector according to periodic boundary condition*/
211 void wrapVector(Vector3d& v);
212
213 /** Scaling a vector to multiples of the periodic box */
214 Vector3d scaleVector(Vector3d& v);
215
216 void setCOM(const Vector3d& com);
217 void setCOMvel(const Vector3d& comVel);
218 void setCOMw(const Vector3d& comw);
219
220 Vector3d getCOM();
221 Vector3d getCOMvel();
222 Vector3d getCOMw();
223
224 RealType getTime();
225 void increaseTime(const RealType dt);
226 void setTime(const RealType time);
227
228 void setBondPotential(const RealType bp);
229 void setBendPotential(const RealType bp);
230 void setTorsionPotential(const RealType tp);
231 void setInversionPotential(const RealType ip);
232 RealType getBondPotential();
233 RealType getBendPotential();
234 RealType getTorsionPotential();
235 RealType getInversionPotential();
236
237 RealType getShortRangePotential();
238
239 void setLongRangePotentials(const potVec lrPot);
240 RealType getLongRangePotential();
241 potVec getLongRangePotentials();
242
243 void setReciprocalPotential(const RealType rp);
244 RealType getReciprocalPotential();
245
246 void setSurfacePotential(const RealType sp);
247 RealType getSurfacePotential();
248
249 void setSelfPotentials(const potVec sp);
250 RealType getSelfPotential();
251 potVec getSelfPotentials();
252
253 void setExcludedPotentials(const potVec exPot);
254 potVec getExcludedPotentials();
255 RealType getExcludedPotential();
256
257 void setRestraintPotential(const RealType rp);
258 RealType getRestraintPotential();
259
260 void setRawPotential(const RealType rp);
261 RealType getRawPotential();
262
263 void setSelectionPotentials(const potVec selPot);
264 potVec getSelectionPotentials();
265
266 RealType getPotentialEnergy();
267 void setPotentialEnergy(const RealType pe);
268 RealType getKineticEnergy();
269 RealType getTranslationalKineticEnergy();
270 RealType getRotationalKineticEnergy();
271 RealType getElectronicKineticEnergy();
272 void setKineticEnergy(const RealType ke);
273 void setTranslationalKineticEnergy(const RealType tke);
274 void setRotationalKineticEnergy(const RealType rke);
275 void setElectronicKineticEnergy(const RealType eke);
276 RealType getTotalEnergy();
277 void setTotalEnergy(const RealType te);
278 RealType getConservedQuantity();
279 void setConservedQuantity(const RealType cq);
280 RealType getTemperature();
281 void setTemperature(const RealType temp);
282 RealType getElectronicTemperature();
283 void setElectronicTemperature(const RealType eTemp);
284 RealType getNetCharge();
285 void setNetCharge(const RealType nChg);
286 RealType getChargeMomentum();
287 void setChargeMomentum(const RealType cMom);
288
289 RealType getPressure();
290 void setPressure(const RealType pressure);
291
292 Mat3x3d getPressureTensor();
293 void setPressureTensor(const Mat3x3d& pressureTensor);
294
295 Mat3x3d getVirialTensor();
296 void setVirialTensor(const Mat3x3d& virialTensor);
297
298 Vector3d getConductiveHeatFlux();
299 void setConductiveHeatFlux(const Vector3d& chf);
300
301 Vector3d getConvectiveHeatFlux();
302 void setConvectiveHeatFlux(const Vector3d& chf);
303
304 Vector3d getHeatFlux();
305
306 Vector3d getSystemDipole();
307 void setSystemDipole(const Vector3d& bd);
308
309 Mat3x3d getSystemQuadrupole();
310 void setSystemQuadrupole(const Mat3x3d& bq);
311
312 pair<RealType, RealType> getThermostat();
313 void setThermostat(const pair<RealType, RealType>& thermostat);
314
315 pair<RealType, RealType> getElectronicThermostat();
316 void setElectronicThermostat(const pair<RealType, RealType>& eThermostat);
317
318 Mat3x3d getBarostat();
319 void setBarostat(const Mat3x3d& barostat);
320
321 std::shared_ptr<SPFData> getSPFData();
322 void setSPFData(std::shared_ptr<SPFData> data);
323
324 Mat3x3d getInertiaTensor();
325 void setInertiaTensor(const Mat3x3d& inertiaTensor);
326
327 RealType getGyrationalVolume();
328 void setGyrationalVolume(const RealType gv);
329
330 RealType getHullVolume();
331 void setHullVolume(const RealType hv);
332
333 void setOrthoTolerance(RealType orthoTolerance);
334
335 DataStorage atomData;
336 DataStorage rigidbodyData;
337 DataStorage cgData;
338 FrameData frameData;
339
340 bool hasTotalEnergy;
341 bool hasTranslationalKineticEnergy;
342 bool hasRotationalKineticEnergy;
343 bool hasElectronicKineticEnergy;
344 bool hasKineticEnergy;
345 bool hasShortRangePotential;
346 bool hasLongRangePotential;
347 bool hasExcludedPotential;
348 bool hasSelfPotential;
349 bool hasPotentialEnergy;
350 bool hasXYarea;
351 bool hasXZarea;
352 bool hasYZarea;
353 bool hasVolume;
354 bool hasPressure;
355 bool hasTemperature;
356 bool hasElectronicTemperature;
357 bool hasNetCharge;
358 bool hasChargeMomentum;
359 bool hasCOM;
360 bool hasCOMvel;
361 bool hasCOMw;
362 bool hasPressureTensor;
363 bool hasSystemDipole;
364 bool hasSystemQuadrupole;
365 bool hasConvectiveHeatFlux;
366 bool hasInertiaTensor;
367 bool hasGyrationalVolume;
368 bool hasHullVolume;
369 bool hasBoundingBox;
370
371 private:
372 RealType orthoTolerance_;
373 };
374
375 typedef DataStorage(Snapshot::*DataStoragePointer);
376
377 // translation from typedef into using:
378 // using DataStoragePointer = DataStorage Snapshot::*;
379} // namespace OpenMD
380
381#endif // BRAINS_SNAPSHOT_HPP
The Snapshot class is a repository storing dynamic data during a Simulation.
Definition Snapshot.hpp:166
Vector3d scaleVector(Vector3d &v)
Scaling a vector to multiples of the periodic box.
Definition Snapshot.cpp:361
Mat3x3d getHmat()
Returns the H-Matrix.
Definition Snapshot.cpp:217
Mat3x3d getInvHmat()
Returns the inverse H-Matrix.
Definition Snapshot.cpp:281
void clearDerivedProperties()
sets the state of the computed properties to false
Definition Snapshot.cpp:138
void setHmat(const Mat3x3d &m)
Sets the H-Matrix.
Definition Snapshot.cpp:220
Mat3x3d getBoundingBox()
Returns the Bounding Box.
Definition Snapshot.cpp:284
int getNumberOfAtoms()
Returns the number of atoms.
Definition Snapshot.cpp:205
int getNumberOfRigidBodies()
Returns the number of rigid bodies.
Definition Snapshot.cpp:208
void setID(int id)
Sets the id of this Snapshot.
Definition Snapshot.cpp:198
Mat3x3d getInvBoundingBox()
Returns the inverse Bounding Box.
Definition Snapshot.cpp:294
void setBoundingBox(const Mat3x3d &m)
Sets the Bounding Box.
Definition Snapshot.cpp:287
static int getFrameDataSize()
Returns the number of bytes in a FrameData structure.
Definition Snapshot.cpp:214
void wrapVector(Vector3d &v)
Wrapping the vector according to periodic boundary condition.
Definition Snapshot.cpp:340
int getNumberOfCutoffGroups()
Returns the number of rigid bodies.
Definition Snapshot.cpp:211
int getID()
Returns the id of this Snapshot.
Definition Snapshot.cpp:195
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:86
RealType xyArea
XY area of this frame.
Definition Snapshot.hpp:127
RealType totalEnergy
total energy of this frame
Definition Snapshot.hpp:95
pair< RealType, RealType > electronicThermostat
thermostat variables for electronic degrees of freedom
Definition Snapshot.hpp:139
RealType yzArea
YZ area of this frame.
Definition Snapshot.hpp:129
RealType excludedPotential
potential energy excluded from atomic forces
Definition Snapshot.hpp:120
Vector3d COMvel
system center of mass velocity
Definition Snapshot.hpp:143
bool orthoRhombic
is this an orthorhombic periodic box?
Definition Snapshot.hpp:94
int id
identification number of the snapshot
Definition Snapshot.hpp:87
Mat3x3d systemQuadrupole
total system quadrupole moment
Definition Snapshot.hpp:151
Mat3x3d invHmat
the inverse of the Hmat matrix
Definition Snapshot.hpp:90
Vector3d COM
location of system center of mass
Definition Snapshot.hpp:142
Mat3x3d inertiaTensor
inertia tensor for entire system
Definition Snapshot.hpp:145
RealType reciprocalPotential
reciprocal-space contributions to the potential
Definition Snapshot.hpp:106
RealType temperature
temperature of this frame
Definition Snapshot.hpp:132
potVec lrPotentials
breakdown of long-range potentials by family
Definition Snapshot.hpp:116
RealType conservedQuantity
anything conserved by the integrator
Definition Snapshot.hpp:154
Vector3d systemDipole
total system dipole moment
Definition Snapshot.hpp:150
RealType chargeMomentum
total charge momentum in the system
Definition Snapshot.hpp:137
Vector3d COMw
system center of mass angular velocity
Definition Snapshot.hpp:144
Mat3x3d bBox
axes of a bounding box in matrix form
Definition Snapshot.hpp:91
RealType xzArea
XZ area of this frame.
Definition Snapshot.hpp:128
RealType rotationalKinetic
rotational kinetic energy of this frame
Definition Snapshot.hpp:98
RealType electronicKinetic
electronic kinetic energy of this frame
Definition Snapshot.hpp:99
RealType bondPotential
bonded contribution to the potential
Definition Snapshot.hpp:110
RealType rawPotential
unrestrained potential energy (when restraints are applied)
Definition Snapshot.hpp:124
RealType kineticEnergy
kinetic energy of this frame
Definition Snapshot.hpp:100
RealType volume
total volume of this frame
Definition Snapshot.hpp:130
RealType electronicTemperature
temperature of the electronic degrees of freedom
Definition Snapshot.hpp:134
RealType gyrationalVolume
gyrational volume for entire system
Definition Snapshot.hpp:146
RealType shortRangePotential
short-range contributions to the potential
Definition Snapshot.hpp:103
RealType restraintPotential
potential energy of restraints
Definition Snapshot.hpp:123
Vector3d convectiveHeatFlux
heat flux vector (convective only)
Definition Snapshot.hpp:153
Mat3x3d barostat
barostat matrix
Definition Snapshot.hpp:141
RealType netCharge
total net charge in the system
Definition Snapshot.hpp:136
RealType translationalKinetic
translational kinetic energy of this frame
Definition Snapshot.hpp:97
RealType potentialEnergy
potential energy of this frame
Definition Snapshot.hpp:101
bool usePBC
are we using a periodic box?
Definition Snapshot.hpp:93
potVec selfPotentials
breakdown of self interactions by family
Definition Snapshot.hpp:118
RealType bendPotential
angle-bending contribution to the potential
Definition Snapshot.hpp:111
potVec excludedPotentials
breakdown of excluded potentials by family
Definition Snapshot.hpp:122
RealType torsionPotential
dihedral (torsion angle) contribution to the potential
Definition Snapshot.hpp:112
RealType pressure
pressure of this frame
Definition Snapshot.hpp:131
Mat3x3d virialTensor
virial tensor
Definition Snapshot.hpp:148
RealType hullVolume
hull volume for entire system
Definition Snapshot.hpp:147
RealType surfacePotential
surface-term contributions to the potential
Definition Snapshot.hpp:109
Mat3x3d hmat
axes of the periodic box in matrix form
Definition Snapshot.hpp:89
pair< RealType, RealType > thermostat
thermostat variables
Definition Snapshot.hpp:133
RealType inversionPotential
inversion (planarity) contribution to the potential
Definition Snapshot.hpp:114
potVec selectionPotentials
potential of selected stuntDoubles
Definition Snapshot.hpp:126
RealType selfPotential
potential energy of self interactions
Definition Snapshot.hpp:117
std::shared_ptr< SPFData > spfData
parameters for restarting an SPF simulation
Definition Snapshot.hpp:155
Mat3x3d pressureTensor
pressure tensor
Definition Snapshot.hpp:149
RealType longRangePotential
long-range contributions to the potential
Definition Snapshot.hpp:105
Mat3x3d invBbox
the inverse of the bounding box
Definition Snapshot.hpp:92
RealType currentTime
current time
Definition Snapshot.hpp:88
Vector3d conductiveHeatFlux
heat flux vector (conductive only)
Definition Snapshot.hpp:152
Storage specific to the SPF-RNEMD method that allows for a new simulation to pick up where an old one...
Definition Snapshot.hpp:66
RealType lambda
how much of the molecule has been transferred
Definition Snapshot.hpp:68
void clear()
Reset member variables to their defaults.
Definition Snapshot.hpp:75
Vector3d pos
location to place a selected molecule
Definition Snapshot.hpp:67
int globalID
which molecule have we selected
Definition Snapshot.hpp:69