# | Line 1 | Line 1 | |
---|---|---|
1 | #include <iostream> | |
2 | < | #include <cstdlib> |
3 | < | #include <cmath> |
2 | > | #include <stdlib.h> |
3 | > | #include <math.h> |
4 | ||
5 | #ifdef IS_MPI | |
6 | #include "mpiSimulation.hpp" | |
7 | #include <unistd.h> | |
8 | #endif //is_mpi | |
9 | ||
10 | + | #ifdef PROFILE |
11 | + | #include "mdProfile.hpp" |
12 | + | #endif // profile |
13 | + | |
14 | #include "Integrator.hpp" | |
15 | #include "simError.h" | |
16 | ||
17 | ||
18 | < | Integrator::Integrator( SimInfo *theInfo, ForceFields* the_ff ){ |
19 | < | |
18 | > | template<typename T> Integrator<T>::Integrator(SimInfo* theInfo, |
19 | > | ForceFields* the_ff){ |
20 | info = theInfo; | |
21 | myFF = the_ff; | |
22 | isFirst = 1; | |
# | Line 21 | Line 25 | Integrator::Integrator( SimInfo *theInfo, ForceFields* | |
25 | nMols = info->n_mol; | |
26 | ||
27 | // give a little love back to the SimInfo object | |
24 | – | |
25 | – | if( info->the_integrator != NULL ) delete info->the_integrator; |
26 | – | info->the_integrator = this; |
28 | ||
29 | < | nAtoms = info->n_atoms; |
29 | > | if (info->the_integrator != NULL){ |
30 | > | delete info->the_integrator; |
31 | > | } |
32 | ||
33 | + | nAtoms = info->n_atoms; |
34 | + | integrableObjects = info->integrableObjects; |
35 | + | |
36 | // check for constraints | |
37 | < | |
38 | < | constrainedA = NULL; |
39 | < | constrainedB = NULL; |
37 | > | |
38 | > | constrainedA = NULL; |
39 | > | constrainedB = NULL; |
40 | constrainedDsqr = NULL; | |
41 | < | moving = NULL; |
42 | < | moved = NULL; |
43 | < | oldPos = NULL; |
44 | < | |
41 | > | moving = NULL; |
42 | > | moved = NULL; |
43 | > | oldPos = NULL; |
44 | > | |
45 | nConstrained = 0; | |
46 | ||
47 | checkConstraints(); | |
48 | + | |
49 | } | |
50 | ||
51 | < | Integrator::~Integrator() { |
52 | < | |
46 | < | if( nConstrained ){ |
51 | > | template<typename T> Integrator<T>::~Integrator(){ |
52 | > | if (nConstrained){ |
53 | delete[] constrainedA; | |
54 | delete[] constrainedB; | |
55 | delete[] constrainedDsqr; | |
# | Line 51 | Line 57 | Integrator::~Integrator() { | |
57 | delete[] moved; | |
58 | delete[] oldPos; | |
59 | } | |
54 | – | |
60 | } | |
61 | ||
62 | < | void Integrator::checkConstraints( void ){ |
58 | < | |
59 | < | |
62 | > | template<typename T> void Integrator<T>::checkConstraints(void){ |
63 | isConstrained = 0; | |
64 | ||
65 | < | Constraint *temp_con; |
66 | < | Constraint *dummy_plug; |
65 | > | Constraint* temp_con; |
66 | > | Constraint* dummy_plug; |
67 | temp_con = new Constraint[info->n_SRI]; | |
68 | nConstrained = 0; | |
69 | int constrained = 0; | |
70 | < | |
70 | > | |
71 | SRI** theArray; | |
72 | < | for(int i = 0; i < nMols; i++){ |
73 | < | |
74 | < | theArray = (SRI**) molecules[i].getMyBonds(); |
75 | < | for(int j=0; j<molecules[i].getNBonds(); j++){ |
73 | < | |
72 | > | for (int i = 0; i < nMols; i++){ |
73 | > | |
74 | > | theArray = (SRI * *) molecules[i].getMyBonds(); |
75 | > | for (int j = 0; j < molecules[i].getNBonds(); j++){ |
76 | constrained = theArray[j]->is_constrained(); | |
77 | < | |
78 | < | if(constrained){ |
79 | < | |
80 | < | dummy_plug = theArray[j]->get_constraint(); |
81 | < | temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
82 | < | temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
83 | < | temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
84 | < | |
85 | < | nConstrained++; |
84 | < | constrained = 0; |
77 | > | |
78 | > | if (constrained){ |
79 | > | dummy_plug = theArray[j]->get_constraint(); |
80 | > | temp_con[nConstrained].set_a(dummy_plug->get_a()); |
81 | > | temp_con[nConstrained].set_b(dummy_plug->get_b()); |
82 | > | temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
83 | > | |
84 | > | nConstrained++; |
85 | > | constrained = 0; |
86 | } | |
87 | } | |
88 | ||
89 | < | theArray = (SRI**) molecules[i].getMyBends(); |
90 | < | for(int j=0; j<molecules[i].getNBends(); j++){ |
90 | < | |
89 | > | theArray = (SRI * *) molecules[i].getMyBends(); |
90 | > | for (int j = 0; j < molecules[i].getNBends(); j++){ |
91 | constrained = theArray[j]->is_constrained(); | |
92 | < | |
93 | < | if(constrained){ |
94 | < | |
95 | < | dummy_plug = theArray[j]->get_constraint(); |
96 | < | temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
97 | < | temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
98 | < | temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
99 | < | |
100 | < | nConstrained++; |
101 | < | constrained = 0; |
92 | > | |
93 | > | if (constrained){ |
94 | > | dummy_plug = theArray[j]->get_constraint(); |
95 | > | temp_con[nConstrained].set_a(dummy_plug->get_a()); |
96 | > | temp_con[nConstrained].set_b(dummy_plug->get_b()); |
97 | > | temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
98 | > | |
99 | > | nConstrained++; |
100 | > | constrained = 0; |
101 | } | |
102 | } | |
103 | ||
104 | < | theArray = (SRI**) molecules[i].getMyTorsions(); |
105 | < | for(int j=0; j<molecules[i].getNTorsions(); j++){ |
107 | < | |
104 | > | theArray = (SRI * *) molecules[i].getMyTorsions(); |
105 | > | for (int j = 0; j < molecules[i].getNTorsions(); j++){ |
106 | constrained = theArray[j]->is_constrained(); | |
107 | < | |
108 | < | if(constrained){ |
109 | < | |
110 | < | dummy_plug = theArray[j]->get_constraint(); |
111 | < | temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
112 | < | temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
113 | < | temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
114 | < | |
115 | < | nConstrained++; |
118 | < | constrained = 0; |
107 | > | |
108 | > | if (constrained){ |
109 | > | dummy_plug = theArray[j]->get_constraint(); |
110 | > | temp_con[nConstrained].set_a(dummy_plug->get_a()); |
111 | > | temp_con[nConstrained].set_b(dummy_plug->get_b()); |
112 | > | temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
113 | > | |
114 | > | nConstrained++; |
115 | > | constrained = 0; |
116 | } | |
117 | } | |
118 | } | |
119 | ||
120 | < | if(nConstrained > 0){ |
121 | < | |
120 | > | |
121 | > | if (nConstrained > 0){ |
122 | isConstrained = 1; | |
123 | ||
124 | < | if(constrainedA != NULL ) delete[] constrainedA; |
125 | < | if(constrainedB != NULL ) delete[] constrainedB; |
126 | < | if(constrainedDsqr != NULL ) delete[] constrainedDsqr; |
124 | > | if (constrainedA != NULL) |
125 | > | delete[] constrainedA; |
126 | > | if (constrainedB != NULL) |
127 | > | delete[] constrainedB; |
128 | > | if (constrainedDsqr != NULL) |
129 | > | delete[] constrainedDsqr; |
130 | ||
131 | < | constrainedA = new int[nConstrained]; |
132 | < | constrainedB = new int[nConstrained]; |
131 | > | constrainedA = new int[nConstrained]; |
132 | > | constrainedB = new int[nConstrained]; |
133 | constrainedDsqr = new double[nConstrained]; | |
134 | < | |
135 | < | for( int i = 0; i < nConstrained; i++){ |
136 | < | |
134 | > | |
135 | > | for (int i = 0; i < nConstrained; i++){ |
136 | constrainedA[i] = temp_con[i].get_a(); | |
137 | constrainedB[i] = temp_con[i].get_b(); | |
138 | constrainedDsqr[i] = temp_con[i].get_dsqr(); | |
140 | – | |
139 | } | |
140 | ||
141 | < | |
142 | < | // save oldAtoms to check for lode balanceing later on. |
143 | < | |
141 | > | |
142 | > | // save oldAtoms to check for lode balancing later on. |
143 | > | |
144 | oldAtoms = nAtoms; | |
145 | < | |
145 | > | |
146 | moving = new int[nAtoms]; | |
147 | < | moved = new int[nAtoms]; |
147 | > | moved = new int[nAtoms]; |
148 | ||
149 | < | oldPos = new double[nAtoms*3]; |
149 | > | oldPos = new double[nAtoms * 3]; |
150 | } | |
151 | < | |
151 | > | |
152 | delete[] temp_con; | |
153 | } | |
154 | ||
155 | ||
156 | < | void Integrator::integrate( void ){ |
156 | > | template<typename T> void Integrator<T>::integrate(void){ |
157 | ||
158 | < | int i, j; // loop counters |
159 | < | |
160 | < | double runTime = info->run_time; |
163 | < | double sampleTime = info->sampleTime; |
164 | < | double statusTime = info->statusTime; |
158 | > | double runTime = info->run_time; |
159 | > | double sampleTime = info->sampleTime; |
160 | > | double statusTime = info->statusTime; |
161 | double thermalTime = info->thermalTime; | |
162 | + | double resetTime = info->resetTime; |
163 | ||
164 | + | double difference; |
165 | double currSample; | |
166 | double currThermal; | |
167 | double currStatus; | |
168 | < | double currTime; |
168 | > | double currReset; |
169 | ||
170 | int calcPot, calcStress; | |
173 | – | int isError; |
171 | ||
172 | + | tStats = new Thermo(info); |
173 | + | statOut = new StatWriter(info); |
174 | + | dumpOut = new DumpWriter(info); |
175 | ||
176 | – | |
177 | – | tStats = new Thermo( info ); |
178 | – | statOut = new StatWriter( info ); |
179 | – | dumpOut = new DumpWriter( info ); |
180 | – | |
176 | atoms = info->atoms; | |
182 | – | DirectionalAtom* dAtom; |
177 | ||
178 | dt = info->dt; | |
179 | dt2 = 0.5 * dt; | |
180 | ||
181 | + | readyCheck(); |
182 | + | |
183 | + | // remove center of mass drift velocity (in case we passed in a configuration |
184 | + | // that was drifting |
185 | + | tStats->removeCOMdrift(); |
186 | + | |
187 | + | // initialize the retraints if necessary |
188 | + | if (info->useThermInt) { |
189 | + | myFF->initRestraints(); |
190 | + | } |
191 | + | |
192 | // initialize the forces before the first step | |
193 | ||
194 | < | myFF->doForces(1,1); |
194 | > | calcForce(1, 1); |
195 | ||
196 | < | if( info->setTemp ){ |
197 | < | |
198 | < | tStats->velocitize(); |
196 | > | if (nConstrained){ |
197 | > | preMove(); |
198 | > | constrainA(); |
199 | > | calcForce(1, 1); |
200 | > | constrainB(); |
201 | } | |
202 | ||
203 | < | dumpOut->writeDump( 0.0 ); |
204 | < | statOut->writeStat( 0.0 ); |
205 | < | |
203 | > | if (info->setTemp){ |
204 | > | thermalize(); |
205 | > | } |
206 | > | |
207 | calcPot = 0; | |
208 | calcStress = 0; | |
209 | < | currSample = sampleTime; |
210 | < | currThermal = thermalTime; |
211 | < | currStatus = statusTime; |
212 | < | currTime = 0.0;; |
209 | > | currSample = sampleTime + info->getTime(); |
210 | > | currThermal = thermalTime+ info->getTime(); |
211 | > | currStatus = statusTime + info->getTime(); |
212 | > | currReset = resetTime + info->getTime(); |
213 | ||
214 | + | dumpOut->writeDump(info->getTime()); |
215 | + | statOut->writeStat(info->getTime()); |
216 | ||
207 | – | readyCheck(); |
217 | ||
218 | #ifdef IS_MPI | |
219 | < | strcpy( checkPointMsg, |
211 | < | "The integrator is ready to go." ); |
219 | > | strcpy(checkPointMsg, "The integrator is ready to go."); |
220 | MPIcheckPoint(); | |
221 | #endif // is_mpi | |
222 | ||
223 | < | |
224 | < | pos = Atom::getPosArray(); |
225 | < | vel = Atom::getVelArray(); |
218 | < | frc = Atom::getFrcArray(); |
219 | < | trq = Atom::getTrqArray(); |
220 | < | Amat = Atom::getAmatArray(); |
221 | < | |
222 | < | while( currTime < runTime ){ |
223 | < | |
224 | < | if( (currTime+dt) >= currStatus ){ |
223 | > | while (info->getTime() < runTime && !stopIntegrator()){ |
224 | > | difference = info->getTime() + dt - currStatus; |
225 | > | if (difference > 0 || fabs(difference) < 1e-4 ){ |
226 | calcPot = 1; | |
227 | calcStress = 1; | |
228 | } | |
229 | ||
230 | < | integrateStep( calcPot, calcStress ); |
231 | < | |
232 | < | currTime += dt; |
230 | > | #ifdef PROFILE |
231 | > | startProfile( pro1 ); |
232 | > | #endif |
233 | > | |
234 | > | integrateStep(calcPot, calcStress); |
235 | ||
236 | < | if( info->setTemp ){ |
237 | < | if( currTime >= currThermal ){ |
238 | < | tStats->velocitize(); |
239 | < | currThermal += thermalTime; |
236 | > | #ifdef PROFILE |
237 | > | endProfile( pro1 ); |
238 | > | |
239 | > | startProfile( pro2 ); |
240 | > | #endif // profile |
241 | > | |
242 | > | info->incrTime(dt); |
243 | > | |
244 | > | if (info->setTemp){ |
245 | > | if (info->getTime() >= currThermal){ |
246 | > | thermalize(); |
247 | > | currThermal += thermalTime; |
248 | } | |
249 | } | |
250 | ||
251 | < | if( currTime >= currSample ){ |
252 | < | dumpOut->writeDump( currTime ); |
251 | > | if (info->getTime() >= currSample){ |
252 | > | dumpOut->writeDump(info->getTime()); |
253 | currSample += sampleTime; | |
254 | } | |
255 | ||
256 | < | if( currTime >= currStatus ){ |
257 | < | statOut->writeStat( currTime ); |
258 | < | calcPot = 0; |
256 | > | if (info->getTime() >= currStatus){ |
257 | > | statOut->writeStat(info->getTime()); |
258 | > | statOut->writeRaw(info->getTime()); |
259 | > | calcPot = 0; |
260 | calcStress = 0; | |
261 | currStatus += statusTime; | |
262 | < | } |
262 | > | } |
263 | ||
264 | + | if (info->resetIntegrator){ |
265 | + | if (info->getTime() >= currReset){ |
266 | + | this->resetIntegrator(); |
267 | + | currReset += resetTime; |
268 | + | } |
269 | + | } |
270 | + | |
271 | + | #ifdef PROFILE |
272 | + | endProfile( pro2 ); |
273 | + | #endif //profile |
274 | + | |
275 | #ifdef IS_MPI | |
276 | < | strcpy( checkPointMsg, |
254 | < | "successfully took a time step." ); |
276 | > | strcpy(checkPointMsg, "successfully took a time step."); |
277 | MPIcheckPoint(); | |
278 | #endif // is_mpi | |
257 | – | |
279 | } | |
280 | ||
281 | < | dumpOut->writeFinal(currTime); |
281 | > | // dump out a file containing the omega values for the final configuration |
282 | > | if (info->useThermInt) |
283 | > | myFF->dumpzAngle(); |
284 | > | |
285 | ||
286 | delete dumpOut; | |
287 | delete statOut; | |
288 | } | |
289 | ||
290 | < | void Integrator::integrateStep( int calcPot, int calcStress ){ |
291 | < | |
268 | < | |
269 | < | |
290 | > | template<typename T> void Integrator<T>::integrateStep(int calcPot, |
291 | > | int calcStress){ |
292 | // Position full step, and velocity half step | |
293 | ||
294 | + | #ifdef PROFILE |
295 | + | startProfile(pro3); |
296 | + | #endif //profile |
297 | + | |
298 | preMove(); | |
299 | + | |
300 | + | #ifdef PROFILE |
301 | + | endProfile(pro3); |
302 | + | |
303 | + | startProfile(pro4); |
304 | + | #endif // profile |
305 | + | |
306 | moveA(); | |
274 | – | if( nConstrained ) constrainA(); |
307 | ||
308 | + | #ifdef PROFILE |
309 | + | endProfile(pro4); |
310 | + | |
311 | + | startProfile(pro5); |
312 | + | #endif//profile |
313 | + | |
314 | + | |
315 | + | #ifdef IS_MPI |
316 | + | strcpy(checkPointMsg, "Succesful moveA\n"); |
317 | + | MPIcheckPoint(); |
318 | + | #endif // is_mpi |
319 | + | |
320 | // calc forces | |
321 | + | calcForce(calcPot, calcStress); |
322 | ||
323 | < | myFF->doForces(calcPot,calcStress); |
323 | > | #ifdef IS_MPI |
324 | > | strcpy(checkPointMsg, "Succesful doForces\n"); |
325 | > | MPIcheckPoint(); |
326 | > | #endif // is_mpi |
327 | ||
328 | + | #ifdef PROFILE |
329 | + | endProfile( pro5 ); |
330 | + | |
331 | + | startProfile( pro6 ); |
332 | + | #endif //profile |
333 | + | |
334 | // finish the velocity half step | |
335 | < | |
335 | > | |
336 | moveB(); | |
337 | < | if( nConstrained ) constrainB(); |
338 | < | |
337 | > | |
338 | > | #ifdef PROFILE |
339 | > | endProfile(pro6); |
340 | > | #endif // profile |
341 | > | |
342 | > | #ifdef IS_MPI |
343 | > | strcpy(checkPointMsg, "Succesful moveB\n"); |
344 | > | MPIcheckPoint(); |
345 | > | #endif // is_mpi |
346 | } | |
347 | ||
348 | ||
349 | < | void Integrator::moveA( void ){ |
350 | < | |
290 | < | int i,j,k; |
291 | < | int atomIndex, aMatIndex; |
349 | > | template<typename T> void Integrator<T>::moveA(void){ |
350 | > | size_t i, j; |
351 | DirectionalAtom* dAtom; | |
352 | < | double Tb[3]; |
353 | < | double ji[3]; |
354 | < | double angle; |
352 | > | double Tb[3], ji[3]; |
353 | > | double vel[3], pos[3], frc[3]; |
354 | > | double mass; |
355 | > | double omega; |
356 | > | |
357 | > | for (i = 0; i < integrableObjects.size() ; i++){ |
358 | > | integrableObjects[i]->getVel(vel); |
359 | > | integrableObjects[i]->getPos(pos); |
360 | > | integrableObjects[i]->getFrc(frc); |
361 | > | |
362 | > | mass = integrableObjects[i]->getMass(); |
363 | ||
364 | + | for (j = 0; j < 3; j++){ |
365 | + | // velocity half step |
366 | + | vel[j] += (dt2 * frc[j] / mass) * eConvert; |
367 | + | // position whole step |
368 | + | pos[j] += dt * vel[j]; |
369 | + | } |
370 | ||
371 | + | integrableObjects[i]->setVel(vel); |
372 | + | integrableObjects[i]->setPos(pos); |
373 | ||
374 | < | for( i=0; i<nAtoms; i++ ){ |
300 | < | atomIndex = i * 3; |
301 | < | aMatIndex = i * 9; |
374 | > | if (integrableObjects[i]->isDirectional()){ |
375 | ||
376 | < | // velocity half step |
304 | < | for( j=atomIndex; j<(atomIndex+3); j++ ) |
305 | < | vel[j] += ( dt2 * frc[j] / atoms[i]->getMass() ) * eConvert; |
376 | > | // get and convert the torque to body frame |
377 | ||
378 | < | // position whole step |
379 | < | for( j=atomIndex; j<(atomIndex+3); j++ ) pos[j] += dt * vel[j]; |
309 | < | |
310 | < | if( atoms[i]->isDirectional() ){ |
378 | > | integrableObjects[i]->getTrq(Tb); |
379 | > | integrableObjects[i]->lab2Body(Tb); |
380 | ||
312 | – | dAtom = (DirectionalAtom *)atoms[i]; |
313 | – | |
314 | – | // get and convert the torque to body frame |
315 | – | |
316 | – | Tb[0] = dAtom->getTx(); |
317 | – | Tb[1] = dAtom->getTy(); |
318 | – | Tb[2] = dAtom->getTz(); |
319 | – | |
320 | – | dAtom->lab2Body( Tb ); |
321 | – | |
381 | // get the angular momentum, and propagate a half step | |
382 | < | |
383 | < | ji[0] = dAtom->getJx() + ( dt2 * Tb[0] ) * eConvert; |
384 | < | ji[1] = dAtom->getJy() + ( dt2 * Tb[1] ) * eConvert; |
385 | < | ji[2] = dAtom->getJz() + ( dt2 * Tb[2] ) * eConvert; |
386 | < | |
387 | < | // use the angular velocities to propagate the rotation matrix a |
388 | < | // full time step |
389 | < | |
390 | < | // rotate about the x-axis |
332 | < | angle = dt2 * ji[0] / dAtom->getIxx(); |
333 | < | this->rotate( 1, 2, angle, ji, &Amat[aMatIndex] ); |
334 | < | |
335 | < | // rotate about the y-axis |
336 | < | angle = dt2 * ji[1] / dAtom->getIyy(); |
337 | < | this->rotate( 2, 0, angle, ji, &Amat[aMatIndex] ); |
338 | < | |
339 | < | // rotate about the z-axis |
340 | < | angle = dt * ji[2] / dAtom->getIzz(); |
341 | < | this->rotate( 0, 1, angle, ji, &Amat[aMatIndex] ); |
342 | < | |
343 | < | // rotate about the y-axis |
344 | < | angle = dt2 * ji[1] / dAtom->getIyy(); |
345 | < | this->rotate( 2, 0, angle, ji, &Amat[aMatIndex] ); |
346 | < | |
347 | < | // rotate about the x-axis |
348 | < | angle = dt2 * ji[0] / dAtom->getIxx(); |
349 | < | this->rotate( 1, 2, angle, ji, &Amat[aMatIndex] ); |
350 | < | |
351 | < | dAtom->setJx( ji[0] ); |
352 | < | dAtom->setJy( ji[1] ); |
353 | < | dAtom->setJz( ji[2] ); |
382 | > | |
383 | > | integrableObjects[i]->getJ(ji); |
384 | > | |
385 | > | for (j = 0; j < 3; j++) |
386 | > | ji[j] += (dt2 * Tb[j]) * eConvert; |
387 | > | |
388 | > | this->rotationPropagation( integrableObjects[i], ji ); |
389 | > | |
390 | > | integrableObjects[i]->setJ(ji); |
391 | } | |
355 | – | |
392 | } | |
393 | + | |
394 | + | if (nConstrained){ |
395 | + | constrainA(); |
396 | + | } |
397 | } | |
398 | ||
399 | ||
400 | < | void Integrator::moveB( void ){ |
401 | < | int i,j,k; |
402 | < | int atomIndex; |
403 | < | DirectionalAtom* dAtom; |
404 | < | double Tb[3]; |
365 | < | double ji[3]; |
400 | > | template<typename T> void Integrator<T>::moveB(void){ |
401 | > | int i, j; |
402 | > | double Tb[3], ji[3]; |
403 | > | double vel[3], frc[3]; |
404 | > | double mass; |
405 | ||
406 | < | for( i=0; i<nAtoms; i++ ){ |
407 | < | atomIndex = i * 3; |
406 | > | for (i = 0; i < integrableObjects.size(); i++){ |
407 | > | integrableObjects[i]->getVel(vel); |
408 | > | integrableObjects[i]->getFrc(frc); |
409 | ||
410 | + | mass = integrableObjects[i]->getMass(); |
411 | + | |
412 | // velocity half step | |
413 | < | for( j=atomIndex; j<(atomIndex+3); j++ ) |
414 | < | vel[j] += ( dt2 * frc[j] / atoms[i]->getMass() ) * eConvert; |
413 | > | for (j = 0; j < 3; j++) |
414 | > | vel[j] += (dt2 * frc[j] / mass) * eConvert; |
415 | ||
416 | < | if( atoms[i]->isDirectional() ){ |
417 | < | |
418 | < | dAtom = (DirectionalAtom *)atoms[i]; |
419 | < | |
420 | < | // get and convert the torque to body frame |
421 | < | |
422 | < | Tb[0] = dAtom->getTx(); |
423 | < | Tb[1] = dAtom->getTy(); |
424 | < | Tb[2] = dAtom->getTz(); |
425 | < | |
426 | < | dAtom->lab2Body( Tb ); |
427 | < | |
428 | < | // get the angular momentum, and complete the angular momentum |
429 | < | // half step |
430 | < | |
431 | < | ji[0] = dAtom->getJx() + ( dt2 * Tb[0] ) * eConvert; |
432 | < | ji[1] = dAtom->getJy() + ( dt2 * Tb[1] ) * eConvert; |
433 | < | ji[2] = dAtom->getJz() + ( dt2 * Tb[2] ) * eConvert; |
392 | < | |
393 | < | dAtom->setJx( ji[0] ); |
394 | < | dAtom->setJy( ji[1] ); |
395 | < | dAtom->setJz( ji[2] ); |
416 | > | integrableObjects[i]->setVel(vel); |
417 | > | |
418 | > | if (integrableObjects[i]->isDirectional()){ |
419 | > | |
420 | > | // get and convert the torque to body frame |
421 | > | |
422 | > | integrableObjects[i]->getTrq(Tb); |
423 | > | integrableObjects[i]->lab2Body(Tb); |
424 | > | |
425 | > | // get the angular momentum, and propagate a half step |
426 | > | |
427 | > | integrableObjects[i]->getJ(ji); |
428 | > | |
429 | > | for (j = 0; j < 3; j++) |
430 | > | ji[j] += (dt2 * Tb[j]) * eConvert; |
431 | > | |
432 | > | |
433 | > | integrableObjects[i]->setJ(ji); |
434 | } | |
435 | } | |
436 | ||
437 | + | if (nConstrained){ |
438 | + | constrainB(); |
439 | + | } |
440 | } | |
441 | ||
442 | < | void Integrator::preMove( void ){ |
443 | < | int i; |
442 | > | template<typename T> void Integrator<T>::preMove(void){ |
443 | > | int i, j; |
444 | > | double pos[3]; |
445 | ||
446 | < | if( nConstrained ){ |
446 | > | if (nConstrained){ |
447 | > | for (i = 0; i < nAtoms; i++){ |
448 | > | atoms[i]->getPos(pos); |
449 | ||
450 | < | for(i=0; i<(nAtoms*3); i++) oldPos[i] = pos[i]; |
450 | > | for (j = 0; j < 3; j++){ |
451 | > | oldPos[3 * i + j] = pos[j]; |
452 | > | } |
453 | > | } |
454 | } | |
455 | < | } |
455 | > | } |
456 | ||
457 | < | void Integrator::constrainA(){ |
458 | < | |
412 | < | int i,j,k; |
457 | > | template<typename T> void Integrator<T>::constrainA(){ |
458 | > | int i, j; |
459 | int done; | |
460 | + | double posA[3], posB[3]; |
461 | + | double velA[3], velB[3]; |
462 | double pab[3]; | |
463 | double rab[3]; | |
464 | int a, b, ax, ay, az, bx, by, bz; | |
# | Line 422 | Line 470 | void Integrator::constrainA(){ | |
470 | double gab; | |
471 | int iteration; | |
472 | ||
473 | < | |
426 | < | |
427 | < | for( i=0; i<nAtoms; i++){ |
428 | < | |
473 | > | for (i = 0; i < nAtoms; i++){ |
474 | moving[i] = 0; | |
475 | < | moved[i] = 1; |
475 | > | moved[i] = 1; |
476 | } | |
477 | ||
478 | iteration = 0; | |
479 | done = 0; | |
480 | < | while( !done && (iteration < maxIteration )){ |
436 | < | |
480 | > | while (!done && (iteration < maxIteration)){ |
481 | done = 1; | |
482 | < | for(i=0; i<nConstrained; i++){ |
439 | < | |
482 | > | for (i = 0; i < nConstrained; i++){ |
483 | a = constrainedA[i]; | |
484 | b = constrainedB[i]; | |
442 | – | |
443 | – | ax = (a*3) + 0; |
444 | – | ay = (a*3) + 1; |
445 | – | az = (a*3) + 2; |
485 | ||
486 | < | bx = (b*3) + 0; |
487 | < | by = (b*3) + 1; |
488 | < | bz = (b*3) + 2; |
486 | > | ax = (a * 3) + 0; |
487 | > | ay = (a * 3) + 1; |
488 | > | az = (a * 3) + 2; |
489 | ||
490 | < | if( moved[a] || moved[b] ){ |
491 | < | |
492 | < | pab[0] = pos[ax] - pos[bx]; |
454 | < | pab[1] = pos[ay] - pos[by]; |
455 | < | pab[2] = pos[az] - pos[bz]; |
490 | > | bx = (b * 3) + 0; |
491 | > | by = (b * 3) + 1; |
492 | > | bz = (b * 3) + 2; |
493 | ||
494 | < | //periodic boundary condition |
494 | > | if (moved[a] || moved[b]){ |
495 | > | atoms[a]->getPos(posA); |
496 | > | atoms[b]->getPos(posB); |
497 | ||
498 | < | info->wrapVector( pab ); |
498 | > | for (j = 0; j < 3; j++) |
499 | > | pab[j] = posA[j] - posB[j]; |
500 | ||
501 | < | pabsq = pab[0] * pab[0] + pab[1] * pab[1] + pab[2] * pab[2]; |
501 | > | //periodic boundary condition |
502 | ||
503 | < | rabsq = constrainedDsqr[i]; |
464 | < | diffsq = rabsq - pabsq; |
503 | > | info->wrapVector(pab); |
504 | ||
505 | < | // the original rattle code from alan tidesley |
467 | < | if (fabs(diffsq) > (tol*rabsq*2)) { |
468 | < | rab[0] = oldPos[ax] - oldPos[bx]; |
469 | < | rab[1] = oldPos[ay] - oldPos[by]; |
470 | < | rab[2] = oldPos[az] - oldPos[bz]; |
505 | > | pabsq = pab[0] * pab[0] + pab[1] * pab[1] + pab[2] * pab[2]; |
506 | ||
507 | < | info->wrapVector( rab ); |
507 | > | rabsq = constrainedDsqr[i]; |
508 | > | diffsq = rabsq - pabsq; |
509 | ||
510 | < | rpab = rab[0] * pab[0] + rab[1] * pab[1] + rab[2] * pab[2]; |
510 | > | // the original rattle code from alan tidesley |
511 | > | if (fabs(diffsq) > (tol * rabsq * 2)){ |
512 | > | rab[0] = oldPos[ax] - oldPos[bx]; |
513 | > | rab[1] = oldPos[ay] - oldPos[by]; |
514 | > | rab[2] = oldPos[az] - oldPos[bz]; |
515 | ||
516 | < | rpabsq = rpab * rpab; |
516 | > | info->wrapVector(rab); |
517 | ||
518 | + | rpab = rab[0] * pab[0] + rab[1] * pab[1] + rab[2] * pab[2]; |
519 | ||
520 | < | if (rpabsq < (rabsq * -diffsq)){ |
520 | > | rpabsq = rpab * rpab; |
521 | ||
522 | + | |
523 | + | if (rpabsq < (rabsq * -diffsq)){ |
524 | #ifdef IS_MPI | |
525 | < | a = atoms[a]->getGlobalIndex(); |
526 | < | b = atoms[b]->getGlobalIndex(); |
525 | > | a = atoms[a]->getGlobalIndex(); |
526 | > | b = atoms[b]->getGlobalIndex(); |
527 | #endif //is_mpi | |
528 | < | sprintf( painCave.errMsg, |
529 | < | "Constraint failure in constrainA at atom %d and %d.\n", |
530 | < | a, b ); |
531 | < | painCave.isFatal = 1; |
532 | < | simError(); |
533 | < | } |
528 | > | sprintf(painCave.errMsg, |
529 | > | "Constraint failure in constrainA at atom %d and %d.\n", a, |
530 | > | b); |
531 | > | painCave.isFatal = 1; |
532 | > | simError(); |
533 | > | } |
534 | ||
535 | < | rma = 1.0 / atoms[a]->getMass(); |
536 | < | rmb = 1.0 / atoms[b]->getMass(); |
535 | > | rma = 1.0 / atoms[a]->getMass(); |
536 | > | rmb = 1.0 / atoms[b]->getMass(); |
537 | ||
538 | < | gab = diffsq / ( 2.0 * ( rma + rmb ) * rpab ); |
538 | > | gab = diffsq / (2.0 * (rma + rmb) * rpab); |
539 | ||
540 | dx = rab[0] * gab; | |
541 | dy = rab[1] * gab; | |
542 | dz = rab[2] * gab; | |
543 | ||
544 | < | pos[ax] += rma * dx; |
545 | < | pos[ay] += rma * dy; |
546 | < | pos[az] += rma * dz; |
544 | > | posA[0] += rma * dx; |
545 | > | posA[1] += rma * dy; |
546 | > | posA[2] += rma * dz; |
547 | ||
548 | < | pos[bx] -= rmb * dx; |
506 | < | pos[by] -= rmb * dy; |
507 | < | pos[bz] -= rmb * dz; |
548 | > | atoms[a]->setPos(posA); |
549 | ||
550 | + | posB[0] -= rmb * dx; |
551 | + | posB[1] -= rmb * dy; |
552 | + | posB[2] -= rmb * dz; |
553 | + | |
554 | + | atoms[b]->setPos(posB); |
555 | + | |
556 | dx = dx / dt; | |
557 | dy = dy / dt; | |
558 | dz = dz / dt; | |
559 | ||
560 | < | vel[ax] += rma * dx; |
514 | < | vel[ay] += rma * dy; |
515 | < | vel[az] += rma * dz; |
560 | > | atoms[a]->getVel(velA); |
561 | ||
562 | < | vel[bx] -= rmb * dx; |
563 | < | vel[by] -= rmb * dy; |
564 | < | vel[bz] -= rmb * dz; |
562 | > | velA[0] += rma * dx; |
563 | > | velA[1] += rma * dy; |
564 | > | velA[2] += rma * dz; |
565 | ||
566 | < | moving[a] = 1; |
567 | < | moving[b] = 1; |
568 | < | done = 0; |
569 | < | } |
566 | > | atoms[a]->setVel(velA); |
567 | > | |
568 | > | atoms[b]->getVel(velB); |
569 | > | |
570 | > | velB[0] -= rmb * dx; |
571 | > | velB[1] -= rmb * dy; |
572 | > | velB[2] -= rmb * dz; |
573 | > | |
574 | > | atoms[b]->setVel(velB); |
575 | > | |
576 | > | moving[a] = 1; |
577 | > | moving[b] = 1; |
578 | > | done = 0; |
579 | > | } |
580 | } | |
581 | } | |
582 | < | |
583 | < | for(i=0; i<nAtoms; i++){ |
529 | < | |
582 | > | |
583 | > | for (i = 0; i < nAtoms; i++){ |
584 | moved[i] = moving[i]; | |
585 | moving[i] = 0; | |
586 | } | |
# | Line 534 | Line 588 | void Integrator::constrainA(){ | |
588 | iteration++; | |
589 | } | |
590 | ||
591 | < | if( !done ){ |
592 | < | |
593 | < | sprintf( painCave.errMsg, |
594 | < | "Constraint failure in constrainA, too many iterations: %d\n", |
541 | < | iteration ); |
591 | > | if (!done){ |
592 | > | sprintf(painCave.errMsg, |
593 | > | "Constraint failure in constrainA, too many iterations: %d\n", |
594 | > | iteration); |
595 | painCave.isFatal = 1; | |
596 | simError(); | |
597 | } | |
598 | ||
599 | } | |
600 | ||
601 | < | void Integrator::constrainB( void ){ |
602 | < | |
550 | < | int i,j,k; |
601 | > | template<typename T> void Integrator<T>::constrainB(void){ |
602 | > | int i, j; |
603 | int done; | |
604 | + | double posA[3], posB[3]; |
605 | + | double velA[3], velB[3]; |
606 | double vxab, vyab, vzab; | |
607 | double rab[3]; | |
608 | int a, b, ax, ay, az, bx, by, bz; | |
609 | double rma, rmb; | |
610 | double dx, dy, dz; | |
611 | < | double rabsq, pabsq, rvab; |
558 | < | double diffsq; |
611 | > | double rvab; |
612 | double gab; | |
613 | int iteration; | |
614 | ||
615 | < | for(i=0; i<nAtoms; i++){ |
615 | > | for (i = 0; i < nAtoms; i++){ |
616 | moving[i] = 0; | |
617 | moved[i] = 1; | |
618 | } | |
619 | ||
620 | done = 0; | |
621 | iteration = 0; | |
622 | < | while( !done && (iteration < maxIteration ) ){ |
570 | < | |
622 | > | while (!done && (iteration < maxIteration)){ |
623 | done = 1; | |
624 | ||
625 | < | for(i=0; i<nConstrained; i++){ |
574 | < | |
625 | > | for (i = 0; i < nConstrained; i++){ |
626 | a = constrainedA[i]; | |
627 | b = constrainedB[i]; | |
628 | ||
629 | < | ax = (a*3) + 0; |
630 | < | ay = (a*3) + 1; |
631 | < | az = (a*3) + 2; |
629 | > | ax = (a * 3) + 0; |
630 | > | ay = (a * 3) + 1; |
631 | > | az = (a * 3) + 2; |
632 | ||
633 | < | bx = (b*3) + 0; |
634 | < | by = (b*3) + 1; |
635 | < | bz = (b*3) + 2; |
633 | > | bx = (b * 3) + 0; |
634 | > | by = (b * 3) + 1; |
635 | > | bz = (b * 3) + 2; |
636 | ||
637 | < | if( moved[a] || moved[b] ){ |
638 | < | |
639 | < | vxab = vel[ax] - vel[bx]; |
589 | < | vyab = vel[ay] - vel[by]; |
590 | < | vzab = vel[az] - vel[bz]; |
637 | > | if (moved[a] || moved[b]){ |
638 | > | atoms[a]->getVel(velA); |
639 | > | atoms[b]->getVel(velB); |
640 | ||
641 | < | rab[0] = pos[ax] - pos[bx]; |
642 | < | rab[1] = pos[ay] - pos[by]; |
643 | < | rab[2] = pos[az] - pos[bz]; |
595 | < | |
596 | < | info->wrapVector( rab ); |
597 | < | |
598 | < | rma = 1.0 / atoms[a]->getMass(); |
599 | < | rmb = 1.0 / atoms[b]->getMass(); |
641 | > | vxab = velA[0] - velB[0]; |
642 | > | vyab = velA[1] - velB[1]; |
643 | > | vzab = velA[2] - velB[2]; |
644 | ||
645 | < | rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab; |
646 | < | |
603 | < | gab = -rvab / ( ( rma + rmb ) * constrainedDsqr[i] ); |
645 | > | atoms[a]->getPos(posA); |
646 | > | atoms[b]->getPos(posB); |
647 | ||
648 | < | if (fabs(gab) > tol) { |
649 | < | |
607 | < | dx = rab[0] * gab; |
608 | < | dy = rab[1] * gab; |
609 | < | dz = rab[2] * gab; |
610 | < | |
611 | < | vel[ax] += rma * dx; |
612 | < | vel[ay] += rma * dy; |
613 | < | vel[az] += rma * dz; |
648 | > | for (j = 0; j < 3; j++) |
649 | > | rab[j] = posA[j] - posB[j]; |
650 | ||
651 | < | vel[bx] -= rmb * dx; |
652 | < | vel[by] -= rmb * dy; |
653 | < | vel[bz] -= rmb * dz; |
654 | < | |
655 | < | moving[a] = 1; |
656 | < | moving[b] = 1; |
657 | < | done = 0; |
658 | < | } |
651 | > | info->wrapVector(rab); |
652 | > | |
653 | > | rma = 1.0 / atoms[a]->getMass(); |
654 | > | rmb = 1.0 / atoms[b]->getMass(); |
655 | > | |
656 | > | rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab; |
657 | > | |
658 | > | gab = -rvab / ((rma + rmb) * constrainedDsqr[i]); |
659 | > | |
660 | > | if (fabs(gab) > tol){ |
661 | > | dx = rab[0] * gab; |
662 | > | dy = rab[1] * gab; |
663 | > | dz = rab[2] * gab; |
664 | > | |
665 | > | velA[0] += rma * dx; |
666 | > | velA[1] += rma * dy; |
667 | > | velA[2] += rma * dz; |
668 | > | |
669 | > | atoms[a]->setVel(velA); |
670 | > | |
671 | > | velB[0] -= rmb * dx; |
672 | > | velB[1] -= rmb * dy; |
673 | > | velB[2] -= rmb * dz; |
674 | > | |
675 | > | atoms[b]->setVel(velB); |
676 | > | |
677 | > | moving[a] = 1; |
678 | > | moving[b] = 1; |
679 | > | done = 0; |
680 | > | } |
681 | } | |
682 | } | |
683 | ||
684 | < | for(i=0; i<nAtoms; i++){ |
684 | > | for (i = 0; i < nAtoms; i++){ |
685 | moved[i] = moving[i]; | |
686 | moving[i] = 0; | |
687 | } | |
688 | < | |
688 | > | |
689 | iteration++; | |
690 | } | |
691 | ||
692 | < | if( !done ){ |
693 | < | |
694 | < | |
695 | < | sprintf( painCave.errMsg, |
638 | < | "Constraint failure in constrainB, too many iterations: %d\n", |
639 | < | iteration ); |
692 | > | if (!done){ |
693 | > | sprintf(painCave.errMsg, |
694 | > | "Constraint failure in constrainB, too many iterations: %d\n", |
695 | > | iteration); |
696 | painCave.isFatal = 1; | |
697 | simError(); | |
698 | < | } |
643 | < | |
698 | > | } |
699 | } | |
700 | ||
701 | + | template<typename T> void Integrator<T>::rotationPropagation |
702 | + | ( StuntDouble* sd, double ji[3] ){ |
703 | ||
704 | + | double angle; |
705 | + | double A[3][3], I[3][3]; |
706 | + | int i, j, k; |
707 | ||
708 | + | // use the angular velocities to propagate the rotation matrix a |
709 | + | // full time step |
710 | ||
711 | + | sd->getA(A); |
712 | + | sd->getI(I); |
713 | ||
714 | + | if (sd->isLinear()) { |
715 | + | i = sd->linearAxis(); |
716 | + | j = (i+1)%3; |
717 | + | k = (i+2)%3; |
718 | + | |
719 | + | angle = dt2 * ji[j] / I[j][j]; |
720 | + | this->rotate( k, i, angle, ji, A ); |
721 | ||
722 | + | angle = dt * ji[k] / I[k][k]; |
723 | + | this->rotate( i, j, angle, ji, A); |
724 | ||
725 | < | void Integrator::rotate( int axes1, int axes2, double angle, double ji[3], |
726 | < | double A[9] ){ |
725 | > | angle = dt2 * ji[j] / I[j][j]; |
726 | > | this->rotate( k, i, angle, ji, A ); |
727 | ||
728 | < | int i,j,k; |
728 | > | } else { |
729 | > | // rotate about the x-axis |
730 | > | angle = dt2 * ji[0] / I[0][0]; |
731 | > | this->rotate( 1, 2, angle, ji, A ); |
732 | > | |
733 | > | // rotate about the y-axis |
734 | > | angle = dt2 * ji[1] / I[1][1]; |
735 | > | this->rotate( 2, 0, angle, ji, A ); |
736 | > | |
737 | > | // rotate about the z-axis |
738 | > | angle = dt * ji[2] / I[2][2]; |
739 | > | sd->addZangle(angle); |
740 | > | this->rotate( 0, 1, angle, ji, A); |
741 | > | |
742 | > | // rotate about the y-axis |
743 | > | angle = dt2 * ji[1] / I[1][1]; |
744 | > | this->rotate( 2, 0, angle, ji, A ); |
745 | > | |
746 | > | // rotate about the x-axis |
747 | > | angle = dt2 * ji[0] / I[0][0]; |
748 | > | this->rotate( 1, 2, angle, ji, A ); |
749 | > | |
750 | > | } |
751 | > | sd->setA( A ); |
752 | > | } |
753 | > | |
754 | > | template<typename T> void Integrator<T>::rotate(int axes1, int axes2, |
755 | > | double angle, double ji[3], |
756 | > | double A[3][3]){ |
757 | > | int i, j, k; |
758 | double sinAngle; | |
759 | double cosAngle; | |
760 | double angleSqr; | |
# | Line 664 | Line 766 | void Integrator::rotate( int axes1, int axes2, double | |
766 | ||
767 | // initialize the tempA | |
768 | ||
769 | < | for(i=0; i<3; i++){ |
770 | < | for(j=0; j<3; j++){ |
771 | < | tempA[j][i] = A[3*i + j]; |
769 | > | for (i = 0; i < 3; i++){ |
770 | > | for (j = 0; j < 3; j++){ |
771 | > | tempA[j][i] = A[i][j]; |
772 | } | |
773 | } | |
774 | ||
775 | // initialize the tempJ | |
776 | ||
777 | < | for( i=0; i<3; i++) tempJ[i] = ji[i]; |
778 | < | |
777 | > | for (i = 0; i < 3; i++) |
778 | > | tempJ[i] = ji[i]; |
779 | > | |
780 | // initalize rot as a unit matrix | |
781 | ||
782 | rot[0][0] = 1.0; | |
# | Line 683 | Line 786 | void Integrator::rotate( int axes1, int axes2, double | |
786 | rot[1][0] = 0.0; | |
787 | rot[1][1] = 1.0; | |
788 | rot[1][2] = 0.0; | |
789 | < | |
789 | > | |
790 | rot[2][0] = 0.0; | |
791 | rot[2][1] = 0.0; | |
792 | rot[2][2] = 1.0; | |
793 | < | |
793 | > | |
794 | // use a small angle aproximation for sin and cosine | |
795 | ||
796 | < | angleSqr = angle * angle; |
796 | > | angleSqr = angle * angle; |
797 | angleSqrOver4 = angleSqr / 4.0; | |
798 | top = 1.0 - angleSqrOver4; | |
799 | bottom = 1.0 + angleSqrOver4; | |
# | Line 703 | Line 806 | void Integrator::rotate( int axes1, int axes2, double | |
806 | ||
807 | rot[axes1][axes2] = sinAngle; | |
808 | rot[axes2][axes1] = -sinAngle; | |
809 | < | |
809 | > | |
810 | // rotate the momentum acoording to: ji[] = rot[][] * ji[] | |
811 | < | |
812 | < | for(i=0; i<3; i++){ |
811 | > | |
812 | > | for (i = 0; i < 3; i++){ |
813 | ji[i] = 0.0; | |
814 | < | for(k=0; k<3; k++){ |
814 | > | for (k = 0; k < 3; k++){ |
815 | ji[i] += rot[i][k] * tempJ[k]; | |
816 | } | |
817 | } | |
818 | ||
819 | < | // rotate the Rotation matrix acording to: |
819 | > | // rotate the Rotation matrix acording to: |
820 | // A[][] = A[][] * transpose(rot[][]) | |
821 | ||
822 | ||
# | Line 721 | Line 824 | void Integrator::rotate( int axes1, int axes2, double | |
824 | // calculation as: | |
825 | // transpose(A[][]) = transpose(A[][]) * transpose(rot[][]) | |
826 | ||
827 | < | for(i=0; i<3; i++){ |
828 | < | for(j=0; j<3; j++){ |
829 | < | A[3*j + i] = 0.0; |
830 | < | for(k=0; k<3; k++){ |
831 | < | A[3*j + i] += tempA[i][k] * rot[j][k]; |
827 | > | for (i = 0; i < 3; i++){ |
828 | > | for (j = 0; j < 3; j++){ |
829 | > | A[j][i] = 0.0; |
830 | > | for (k = 0; k < 3; k++){ |
831 | > | A[j][i] += tempA[i][k] * rot[j][k]; |
832 | } | |
833 | } | |
834 | } | |
835 | } | |
836 | + | |
837 | + | template<typename T> void Integrator<T>::calcForce(int calcPot, int calcStress){ |
838 | + | myFF->doForces(calcPot, calcStress); |
839 | + | } |
840 | + | |
841 | + | template<typename T> void Integrator<T>::thermalize(){ |
842 | + | tStats->velocitize(); |
843 | + | } |
844 | + | |
845 | + | template<typename T> double Integrator<T>::getConservedQuantity(void){ |
846 | + | return tStats->getTotalE(); |
847 | + | } |
848 | + | template<typename T> string Integrator<T>::getAdditionalParameters(void){ |
849 | + | //By default, return a null string |
850 | + | //The reason we use string instead of char* is that if we use char*, we will |
851 | + | //return a pointer point to local variable which might cause problem |
852 | + | return string(); |
853 | + | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |