ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1910
Committed: Fri Jan 7 21:50:13 2005 UTC (19 years, 7 months ago) by tim
File size: 5103 byte(s)
Log Message:
ZConstraintForceManager in progress

File Contents

# Content
1 /*
2 * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project
3 *
4 * Contact: oopse@oopse.org
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 * All we ask is that proper credit is given for our work, which includes
11 * - but is not limited to - adding the above copyright notice to the beginning
12 * of your source code files, and to any copyright notice that you may distribute
13 * with programs based on this work.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 */
25
26 /**
27 * @file VelocityVerletIntegrator.cpp
28 * @author tlin
29 * @date 11/09/2004
30 * @time 16:16am
31 * @version 1.0
32 */
33
34 #include "integrators/VelocityVerletIntegrator.hpp"
35 #include "integrators/DLM.hpp"
36
37 namespace oopse {
38 VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
39 dt2 = 0.5 * dt;
40 rotAlgo = new DLM();
41 rattle = new Rattle(info);
42 }
43
44 VelocityVerletIntegrator::~VelocityVerletIntegrator() {
45 delete rotAlgo;
46 delete rattle;
47 }
48
49 void VelocityVerletIntegrator::initialize(){
50
51 // remove center of mass drift velocity (in case we passed in a configuration
52 // that was drifting
53 velocitizer_->removeComDrift();
54
55 // initialize the forces before the first step
56 calcForce(true, true);
57
58 //execute constraint algorithm to make sure at the very beginning the system is constrained
59 if (info_->getNGlobalConstraints() > 0) {
60 rattle->constraintA();
61 calcForce(true, true);
62 rattle->constraintB();
63 info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
64 }
65
66 if (needVelocityScaling) {
67 velocitizer_->velocitize(targetScalingTemp);
68 }
69
70 dumpWriter = createDumpWriter();
71 statWriter = createStatWriter();
72
73 dumpWriter->writeDump();
74
75 //save statistics, before writeStat, we must save statistics
76 thermo.saveStat();
77 saveConservedQuantity();
78 statWriter->writeStat(currentSnapshot_->statData);
79
80 currSample = sampleTime + currentSnapshot_->getTime();
81 currStatus = statusTime + currentSnapshot_->getTime();;
82 currThermal = thermalTime + + currentSnapshot_->getTime();
83 needPotential = false;
84 needStress = false;
85
86 }
87
88 void VelocityVerletIntegrator::doIntegrate() {
89
90
91 initialize();
92
93 while (currentSnapshot_->getTime() < runTime) {
94
95 preStep();
96
97 integrateStep();
98
99 postStep();
100
101 }
102
103 finalize();
104
105 }
106
107
108 void VelocityVerletIntegrator::preStep() {
109 double difference = currentSnapshot_->getTime() + dt - currStatus;
110
111 if (difference > 0 || fabs(difference) < oopse::epsilon) {
112 needPotential = true;
113 needStress = true;
114 }
115
116 }
117
118 void VelocityVerletIntegrator::postStep() {
119
120 //save snapshot
121 info_->getSnapshotManager()->advance();
122
123 //increase time
124 currentSnapshot_->increaseTime(dt);
125
126 if (needVelocityScaling) {
127 if (currentSnapshot_->getTime() >= currThermal) {
128 velocitizer_->velocitize(targetScalingTemp);
129 currThermal += thermalTime;
130 }
131 }
132
133 if (currentSnapshot_->getTime() >= currSample) {
134 dumpWriter->writeDump();
135 currSample += sampleTime;
136 }
137
138 if (currentSnapshot_->getTime() >= currStatus) {
139 //save statistics, before writeStat, we must save statistics
140 thermo.saveStat();
141 saveConservedQuantity();
142 statWriter->writeStat(currentSnapshot_->statData);
143
144 needPotential = false;
145 needStress = false;
146 currStatus += statusTime;
147 }
148
149
150 }
151
152
153 void VelocityVerletIntegrator::finalize() {
154
155 dumpWriter->writeDump();
156
157 delete dumpWriter;
158 delete statWriter;
159
160 dumpWriter = NULL;
161 statWriter = NULL;
162
163 }
164
165 void VelocityVerletIntegrator::integrateStep() {
166
167 moveA();
168 calcForce(needPotential, needStress);
169 moveB();
170 }
171
172
173 void VelocityVerletIntegrator::calcForce(bool needPotential,
174 bool needStress) {
175 forceMan_->calcForces(needPotential, needStress);
176 }
177
178 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
179 return new DumpWriter(info_, info_->getDumpFileName());
180 }
181
182 StatWriter* VelocityVerletIntegrator::createStatWriter() {
183 return new StatWriter(info_->getStatFileName());
184 }
185
186
187 } //end namespace oopse

Properties

Name Value
svn:executable *