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