ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp (file contents):
Revision 2019 by tim, Mon Feb 14 18:12:43 2005 UTC vs.
Revision 2448 by tim, Wed Nov 16 23:10:02 2005 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 52 | Line 52 | VelocityVerletIntegrator::VelocityVerletIntegrator(Sim
52   #include "utils/StringUtils.hpp"
53  
54   namespace oopse {
55 < VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
55 >  VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
56      dt2 = 0.5 * dt;
57      rotAlgo = new DLM();
58      rattle = new Rattle(info);
59 < }
60 <
61 < VelocityVerletIntegrator::~VelocityVerletIntegrator() {
59 >  }
60 >  
61 >  VelocityVerletIntegrator::~VelocityVerletIntegrator() {
62      delete rotAlgo;
63      delete rattle;
64 < }
65 <
66 < void VelocityVerletIntegrator::initialize(){
67 <
64 >  }
65 >  
66 >  void VelocityVerletIntegrator::initialize(){
67 >    
68      forceMan_->init();
69 <
69 >    
70      // remove center of mass drift velocity (in case we passed in a configuration
71      // that was drifting
72      velocitizer_->removeComDrift();
73 <
73 >    
74      // initialize the forces before the first step
75      calcForce(true, true);
76 <
76 >    
77      //execute constraint algorithm to make sure at the very beginning the system is constrained  
78      if (info_->getNGlobalConstraints() > 0) {
79 <        rattle->constraintA();
80 <        calcForce(true, true);
81 <        rattle->constraintB();        
82 <        info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
79 >      rattle->constraintA();
80 >      calcForce(true, true);
81 >      rattle->constraintB();        
82 >      info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
83      }
84 <
84 >    
85      if (needVelocityScaling) {
86 <        velocitizer_->velocitize(targetScalingTemp);
86 >      velocitizer_->velocitize(targetScalingTemp);
87      }
88      
89      dumpWriter = createDumpWriter();
90 <
90 >    
91      statWriter = createStatWriter();
92
93    dumpWriter->writeDump();
92      
93 +    if (simParams->getUseSolidThermInt()) {
94 +      restWriter = createRestWriter();
95 +      restWriter->writeZangle();
96 +    }
97 +    
98 +    dumpWriter->writeDumpAndEor();
99 +    
100 +    
101      //save statistics, before writeStat,  we must save statistics
102      thermo.saveStat();
103      saveConservedQuantity();
104      statWriter->writeStat(currentSnapshot_->statData);
105 <
105 >    
106      currSample = sampleTime + currentSnapshot_->getTime();
107      currStatus =  statusTime + currentSnapshot_->getTime();;
108 <    currThermal = thermalTime +  + currentSnapshot_->getTime();
108 >    currThermal = thermalTime + currentSnapshot_->getTime();
109 >    if (needReset) {
110 >      currReset = resetTime + currentSnapshot_->getTime();
111 >    }
112      needPotential = false;
113      needStress = false;      
114 <  
115 < }
107 <        
108 < void VelocityVerletIntegrator::doIntegrate() {
114 >    
115 >  }
116  
117 <
117 >  void VelocityVerletIntegrator::doIntegrate() {
118 >  
119 >  
120      initialize();
121 <
121 >  
122      while (currentSnapshot_->getTime() < runTime) {
123 <        
124 <        preStep();
125 <
126 <        integrateStep();
127 <        
128 <        postStep();
129 <
123 >    
124 >      preStep();
125 >    
126 >      integrateStep();
127 >    
128 >      postStep();
129 >    
130      }
131 <
131 >  
132      finalize();
133 <    
134 < }
133 >  
134 >  }
135  
136  
137 < void VelocityVerletIntegrator::preStep() {
138 <        double difference = currentSnapshot_->getTime() + dt - currStatus;
137 >  void VelocityVerletIntegrator::preStep() {
138 >    double difference = currentSnapshot_->getTime() + dt - currStatus;
139 >  
140 >    if (difference > 0 || fabs(difference) < oopse::epsilon) {
141 >      needPotential = true;
142 >      needStress = true;  
143 >    }
144  
145 <        if (difference > 0 || fabs(difference) < oopse::epsilon) {
146 <            needPotential = true;
133 <            needStress = true;  
134 <        }
145 >    std::cout << currentSnapshot_->getTime()<< ": \n";  
146 >  }
147  
148 < }
148 >  void VelocityVerletIntegrator::postStep() {
149  
150 < void VelocityVerletIntegrator::postStep() {
150 >    //save snapshot
151 >    info_->getSnapshotManager()->advance();
152 >  
153 >    //increase time
154 >    currentSnapshot_->increaseTime(dt);        
155 >  
156 >    if (needVelocityScaling) {
157 >      if (currentSnapshot_->getTime() >= currThermal) {
158 >        velocitizer_->velocitize(targetScalingTemp);
159 >        currThermal += thermalTime;
160 >      }
161 >    }
162 >  
163 >    if (currentSnapshot_->getTime() >= currSample) {
164 >      dumpWriter->writeDumpAndEor();
165 >    
166 >      if (simParams->getUseSolidThermInt())
167 >        restWriter->writeZangle();
168 >    
169 >      currSample += sampleTime;
170 >    }
171 >  
172 >    if (currentSnapshot_->getTime() >= currStatus) {
173 >      //save statistics, before writeStat,  we must save statistics
174 >      thermo.saveStat();
175 >      saveConservedQuantity();
176 >      statWriter->writeStat(currentSnapshot_->statData);
177 >    
178 >      needPotential = false;
179 >      needStress = false;
180 >      currStatus += statusTime;
181 >    }
182  
183 <        //save snapshot
184 <        info_->getSnapshotManager()->advance();
183 >      if (needReset && currentSnapshot_->getTime() >= currReset) {    
184 >        resetIntegrator();
185 >        currReset += resetTime;
186 >      }
187 >  
188 >  }
189  
143        //increase time
144        currentSnapshot_->increaseTime(dt);        
145        
146        if (needVelocityScaling) {
147            if (currentSnapshot_->getTime() >= currThermal) {
148                velocitizer_->velocitize(targetScalingTemp);
149                currThermal += thermalTime;
150            }
151        }
190  
191 <        if (currentSnapshot_->getTime() >= currSample) {
192 <            dumpWriter->writeDump();
193 <            //eorWriter->writeDump();
194 <            currSample += sampleTime;
195 <        }
196 <
197 <        if (currentSnapshot_->getTime() >= currStatus) {
198 <            //save statistics, before writeStat,  we must save statistics
199 <            thermo.saveStat();
162 <            saveConservedQuantity();
163 <            statWriter->writeStat(currentSnapshot_->statData);
164 <
165 <            needPotential = false;
166 <            needStress = false;
167 <            currStatus += statusTime;
168 <        }
169 <
170 <        
171 < }
172 <
173 <
174 < void VelocityVerletIntegrator::finalize() {
175 <
191 >  void VelocityVerletIntegrator::finalize() {
192 >    dumpWriter->writeEor();
193 >  
194 >    if (simParams->getUseSolidThermInt()) {
195 >      restWriter->writeZangle();
196 >      delete restWriter;
197 >      restWriter = NULL;
198 >    }
199 >  
200      delete dumpWriter;
201      delete statWriter;
202 <
202 >  
203      dumpWriter = NULL;
204      statWriter = NULL;
205 <    
206 < }
205 >  
206 >  }
207  
208 < void VelocityVerletIntegrator::integrateStep() {
209 <
208 >  void VelocityVerletIntegrator::integrateStep() {
209 >  
210      moveA();
211      calcForce(needPotential, needStress);
212      moveB();
213 < }
213 >  }
214  
215  
216 < void VelocityVerletIntegrator::calcForce(bool needPotential,
217 <                                         bool needStress) {
216 >  void VelocityVerletIntegrator::calcForce(bool needPotential,
217 >                                           bool needStress) {
218      forceMan_->calcForces(needPotential, needStress);
219 < }
219 >  }
220  
221 < DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
222 <    return new DumpWriter(info_, info_->getDumpFileName());
223 < }
221 >  DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
222 >    return new DumpWriter(info_);
223 >  }
224  
225 < StatWriter* VelocityVerletIntegrator::createStatWriter() {
202 <    return new StatWriter(info_->getStatFileName());
203 < }
225 >  StatWriter* VelocityVerletIntegrator::createStatWriter() {
226  
227 +    std::string statFileFormatString = simParams->getStatFileFormat();
228 +    StatsBitSet mask = parseStatFileFormat(statFileFormatString);
229 +    
230 +    // if solidThermInt is true, add extra information to the statfile
231 +    if (simParams->getUseSolidThermInt()){
232 +      mask.set(Stats::VRAW);
233 +      mask.set(Stats::VHARM);
234 +    }
235  
236 +    if (simParams->havePrintPressureTensor() && simParams->getPrintPressureTensor()){
237 +        mask.set(Stats::PRESSURE_TENSOR_X);
238 +        mask.set(Stats::PRESSURE_TENSOR_Y);
239 +        mask.set(Stats::PRESSURE_TENSOR_Z);
240 +    }
241 +    
242 +     return new StatWriter(info_->getStatFileName(), mask);
243 +  }
244 +
245 +  RestWriter* VelocityVerletIntegrator::createRestWriter(){
246 +    return new RestWriter(info_);
247 +  }
248 +
249 +
250   } //end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines