ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1901
Committed: Tue Jan 4 22:18:36 2005 UTC (21 years, 4 months ago) by tim
File size: 4969 byte(s)
Log Message:
constraints 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 1819 //if (nConstrained) {
60     // constrainA();
61     // calcForce(true, true);
62     // constrainB();
63     //}
64 tim 1725
65 tim 1819 if (needVelocityScaling) {
66     velocitizer_->velocitize(targetScalingTemp);
67 tim 1725 }
68 tim 1819
69     dumpWriter = createDumpWriter();
70     statWriter = createStatWriter();
71 tim 1725
72 tim 1820 dumpWriter->writeDump();
73 tim 1847
74 tim 1868 //save statistics, before writeStat, we must save statistics
75 tim 1847 thermo.saveStat();
76     saveConservedQuantity();
77 tim 1868 statWriter->writeStat(currentSnapshot_->statData);
78 tim 1847
79 tim 1868 currSample = sampleTime + currentSnapshot_->getTime();
80     currStatus = statusTime + currentSnapshot_->getTime();;
81     currThermal = thermalTime + + currentSnapshot_->getTime();
82     needPotential = false;
83     needStress = false;
84 tim 1820
85 tim 1819 }
86    
87     void VelocityVerletIntegrator::doIntegrate() {
88 tim 1725
89    
90 tim 1819 initialize();
91 tim 1725
92 tim 1819 while (currentSnapshot_->getTime() < runTime) {
93    
94     preStep();
95 tim 1725
96 tim 1819 integrateStep();
97    
98     postStep();
99    
100     }
101    
102     finalize();
103    
104     }
105    
106    
107     void VelocityVerletIntegrator::preStep() {
108     double difference = currentSnapshot_->getTime() + dt - currStatus;
109    
110     if (difference > 0 || fabs(difference) < oopse::epsilon) {
111     needPotential = true;
112     needStress = true;
113 tim 1725 }
114    
115 tim 1819 }
116    
117     void VelocityVerletIntegrator::postStep() {
118 tim 1820
119     //save snapshot
120     info_->getSnapshotManager()->advance();
121    
122     //increase time
123     currentSnapshot_->increaseTime(dt);
124 tim 1756
125 tim 1819 if (needVelocityScaling) {
126     if (currentSnapshot_->getTime() >= currThermal) {
127     velocitizer_->velocitize(targetScalingTemp);
128 tim 1725 currThermal += thermalTime;
129     }
130     }
131    
132 tim 1819 if (currentSnapshot_->getTime() >= currSample) {
133 tim 1820 dumpWriter->writeDump();
134 tim 1725 currSample += sampleTime;
135     }
136    
137 tim 1819 if (currentSnapshot_->getTime() >= currStatus) {
138 tim 1868 //save statistics, before writeStat, we must save statistics
139     thermo.saveStat();
140     saveConservedQuantity();
141 tim 1820 statWriter->writeStat(currentSnapshot_->statData);
142 tim 1868
143 tim 1819 needPotential = false;
144     needStress = false;
145 tim 1725 currStatus += statusTime;
146     }
147 tim 1820
148    
149 tim 1819 }
150 tim 1725
151    
152 tim 1819 void VelocityVerletIntegrator::finalize() {
153 tim 1725
154 tim 1820 dumpWriter->writeDump();
155 tim 1725
156 tim 1819 delete dumpWriter;
157     delete statWriter;
158 tim 1725
159 tim 1819 dumpWriter = NULL;
160     statWriter = NULL;
161    
162 tim 1722 }
163    
164 tim 1774 void VelocityVerletIntegrator::integrateStep() {
165 tim 1725
166 tim 1774 moveA();
167 tim 1819 calcForce(needPotential, needStress);
168 tim 1774 moveB();
169     }
170 tim 1725
171 tim 1774
172 tim 1819 void VelocityVerletIntegrator::calcForce(bool needPotential,
173     bool needStress) {
174 tim 1820 forceMan_->calcForces(needPotential, needStress);
175 tim 1722 }
176    
177 tim 1820 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
178     return new DumpWriter(info_, info_->getDumpFileName());
179     }
180 tim 1722
181 tim 1820 StatWriter* VelocityVerletIntegrator::createStatWriter() {
182     return new StatWriter(info_->getStatFileName());
183     }
184    
185    
186 tim 1725 } //end namespace oopse

Properties

Name Value
svn:executable *