ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1930
Committed: Wed Jan 12 22:41:40 2005 UTC (19 years, 5 months ago) by gezelter
File size: 6057 byte(s)
Log Message:
merging new_design branch into OOPSE-2.0

File Contents

# Content
1 /*
2 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 *
4 * The University of Notre Dame grants you ("Licensee") a
5 * non-exclusive, royalty free, license to use, modify and
6 * redistribute this software in source and binary code form, provided
7 * that the following conditions are met:
8 *
9 * 1. Acknowledgement of the program authors must be made in any
10 * publication of scientific results based in part on use of the
11 * program. An acceptable form of acknowledgement is citation of
12 * the article in which the program was described (Matthew
13 * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 * Parallel Simulation Engine for Molecular Dynamics,"
16 * J. Comput. Chem. 26, pp. 252-271 (2005))
17 *
18 * 2. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * 3. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * This software is provided "AS IS," without a warranty of any
27 * kind. All express or implied conditions, representations and
28 * warranties, including any implied warranty of merchantability,
29 * fitness for a particular purpose or non-infringement, are hereby
30 * excluded. The University of Notre Dame and its licensors shall not
31 * be liable for any damages suffered by licensee as a result of
32 * using, modifying or distributing the software or its
33 * derivatives. In no event will the University of Notre Dame or its
34 * licensors be liable for any lost revenue, profit or data, or for
35 * direct, indirect, special, consequential, incidental or punitive
36 * damages, however caused and regardless of the theory of liability,
37 * arising out of the use of or inability to use software, even if the
38 * University of Notre Dame has been advised of the possibility of
39 * such damages.
40 */
41
42 /**
43 * @file VelocityVerletIntegrator.cpp
44 * @author tlin
45 * @date 11/09/2004
46 * @time 16:16am
47 * @version 1.0
48 */
49
50 #include "integrators/VelocityVerletIntegrator.hpp"
51 #include "integrators/DLM.hpp"
52
53 namespace oopse {
54 VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
55 dt2 = 0.5 * dt;
56 rotAlgo = new DLM();
57 rattle = new Rattle(info);
58 }
59
60 VelocityVerletIntegrator::~VelocityVerletIntegrator() {
61 delete rotAlgo;
62 delete rattle;
63 }
64
65 void VelocityVerletIntegrator::initialize(){
66
67 forceMan_->init();
68
69 // remove center of mass drift velocity (in case we passed in a configuration
70 // that was drifting
71 velocitizer_->removeComDrift();
72
73 // initialize the forces before the first step
74 calcForce(true, true);
75
76 //execute constraint algorithm to make sure at the very beginning the system is constrained
77 if (info_->getNGlobalConstraints() > 0) {
78 rattle->constraintA();
79 calcForce(true, true);
80 rattle->constraintB();
81 info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
82 }
83
84 if (needVelocityScaling) {
85 velocitizer_->velocitize(targetScalingTemp);
86 }
87
88 dumpWriter = createDumpWriter();
89 statWriter = createStatWriter();
90
91 dumpWriter->writeDump();
92
93 //save statistics, before writeStat, we must save statistics
94 thermo.saveStat();
95 saveConservedQuantity();
96 statWriter->writeStat(currentSnapshot_->statData);
97
98 currSample = sampleTime + currentSnapshot_->getTime();
99 currStatus = statusTime + currentSnapshot_->getTime();;
100 currThermal = thermalTime + + currentSnapshot_->getTime();
101 needPotential = false;
102 needStress = false;
103
104 }
105
106 void VelocityVerletIntegrator::doIntegrate() {
107
108
109 initialize();
110
111 while (currentSnapshot_->getTime() < runTime) {
112
113 preStep();
114
115 integrateStep();
116
117 postStep();
118
119 }
120
121 finalize();
122
123 }
124
125
126 void VelocityVerletIntegrator::preStep() {
127 double difference = currentSnapshot_->getTime() + dt - currStatus;
128
129 if (difference > 0 || fabs(difference) < oopse::epsilon) {
130 needPotential = true;
131 needStress = true;
132 }
133
134 }
135
136 void VelocityVerletIntegrator::postStep() {
137
138 //save snapshot
139 info_->getSnapshotManager()->advance();
140
141 //increase time
142 currentSnapshot_->increaseTime(dt);
143
144 if (needVelocityScaling) {
145 if (currentSnapshot_->getTime() >= currThermal) {
146 velocitizer_->velocitize(targetScalingTemp);
147 currThermal += thermalTime;
148 }
149 }
150
151 if (currentSnapshot_->getTime() >= currSample) {
152 dumpWriter->writeDump();
153 currSample += sampleTime;
154 }
155
156 if (currentSnapshot_->getTime() >= currStatus) {
157 //save statistics, before writeStat, we must save statistics
158 thermo.saveStat();
159 saveConservedQuantity();
160 statWriter->writeStat(currentSnapshot_->statData);
161
162 needPotential = false;
163 needStress = false;
164 currStatus += statusTime;
165 }
166
167
168 }
169
170
171 void VelocityVerletIntegrator::finalize() {
172
173 dumpWriter->writeDump();
174
175 delete dumpWriter;
176 delete statWriter;
177
178 dumpWriter = NULL;
179 statWriter = NULL;
180
181 }
182
183 void VelocityVerletIntegrator::integrateStep() {
184
185 moveA();
186 calcForce(needPotential, needStress);
187 moveB();
188 }
189
190
191 void VelocityVerletIntegrator::calcForce(bool needPotential,
192 bool needStress) {
193 forceMan_->calcForces(needPotential, needStress);
194 }
195
196 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
197 return new DumpWriter(info_, info_->getDumpFileName());
198 }
199
200 StatWriter* VelocityVerletIntegrator::createStatWriter() {
201 return new StatWriter(info_->getStatFileName());
202 }
203
204
205 } //end namespace oopse

Properties

Name Value
svn:executable *