ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1960
Committed: Wed Jan 26 15:26:47 2005 UTC (19 years, 5 months ago) by tim
File size: 6406 byte(s)
Log Message:
forget to add eorWriter

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 eorWriter = createEorWriter();
91 statWriter = createStatWriter();
92
93 dumpWriter->writeDump();
94 eorWriter->writeDump();
95
96 //save statistics, before writeStat, we must save statistics
97 thermo.saveStat();
98 saveConservedQuantity();
99 statWriter->writeStat(currentSnapshot_->statData);
100
101 currSample = sampleTime + currentSnapshot_->getTime();
102 currStatus = statusTime + currentSnapshot_->getTime();;
103 currThermal = thermalTime + + currentSnapshot_->getTime();
104 needPotential = false;
105 needStress = false;
106
107 }
108
109 void VelocityVerletIntegrator::doIntegrate() {
110
111
112 initialize();
113
114 while (currentSnapshot_->getTime() < runTime) {
115
116 preStep();
117
118 integrateStep();
119
120 postStep();
121
122 }
123
124 finalize();
125
126 }
127
128
129 void VelocityVerletIntegrator::preStep() {
130 double difference = currentSnapshot_->getTime() + dt - currStatus;
131
132 if (difference > 0 || fabs(difference) < oopse::epsilon) {
133 needPotential = true;
134 needStress = true;
135 }
136
137 }
138
139 void VelocityVerletIntegrator::postStep() {
140
141 //save snapshot
142 info_->getSnapshotManager()->advance();
143
144 //increase time
145 currentSnapshot_->increaseTime(dt);
146
147 if (needVelocityScaling) {
148 if (currentSnapshot_->getTime() >= currThermal) {
149 velocitizer_->velocitize(targetScalingTemp);
150 currThermal += thermalTime;
151 }
152 }
153
154 if (currentSnapshot_->getTime() >= currSample) {
155 dumpWriter->writeDump();
156 eorWriter->writeDump();
157 currSample += sampleTime;
158 }
159
160 if (currentSnapshot_->getTime() >= currStatus) {
161 //save statistics, before writeStat, we must save statistics
162 thermo.saveStat();
163 saveConservedQuantity();
164 statWriter->writeStat(currentSnapshot_->statData);
165
166 needPotential = false;
167 needStress = false;
168 currStatus += statusTime;
169 }
170
171
172 }
173
174
175 void VelocityVerletIntegrator::finalize() {
176
177 dumpWriter->writeDump();
178 eorWriter->writeDump();
179
180 delete dumpWriter;
181 delete eorWriter;
182 delete statWriter;
183
184 dumpWriter = NULL;
185 eorWriter = NULL;
186 statWriter = NULL;
187
188 }
189
190 void VelocityVerletIntegrator::integrateStep() {
191
192 moveA();
193 calcForce(needPotential, needStress);
194 moveB();
195 }
196
197
198 void VelocityVerletIntegrator::calcForce(bool needPotential,
199 bool needStress) {
200 forceMan_->calcForces(needPotential, needStress);
201 }
202
203 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
204 return new DumpWriter(info_, info_->getDumpFileName());
205 }
206
207 DumpWriter* VelocityVerletIntegrator::createEorWriter() {
208 return new DumpWriter(info_, getPrefix(info_->getDumpFileName()) + ".eor");
209 }
210
211 StatWriter* VelocityVerletIntegrator::createStatWriter() {
212 return new StatWriter(info_->getStatFileName());
213 }
214
215
216 } //end namespace oopse

Properties

Name Value
svn:executable *