ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Integrator.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Integrator.cpp (file contents):
Revision 558 by mmeineke, Thu Jun 19 19:21:23 2003 UTC vs.
Revision 597 by mmeineke, Mon Jul 14 21:28:54 2003 UTC

# Line 1 | Line 1
1   #include <iostream>
2   #include <cstdlib>
3 + #include <cmath>
4  
5   #ifdef IS_MPI
6   #include "mpiSimulation.hpp"
# Line 10 | Line 11 | Integrator::Integrator( SimInfo* theInfo, ForceFields*
11   #include "simError.h"
12  
13  
14 < Integrator::Integrator( SimInfo* theInfo, ForceFields* the_ff ){
14 > Integrator::Integrator( SimInfo *theInfo, ForceFields* the_ff ){
15    
16    info = theInfo;
17    myFF = the_ff;
# Line 26 | Line 27 | Integrator::Integrator( SimInfo* theInfo, ForceFields*
27  
28    nAtoms = info->n_atoms;
29  
30 +  std::cerr << "integ nAtoms = "  << nAtoms << "\n";
31 +
32    // check for constraints
33    
34    constrainedA    = NULL;
# Line 33 | Line 36 | Integrator::Integrator( SimInfo* theInfo, ForceFields*
36    constrainedDsqr = NULL;
37    moving          = NULL;
38    moved           = NULL;
39 <  prePos          = NULL;
39 >  oldPos          = NULL;
40    
41    nConstrained = 0;
42  
# Line 48 | Line 51 | Integrator::~Integrator() {
51      delete[] constrainedDsqr;
52      delete[] moving;
53      delete[] moved;
54 <    delete[] prePos;
52 < k
54 >    delete[] oldPos;
55    }
56    
57   }
# Line 72 | Line 74 | void Integrator::checkConstraints( void ){
74      for(int j=0; j<molecules[i].getNBonds(); j++){
75        
76        constrained = theArray[j]->is_constrained();
77 +
78 +      std::cerr << "Is the folowing bond constrained \n";
79 +      theArray[j]->printMe();
80        
81        if(constrained){
82          
83 +        std::cerr << "Yes\n";
84 +
85          dummy_plug = theArray[j]->get_constraint();
86          temp_con[nConstrained].set_a( dummy_plug->get_a() );
87          temp_con[nConstrained].set_b( dummy_plug->get_b() );
# Line 82 | Line 89 | void Integrator::checkConstraints( void ){
89          
90          nConstrained++;
91          constrained = 0;
92 <      }
92 >      }
93 >      else std::cerr << "No.\n";
94      }
95  
96      theArray = (SRI**) molecules[i].getMyBends();
# Line 137 | Line 145 | void Integrator::checkConstraints( void ){
145        constrainedA[i] = temp_con[i].get_a();
146        constrainedB[i] = temp_con[i].get_b();
147        constrainedDsqr[i] = temp_con[i].get_dsqr();
148 +
149      }
150  
151      
# Line 147 | Line 156 | void Integrator::checkConstraints( void ){
156      moving = new int[nAtoms];
157      moved  = new int[nAtoms];
158  
159 <    prePos = new double[nAtoms*3];
159 >    oldPos = new double[nAtoms*3];
160    }
161    
162    delete[] temp_con;
# Line 157 | Line 166 | void Integrator::integrate( void ){
166   void Integrator::integrate( void ){
167  
168    int i, j;                         // loop counters
160  double kE = 0.0;                  // the kinetic energy  
161  double rot_kE;
162  double trans_kE;
163  int tl;                        // the time loop conter
164  double dt2;                       // half the dt
169  
166  double vx, vy, vz;    // the velocities
167  double vx2, vy2, vz2; // the square of the velocities
168  double rx, ry, rz;    // the postitions
169  
170  double ji[3];   // the body frame angular momentum
171  double jx2, jy2, jz2; // the square of the angular momentums
172  double Tb[3];   // torque in the body frame
173  double angle;   // the angle through which to rotate the rotation matrix
174  double A[3][3]; // the rotation matrix
175  double press[9];
176
177  double dt          = info->dt;
170    double runTime     = info->run_time;
171    double sampleTime  = info->sampleTime;
172    double statusTime  = info->statusTime;
# Line 188 | Line 180 | void Integrator::integrate( void ){
180    int calcPot, calcStress;
181    int isError;
182  
183 +
184 +
185    tStats   = new Thermo( info );
186 <  e_out    = new StatWriter( info );
187 <  dump_out = new DumpWriter( info );
186 >  statOut  = new StatWriter( info );
187 >  dumpOut  = new DumpWriter( info );
188  
189 <  Atom** atoms = info->atoms;
189 >  atoms = info->atoms;
190    DirectionalAtom* dAtom;
191 +
192 +  dt = info->dt;
193    dt2 = 0.5 * dt;
194  
195    // initialize the forces before the first step
# Line 205 | Line 201 | void Integrator::integrate( void ){
201      tStats->velocitize();
202    }
203    
204 <  dump_out->writeDump( 0.0 );
205 <  e_out->writeStat( 0.0 );
204 >  dumpOut->writeDump( 0.0 );
205 >  statOut->writeStat( 0.0 );
206    
207    calcPot     = 0;
208    calcStress  = 0;
# Line 215 | Line 211 | void Integrator::integrate( void ){
211    currStatus  = statusTime;
212    currTime    = 0.0;;
213  
214 +
215 +  readyCheck();
216 +
217 + #ifdef IS_MPI
218 +  strcpy( checkPointMsg,
219 +          "The integrator is ready to go." );
220 +  MPIcheckPoint();
221 + #endif // is_mpi
222 +
223 +
224 +  pos  = Atom::getPosArray();
225 +  vel  = Atom::getVelArray();
226 +  frc  = Atom::getFrcArray();
227 +
228    while( currTime < runTime ){
229  
230      if( (currTime+dt) >= currStatus ){
231        calcPot = 1;
232        calcStress = 1;
233      }
234 <    
234 >
235 >    std::cerr << currTime << "\n";
236 >
237      integrateStep( calcPot, calcStress );
238        
239      currTime += dt;
# Line 234 | Line 246 | void Integrator::integrate( void ){
246      }
247  
248      if( currTime >= currSample ){
249 <      dump_out->writeDump( currTime );
249 >      dumpOut->writeDump( currTime );
250        currSample += sampleTime;
251      }
252  
253      if( currTime >= currStatus ){
254 <      e_out->writeStat( time * dt );
254 >      statOut->writeStat( currTime );
255        calcPot = 0;
256        calcStress = 0;
257        currStatus += statusTime;
258      }
259 +
260 + #ifdef IS_MPI
261 +    strcpy( checkPointMsg,
262 +            "successfully took a time step." );
263 +    MPIcheckPoint();
264 + #endif // is_mpi
265 +
266    }
267  
268 <  dump_out->writeFinal();
268 >  dumpOut->writeFinal(currTime);
269  
270 <  delete dump_out;
271 <  delete e_out;
270 >  delete dumpOut;
271 >  delete statOut;
272   }
273  
274   void Integrator::integrateStep( int calcPot, int calcStress ){
275  
276 +
277 +      
278    // Position full step, and velocity half step
279  
280 <  //preMove();
280 >  preMove();
281    moveA();
282 <  if( nConstrained ) constrainA();
282 >  //if( nConstrained ) constrainA();
283  
284    // calc forces
285  
# Line 279 | Line 300 | void Integrator::moveA( void ){
300    DirectionalAtom* dAtom;
301    double Tb[3];
302    double ji[3];
303 +  double angle;
304 +  double A[3][3], At[3][3];
305  
306 +
307    for( i=0; i<nAtoms; i++ ){
308      atomIndex = i * 3;
309      aMatIndex = i * 9;
310 <    
310 >
311      // velocity half step
312      for( j=atomIndex; j<(atomIndex+3); j++ )
313        vel[j] += ( dt2 * frc[j] / atoms[i]->getMass() ) * eConvert;
314  
315 +
316      // position whole step    
317 <    for( j=atomIndex; j<(atomIndex+3); j++ )
318 <      pos[j] += dt * vel[j];
317 >    for( j=atomIndex; j<(atomIndex+3); j++ ) pos[j] += dt * vel[j];
318 >    
319  
295  
320      if( atoms[i]->isDirectional() ){
321  
322        dAtom = (DirectionalAtom *)atoms[i];
# Line 302 | Line 326 | void Integrator::moveA( void ){
326        Tb[0] = dAtom->getTx();
327        Tb[1] = dAtom->getTy();
328        Tb[2] = dAtom->getTz();
329 <      
329 >
330        dAtom->lab2Body( Tb );
331 <      
331 >
332        // get the angular momentum, and propagate a half step
333        
334        ji[0] = dAtom->getJx() + ( dt2 * Tb[0] ) * eConvert;
# Line 316 | Line 340 | void Integrator::moveA( void ){
340        
341        // rotate about the x-axis      
342        angle = dt2 * ji[0] / dAtom->getIxx();
343 <      this->rotate( 1, 2, angle, ji, &aMat[aMatIndex] );
344 <      
343 >      this->rotate( 1, 2, angle, ji, &Amat[aMatIndex] );
344 >
345        // rotate about the y-axis
346        angle = dt2 * ji[1] / dAtom->getIyy();
347 <      this->rotate( 2, 0, angle, ji, &aMat[aMatIndex] );
347 >      this->rotate( 2, 0, angle, ji, &Amat[aMatIndex] );
348        
349        // rotate about the z-axis
350        angle = dt * ji[2] / dAtom->getIzz();
351 <      this->rotate( 0, 1, angle, ji, &aMat[aMatIndex] );
351 >      this->rotate( 0, 1, angle, ji, &Amat[aMatIndex] );
352        
353        // rotate about the y-axis
354        angle = dt2 * ji[1] / dAtom->getIyy();
355 <      this->rotate( 2, 0, angle, ji, &aMat[aMatIndex] );
355 >      this->rotate( 2, 0, angle, ji, &Amat[aMatIndex] );
356        
357         // rotate about the x-axis
358        angle = dt2 * ji[0] / dAtom->getIxx();
359 <      this->rotate( 1, 2, angle, ji, &aMat[aMatIndex] );
359 >      this->rotate( 1, 2, angle, ji, &Amat[aMatIndex] );
360        
361        dAtom->setJx( ji[0] );
362        dAtom->setJy( ji[1] );
363        dAtom->setJz( ji[2] );
364 +
365 +      std::cerr << "Amat[" << i << "]\n";
366 +      info->printMat9( &Amat[aMatIndex] );
367 +          
368 +      std::cerr << "ji[" << i << "]\t"
369 +                << ji[0] << "\t"
370 +                << ji[1] << "\t"
371 +                << ji[2] << "\n";
372 +          
373      }
374      
375    }
# Line 345 | Line 378 | void Integrator::moveB( void ){
378  
379   void Integrator::moveB( void ){
380    int i,j,k;
381 <  int atomIndex;
381 >  int atomIndex, aMatIndex;
382    DirectionalAtom* dAtom;
383    double Tb[3];
384    double ji[3];
385  
386    for( i=0; i<nAtoms; i++ ){
387      atomIndex = i * 3;
388 +    aMatIndex = i * 9;
389  
390      // velocity half step
391      for( j=atomIndex; j<(atomIndex+3); j++ )
392        vel[j] += ( dt2 * frc[j] / atoms[i]->getMass() ) * eConvert;
393  
394 +
395      if( atoms[i]->isDirectional() ){
396        
397        dAtom = (DirectionalAtom *)atoms[i];
# Line 367 | Line 402 | void Integrator::moveB( void ){
402        Tb[1] = dAtom->getTy();
403        Tb[2] = dAtom->getTz();
404        
405 +      std::cerr << "TrqB[" << i << "]\t"
406 +                << Tb[0] << "\t"
407 +                << Tb[1] << "\t"
408 +                << Tb[2] << "\n";
409 +
410        dAtom->lab2Body( Tb );
411        
412        // get the angular momentum, and complete the angular momentum
# Line 376 | Line 416 | void Integrator::moveB( void ){
416        ji[1] = dAtom->getJy() + ( dt2 * Tb[1] ) * eConvert;
417        ji[2] = dAtom->getJz() + ( dt2 * Tb[2] ) * eConvert;
418        
379      jx2 = ji[0] * ji[0];
380      jy2 = ji[1] * ji[1];
381      jz2 = ji[2] * ji[2];
382      
419        dAtom->setJx( ji[0] );
420        dAtom->setJy( ji[1] );
421        dAtom->setJz( ji[2] );
422 +
423 +
424 +      std::cerr << "Amat[" << i << "]\n";
425 +      info->printMat9( &Amat[aMatIndex] );
426 +          
427 +      std::cerr << "ji[" << i << "]\t"
428 +                << ji[0] << "\t"
429 +                << ji[1] << "\t"
430 +                << ji[2] << "\n";
431      }
432    }
433  
# Line 392 | Line 437 | void Integrator::preMove( void ){
437    int i;
438  
439    if( nConstrained ){
440 <    if( oldAtoms != nAtoms ){
396 <      
397 <      // save oldAtoms to check for lode balanceing later on.
398 <      
399 <      oldAtoms = nAtoms;
400 <      
401 <      delete[] moving;
402 <      delete[] moved;
403 <      delete[] oldPos;
404 <      
405 <      moving = new int[nAtoms];
406 <      moved  = new int[nAtoms];
407 <      
408 <      oldPos = new double[nAtoms*3];
409 <    }
410 <  
440 >
441      for(i=0; i<(nAtoms*3); i++) oldPos[i] = pos[i];
442    }
443   }  
# Line 416 | Line 446 | void Integrator::constrainA(){
446  
447    int i,j,k;
448    int done;
449 <  double pxab, pyab, pzab;
450 <  double rxab, ryab, rzab;
451 <  int a, b;
449 >  double pab[3];
450 >  double rab[3];
451 >  int a, b, ax, ay, az, bx, by, bz;
452    double rma, rmb;
453    double dx, dy, dz;
454 +  double rpab;
455    double rabsq, pabsq, rpabsq;
456    double diffsq;
457    double gab;
458    int iteration;
459  
429
430  
460    for( i=0; i<nAtoms; i++){
461      
462      moving[i] = 0;
463      moved[i]  = 1;
464    }
465 <  
437 <  
465 >
466    iteration = 0;
467    done = 0;
468    while( !done && (iteration < maxIteration )){
# Line 444 | Line 472 | void Integrator::constrainA(){
472  
473        a = constrainedA[i];
474        b = constrainedB[i];
475 <    
475 >      
476 >      ax = (a*3) + 0;
477 >      ay = (a*3) + 1;
478 >      az = (a*3) + 2;
479 >
480 >      bx = (b*3) + 0;
481 >      by = (b*3) + 1;
482 >      bz = (b*3) + 2;
483 >
484        if( moved[a] || moved[b] ){
485          
486 <        pxab = pos[3*a+0] - pos[3*b+0];
487 <        pyab = pos[3*a+1] - pos[3*b+1];
488 <        pzab = pos[3*a+2] - pos[3*b+2];
486 >        pab[0] = pos[ax] - pos[bx];
487 >        pab[1] = pos[ay] - pos[by];
488 >        pab[2] = pos[az] - pos[bz];
489  
490 <        //periodic boundary condition
455 <        pxab = pxab - info->box_x * copysign(1, pxab)
456 <          * int(pxab / info->box_x + 0.5);
457 <        pyab = pyab - info->box_y * copysign(1, pyab)
458 <          * int(pyab / info->box_y + 0.5);
459 <        pzab = pzab - info->box_z * copysign(1, pzab)
460 <          * int(pzab / info->box_z + 0.5);
461 <      
462 <        pabsq = pxab * pxab + pyab * pyab + pzab * pzab;
463 <        rabsq = constraintedDsqr[i];
464 <        diffsq = pabsq - rabsq;
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 <          rxab = oldPos[3*a+0] - oldPos[3*b+0];
502 <          ryab = oldPos[3*a+1] - oldPos[3*b+1];
503 <          rzab = oldPos[3*a+2] - oldPos[3*b+2];
471 <
472 <          rxab = rxab - info->box_x * copysign(1, rxab)
473 <            * int(rxab / info->box_x + 0.5);
474 <          ryab = ryab - info->box_y * copysign(1, ryab)
475 <            * int(ryab / info->box_y + 0.5);
476 <          rzab = rzab - info->box_z * copysign(1, rzab)
477 <            * int(rzab / info->box_z + 0.5);
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 <          rpab = rxab * pxab + ryab * pyab + rzab * pzab;
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 +
514   #ifdef IS_MPI
515              a = atoms[a]->getGlobalIndex();
516              b = atoms[b]->getGlobalIndex();
517   #endif //is_mpi
518              sprintf( painCave.errMsg,
519 <                     "Constraint failure in constrainA at atom %d and %d\n.",
519 >                     "Constraint failure in constrainA at atom %d and %d.\n",
520                       a, b );
521              painCave.isFatal = 1;
522              simError();
# Line 494 | Line 524 | void Integrator::constrainA(){
524  
525            rma = 1.0 / atoms[a]->getMass();
526            rmb = 1.0 / atoms[b]->getMass();
527 <          
527 >
528            gab = diffsq / ( 2.0 * ( rma + rmb ) * rpab );
499          dx = rxab * gab;
500          dy = ryab * gab;
501          dz = rzab * gab;
529  
530 <          pos[3*a+0] += rma * dx;
531 <          pos[3*a+1] += rma * dy;
532 <          pos[3*a+2] += rma * dz;
530 >          dx = rab[0] * gab;
531 >          dy = rab[1] * gab;
532 >          dz = rab[2] * gab;
533  
534 <          pos[3*b+0] -= rmb * dx;
535 <          pos[3*b+1] -= rmb * dy;
536 <          pos[3*b+2] -= rmb * dz;
534 >          pos[ax] += rma * dx;
535 >          pos[ay] += rma * dy;
536 >          pos[az] += rma * dz;
537  
538 +          pos[bx] -= rmb * dx;
539 +          pos[by] -= rmb * dy;
540 +          pos[bz] -= rmb * dz;
541 +
542            dx = dx / dt;
543            dy = dy / dt;
544            dz = dz / dt;
545  
546 <          vel[3*a+0] += rma * dx;
547 <          vel[3*a+1] += rma * dy;
548 <          vel[3*a+2] += rma * dz;
546 >          vel[ax] += rma * dx;
547 >          vel[ay] += rma * dy;
548 >          vel[az] += rma * dz;
549  
550 <          vel[3*b+0] -= rmb * dx;
551 <          vel[3*b+1] -= rmb * dy;
552 <          vel[3*b+2] -= rmb * dz;
550 >          vel[bx] -= rmb * dx;
551 >          vel[by] -= rmb * dy;
552 >          vel[bz] -= rmb * dz;
553  
554            moving[a] = 1;
555            moving[b] = 1;
# Line 538 | Line 569 | void Integrator::constrainA(){
569  
570    if( !done ){
571  
572 <    sprintf( painCae.errMsg,
572 >    sprintf( painCave.errMsg,
573               "Constraint failure in constrainA, too many iterations: %d\n",
574 <             iterations );
574 >             iteration );
575      painCave.isFatal = 1;
576      simError();
577    }
# Line 552 | Line 583 | void Integrator::constrainB( void ){
583    int i,j,k;
584    int done;
585    double vxab, vyab, vzab;
586 <  double rxab, ryab, rzab;
587 <  int a, b;
586 >  double rab[3];
587 >  int a, b, ax, ay, az, bx, by, bz;
588    double rma, rmb;
589    double dx, dy, dz;
590    double rabsq, pabsq, rvab;
# Line 561 | Line 592 | void Integrator::constrainB( void ){
592    double gab;
593    int iteration;
594  
595 <  for(i=0; i<nAtom; i++){
595 >  for(i=0; i<nAtoms; i++){
596      moving[i] = 0;
597      moved[i] = 1;
598    }
599  
600    done = 0;
601 +  iteration = 0;
602    while( !done && (iteration < maxIteration ) ){
603  
604 +    done = 1;
605 +
606      for(i=0; i<nConstrained; i++){
607        
608        a = constrainedA[i];
609        b = constrainedB[i];
610  
611 +      ax = (a*3) + 0;
612 +      ay = (a*3) + 1;
613 +      az = (a*3) + 2;
614 +
615 +      bx = (b*3) + 0;
616 +      by = (b*3) + 1;
617 +      bz = (b*3) + 2;
618 +
619        if( moved[a] || moved[b] ){
620          
621 <        vxab = vel[3*a+0] - vel[3*b+0];
622 <        vyab = vel[3*a+1] - vel[3*b+1];
623 <        vzab = vel[3*a+2] - vel[3*b+2];
621 >        vxab = vel[ax] - vel[bx];
622 >        vyab = vel[ay] - vel[by];
623 >        vzab = vel[az] - vel[bz];
624  
625 <        rxab = pos[3*a+0] - pos[3*b+0];q
626 <        ryab = pos[3*a+1] - pos[3*b+1];
627 <        rzab = pos[3*a+2] - pos[3*b+2];
625 >        rab[0] = pos[ax] - pos[bx];
626 >        rab[1] = pos[ay] - pos[by];
627 >        rab[2] = pos[az] - pos[bz];
628          
629 <        rxab = rxab - info->box_x * copysign(1, rxab)
630 <          * int(rxab / info->box_x + 0.5);
589 <        ryab = ryab - info->box_y * copysign(1, ryab)
590 <          * int(ryab / info->box_y + 0.5);
591 <        rzab = rzab - info->box_z * copysign(1, rzab)
592 <          * int(rzab / info->box_z + 0.5);
593 <
629 >        info->wrapVector( rab );
630 >        
631          rma = 1.0 / atoms[a]->getMass();
632          rmb = 1.0 / atoms[b]->getMass();
633  
634 <        rvab = rxab * vxab + ryab * vyab + rzab * vzab;
634 >        rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab;
635            
636 <        gab = -rvab / ( ( rma + rmb ) * constraintsDsqr[i] );
636 >        gab = -rvab / ( ( rma + rmb ) * constrainedDsqr[i] );
637  
638          if (fabs(gab) > tol) {
639            
640 <          dx = rxab * gab;
641 <          dy = ryab * gab;
642 <          dz = rzab * gab;
640 >          dx = rab[0] * gab;
641 >          dy = rab[1] * gab;
642 >          dz = rab[2] * gab;
643            
644 <          vel[3*a+0] += rma * dx;
645 <          vel[3*a+1] += rma * dy;
646 <          vel[3*a+2] += rma * dz;
644 >          vel[ax] += rma * dx;
645 >          vel[ay] += rma * dy;
646 >          vel[az] += rma * dz;
647  
648 <          vel[3*b+0] -= rmb * dx;
649 <          vel[3*b+1] -= rmb * dy;
650 <          vel[3*b+2] -= rmb * dz;
648 >          vel[bx] -= rmb * dx;
649 >          vel[by] -= rmb * dy;
650 >          vel[bz] -= rmb * dz;
651            
652            moving[a] = 1;
653            moving[b] = 1;
# Line 630 | Line 667 | void Integrator::constrainB( void ){
667    if( !done ){
668  
669    
670 <    sprintf( painCae.errMsg,
670 >    sprintf( painCave.errMsg,
671               "Constraint failure in constrainB, too many iterations: %d\n",
672 <             iterations );
672 >             iteration );
673      painCave.isFatal = 1;
674      simError();
675    }
# Line 646 | Line 683 | void Integrator::rotate( int axes1, int axes2, double
683  
684  
685   void Integrator::rotate( int axes1, int axes2, double angle, double ji[3],
686 <                         double A[3][3] ){
686 >                         double A[9] ){
687  
688    int i,j,k;
689    double sinAngle;
# Line 658 | Line 695 | void Integrator::rotate( int axes1, int axes2, double
695    double tempA[3][3];
696    double tempJ[3];
697  
698 +
699    // initialize the tempA
700  
701    for(i=0; i<3; i++){
702      for(j=0; j<3; j++){
703 <      tempA[j][i] = A[i][j];
703 >      tempA[j][i] = A[3*i+j];
704      }
705    }
706  
# Line 713 | Line 751 | void Integrator::rotate( int axes1, int axes2, double
751    //            A[][] = A[][] * transpose(rot[][])
752  
753  
754 <  // NOte for as yet unknown reason, we are setting the performing the
754 >  // NOte for as yet unknown reason, we are performing the
755    // calculation as:
756    //                transpose(A[][]) = transpose(A[][]) * transpose(rot[][])
757  
758    for(i=0; i<3; i++){
759      for(j=0; j<3; j++){
760 <      A[j][i] = 0.0;
760 >      A[3*j+i] = 0.0;
761        for(k=0; k<3; k++){
762 <        A[j][i] += tempA[i][k] * rot[j][k];
762 >        A[3*j+i] += tempA[i][k] * rot[j][k];
763        }
764      }
765    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines