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

Comparing trunk/OOPSE/libmdtools/Symplectic.cpp (file contents):
Revision 469 by mmeineke, Mon Apr 7 20:06:31 2003 UTC vs.
Revision 497 by chuckv, Mon Apr 14 21:16:37 2003 UTC

# Line 38 | Line 38 | Symplectic::Symplectic( SimInfo* the_entry_plug, Force
38    myES = the_es;
39    isFirst = 1;
40  
41  std::cerr<< "calling symplectic constructor\n";
42
41    molecules = entry_plug->molecules;
42    nMols = entry_plug->n_mol;
43  
# Line 164 | Line 162 | void Symplectic::integrate( void ){
162    double dt2;                       // half the dt
163  
164    double vx, vy, vz;    // the velocities
165 < //  double vx2, vy2, vz2; // the square of the velocities
165 >  double vx2, vy2, vz2; // the square of the velocities
166    double rx, ry, rz;    // the postitions
167    
168    double ji[3];   // the body frame angular momentum
# Line 172 | Line 170 | void Symplectic::integrate( void ){
170    double Tb[3];   // torque in the body frame
171    double angle;   // the angle through which to rotate the rotation matrix
172    double A[3][3]; // the rotation matrix
173 +  double press[9];
174  
175    int time;
176  
# Line 192 | Line 191 | void Symplectic::integrate( void ){
191    StatWriter*  e_out;
192    DumpWriter*  dump_out;
193  
195  std::cerr << "about to call new thermo\n";
196
194    tStats   = new Thermo( entry_plug );
195    e_out    = new StatWriter( entry_plug );
199
200  std::cerr << "calling dumpWriter \n";
196    dump_out = new DumpWriter( entry_plug );
202  std::cerr << "called dumpWriter \n";
197  
198    Atom** atoms = entry_plug->atoms;
199    DirectionalAtom* dAtom;
# Line 219 | Line 213 | void Symplectic::integrate( void ){
213    
214    calcPot = 0;
215  
216 +  if (!strcasecmp( entry_plug->ensemble, "NPT")) {
217 +    calcStress = 1;
218 +  } else {
219 +    calcStress = 0;
220 +  }
221 +
222    if( n_constrained ){
223  
224      double *Rx = new double[nAtoms];
# Line 235 | Line 235 | void Symplectic::integrate( void ){
235      
236  
237      for( tl=0; tl < n_loops; tl++ ){
238 +
239        
240        for( j=0; j<nAtoms; j++ ){
241  
# Line 333 | Line 334 | void Symplectic::integrate( void ){
334          }
335        }
336        
337 +      if (!strcasecmp( entry_plug->ensemble, "NVT"))
338 +        myES->NoseHooverNVT( dt / 2.0 , tStats->getKinetic() );
339 +
340        // calculate the forces
341        
342        myFF->doForces(calcPot, calcStress);
# Line 400 | Line 404 | void Symplectic::integrate( void ){
404          }
405        }
406      
407 +
408 +      if (!strcasecmp( entry_plug->ensemble, "NVT"))
409 +        myES->NoseHooverNVT( dt / 2.0, tStats->getKinetic() );
410 +
411 +      if (!strcasecmp( entry_plug->ensemble, "NPT") ) {
412 +        tStats->getPressureTensor(press);
413 +        myES->NoseHooverAndersonNPT( dt,
414 +                                     tStats->getKinetic(),
415 +                                     press);
416 +      }
417 +
418        time = tl + 1;
419        
420        if( entry_plug->setTemp ){
# Line 408 | Line 423 | void Symplectic::integrate( void ){
423        if( !(time % sample_n) ) dump_out->writeDump( time * dt );
424        if( !((time+1) % status_n) ) {
425          calcPot = 1;
426 <        calcStress = 1;
426 >        calcStress = 1;
427        }
428        if( !(time % status_n) ){
429          e_out->writeStat( time * dt );
430          calcPot = 0;
431 <        calcStress = 0;
431 >        if (!strcasecmp(entry_plug->ensemble, "NPT")) calcStress = 1;
432 >        else calcStress = 0;
433        }
434      }
435    }
# Line 424 | Line 440 | void Symplectic::integrate( void ){
440        kE = 0.0;
441        rot_kE= 0.0;
442        trans_kE = 0.0;
443 <      
443 >
444        for( i=0; i<nAtoms; i++ ){
445          
446          // velocity half step
# Line 509 | Line 525 | void Symplectic::integrate( void ){
525            dAtom->setJz( ji[2] );
526          }
527        }
528 +
529 +      if (!strcasecmp( entry_plug->ensemble, "NVT"))
530 +        myES->NoseHooverNVT( dt / 2.0, tStats->getKinetic() );
531        
532 +      
533        // calculate the forces
534        
535        myFF->doForces(calcPot,calcStress);
# Line 529 | Line 549 | void Symplectic::integrate( void ){
549          atoms[i]->set_vy( vy );
550          atoms[i]->set_vz( vz );
551          
552 < //      vx2 = vx * vx;
553 < //      vy2 = vy * vy;
554 < //      vz2 = vz * vz;
552 >        vx2 = vx * vx;
553 >        vy2 = vy * vy;
554 >        vz2 = vz * vz;
555          
556          if( atoms[i]->isDirectional() ){
557  
# Line 563 | Line 583 | void Symplectic::integrate( void ){
583            dAtom->setJy( ji[1] );
584            dAtom->setJz( ji[2] );
585          }
586 +
587        }
588 <      
588 >    
589 >      if (!strcasecmp( entry_plug->ensemble, "NVT"))
590 >        myES->NoseHooverNVT( dt / 2.0, tStats->getKinetic() );
591 >
592 >      if (!strcasecmp( entry_plug->ensemble, "NPT") ) {
593 >        tStats->getPressureTensor(press);
594 >        myES->NoseHooverAndersonNPT( dt,
595 >                                     tStats->getKinetic(),
596 >                                     press);
597 >      }
598 >  
599        time = tl + 1;
600        
601        if( entry_plug->setTemp ){
# Line 573 | Line 604 | void Symplectic::integrate( void ){
604        if( !(time % sample_n) ) dump_out->writeDump( time * dt );
605        if( !((time+1) % status_n) ) {
606          calcPot = 1;
607 <        calcStress = 1;
607 >        calcStress = 1;
608        }
609        if( !(time % status_n) ){
610          e_out->writeStat( time * dt );
611          calcPot = 0;
612 <        calcStress = 0;
612 >        if (!strcasecmp(entry_plug->ensemble, "NPT")) calcStress = 1;
613 >        else calcStress = 0;
614        }      
615      }
616    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines