--- trunk/mdtools/md_code/Thermo.cpp 2003/01/02 20:14:08 221 +++ trunk/mdtools/md_code/Thermo.cpp 2003/01/30 20:03:37 254 @@ -1,12 +1,32 @@ #include +#include +using namespace std; + +#ifdef IS_MPI +#include #include +#endif //is_mpi #include "Thermo.hpp" #include "SRI.hpp" #include "LRI.hpp" #include "Integrator.hpp" +#define BASE_SEED 123456789 +Thermo::Thermo( SimInfo* the_entry_plug ) { + entry_plug = the_entry_plug; + int baseSeed = BASE_SEED; + + cerr << "creating thermo stream\n"; + gaussStream = new gaussianSPRNG( baseSeed ); + cerr << "created thermo stream\n"; +} + +Thermo::~Thermo(){ + delete gaussStream; +} + double Thermo::getKinetic(){ const double e_convert = 4.184E-4; // convert kcal/mol -> (amu A^2)/fs^2 @@ -49,9 +69,9 @@ double Thermo::getKinetic(){ } } #ifdef IS_MPI - MPI_COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM); + MPI::COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM); kinetic = kinetic_global; -#endif +#endif //is_mpi kinetic = kinetic * 0.5 / e_convert; @@ -70,7 +90,7 @@ double Thermo::getPotential(){ potential = 0.0; potential_global = 0.0; - potential += entry_plug->longRange->get_potential();; + potential += entry_plug->lrPot; // std::cerr << "long range potential: " << potential << "\n"; for( el=0; elgaussStream->getGaussian(); - vy = vbar * entry_plug->gaussStream->getGaussian(); - vz = vbar * entry_plug->gaussStream->getGaussian(); -#endif + vx = vbar * gaussStream->getGaussian(); + vy = vbar * gaussStream->getGaussian(); + vz = vbar * gaussStream->getGaussian(); +#endif // use_spring atoms[vr]->set_vx( vx ); atoms[vr]->set_vy( vy ); @@ -238,11 +261,14 @@ void Thermo::velocitize() { if( atoms[i]->isDirectional() ){ dAtom = (DirectionalAtom *)atoms[i]; + +#ifndef USE_SPRNG + #ifdef IS_MPI #error "SPRNG random number generator must be used for MPI" -#else -#warning "Using drand48 for random number generation" -#endif +#else // is_mpi + //warning "Using drand48 for random number generation" +#endif // is_MPI vbar = sqrt( 2.0 * kebar * dAtom->getIxx() ); x = drand48(); @@ -258,17 +284,18 @@ void Thermo::velocitize() { x = drand48(); y = drand48(); jz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); -#endif -#ifdef USE_SPRNG + +#else //use_sprng + vbar = sqrt( 2.0 * kebar * dAtom->getIxx() ); - jx = vbar * entry_plug->gaussStream->getGaussian(); + jx = vbar * gaussStream->getGaussian(); vbar = sqrt( 2.0 * kebar * dAtom->getIyy() ); - jy = vbar * entry_plug->gaussStream->getGaussian(); + jy = vbar * gaussStream->getGaussian(); vbar = sqrt( 2.0 * kebar * dAtom->getIzz() ); - jz = vbar * entry_plug->gaussStream->getGaussian(); -#endif + jz = vbar * gaussStream->getGaussian(); +#endif //use_sprng dAtom->setJx( jx ); dAtom->setJy( jy );