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: 1913
Committed: Mon Jan 10 22:04:20 2005 UTC (19 years, 6 months ago) by tim
File size: 4578 byte(s)
Log Message:
create a register module to register force fields, integrators and minimizers

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

Properties

Name Value
svn:executable *