ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1338
Committed: Thu Apr 23 18:22:30 2009 UTC (16 years ago) by skuang
File size: 8228 byte(s)
Log Message:
Added a getStatus routine to check the temperatures

File Contents

# Content
1 /*
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. Acknowledgement of the program authors must be made in any
10 * publication of scientific results based in part on use of the
11 * program. An acceptable form of acknowledgement is citation of
12 * the article in which the program was described (Matthew
13 * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 * Parallel Simulation Engine for Molecular Dynamics,"
16 * J. Comput. Chem. 26, pp. 252-271 (2005))
17 *
18 * 2. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * 3. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * This software is provided "AS IS," without a warranty of any
27 * kind. All express or implied conditions, representations and
28 * warranties, including any implied warranty of merchantability,
29 * fitness for a particular purpose or non-infringement, are hereby
30 * excluded. The University of Notre Dame and its licensors shall not
31 * be liable for any damages suffered by licensee as a result of
32 * using, modifying or distributing the software or its
33 * derivatives. In no event will the University of Notre Dame or its
34 * licensors be liable for any lost revenue, profit or data, or for
35 * direct, indirect, special, consequential, incidental or punitive
36 * damages, however caused and regardless of the theory of liability,
37 * arising out of the use of or inability to use software, even if the
38 * University of Notre Dame has been advised of the possibility of
39 * such damages.
40 */
41
42 /**
43 * @file VelocityVerletIntegrator.cpp
44 * @author tlin
45 * @date 11/09/2004
46 * @time 16:16am
47 * @version 1.0
48 */
49
50 #include "integrators/VelocityVerletIntegrator.hpp"
51 #include "integrators/DLM.hpp"
52 #include "utils/StringUtils.hpp"
53
54 namespace oopse {
55 VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
56 dt2 = 0.5 * dt;
57 rotAlgo = new DLM();
58 rattle = new Rattle(info);
59 }
60
61 VelocityVerletIntegrator::~VelocityVerletIntegrator() {
62 delete rotAlgo;
63 delete rattle;
64 }
65
66 void VelocityVerletIntegrator::initialize(){
67
68 forceMan_->init();
69
70 // remove center of mass drift velocity (in case we passed in a
71 // configuration that was drifting)
72 velocitizer_->removeComDrift();
73
74 // initialize the forces before the first step
75 calcForce(true, true);
76
77 // execute the constraint algorithm to make sure that the system is
78 // constrained at the very beginning
79 if (info_->getNGlobalConstraints() > 0) {
80 rattle->constraintA();
81 calcForce(true, true);
82 rattle->constraintB();
83 //copy the current snapshot to previous snapshot
84 info_->getSnapshotManager()->advance();
85 }
86
87 if (needVelocityScaling) {
88 velocitizer_->velocitize(targetScalingTemp);
89 }
90
91 dumpWriter = createDumpWriter();
92
93 statWriter = createStatWriter();
94
95 dumpWriter->writeDumpAndEor();
96
97 if (simParams->getUseSolidThermInt()) {
98 restWriter = createRestWriter();
99 restWriter->writeZAngFile();
100 }
101
102 //save statistics, before writeStat, we must save statistics
103 thermo.saveStat();
104 saveConservedQuantity();
105 statWriter->writeStat(currentSnapshot_->statData);
106
107 currSample = sampleTime + currentSnapshot_->getTime();
108 currStatus = statusTime + currentSnapshot_->getTime();
109 currThermal = thermalTime + currentSnapshot_->getTime();
110 if (needReset) {
111 currReset = resetTime + currentSnapshot_->getTime();
112 }
113 if (simParams->getUseRNEMD()){
114 currRNEMD = RNEMD_swapTime + currentSnapshot_->getTime();
115 }
116 needPotential = false;
117 needStress = false;
118
119 }
120
121 void VelocityVerletIntegrator::doIntegrate() {
122
123
124 initialize();
125
126 while (currentSnapshot_->getTime() < runTime) {
127
128 preStep();
129
130 integrateStep();
131
132 postStep();
133
134 }
135
136 finalize();
137
138 }
139
140
141 void VelocityVerletIntegrator::preStep() {
142 RealType difference = currentSnapshot_->getTime() + dt - currStatus;
143
144 if (difference > 0 || fabs(difference) < oopse::epsilon) {
145 needPotential = true;
146 needStress = true;
147 }
148 }
149
150 void VelocityVerletIntegrator::postStep() {
151
152 //save snapshot
153 info_->getSnapshotManager()->advance();
154
155 //increase time
156 currentSnapshot_->increaseTime(dt);
157
158 if (needVelocityScaling) {
159 if (currentSnapshot_->getTime() >= currThermal) {
160 velocitizer_->velocitize(targetScalingTemp);
161 currThermal += thermalTime;
162 }
163 }
164 if (useRNEMD) {
165 if (currentSnapshot_->getTime() >= currRNEMD) {
166 rnemd_->doSwap();
167 currRNEMD += RNEMD_swapTime;
168 }
169 }
170
171 if (currentSnapshot_->getTime() >= currSample) {
172 dumpWriter->writeDumpAndEor();
173
174 if (simParams->getUseSolidThermInt())
175 restWriter->writeZAngFile();
176
177 currSample += sampleTime;
178 }
179
180 if (currentSnapshot_->getTime() >= currStatus) {
181 //save statistics, before writeStat, we must save statistics
182 thermo.saveStat();
183 saveConservedQuantity();
184 statWriter->writeStat(currentSnapshot_->statData);
185 if (simParams->getUseRNEMD())
186 rnemd_->getStatus();
187
188 needPotential = false;
189 needStress = false;
190 currStatus += statusTime;
191 }
192
193 if (needReset && currentSnapshot_->getTime() >= currReset) {
194 resetIntegrator();
195 currReset += resetTime;
196 }
197 }
198
199
200 void VelocityVerletIntegrator::finalize() {
201 dumpWriter->writeEor();
202
203 if (simParams->getUseSolidThermInt()) {
204 restWriter->writeZAngFile();
205 delete restWriter;
206 restWriter = NULL;
207 }
208
209 delete dumpWriter;
210 delete statWriter;
211
212 dumpWriter = NULL;
213 statWriter = NULL;
214
215 }
216
217 void VelocityVerletIntegrator::integrateStep() {
218
219 moveA();
220 calcForce(needPotential, needStress);
221 moveB();
222 }
223
224
225 void VelocityVerletIntegrator::calcForce(bool needPotential,
226 bool needStress) {
227 forceMan_->calcForces(needPotential, needStress);
228 }
229
230 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
231 return new DumpWriter(info_);
232 }
233
234 StatWriter* VelocityVerletIntegrator::createStatWriter() {
235
236 std::string statFileFormatString = simParams->getStatFileFormat();
237 StatsBitSet mask = parseStatFileFormat(statFileFormatString);
238
239 // if solidThermInt is true, add extra information to the statfile
240 if (simParams->getUseSolidThermInt()){
241 mask.set(Stats::VRAW);
242 mask.set(Stats::VHARM);
243 }
244
245 if (simParams->havePrintPressureTensor() &&
246 simParams->getPrintPressureTensor()){
247 mask.set(Stats::PRESSURE_TENSOR_XX);
248 mask.set(Stats::PRESSURE_TENSOR_XY);
249 mask.set(Stats::PRESSURE_TENSOR_XZ);
250 mask.set(Stats::PRESSURE_TENSOR_YX);
251 mask.set(Stats::PRESSURE_TENSOR_YY);
252 mask.set(Stats::PRESSURE_TENSOR_YZ);
253 mask.set(Stats::PRESSURE_TENSOR_ZX);
254 mask.set(Stats::PRESSURE_TENSOR_ZY);
255 mask.set(Stats::PRESSURE_TENSOR_ZZ);
256 }
257
258 if (simParams->getAccumulateBoxDipole()) {
259 mask.set(Stats::BOX_DIPOLE_X);
260 mask.set(Stats::BOX_DIPOLE_Y);
261 mask.set(Stats::BOX_DIPOLE_Z);
262 }
263
264 if (simParams->haveTaggedAtomPair() && simParams->havePrintTaggedPairDistance()) {
265 if (simParams->getPrintTaggedPairDistance()) {
266 mask.set(Stats::TAGGED_PAIR_DISTANCE);
267 }
268 }
269
270 if (simParams->getUseRNEMD()) {
271 mask.set(Stats::RNEMD_SWAP_TOTAL);
272 }
273
274
275 return new StatWriter(info_->getStatFileName(), mask);
276 }
277
278 RestWriter* VelocityVerletIntegrator::createRestWriter(){
279 return new RestWriter(info_);
280 }
281
282
283 } //end namespace oopse

Properties

Name Value
svn:executable *