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: 1868
Committed: Wed Dec 8 17:03:50 2004 UTC (19 years, 7 months ago) by tim
File size: 4919 byte(s)
Log Message:
Butane in  NVT is working

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

Properties

Name Value
svn:executable *