ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/brains/SimCreator.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/brains/SimCreator.cpp (file contents):
Revision 2065 by tim, Tue Mar 1 14:45:45 2005 UTC vs.
Revision 2068 by tim, Tue Mar 1 19:11:47 2005 UTC

# Line 57 | Line 57
57   #include "UseTheForce/ForceFieldFactory.hpp"
58   #include "utils/simError.h"
59   #include "utils/StringUtils.hpp"
60 + #include "math/OOPSERandNumGen.hpp"
61   #ifdef IS_MPI
62   #include "io/mpiBASS.h"
63 < #include "math/randomSPRNG.hpp"
63 >
64   #endif
65  
66   namespace oopse {
# Line 188 | Line 189 | void SimCreator::gatherParameters(SimInfo *info, const
189   }
190  
191   void SimCreator::gatherParameters(SimInfo *info, const std::string& mdfile) {
191
192    //setup seed for random number generator
193    int seedValue;
194    Globals * simParams = info->getSimParams();
195
196    if (simParams->haveSeed()) {
197        seedValue = simParams->getSeed();
198
199        if (seedValue < 100000000 ) {
200            sprintf(painCave.errMsg,
201                    "Seed for sprng library should contain at least 9 digits\n"
202                        "OOPSE will generate a seed for user\n");
203
204            painCave.isFatal = 0;
205            simError();
206
207            //using seed generated by system instead of invalid seed set by user
208
209 #ifndef IS_MPI
210
211            seedValue = make_sprng_seed();
212
213 #else
214
215            if (worldRank == 0) {
216                seedValue = make_sprng_seed();
217            }
218
219            MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD);
220
221 #endif
222
223        } //end if (seedValue /1000000000 == 0)
224    } else {
225
226 #ifndef IS_MPI
227
228        seedValue = make_sprng_seed();
229
230 #else
231
232        if (worldRank == 0) {
233            seedValue = make_sprng_seed();
234        }
235
236        MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD);
237
238 #endif
239
240    } //end of simParams->haveSeed()
241
242    info->setSeed(seedValue);
243
192  
193      //figure out the ouput file names
194      std::string prefix;
# Line 249 | Line 197 | void SimCreator::gatherParameters(SimInfo *info, const
197  
198      if (worldRank == 0) {
199   #endif // is_mpi
200 <
200 >        Globals * simParams = info->getSimParams();
201          if (simParams->haveFinalConfig()) {
202              prefix = getPrefix(simParams->getFinalConfig());
203          } else {
# Line 305 | Line 253 | void SimCreator::divideMolecules(SimInfo *info) {
253          simError();
254      }
255  
256 <    MTRand myRandom(info->getSeed(), nProcessors, worldRank);
256 >    int seedValue;
257 >    Globals * simParams = info->getSimParams();
258 >    OOPSERandNumGen* myRandom;
259 >    if (simParams->haveSeed()) {
260 >        seedValue = simParams->getSeed();
261 >        myRandom = new OOPSERandNumGen(seedValue);
262 >    }else {
263 >        myRandom = new OOPSERandNumGen();
264 >    }  
265  
266  
267      a = 3.0 * nGlobalMols / info->getNGlobalAtoms();
# Line 328 | Line 284 | void SimCreator::divideMolecules(SimInfo *info) {
284  
285                  // Pick a processor at random
286  
287 <                which_proc = (int) (myRandom.rand() * nProcessors);
287 >                which_proc = (int) (myRandom->rand() * nProcessors);
288  
289                  //get the molecule stamp first
290                  int stampId = info->getMoleculeStampId(i);
# Line 380 | Line 336 | void SimCreator::divideMolecules(SimInfo *info) {
336                  // where a = penalty / (average atoms per molecule)
337  
338                  x = (double)(new_atoms - nTarget);
339 <                y = myRandom.getRandom();
339 >                y = myRandom->rand();
340  
341                  if (y < exp(- a * x)) {
342                      molToProcMap[i] = which_proc;
# Line 394 | Line 350 | void SimCreator::divideMolecules(SimInfo *info) {
350              }
351          }
352  
353 +        delete myRandom;
354 +        
355          // Spray out this nonsense to all other processors:
356  
357          MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines