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: 1765
Committed: Mon Nov 22 20:55:52 2004 UTC (19 years, 7 months ago) by tim
File size: 4737 byte(s)
Log Message:
adding section parsers

File Contents

# Content
1 /*
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 Integrator* createNVE(SimInfo* info) {
38 return new NVE(info);
39 }
40
41 //register the creator to IntegratorFactory
42 IntegratorFactory::getInstance()->registerIntegrator("NVE", createNVE);
43
44 NVE::NVE(SimInfo* info) : VelocityVerletIntegrator(info){
45
46 }
47
48 void NVE::moveA(){
49 typename SimInfo::MoleculeIterator i;
50 typename Molecule::IntegrableObjectIterator 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 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
61 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 } //end for(mol = info_->beginMolecule(i))
98
99 //constraintAlgorithm->doConstrainA();
100
101 }
102
103 void NVE::moveB(){
104 typename SimInfo::MoleculeIterator i;
105 typename Molecule::IntegrableObjectIterator j;
106 Molecule* mol;
107 StuntDouble* integrableObject;
108 Vector3d vel;
109 Vector3d frc;
110 Vector3d Tb;
111 Vector3d ji;
112 double mass;
113
114 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
115 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 } //end for(mol = info_->beginMolecule(i))
145
146
147 //constraintAlgorithm->doConstrainB();
148
149 }
150
151
152 void NVE::calcConservedQuantity() {
153
154 }
155
156 } //end namespace oopse

Properties

Name Value
svn:executable *