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 |
< |
REGISTER_CREATOR(IntegratorFactory, "NVE", NVE); |
42 |
> |
IntegratorFactory::getInstance()->registerIntegrator("NVE", createNVE); |
43 |
|
|
44 |
< |
NVE::NVE(SimInfo* info) { |
44 |
> |
NVE::NVE(SimInfo* info) : VelocityVerletIntegrator(info){ |
45 |
|
|
46 |
|
} |
47 |
|
|
48 |
< |
NVE::moveA(){ |
49 |
< |
std::vector<Molecule*>::iterator i; |
50 |
< |
std::vector<StuntDouble*>::iterator j; |
48 |
> |
void NVE::moveA(){ |
49 |
> |
typename SimInfo::MoleculeIterator i; |
50 |
> |
typename Molecule::IntegrableObjectIterator j; |
51 |
|
Molecule* mol; |
52 |
|
StuntDouble* integrableObject; |
53 |
|
Vector3d vel; |
56 |
|
Vector3d Tb; |
57 |
|
Vector3d ji; |
58 |
|
double mass; |
55 |
– |
|
56 |
– |
// Raw degrees of freedom that we have to set |
59 |
|
|
60 |
< |
for (mol = info->beginMolecule(i); mol != NULL; mol = info->nextMolecule(i)) { |
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 |
|
|
67 |
|
mass = integrableObject->getMass(); |
68 |
|
|
69 |
|
// velocity half step |
70 |
< |
vel += (halfStep /mass * UnitConstant::eConvert) * frc; |
70 |
> |
vel += (dt2 /mass * UnitConstant::eConvert) * frc; |
71 |
|
|
72 |
|
// position whole step |
73 |
< |
pos += fullStep * vel; |
73 |
> |
pos += dt * vel; |
74 |
|
|
75 |
|
integrableObject->setVel(vel); |
76 |
|
integrableObject->setPos(pos); |
85 |
|
|
86 |
|
ji = integrableObject->getJ(); |
87 |
|
|
88 |
< |
ji += (halfStep * UnitConstant::eConvert) * Tb; |
88 |
> |
ji += (dt2 * UnitConstant::eConvert) * Tb; |
89 |
|
|
90 |
|
this->rotationPropagation( integrableObject, ji ); |
91 |
|
|
94 |
|
|
95 |
|
|
96 |
|
} |
97 |
< |
} //end for(mol = info->beginMolecule(i)) |
97 |
> |
} //end for(mol = info_->beginMolecule(i)) |
98 |
|
|
99 |
< |
constraintAlgorithm->doConstrainA(); |
99 |
> |
//constraintAlgorithm->doConstrainA(); |
100 |
|
|
101 |
|
} |
102 |
|
|
103 |
< |
NVE::moveB(){ |
104 |
< |
std::vector<Molecule*>::iterator i; |
105 |
< |
std::vector<StuntDouble*>::iterator j; |
103 |
> |
void NVE::moveB(){ |
104 |
> |
typename SimInfo::MoleculeIterator i; |
105 |
> |
typename Molecule::IntegrableObjectIterator j; |
106 |
|
Molecule* mol; |
107 |
|
StuntDouble* integrableObject; |
108 |
|
Vector3d vel; |
111 |
|
Vector3d ji; |
112 |
|
double mass; |
113 |
|
|
114 |
< |
for (mol = info->beginMolecule(i); mol != NULL; mol = info->nextMolecule(i)) { |
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 |
|
|
120 |
|
mass = integrableObject->getMass(); |
121 |
|
|
122 |
|
// velocity half step |
123 |
< |
vel += (halfStep /mass * UnitConstant::eConvert) * frc; |
123 |
> |
vel += (dt2 /mass * UnitConstant::eConvert) * frc; |
124 |
|
|
125 |
|
integrableObject->setVel(vel); |
126 |
|
|
134 |
|
|
135 |
|
ji = integrableObject->getJ(); |
136 |
|
|
137 |
< |
ji += (halfStep * UnitConstant::eConvert) * Tb; |
137 |
> |
ji += (dt2 * UnitConstant::eConvert) * Tb; |
138 |
|
|
139 |
|
integrableObject->setJ(ji); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
|
} |
144 |
< |
} //end for(mol = info->beginMolecule(i)) |
144 |
> |
} //end for(mol = info_->beginMolecule(i)) |
145 |
|
|
146 |
|
|
147 |
< |
constraintAlgorithm->doConstrainB(); |
147 |
> |
//constraintAlgorithm->doConstrainB(); |
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
+ |
|
152 |
+ |
double NVE::calcConservedQuantity() { |
153 |
+ |
|
154 |
+ |
} |
155 |
+ |
|
156 |
|
} //end namespace oopse |