ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/integrators/NVE.cpp
Revision: 1901
Committed: Tue Jan 4 22:18:36 2005 UTC (19 years, 6 months ago) by tim
File size: 4706 byte(s)
Log Message:
constraints in progress

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/IntegratorCreator.hpp"
35 #include "integrators/NVE.hpp"
36 #include "primitives/Molecule.hpp"
37 #include "utils/OOPSEConstant.hpp"
38
39 namespace oopse {
40
41 //static IntegratorBuilder<NVE>* NVECreator = new IntegratorBuilder<NVE>("NVE");
42
43 NVE::NVE(SimInfo* info) : VelocityVerletIntegrator(info){
44
45 }
46
47 void NVE::moveA(){
48 SimInfo::MoleculeIterator i;
49 Molecule::IntegrableObjectIterator j;
50 Molecule* mol;
51 StuntDouble* integrableObject;
52 Vector3d vel;
53 Vector3d pos;
54 Vector3d frc;
55 Vector3d Tb;
56 Vector3d ji;
57 double mass;
58
59 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
60 for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
61 integrableObject = mol->nextIntegrableObject(j)) {
62
63 vel =integrableObject->getVel();
64 pos = integrableObject->getPos();
65 frc = integrableObject->getFrc();
66 mass = integrableObject->getMass();
67
68 // velocity half step
69 vel += (dt2 /mass * OOPSEConstant::energyConvert) * frc;
70
71 // position whole step
72 pos += dt * vel;
73
74 integrableObject->setVel(vel);
75 integrableObject->setPos(pos);
76
77 if (integrableObject->isDirectional()){
78
79 // get and convert the torque to body frame
80
81 Tb = integrableObject->lab2Body(integrableObject->getTrq());
82
83 // get the angular momentum, and propagate a half step
84
85 ji = integrableObject->getJ();
86
87 ji += (dt2 * OOPSEConstant::energyConvert) * Tb;
88
89 rotAlgo->rotate(integrableObject, ji, dt);
90
91 integrableObject->setJ(ji);
92 }
93
94
95 }
96 } //end for(mol = info_->beginMolecule(i))
97
98 rattle->constraintA();
99
100 }
101
102 void NVE::moveB(){
103 SimInfo::MoleculeIterator i;
104 Molecule::IntegrableObjectIterator j;
105 Molecule* mol;
106 StuntDouble* integrableObject;
107 Vector3d vel;
108 Vector3d frc;
109 Vector3d Tb;
110 Vector3d ji;
111 double mass;
112
113 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
114 for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
115 integrableObject = mol->nextIntegrableObject(j)) {
116
117 vel =integrableObject->getVel();
118 frc = integrableObject->getFrc();
119 mass = integrableObject->getMass();
120
121 // velocity half step
122 vel += (dt2 /mass * OOPSEConstant::energyConvert) * frc;
123
124 integrableObject->setVel(vel);
125
126 if (integrableObject->isDirectional()){
127
128 // get and convert the torque to body frame
129
130 Tb = integrableObject->lab2Body(integrableObject->getTrq());
131
132 // get the angular momentum, and propagate a half step
133
134 ji = integrableObject->getJ();
135
136 ji += (dt2 * OOPSEConstant::energyConvert) * Tb;
137
138 integrableObject->setJ(ji);
139 }
140
141
142 }
143 } //end for(mol = info_->beginMolecule(i))
144
145
146 rattle->constraintB();
147
148 }
149
150
151 double NVE::calcConservedQuantity() {
152 return thermo.getTotalE();
153 }
154
155 } //end namespace oopse

Properties

Name Value
svn:executable *