OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
SPFDynamics.cpp
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#include "integrators/SPFDynamics.hpp"
46
47#include <config.h>
48
50#include "rnemd/SPFForceManager.hpp"
51#include "utils/Constants.hpp"
52
53namespace OpenMD {
54
55 void SPFDynamics::postStep() {
56 RealType difference;
57
58 if (needVelocityScaling) {
59 difference = snap->getTime() - currThermal;
60
61 if (difference > 0 || fabs(difference) <= OpenMD::epsilon) {
62 velocitizer_->randomize(targetScalingTemp);
63 currThermal += thermalTime;
64 }
65 }
66
67 if (useRNEMD) {
68 difference = snap->getTime() - currRNEMD;
69
70 if (difference > 0 || fabs(difference) <= OpenMD::epsilon) {
71 rnemd_->doRNEMD();
72 currRNEMD += RNEMD_exchangeTime;
73 }
74
75 if (RNEMD::SPFForceManager* spfForceManager =
76 dynamic_cast<RNEMD::SPFForceManager*>(forceMan_)) {
77 if (rnemd_->failedLastKick()) {
79
80 spfForceManager->combineForcesAndTorques();
81 spfForceManager->updatePotentials();
82 spfForceManager->updateVirialTensor();
83
84 Snapshot tempSourceSnap =
85 spfForceManager->getTemporarySourceSnapshot();
86
87 snap->atomData.velocity = tempSourceSnap.atomData.velocity;
88 snap->rigidbodyData.velocity = tempSourceSnap.rigidbodyData.velocity;
89 snap->cgData.velocity = tempSourceSnap.cgData.velocity;
90
91 // Angular velocities
92 snap->atomData.angularMomentum =
93 tempSourceSnap.atomData.angularMomentum;
94 snap->rigidbodyData.angularMomentum =
95 tempSourceSnap.rigidbodyData.angularMomentum;
96
97 this->moveB();
98 }
99 } else {
100 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
101 "SPFDynamics cannot be used with the "
102 "default ForceManager.\n");
103 painCave.isFatal = 1;
104 painCave.severity = OPENMD_ERROR;
105 simError();
106 }
107
108 rnemd_->collectData();
109 }
110
111 saveConservedQuantity();
112
113 difference = snap->getTime() - currSample;
114
115 if (difference > 0 || fabs(difference) <= OpenMD::epsilon) {
116 dumpWriter->writeDumpAndEor();
117 currSample += sampleTime;
118 }
119
120 difference = snap->getTime() - currStatus;
121
122 if (difference > 0 || fabs(difference) <= OpenMD::epsilon) {
123 stats->collectStats();
124
125 statWriter->writeStat();
126
127 progressBar->setStatus(snap->getTime(), runTime);
128 progressBar->update();
129
130 needPotential = false;
131 needVirial = false;
132 currStatus += statusTime;
133 }
134
135 // Write to RNEMD file every timestep
136 if (useRNEMD) { rnemd_->writeOutputFile(); }
137
138 difference = snap->getTime() - currReset;
139
140 if (needReset && (difference > 0 || fabs(difference) <= OpenMD::epsilon)) {
141 resetIntegrator();
142 currReset += resetTime;
143 }
144
145 // save snapshot
146 info_->getSnapshotManager()->advance();
147
148 // increase time
149 snap->increaseTime(dt);
150 }
151} // namespace OpenMD
vector< Vector3d > velocity
position array
vector< Vector3d > angularMomentum
rotation matrix array
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
Definition SimInfo.hpp:248
The Snapshot class is a repository storing dynamic data during a Simulation.
Definition Snapshot.hpp:147
void clearDerivedProperties()
sets the state of the computed properties to false
Definition Snapshot.cpp:135
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.