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

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

Properties

Name Value
svn:executable *