ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/integrators/NVE.cpp
Revision: 1913
Committed: Mon Jan 10 22:04:20 2005 UTC (21 years, 5 months ago) by tim
File size: 4578 byte(s)
Log Message:
create a register module to register force fields, integrators and minimizers

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 1837
34 tim 1820 #include "integrators/NVE.hpp"
35     #include "primitives/Molecule.hpp"
36     #include "utils/OOPSEConstant.hpp"
37 tim 1722
38     namespace oopse {
39    
40 tim 1758
41 tim 1756 NVE::NVE(SimInfo* info) : VelocityVerletIntegrator(info){
42 tim 1722
43     }
44    
45 tim 1756 void NVE::moveA(){
46 tim 1820 SimInfo::MoleculeIterator i;
47     Molecule::IntegrableObjectIterator j;
48 tim 1722 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 tim 1756 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
58 tim 1722 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 tim 1820 vel += (dt2 /mass * OOPSEConstant::energyConvert) * frc;
68 tim 1722
69     // position whole step
70 tim 1774 pos += dt * vel;
71 tim 1722
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 tim 1820 ji += (dt2 * OOPSEConstant::energyConvert) * Tb;
86 tim 1722
87 tim 1820 rotAlgo->rotate(integrableObject, ji, dt);
88 tim 1722
89     integrableObject->setJ(ji);
90     }
91    
92    
93     }
94 tim 1756 } //end for(mol = info_->beginMolecule(i))
95 tim 1722
96 tim 1901 rattle->constraintA();
97 tim 1722
98     }
99    
100 tim 1756 void NVE::moveB(){
101 tim 1820 SimInfo::MoleculeIterator i;
102     Molecule::IntegrableObjectIterator j;
103 tim 1722 Molecule* mol;
104     StuntDouble* integrableObject;
105     Vector3d vel;
106     Vector3d frc;
107     Vector3d Tb;
108     Vector3d ji;
109     double mass;
110    
111 tim 1756 for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
112 tim 1722 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 tim 1820 vel += (dt2 /mass * OOPSEConstant::energyConvert) * frc;
121 tim 1722
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 tim 1820 ji += (dt2 * OOPSEConstant::energyConvert) * Tb;
135 tim 1722
136     integrableObject->setJ(ji);
137     }
138    
139    
140     }
141 tim 1756 } //end for(mol = info_->beginMolecule(i))
142 tim 1722
143    
144 tim 1901 rattle->constraintB();
145 tim 1722
146     }
147    
148 tim 1756
149 tim 1774 double NVE::calcConservedQuantity() {
150 tim 1820 return thermo.getTotalE();
151 tim 1756 }
152    
153 tim 1722 } //end namespace oopse

Properties

Name Value
svn:executable *