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

File Contents

# User Rev Content
1 tim 1722 /*
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 tim 1725 /**
27     * @file VelocityVerletIntegrator.cpp
28     * @author tlin
29     * @date 11/09/2004
30     * @time 16:16am
31     * @version 1.0
32     */
33    
34 tim 1722 #include "integrators/VelocityVerletIntegrator.hpp"
35 tim 1820 #include "integrators/DLM.hpp"
36 tim 1722
37     namespace oopse {
38 tim 1820 VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
39 tim 1901 dt2 = 0.5 * dt;
40 tim 1820 rotAlgo = new DLM();
41 tim 1901 rattle = new Rattle(info);
42 tim 1819 }
43 tim 1722
44 tim 1820 VelocityVerletIntegrator::~VelocityVerletIntegrator() {
45     delete rotAlgo;
46 tim 1901 delete rattle;
47 tim 1820 }
48 tim 1722
49 tim 1819 void VelocityVerletIntegrator::initialize(){
50 tim 1722
51 tim 1912 forceMan_->init();
52    
53 tim 1725 // remove center of mass drift velocity (in case we passed in a configuration
54     // that was drifting
55 tim 1819 velocitizer_->removeComDrift();
56 tim 1722
57 tim 1725 // initialize the forces before the first step
58 tim 1819 calcForce(true, true);
59 tim 1722
60 tim 1725 //execute constraint algorithm to make sure at the very beginning the system is constrained
61 tim 1907 if (info_->getNGlobalConstraints() > 0) {
62     rattle->constraintA();
63     calcForce(true, true);
64 tim 1910 rattle->constraintB();
65     info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
66 tim 1907 }
67 tim 1725
68 tim 1819 if (needVelocityScaling) {
69     velocitizer_->velocitize(targetScalingTemp);
70 tim 1725 }
71 tim 1819
72     dumpWriter = createDumpWriter();
73     statWriter = createStatWriter();
74 tim 1725
75 tim 1820 dumpWriter->writeDump();
76 tim 1847
77 tim 1868 //save statistics, before writeStat, we must save statistics
78 tim 1847 thermo.saveStat();
79     saveConservedQuantity();
80 tim 1868 statWriter->writeStat(currentSnapshot_->statData);
81 tim 1847
82 tim 1868 currSample = sampleTime + currentSnapshot_->getTime();
83     currStatus = statusTime + currentSnapshot_->getTime();;
84     currThermal = thermalTime + + currentSnapshot_->getTime();
85     needPotential = false;
86     needStress = false;
87 tim 1820
88 tim 1819 }
89    
90     void VelocityVerletIntegrator::doIntegrate() {
91 tim 1725
92    
93 tim 1819 initialize();
94 tim 1725
95 tim 1819 while (currentSnapshot_->getTime() < runTime) {
96    
97     preStep();
98 tim 1725
99 tim 1819 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 tim 1725 }
117    
118 tim 1819 }
119    
120     void VelocityVerletIntegrator::postStep() {
121 tim 1820
122     //save snapshot
123     info_->getSnapshotManager()->advance();
124    
125     //increase time
126     currentSnapshot_->increaseTime(dt);
127 tim 1756
128 tim 1819 if (needVelocityScaling) {
129     if (currentSnapshot_->getTime() >= currThermal) {
130     velocitizer_->velocitize(targetScalingTemp);
131 tim 1725 currThermal += thermalTime;
132     }
133     }
134    
135 tim 1819 if (currentSnapshot_->getTime() >= currSample) {
136 tim 1820 dumpWriter->writeDump();
137 tim 1725 currSample += sampleTime;
138     }
139    
140 tim 1819 if (currentSnapshot_->getTime() >= currStatus) {
141 tim 1868 //save statistics, before writeStat, we must save statistics
142     thermo.saveStat();
143     saveConservedQuantity();
144 tim 1820 statWriter->writeStat(currentSnapshot_->statData);
145 tim 1868
146 tim 1819 needPotential = false;
147     needStress = false;
148 tim 1725 currStatus += statusTime;
149     }
150 tim 1820
151    
152 tim 1819 }
153 tim 1725
154    
155 tim 1819 void VelocityVerletIntegrator::finalize() {
156 tim 1725
157 tim 1820 dumpWriter->writeDump();
158 tim 1725
159 tim 1819 delete dumpWriter;
160     delete statWriter;
161 tim 1725
162 tim 1819 dumpWriter = NULL;
163     statWriter = NULL;
164    
165 tim 1722 }
166    
167 tim 1774 void VelocityVerletIntegrator::integrateStep() {
168 tim 1725
169 tim 1774 moveA();
170 tim 1819 calcForce(needPotential, needStress);
171 tim 1774 moveB();
172     }
173 tim 1725
174 tim 1774
175 tim 1819 void VelocityVerletIntegrator::calcForce(bool needPotential,
176     bool needStress) {
177 tim 1820 forceMan_->calcForces(needPotential, needStress);
178 tim 1722 }
179    
180 tim 1820 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
181     return new DumpWriter(info_, info_->getDumpFileName());
182     }
183 tim 1722
184 tim 1820 StatWriter* VelocityVerletIntegrator::createStatWriter() {
185     return new StatWriter(info_->getStatFileName());
186     }
187    
188    
189 tim 1725 } //end namespace oopse

Properties

Name Value
svn:executable *