ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/integrators/VelocityVerletIntegrator.cpp
Revision: 2243
Committed: Sun May 29 00:06:14 2005 UTC (19 years, 1 month ago) by tim
File size: 7803 byte(s)
Log Message:
adding resetIntegrator

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 configuration
71 // that was drifting
72 velocitizer_->removeComDrift();
73
74 // initialize the forces before the first step
75 calcForce(true, true);
76
77 //execute constraint algorithm to make sure at the very beginning the system is constrained
78 if (info_->getNGlobalConstraints() > 0) {
79 rattle->constraintA();
80 calcForce(true, true);
81 rattle->constraintB();
82 info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
83 }
84
85 if (needVelocityScaling) {
86 velocitizer_->velocitize(targetScalingTemp);
87 }
88
89 dumpWriter = createDumpWriter();
90
91 statWriter = createStatWriter();
92
93 if (simParams->getUseSolidThermInt()) {
94 restWriter = createRestWriter();
95 restWriter->writeZangle();
96 }
97
98 dumpWriter->writeDumpAndEor();
99
100
101 //save statistics, before writeStat, we must save statistics
102 thermo.saveStat();
103 saveConservedQuantity();
104 statWriter->writeStat(currentSnapshot_->statData);
105
106 currSample = sampleTime + currentSnapshot_->getTime();
107 currStatus = statusTime + currentSnapshot_->getTime();;
108 currThermal = thermalTime + currentSnapshot_->getTime();
109 if (needReset) {
110 currReset = resetTime + currentSnapshot_->getTime();
111 }
112 needPotential = false;
113 needStress = false;
114
115 }
116
117 void VelocityVerletIntegrator::doIntegrate() {
118
119
120 initialize();
121
122 while (currentSnapshot_->getTime() < runTime) {
123
124 preStep();
125
126 integrateStep();
127
128 postStep();
129
130 }
131
132 finalize();
133
134 }
135
136
137 void VelocityVerletIntegrator::preStep() {
138 double difference = currentSnapshot_->getTime() + dt - currStatus;
139
140 if (difference > 0 || fabs(difference) < oopse::epsilon) {
141 needPotential = true;
142 needStress = true;
143 }
144
145 }
146
147 void VelocityVerletIntegrator::postStep() {
148
149 //save snapshot
150 info_->getSnapshotManager()->advance();
151
152 //increase time
153 currentSnapshot_->increaseTime(dt);
154
155 if (needVelocityScaling) {
156 if (currentSnapshot_->getTime() >= currThermal) {
157 velocitizer_->velocitize(targetScalingTemp);
158 currThermal += thermalTime;
159 }
160 }
161
162 if (currentSnapshot_->getTime() >= currSample) {
163 dumpWriter->writeDumpAndEor();
164
165 if (simParams->getUseSolidThermInt())
166 restWriter->writeZangle();
167
168 currSample += sampleTime;
169 }
170
171 if (currentSnapshot_->getTime() >= currStatus) {
172 //save statistics, before writeStat, we must save statistics
173 thermo.saveStat();
174 saveConservedQuantity();
175 statWriter->writeStat(currentSnapshot_->statData);
176
177 needPotential = false;
178 needStress = false;
179 currStatus += statusTime;
180 }
181
182 if (needReset && currentSnapshot_->getTime() >= currReset) {
183 resetIntegrator();
184 currReset += resetTime;
185 }
186
187 }
188
189
190 void VelocityVerletIntegrator::finalize() {
191 dumpWriter->writeEor();
192
193 if (simParams->getUseSolidThermInt()) {
194 restWriter->writeZangle();
195 delete restWriter;
196 restWriter = NULL;
197 }
198
199 delete dumpWriter;
200 delete statWriter;
201
202 dumpWriter = NULL;
203 statWriter = NULL;
204
205 }
206
207 void VelocityVerletIntegrator::integrateStep() {
208
209 moveA();
210 calcForce(needPotential, needStress);
211 moveB();
212 }
213
214
215 void VelocityVerletIntegrator::calcForce(bool needPotential,
216 bool needStress) {
217 forceMan_->calcForces(needPotential, needStress);
218 }
219
220 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
221 return new DumpWriter(info_);
222 }
223
224 StatWriter* VelocityVerletIntegrator::createStatWriter() {
225 // if solidThermInt is true, add extra information to the statfile
226 if (simParams->getUseSolidThermInt()){
227 StatsBitSet mask;
228 mask.set(Stats::TIME);
229 mask.set(Stats::TOTAL_ENERGY);
230 mask.set(Stats::POTENTIAL_ENERGY);
231 mask.set(Stats::KINETIC_ENERGY);
232 mask.set(Stats::TEMPERATURE);
233 mask.set(Stats::PRESSURE);
234 mask.set(Stats::VOLUME);
235 mask.set(Stats::CONSERVED_QUANTITY);
236 mask.set(Stats::VRAW);
237 mask.set(Stats::VHARM);
238 return new StatWriter(info_->getStatFileName(), mask);
239 }
240
241 if (simParams->havePrintPressureTensor() && simParams->getPrintPressureTensor()){
242 StatsBitSet mask;
243 mask.set(Stats::TIME);
244 mask.set(Stats::TOTAL_ENERGY);
245 mask.set(Stats::POTENTIAL_ENERGY);
246 mask.set(Stats::KINETIC_ENERGY);
247 mask.set(Stats::TEMPERATURE);
248 mask.set(Stats::PRESSURE);
249 mask.set(Stats::VOLUME);
250 mask.set(Stats::CONSERVED_QUANTITY);
251 mask.set(Stats::PRESSURE_TENSOR_X);
252 mask.set(Stats::PRESSURE_TENSOR_Y);
253 mask.set(Stats::PRESSURE_TENSOR_Z);
254 return new StatWriter(info_->getStatFileName(), mask);
255 }
256
257 return new StatWriter(info_->getStatFileName());
258 }
259
260 RestWriter* VelocityVerletIntegrator::createRestWriter(){
261 return new RestWriter(info_);
262 }
263
264
265 } //end namespace oopse

Properties

Name Value
svn:executable *