ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/integrators/NVE.cpp
Revision: 1758
Committed: Fri Nov 19 17:56:32 2004 UTC (19 years, 7 months ago) by tim
File size: 4719 byte(s)
Log Message:
DUFF is almost done except error checking

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     /**
27     * @file NVE.cpp
28     * @author tlin
29     * @date 11/08/2004
30     * @time 15:13am
31     * @version 1.0
32     */
33    
34     #include "integrators/NVE.hpp"
35     namespace oopse {
36    
37 tim 1758 Integrator* createNVE(SimInfo* info) {
38     return new NVE(info);
39     }
40    
41 tim 1722 //register the creator to IntegratorFactory
42 tim 1758 IntegratorFactory::getInstance()->registerIntegrator("NVE", createNVE);
43 tim 1722
44 tim 1756 NVE::NVE(SimInfo* info) : VelocityVerletIntegrator(info){
45 tim 1722
46     }
47    
48 tim 1756 void NVE::moveA(){
49 tim 1726 typename SimInfo::MoleculeIterator i;
50 tim 1722 std::vector<StuntDouble*>::iterator j;
51     Molecule* mol;
52     StuntDouble* integrableObject;
53     Vector3d vel;
54     Vector3d pos;
55     Vector3d frc;
56     Vector3d Tb;
57     Vector3d ji;
58     double mass;
59    
60 tim 1756 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
61 tim 1722 for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
62     integrableObject = mol->nextIntegrableObject(j)) {
63    
64     vel =integrableObject->getVel();
65     pos = integrableObject->getPos();
66     frc = integrableObject->getFrc();
67     mass = integrableObject->getMass();
68    
69     // velocity half step
70     vel += (halfStep /mass * UnitConstant::eConvert) * frc;
71    
72     // position whole step
73     pos += fullStep * vel;
74    
75     integrableObject->setVel(vel);
76     integrableObject->setPos(pos);
77    
78     if (integrableObject->isDirectional()){
79    
80     // get and convert the torque to body frame
81    
82     Tb = integrableObject->lab2Body(integrableObject->getTrq());
83    
84     // get the angular momentum, and propagate a half step
85    
86     ji = integrableObject->getJ();
87    
88     ji += (halfStep * UnitConstant::eConvert) * Tb;
89    
90     this->rotationPropagation( integrableObject, ji );
91    
92     integrableObject->setJ(ji);
93     }
94    
95    
96     }
97 tim 1756 } //end for(mol = info_->beginMolecule(i))
98 tim 1722
99 tim 1758 //constraintAlgorithm->doConstrainA();
100 tim 1722
101     }
102    
103 tim 1756 void NVE::moveB(){
104 tim 1726 typename SimInfo::MoleculeIterator i;
105 tim 1722 std::vector<StuntDouble*>::iterator j;
106     Molecule* mol;
107     StuntDouble* integrableObject;
108     Vector3d vel;
109     Vector3d frc;
110     Vector3d Tb;
111     Vector3d ji;
112     double mass;
113    
114 tim 1756 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
115 tim 1722 for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
116     integrableObject = mol->nextIntegrableObject(j)) {
117    
118     vel =integrableObject->getVel();
119     frc = integrableObject->getFrc();
120     mass = integrableObject->getMass();
121    
122     // velocity half step
123     vel += (halfStep /mass * UnitConstant::eConvert) * frc;
124    
125     integrableObject->setVel(vel);
126    
127     if (integrableObject->isDirectional()){
128    
129     // get and convert the torque to body frame
130    
131     Tb = integrableObject->lab2Body(integrableObject->getTrq());
132    
133     // get the angular momentum, and propagate a half step
134    
135     ji = integrableObject->getJ();
136    
137     ji += (halfStep * UnitConstant::eConvert) * Tb;
138    
139     integrableObject->setJ(ji);
140     }
141    
142    
143     }
144 tim 1756 } //end for(mol = info_->beginMolecule(i))
145 tim 1722
146    
147 tim 1758 //constraintAlgorithm->doConstrainB();
148 tim 1722
149     }
150    
151 tim 1756
152     void NVE::calcConservedQuantity() {
153    
154     }
155    
156 tim 1722 } //end namespace oopse

Properties

Name Value
svn:executable *