OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Snapshot.cpp
Go to the documentation of this file.
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/**
49 * @file Snapshot.cpp
50 * @author tlin
51 * @date 11/11/2004
52 * @version 1.0
53 */
54
55#include "brains/Snapshot.hpp"
56
57#include <cstdio>
58
59#include "utils/Utility.hpp"
60#include "utils/simError.h"
61
62namespace OpenMD {
63
64 Snapshot::Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
65 bool usePBC) :
66 atomData(nAtoms),
67 rigidbodyData(nRigidbodies),
68 cgData(nCutoffGroups, DataStorage::dslPosition), orthoTolerance_(1e-6) {
69 frameData.id = -1;
70 frameData.currentTime = 0;
71 frameData.hmat = Mat3x3d(0.0);
72 frameData.invHmat = Mat3x3d(0.0);
73 frameData.orthoRhombic = false;
74 frameData.usePBC = usePBC;
75 frameData.bondPotential = 0.0;
76 frameData.bendPotential = 0.0;
77 frameData.torsionPotential = 0.0;
78 frameData.inversionPotential = 0.0;
79 frameData.lrPotentials = potVec(0.0);
80 frameData.surfacePotential = 0.0;
81 frameData.reciprocalPotential = 0.0;
82 frameData.selfPotentials = potVec(0.0);
83 frameData.excludedPotentials = potVec(0.0);
84 frameData.restraintPotential = 0.0;
85 frameData.rawPotential = 0.0;
86 frameData.xyArea = 0.0;
87 frameData.xzArea = 0.0;
88 frameData.yzArea = 0.0;
89 frameData.volume = 0.0;
90 frameData.thermostat = make_pair(0.0, 0.0);
91 frameData.electronicThermostat = make_pair(0.0, 0.0);
92 frameData.barostat = Mat3x3d(0.0);
93 frameData.virialTensor = Mat3x3d(0.0);
94 frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
95 frameData.spfData = std::make_shared<SPFData>();
96 clearDerivedProperties();
97 }
98
99 Snapshot::Snapshot(int nAtoms, int nRigidbodies, int nCutoffGroups,
100 int atomStorageLayout, int rigidBodyStorageLayout,
101 int cutoffGroupStorageLayout, bool usePBC) :
102 atomData(nAtoms, atomStorageLayout),
103 rigidbodyData(nRigidbodies, rigidBodyStorageLayout),
104 cgData(nCutoffGroups, cutoffGroupStorageLayout), orthoTolerance_(1e-6) {
105 frameData.id = -1;
106 frameData.currentTime = 0;
107 frameData.hmat = Mat3x3d(0.0);
108 frameData.invHmat = Mat3x3d(0.0);
109 frameData.bBox = Mat3x3d(0.0);
110 frameData.invBbox = Mat3x3d(0.0);
111 frameData.orthoRhombic = false;
112 frameData.usePBC = usePBC;
113 frameData.bondPotential = 0.0;
114 frameData.bendPotential = 0.0;
115 frameData.torsionPotential = 0.0;
116 frameData.inversionPotential = 0.0;
117 frameData.lrPotentials = potVec(0.0);
118 frameData.surfacePotential = 0.0;
119 frameData.reciprocalPotential = 0.0;
120 frameData.selfPotentials = potVec(0.0);
121 frameData.excludedPotentials = potVec(0.0);
122 frameData.restraintPotential = 0.0;
123 frameData.rawPotential = 0.0;
124 frameData.xyArea = 0.0;
125 frameData.xzArea = 0.0;
126 frameData.yzArea = 0.0;
127 frameData.volume = 0.0;
128 frameData.thermostat = make_pair(0.0, 0.0);
129 frameData.electronicThermostat = make_pair(0.0, 0.0);
130 frameData.barostat = Mat3x3d(0.0);
131 frameData.virialTensor = Mat3x3d(0.0);
132 frameData.conductiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
133 frameData.spfData = std::make_shared<SPFData>();
134
135 clearDerivedProperties();
136 }
137
139 frameData.totalEnergy = 0.0;
140 frameData.translationalKinetic = 0.0;
141 frameData.rotationalKinetic = 0.0;
142 frameData.electronicKinetic = 0.0;
143 frameData.kineticEnergy = 0.0;
144 frameData.potentialEnergy = 0.0;
145 frameData.shortRangePotential = 0.0;
146 frameData.longRangePotential = 0.0;
147 frameData.excludedPotential = 0.0;
148 frameData.selfPotential = 0.0;
149 frameData.pressure = 0.0;
150 frameData.temperature = 0.0;
151 frameData.pressureTensor = Mat3x3d(0.0);
152 frameData.systemDipole = Vector3d(0.0);
153 frameData.systemQuadrupole = Mat3x3d(0.0);
154 frameData.convectiveHeatFlux = Vector3d(0.0, 0.0, 0.0);
155 frameData.electronicTemperature = 0.0;
156 frameData.netCharge = 0.0;
157 frameData.chargeMomentum = 0.0;
158 frameData.COM = V3Zero;
159 frameData.COMvel = V3Zero;
160 frameData.COMw = V3Zero;
161
162 hasTotalEnergy = false;
163 hasTranslationalKineticEnergy = false;
164 hasRotationalKineticEnergy = false;
165 hasElectronicKineticEnergy = false;
166 hasKineticEnergy = false;
167 hasShortRangePotential = false;
168 hasLongRangePotential = false;
169 hasExcludedPotential = false;
170 hasSelfPotential = false;
171 hasPotentialEnergy = false;
172 hasXYarea = false;
173 hasXZarea = false;
174 hasYZarea = false;
175 hasVolume = false;
176 hasPressure = false;
177 hasTemperature = false;
178 hasElectronicTemperature = false;
179 hasNetCharge = false;
180 hasChargeMomentum = false;
181 hasCOM = false;
182 hasCOMvel = false;
183 hasCOMw = false;
184 hasPressureTensor = false;
185 hasSystemDipole = false;
186 hasSystemQuadrupole = false;
187 hasConvectiveHeatFlux = false;
188 hasInertiaTensor = false;
189 hasGyrationalVolume = false;
190 hasHullVolume = false;
191 hasBoundingBox = false;
192 }
193
194 /** Returns the id of this Snapshot */
195 int Snapshot::getID() { return frameData.id; }
196
197 /** Sets the id of this Snapshot */
198 void Snapshot::setID(int id) { frameData.id = id; }
199
200 int Snapshot::getSize() {
201 return atomData.getSize() + rigidbodyData.getSize();
202 }
203
204 /** Returns the number of atoms */
205 int Snapshot::getNumberOfAtoms() { return atomData.getSize(); }
206
207 /** Returns the number of rigid bodies */
208 int Snapshot::getNumberOfRigidBodies() { return rigidbodyData.getSize(); }
209
210 /** Returns the number of rigid bodies */
211 int Snapshot::getNumberOfCutoffGroups() { return cgData.getSize(); }
212
213 /** Returns the number of bytes in a FrameData structure */
214 int Snapshot::getFrameDataSize() { return sizeof(FrameData); }
215
216 /** Returns the H-Matrix */
217 Mat3x3d Snapshot::getHmat() { return frameData.hmat; }
218
219 /** Sets the H-Matrix */
220 void Snapshot::setHmat(const Mat3x3d& m) {
221 hasVolume = false;
222 frameData.hmat = m;
223 frameData.invHmat = frameData.hmat.inverse();
224
225 // determine whether the box is orthoTolerance or not
226 bool oldOrthoRhombic = frameData.orthoRhombic;
227
228 RealType smallDiag = fabs(frameData.hmat(0, 0));
229 if (smallDiag > fabs(frameData.hmat(1, 1)))
230 smallDiag = fabs(frameData.hmat(1, 1));
231 if (smallDiag > fabs(frameData.hmat(2, 2)))
232 smallDiag = fabs(frameData.hmat(2, 2));
233 RealType tol = smallDiag * orthoTolerance_;
234
235 frameData.orthoRhombic = true;
236
237 for (int i = 0; i < 3; i++) {
238 for (int j = 0; j < 3; j++) {
239 if (i != j) {
240 if (frameData.orthoRhombic) {
241 if (fabs(frameData.hmat(i, j)) >= tol)
242 frameData.orthoRhombic = false;
243 }
244 }
245 }
246 }
247
248 if (oldOrthoRhombic != frameData.orthoRhombic) {
249 // It is finally time to suppress these warnings once and for
250 // all. They were annoying and not very informative.
251
252 // if( frameData.orthoRhombic ) {
253 // snprintf( painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
254 // "OpenMD is switching from the default Non-Orthorhombic\n"
255 // "\tto the faster Orthorhombic periodic boundary
256 // computations.\n"
257 // "\tThis is usually a good thing, but if you want the\n"
258 // "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n"
259 // "\tvariable ( currently set to %G ) smaller.\n",
260 // orthoTolerance_);
261 // painCave.severity = OPENMD_INFO;
262 // simError();
263 // }
264 // else {
265 // snprintf( painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
266 // "OpenMD is switching from the faster Orthorhombic to the
267 // more\n"
268 // "\tflexible Non-Orthorhombic periodic boundary computations.\n"
269 // "\tThis is usually because the box has deformed under\n"
270 // "\tNPTf integration. If you want to live on the edge with\n"
271 // "\tthe Orthorhombic computations, make the orthoBoxTolerance\n"
272 // "\tvariable ( currently set to %G ) larger.\n",
273 // orthoTolerance_);
274 // painCave.severity = OPENMD_WARNING;
275 // simError();
276 // }
277 }
278 }
279
280 /** Returns the inverse H-Matrix */
281 Mat3x3d Snapshot::getInvHmat() { return frameData.invHmat; }
282
283 /** Returns the Bounding Box */
284 Mat3x3d Snapshot::getBoundingBox() { return frameData.bBox; }
285
286 /** Sets the Bounding Box */
287 void Snapshot::setBoundingBox(const Mat3x3d& m) {
288 frameData.bBox = m;
289 frameData.invBbox = frameData.bBox.inverse();
290 hasBoundingBox = true;
291 }
292
293 /** Returns the inverse Bounding Box */
294 Mat3x3d Snapshot::getInvBoundingBox() { return frameData.invBbox; }
295
296 RealType Snapshot::getXYarea() {
297 if (!hasXYarea) {
298 Vector3d x = frameData.hmat.getColumn(0);
299 Vector3d y = frameData.hmat.getColumn(1);
300 frameData.xyArea = cross(x, y).length();
301 hasXYarea = true;
302 }
303 return frameData.xyArea;
304 }
305
306 RealType Snapshot::getXZarea() {
307 if (!hasXZarea) {
308 Vector3d x = frameData.hmat.getColumn(0);
309 Vector3d z = frameData.hmat.getColumn(2);
310 frameData.xzArea = cross(x, z).length();
311 hasXZarea = true;
312 }
313 return frameData.xzArea;
314 }
315
316 RealType Snapshot::getYZarea() {
317 if (!hasYZarea) {
318 Vector3d y = frameData.hmat.getColumn(1);
319 Vector3d z = frameData.hmat.getColumn(2);
320 frameData.yzArea = cross(y, z).length();
321 hasYZarea = true;
322 }
323 return frameData.yzArea;
324 }
325
326 RealType Snapshot::getVolume() {
327 if (!hasVolume) {
328 frameData.volume = frameData.hmat.determinant();
329 hasVolume = true;
330 }
331 return frameData.volume;
332 }
333
334 void Snapshot::setVolume(RealType vol) {
335 hasVolume = true;
336 frameData.volume = vol;
337 }
338
339 /** Wrap a vector according to periodic boundary conditions */
340 void Snapshot::wrapVector(Vector3d& pos) {
341 if (!frameData.usePBC) return;
342
343 if (!frameData.orthoRhombic) {
344 Vector3d scaled = frameData.invHmat * pos;
345 for (int i = 0; i < 3; i++) {
346 scaled[i] -= roundMe(scaled[i]);
347 }
348 // calc the wrapped real coordinates from the wrapped scaled coordinates
349 pos = frameData.hmat * scaled;
350 } else {
351 RealType scaled;
352 for (int i = 0; i < 3; i++) {
353 scaled = pos[i] * frameData.invHmat(i, i);
354 scaled -= roundMe(scaled);
355 pos[i] = scaled * frameData.hmat(i, i);
356 }
357 }
358 }
359
360 /** Scaling a vector to multiples of the periodic box */
361 inline Vector3d Snapshot::scaleVector(Vector3d& pos) {
362 Vector3d scaled;
363
364 if (!frameData.orthoRhombic)
365 scaled = frameData.invHmat * pos;
366 else {
367 // calc the scaled coordinates.
368 for (int i = 0; i < 3; i++)
369 scaled[i] = pos[i] * frameData.invHmat(i, i);
370 }
371
372 return scaled;
373 }
374
375 void Snapshot::setCOM(const Vector3d& com) {
376 frameData.COM = com;
377 hasCOM = true;
378 }
379
380 void Snapshot::setCOMvel(const Vector3d& comVel) {
381 frameData.COMvel = comVel;
382 hasCOMvel = true;
383 }
384
385 void Snapshot::setCOMw(const Vector3d& comw) {
386 frameData.COMw = comw;
387 hasCOMw = true;
388 }
389
390 Vector3d Snapshot::getCOM() { return frameData.COM; }
391
392 Vector3d Snapshot::getCOMvel() { return frameData.COMvel; }
393
394 Vector3d Snapshot::getCOMw() { return frameData.COMw; }
395
396 RealType Snapshot::getTime() { return frameData.currentTime; }
397
398 void Snapshot::increaseTime(RealType dt) { setTime(getTime() + dt); }
399
400 void Snapshot::setTime(RealType time) { frameData.currentTime = time; }
401
402 void Snapshot::setBondPotential(RealType bp) {
403 frameData.bondPotential = bp;
404 hasShortRangePotential = false;
405 hasPotentialEnergy = false;
406 hasTotalEnergy = false;
407 }
408
409 void Snapshot::setBendPotential(RealType bp) {
410 frameData.bendPotential = bp;
411 hasShortRangePotential = false;
412 hasPotentialEnergy = false;
413 hasTotalEnergy = false;
414 }
415
416 void Snapshot::setTorsionPotential(RealType tp) {
417 frameData.torsionPotential = tp;
418 hasShortRangePotential = false;
419 hasPotentialEnergy = false;
420 hasTotalEnergy = false;
421 }
422
423 void Snapshot::setInversionPotential(RealType ip) {
424 frameData.inversionPotential = ip;
425 hasShortRangePotential = false;
426 hasPotentialEnergy = false;
427 hasTotalEnergy = false;
428 }
429
430 RealType Snapshot::getBondPotential() { return frameData.bondPotential; }
431
432 RealType Snapshot::getBendPotential() { return frameData.bendPotential; }
433
434 RealType Snapshot::getTorsionPotential() {
435 return frameData.torsionPotential;
436 }
437
438 RealType Snapshot::getInversionPotential() {
439 return frameData.inversionPotential;
440 }
441
442 RealType Snapshot::getShortRangePotential() {
443 if (!hasShortRangePotential) {
444 frameData.shortRangePotential = frameData.bondPotential;
445 frameData.shortRangePotential += frameData.bendPotential;
446 frameData.shortRangePotential += frameData.torsionPotential;
447 frameData.shortRangePotential += frameData.inversionPotential;
448 hasShortRangePotential = true;
449 hasPotentialEnergy = false;
450 hasTotalEnergy = false;
451 }
452 return frameData.shortRangePotential;
453 }
454
455 void Snapshot::setSurfacePotential(RealType sp) {
456 frameData.surfacePotential = sp;
457 hasLongRangePotential = false;
458 hasPotentialEnergy = false;
459 hasTotalEnergy = false;
460 }
461
462 RealType Snapshot::getSurfacePotential() {
463 return frameData.surfacePotential;
464 }
465
466 void Snapshot::setReciprocalPotential(RealType rp) {
467 frameData.reciprocalPotential = rp;
468 hasLongRangePotential = false;
469 hasPotentialEnergy = false;
470 }
471
472 RealType Snapshot::getReciprocalPotential() {
473 return frameData.reciprocalPotential;
474 }
475
476 void Snapshot::setSelfPotentials(potVec sp) {
477 frameData.selfPotentials = sp;
478 hasSelfPotential = false;
479 hasPotentialEnergy = false;
480 hasTotalEnergy = false;
481 }
482
483 potVec Snapshot::getSelfPotentials() { return frameData.selfPotentials; }
484
485 RealType Snapshot::getSelfPotential() {
486 if (!hasSelfPotential) {
487 frameData.selfPotential = 0.0;
488 for (int i = 0; i < N_INTERACTION_FAMILIES; i++) {
489 frameData.selfPotential += frameData.selfPotentials[i];
490 }
491 hasSelfPotential = true;
492 hasPotentialEnergy = false;
493 hasTotalEnergy = false;
494 }
495 return frameData.selfPotential;
496 }
497
498 void Snapshot::setLongRangePotentials(potVec lrPot) {
499 frameData.lrPotentials = lrPot;
500 hasLongRangePotential = false;
501 hasPotentialEnergy = false;
502 hasTotalEnergy = false;
503 }
504
505 RealType Snapshot::getLongRangePotential() {
506 if (!hasLongRangePotential) {
507 frameData.longRangePotential = 0.0;
508 for (int i = 0; i < N_INTERACTION_FAMILIES; i++) {
509 frameData.longRangePotential += frameData.lrPotentials[i];
510 }
511 frameData.longRangePotential += frameData.reciprocalPotential;
512 frameData.longRangePotential += frameData.surfacePotential;
513 hasLongRangePotential = true;
514 hasPotentialEnergy = false;
515 hasTotalEnergy = false;
516 }
517 return frameData.longRangePotential;
518 }
519
520 potVec Snapshot::getLongRangePotentials() { return frameData.lrPotentials; }
521
522 RealType Snapshot::getPotentialEnergy() {
523 if (!hasPotentialEnergy) {
524 frameData.potentialEnergy = this->getLongRangePotential();
525 frameData.potentialEnergy += this->getShortRangePotential();
526 frameData.potentialEnergy += this->getSelfPotential();
527 frameData.potentialEnergy += this->getExcludedPotential();
528 hasPotentialEnergy = true;
529 hasTotalEnergy = false;
530 }
531 return frameData.potentialEnergy;
532 }
533
534 void Snapshot::setPotentialEnergy(const RealType pe) {
535 frameData.potentialEnergy = pe;
536 hasPotentialEnergy = true;
537 hasTotalEnergy = false;
538 }
539
540 void Snapshot::setExcludedPotentials(potVec exPot) {
541 frameData.excludedPotentials = exPot;
542 hasExcludedPotential = false;
543 hasPotentialEnergy = false;
544 hasTotalEnergy = false;
545 }
546
547 potVec Snapshot::getExcludedPotentials() {
548 return frameData.excludedPotentials;
549 }
550
551 RealType Snapshot::getExcludedPotential() {
552 if (!hasExcludedPotential) {
553 frameData.excludedPotential = 0.0;
554 for (int i = 0; i < N_INTERACTION_FAMILIES; i++) {
555 frameData.excludedPotential += frameData.excludedPotentials[i];
556 }
557 hasExcludedPotential = true;
558 hasPotentialEnergy = false;
559 hasTotalEnergy = false;
560 }
561 return frameData.excludedPotential;
562 }
563
564 void Snapshot::setRestraintPotential(RealType rp) {
565 frameData.restraintPotential = rp;
566 }
567
568 RealType Snapshot::getRestraintPotential() {
569 return frameData.restraintPotential;
570 }
571
572 void Snapshot::setRawPotential(RealType rp) { frameData.rawPotential = rp; }
573
574 RealType Snapshot::getRawPotential() { return frameData.rawPotential; }
575
576 void Snapshot::setSelectionPotentials(potVec selPot) {
577 frameData.selectionPotentials = selPot;
578 }
579
580 potVec Snapshot::getSelectionPotentials() {
581 return frameData.selectionPotentials;
582 }
583
584 RealType Snapshot::getTranslationalKineticEnergy() {
585 return frameData.translationalKinetic;
586 }
587
588 RealType Snapshot::getRotationalKineticEnergy() {
589 return frameData.rotationalKinetic;
590 }
591
592 RealType Snapshot::getElectronicKineticEnergy() {
593 return frameData.electronicKinetic;
594 }
595
596 RealType Snapshot::getKineticEnergy() { return frameData.kineticEnergy; }
597
598 void Snapshot::setTranslationalKineticEnergy(RealType tke) {
599 frameData.translationalKinetic = tke;
600 hasTranslationalKineticEnergy = true;
601 hasKineticEnergy = false;
602 hasTotalEnergy = false;
603 }
604
605 void Snapshot::setRotationalKineticEnergy(RealType rke) {
606 frameData.rotationalKinetic = rke;
607 hasRotationalKineticEnergy = true;
608 hasKineticEnergy = false;
609 hasTotalEnergy = false;
610 }
611
612 void Snapshot::setElectronicKineticEnergy(RealType eke) {
613 frameData.electronicKinetic = eke;
614 hasElectronicKineticEnergy = true;
615 hasKineticEnergy = false;
616 hasTotalEnergy = false;
617 }
618
619 void Snapshot::setKineticEnergy(RealType ke) {
620 frameData.kineticEnergy = ke;
621 hasKineticEnergy = true;
622 hasTotalEnergy = false;
623 }
624
625 RealType Snapshot::getTotalEnergy() { return frameData.totalEnergy; }
626
627 void Snapshot::setTotalEnergy(RealType te) {
628 frameData.totalEnergy = te;
629 hasTotalEnergy = true;
630 }
631
632 RealType Snapshot::getConservedQuantity() {
633 return frameData.conservedQuantity;
634 }
635
636 void Snapshot::setConservedQuantity(RealType cq) {
637 frameData.conservedQuantity = cq;
638 }
639
640 RealType Snapshot::getTemperature() { return frameData.temperature; }
641
642 void Snapshot::setTemperature(RealType temp) {
643 hasTemperature = true;
644 frameData.temperature = temp;
645 }
646
647 RealType Snapshot::getElectronicTemperature() {
648 return frameData.electronicTemperature;
649 }
650
651 void Snapshot::setElectronicTemperature(RealType eTemp) {
652 hasElectronicTemperature = true;
653 frameData.electronicTemperature = eTemp;
654 }
655
656 RealType Snapshot::getNetCharge() { return frameData.netCharge; }
657
658 void Snapshot::setNetCharge(RealType nChg) {
659 hasNetCharge = true;
660 frameData.netCharge = nChg;
661 }
662
663 RealType Snapshot::getChargeMomentum() { return frameData.chargeMomentum; }
664
665 void Snapshot::setChargeMomentum(RealType cMom) {
666 hasChargeMomentum = true;
667 frameData.chargeMomentum = cMom;
668 }
669
670 RealType Snapshot::getPressure() { return frameData.pressure; }
671
672 void Snapshot::setPressure(RealType pressure) {
673 hasPressure = true;
674 frameData.pressure = pressure;
675 }
676
677 Mat3x3d Snapshot::getPressureTensor() { return frameData.pressureTensor; }
678
679 void Snapshot::setPressureTensor(const Mat3x3d& pressureTensor) {
680 hasPressureTensor = true;
681 frameData.pressureTensor = pressureTensor;
682 }
683
684 void Snapshot::setVirialTensor(const Mat3x3d& virialTensor) {
685 frameData.virialTensor = virialTensor;
686 }
687
688 Mat3x3d Snapshot::getVirialTensor() { return frameData.virialTensor; }
689
690 void Snapshot::setConductiveHeatFlux(const Vector3d& chf) {
691 frameData.conductiveHeatFlux = chf;
692 }
693
694 Vector3d Snapshot::getConductiveHeatFlux() {
695 return frameData.conductiveHeatFlux;
696 }
697
698 Vector3d Snapshot::getConvectiveHeatFlux() {
699 return frameData.convectiveHeatFlux;
700 }
701
702 void Snapshot::setConvectiveHeatFlux(const Vector3d& chf) {
703 hasConvectiveHeatFlux = true;
704 frameData.convectiveHeatFlux = chf;
705 }
706
707 Vector3d Snapshot::getHeatFlux() {
708 // BE CAREFUL WITH UNITS
709 return getConductiveHeatFlux() + getConvectiveHeatFlux();
710 }
711
712 Vector3d Snapshot::getSystemDipole() { return frameData.systemDipole; }
713
714 void Snapshot::setSystemDipole(const Vector3d& bd) {
715 hasSystemDipole = true;
716 frameData.systemDipole = bd;
717 }
718
719 Mat3x3d Snapshot::getSystemQuadrupole() { return frameData.systemQuadrupole; }
720
721 void Snapshot::setSystemQuadrupole(const Mat3x3d& bq) {
722 hasSystemQuadrupole = true;
723 frameData.systemQuadrupole = bq;
724 }
725
726 void Snapshot::setThermostat(const pair<RealType, RealType>& thermostat) {
727 frameData.thermostat = thermostat;
728 }
729
730 pair<RealType, RealType> Snapshot::getThermostat() {
731 return frameData.thermostat;
732 }
733
734 void Snapshot::setElectronicThermostat(
735 const pair<RealType, RealType>& eTherm) {
736 frameData.electronicThermostat = eTherm;
737 }
738
739 pair<RealType, RealType> Snapshot::getElectronicThermostat() {
740 return frameData.electronicThermostat;
741 }
742
743 void Snapshot::setBarostat(const Mat3x3d& barostat) {
744 frameData.barostat = barostat;
745 }
746
747 Mat3x3d Snapshot::getBarostat() { return frameData.barostat; }
748
749 void Snapshot::setSPFData(std::shared_ptr<SPFData> data) {
750 frameData.spfData = data;
751 }
752
753 std::shared_ptr<SPFData> Snapshot::getSPFData() { return frameData.spfData; }
754
755 void Snapshot::setInertiaTensor(const Mat3x3d& inertiaTensor) {
756 frameData.inertiaTensor = inertiaTensor;
757 hasInertiaTensor = true;
758 }
759
760 Mat3x3d Snapshot::getInertiaTensor() { return frameData.inertiaTensor; }
761
762 void Snapshot::setGyrationalVolume(const RealType gyrationalVolume) {
763 frameData.gyrationalVolume = gyrationalVolume;
764 hasGyrationalVolume = true;
765 }
766
767 RealType Snapshot::getGyrationalVolume() {
768 return frameData.gyrationalVolume;
769 }
770
771 void Snapshot::setHullVolume(const RealType hullVolume) {
772 frameData.hullVolume = hullVolume;
773 hasHullVolume = true;
774 }
775
776 RealType Snapshot::getHullVolume() { return frameData.hullVolume; }
777
778 void Snapshot::setOrthoTolerance(RealType ot) { orthoTolerance_ = ot; }
779} // namespace OpenMD
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
SquareMatrix3< Real > inverse() const
Sets the value of this matrix to the inverse of itself.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Vector3< Real > cross(const Vector3< Real > &v1, const Vector3< Real > &v2)
Returns the cross product of two Vectors.
Definition Vector3.hpp:139
FrameData is a structure for holding system-wide dynamic data about the simulation.
Definition Snapshot.hpp:86