ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1912
Committed: Mon Jan 10 20:52:07 2005 UTC (19 years, 6 months ago) by tim
File size: 5127 byte(s)
Log Message:
zconstraint method is working now

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 forceMan_->init();
52
53 // remove center of mass drift velocity (in case we passed in a configuration
54 // that was drifting
55 velocitizer_->removeComDrift();
56
57 // initialize the forces before the first step
58 calcForce(true, true);
59
60 //execute constraint algorithm to make sure at the very beginning the system is constrained
61 if (info_->getNGlobalConstraints() > 0) {
62 rattle->constraintA();
63 calcForce(true, true);
64 rattle->constraintB();
65 info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
66 }
67
68 if (needVelocityScaling) {
69 velocitizer_->velocitize(targetScalingTemp);
70 }
71
72 dumpWriter = createDumpWriter();
73 statWriter = createStatWriter();
74
75 dumpWriter->writeDump();
76
77 //save statistics, before writeStat, we must save statistics
78 thermo.saveStat();
79 saveConservedQuantity();
80 statWriter->writeStat(currentSnapshot_->statData);
81
82 currSample = sampleTime + currentSnapshot_->getTime();
83 currStatus = statusTime + currentSnapshot_->getTime();;
84 currThermal = thermalTime + + currentSnapshot_->getTime();
85 needPotential = false;
86 needStress = false;
87
88 }
89
90 void VelocityVerletIntegrator::doIntegrate() {
91
92
93 initialize();
94
95 while (currentSnapshot_->getTime() < runTime) {
96
97 preStep();
98
99 integrateStep();
100
101 postStep();
102
103 }
104
105 finalize();
106
107 }
108
109
110 void VelocityVerletIntegrator::preStep() {
111 double difference = currentSnapshot_->getTime() + dt - currStatus;
112
113 if (difference > 0 || fabs(difference) < oopse::epsilon) {
114 needPotential = true;
115 needStress = true;
116 }
117
118 }
119
120 void VelocityVerletIntegrator::postStep() {
121
122 //save snapshot
123 info_->getSnapshotManager()->advance();
124
125 //increase time
126 currentSnapshot_->increaseTime(dt);
127
128 if (needVelocityScaling) {
129 if (currentSnapshot_->getTime() >= currThermal) {
130 velocitizer_->velocitize(targetScalingTemp);
131 currThermal += thermalTime;
132 }
133 }
134
135 if (currentSnapshot_->getTime() >= currSample) {
136 dumpWriter->writeDump();
137 currSample += sampleTime;
138 }
139
140 if (currentSnapshot_->getTime() >= currStatus) {
141 //save statistics, before writeStat, we must save statistics
142 thermo.saveStat();
143 saveConservedQuantity();
144 statWriter->writeStat(currentSnapshot_->statData);
145
146 needPotential = false;
147 needStress = false;
148 currStatus += statusTime;
149 }
150
151
152 }
153
154
155 void VelocityVerletIntegrator::finalize() {
156
157 dumpWriter->writeDump();
158
159 delete dumpWriter;
160 delete statWriter;
161
162 dumpWriter = NULL;
163 statWriter = NULL;
164
165 }
166
167 void VelocityVerletIntegrator::integrateStep() {
168
169 moveA();
170 calcForce(needPotential, needStress);
171 moveB();
172 }
173
174
175 void VelocityVerletIntegrator::calcForce(bool needPotential,
176 bool needStress) {
177 forceMan_->calcForces(needPotential, needStress);
178 }
179
180 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
181 return new DumpWriter(info_, info_->getDumpFileName());
182 }
183
184 StatWriter* VelocityVerletIntegrator::createStatWriter() {
185 return new StatWriter(info_->getStatFileName());
186 }
187
188
189 } //end namespace oopse

Properties

Name Value
svn:executable *