ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp
Revision: 2008
Committed: Sun Feb 13 19:10:25 2005 UTC (19 years, 4 months ago) by tim
File size: 6133 byte(s)
Log Message:
dynamicProps get built

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

Properties

Name Value
svn:executable *