ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp
Revision: 1927
Committed: Wed Jan 12 17:14:35 2005 UTC (21 years, 4 months ago) by tim
File size: 6057 byte(s)
Log Message:
change license

File Contents

# User Rev Content
1 tim 1927 /*
2     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 tim 1722 *
4 tim 1927 * 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 tim 1722 */
41 tim 1927
42 tim 1725 /**
43     * @file VelocityVerletIntegrator.cpp
44     * @author tlin
45     * @date 11/09/2004
46     * @time 16:16am
47     * @version 1.0
48     */
49    
50 tim 1722 #include "integrators/VelocityVerletIntegrator.hpp"
51 tim 1820 #include "integrators/DLM.hpp"
52 tim 1722
53     namespace oopse {
54 tim 1820 VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
55 tim 1901 dt2 = 0.5 * dt;
56 tim 1820 rotAlgo = new DLM();
57 tim 1901 rattle = new Rattle(info);
58 tim 1819 }
59 tim 1722
60 tim 1820 VelocityVerletIntegrator::~VelocityVerletIntegrator() {
61     delete rotAlgo;
62 tim 1901 delete rattle;
63 tim 1820 }
64 tim 1722
65 tim 1819 void VelocityVerletIntegrator::initialize(){
66 tim 1722
67 tim 1912 forceMan_->init();
68    
69 tim 1725 // remove center of mass drift velocity (in case we passed in a configuration
70     // that was drifting
71 tim 1819 velocitizer_->removeComDrift();
72 tim 1722
73 tim 1725 // initialize the forces before the first step
74 tim 1819 calcForce(true, true);
75 tim 1722
76 tim 1725 //execute constraint algorithm to make sure at the very beginning the system is constrained
77 tim 1907 if (info_->getNGlobalConstraints() > 0) {
78     rattle->constraintA();
79     calcForce(true, true);
80 tim 1910 rattle->constraintB();
81     info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
82 tim 1907 }
83 tim 1725
84 tim 1819 if (needVelocityScaling) {
85     velocitizer_->velocitize(targetScalingTemp);
86 tim 1725 }
87 tim 1819
88     dumpWriter = createDumpWriter();
89     statWriter = createStatWriter();
90 tim 1725
91 tim 1820 dumpWriter->writeDump();
92 tim 1847
93 tim 1868 //save statistics, before writeStat, we must save statistics
94 tim 1847 thermo.saveStat();
95     saveConservedQuantity();
96 tim 1868 statWriter->writeStat(currentSnapshot_->statData);
97 tim 1847
98 tim 1868 currSample = sampleTime + currentSnapshot_->getTime();
99     currStatus = statusTime + currentSnapshot_->getTime();;
100     currThermal = thermalTime + + currentSnapshot_->getTime();
101     needPotential = false;
102     needStress = false;
103 tim 1820
104 tim 1819 }
105    
106     void VelocityVerletIntegrator::doIntegrate() {
107 tim 1725
108    
109 tim 1819 initialize();
110 tim 1725
111 tim 1819 while (currentSnapshot_->getTime() < runTime) {
112    
113     preStep();
114 tim 1725
115 tim 1819 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 tim 1725 }
133    
134 tim 1819 }
135    
136     void VelocityVerletIntegrator::postStep() {
137 tim 1820
138     //save snapshot
139     info_->getSnapshotManager()->advance();
140    
141     //increase time
142     currentSnapshot_->increaseTime(dt);
143 tim 1756
144 tim 1819 if (needVelocityScaling) {
145     if (currentSnapshot_->getTime() >= currThermal) {
146     velocitizer_->velocitize(targetScalingTemp);
147 tim 1725 currThermal += thermalTime;
148     }
149     }
150    
151 tim 1819 if (currentSnapshot_->getTime() >= currSample) {
152 tim 1820 dumpWriter->writeDump();
153 tim 1725 currSample += sampleTime;
154     }
155    
156 tim 1819 if (currentSnapshot_->getTime() >= currStatus) {
157 tim 1868 //save statistics, before writeStat, we must save statistics
158     thermo.saveStat();
159     saveConservedQuantity();
160 tim 1820 statWriter->writeStat(currentSnapshot_->statData);
161 tim 1868
162 tim 1819 needPotential = false;
163     needStress = false;
164 tim 1725 currStatus += statusTime;
165     }
166 tim 1820
167    
168 tim 1819 }
169 tim 1725
170    
171 tim 1819 void VelocityVerletIntegrator::finalize() {
172 tim 1725
173 tim 1820 dumpWriter->writeDump();
174 tim 1725
175 tim 1819 delete dumpWriter;
176     delete statWriter;
177 tim 1725
178 tim 1819 dumpWriter = NULL;
179     statWriter = NULL;
180    
181 tim 1722 }
182    
183 tim 1774 void VelocityVerletIntegrator::integrateStep() {
184 tim 1725
185 tim 1774 moveA();
186 tim 1819 calcForce(needPotential, needStress);
187 tim 1774 moveB();
188     }
189 tim 1725
190 tim 1774
191 tim 1819 void VelocityVerletIntegrator::calcForce(bool needPotential,
192     bool needStress) {
193 tim 1820 forceMan_->calcForces(needPotential, needStress);
194 tim 1722 }
195    
196 tim 1820 DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
197     return new DumpWriter(info_, info_->getDumpFileName());
198     }
199 tim 1722
200 tim 1820 StatWriter* VelocityVerletIntegrator::createStatWriter() {
201     return new StatWriter(info_->getStatFileName());
202     }
203    
204    
205 tim 1725 } //end namespace oopse

Properties

Name Value
svn:executable *