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: 1820
Committed: Thu Dec 2 00:09:35 2004 UTC (19 years, 7 months ago) by tim
File size: 4866 byte(s)
Log Message:
NVE get built

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

Properties

Name Value
svn:executable *