--- trunk/OOPSE-4/src/integrators/Velocitizer.cpp 2005/03/01 14:45:45 2065 +++ trunk/OOPSE-4/src/integrators/Velocitizer.cpp 2005/03/01 19:11:47 2068 @@ -43,9 +43,27 @@ #include "math/SquareMatrix3.hpp" #include "primitives/Molecule.hpp" #include "primitives/StuntDouble.hpp" -#include "math/MersenneTwister.hpp" + namespace oopse { +Velocitizer::Velocitizer(SimInfo* info) { + + int seedValue; + Globals * simParams = info->getSimParams(); + + if (simParams->haveSeed()) { + seedValue = simParams->getSeed(); + randNumGen_ = new OOPSERandNumGen(seedValue); + }else { + randNumGen_ = new OOPSERandNumGen(); + } + +} + +Velocitizer::~Velocitizer() { + delete randNumGen_; +} + void Velocitizer::velocitize(double temperature) { Vector3d aVel; Vector3d aJ; @@ -65,15 +83,8 @@ void Velocitizer::velocitize(double temperature) { Molecule * mol; StuntDouble * integrableObject; - -#ifndef IS_MPI - MTRand randNumGen(info_->getSeed()); -#else - int nProcessors; - MPI_Comm_size(MPI_COMM_WORLD, &nProcessors); - MTRand randNumGen(info_->getSeed(), nProcessors, worldRank); -#endif + kebar = kb * temperature * info_->getNdfRaw() / (2.0 * info_->getNdf()); for( mol = info_->beginMolecule(i); mol != NULL; @@ -91,7 +102,7 @@ void Velocitizer::velocitize(double temperature) { // centered on vbar for( int k = 0; k < 3; k++ ) { - aVel[k] = vbar * randNumGen.randNorm(0.0, 1.0); + aVel[k] = vbar * randNumGen_->randNorm(0.0, 1.0); } integrableObject->setVel(aVel); @@ -106,13 +117,13 @@ void Velocitizer::velocitize(double temperature) { aJ[l] = 0.0; vbar = sqrt(2.0 * kebar * I(m, m)); - aJ[m] = vbar * randNumGen.randNorm(0.0, 1.0); + aJ[m] = vbar * randNumGen_->randNorm(0.0, 1.0); vbar = sqrt(2.0 * kebar * I(n, n)); - aJ[n] = vbar * randNumGen.randNorm(0.0, 1.0); + aJ[n] = vbar * randNumGen_->randNorm(0.0, 1.0); } else { for( int k = 0; k < 3; k++ ) { vbar = sqrt(2.0 * kebar * I(k, k)); - aJ[k] = vbar * randNumGen.randNorm(0.0, 1.0); + aJ[k] = vbar *randNumGen_->randNorm(0.0, 1.0); } } // else isLinear