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