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

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 605 by gezelter, Tue Jul 15 03:27:24 2003 UTC vs.
Revision 614 by mmeineke, Tue Jul 15 17:57:04 2003 UTC

# Line 82 | Line 82 | void SimSetup::createSim( void ){
82    Globals* the_globals;
83    int i, j, k, globalAtomIndex;
84    
85 <  int ensembleCase;
86 <  int ffCase;
85 >  // gather all of the information from the Bass file
86    
87 <  ensembleCase = -1;
89 <  ffCase = -1;
87 >  gatherInfo();
88  
89 <  // get the stamps and globals;
92 <  the_stamps = stamps;
93 <  the_globals = globals;
89 >  // creation of complex system objects
90  
91 <  // set the easy ones first
96 <  simnfo->target_temp = the_globals->getTargetTemp();
97 <  simnfo->dt = the_globals->getDt();
98 <  simnfo->run_time = the_globals->getRunTime();
91 >  sysObjectsCreation();
92  
100  // get the ones we know are there, yet still may need some work.
101  n_components = the_globals->getNComponents();
102  strcpy( force_field, the_globals->getForceField() );
93  
104  if( !strcasecmp( force_field, "DUFF" )) ffCase = FF_DUFF;
105  else if( !strcasecmp( force_field, "LJ" )) ffCase = FF_LJ;
106  else{
107    sprintf( painCave.errMsg,
108             "SimSetup Error. Unrecognized force field -> %s\n",
109             force_field );
110    painCave.isFatal = 1;
111    simError();
112  }
94  
95 <  // get the ensemble:
115 <  strcpy( ensemble, the_globals->getEnsemble() );
95 >  // initialize the arrays
96  
97 <  if( !strcasecmp( ensemble, "NVE" ))      ensembleCase = NVE_ENS;
118 <  else if( !strcasecmp( ensemble, "NVT" )) ensembleCase = NVT_ENS;
119 <  else if( !strcasecmp( ensemble, "NPTi" ) || !strcasecmp( ensemble, "NPT") )
120 <    ensembleCase = NPTi_ENS;
121 <  else if( !strcasecmp( ensemble, "NPTf" )) ensembleCase = NPTf_ENS;
122 <  else if( !strcasecmp( ensemble, "NPTim" )) ensembleCase = NPTim_ENS;
123 <  else if( !strcasecmp( ensemble, "NPTfm" )) ensembleCase = NPTfm_ENS;
124 <  else{
125 <    sprintf( painCave.errMsg,
126 <             "SimSetup Warning. Unrecognized Ensemble -> %s, "
127 <             "reverting to NVE for this simulation.\n",
128 <             ensemble );
129 <    painCave.isFatal = 0;
130 <    simError();
131 <    strcpy( ensemble, "NVE" );
132 <    ensembleCase = NVE_ENS;
133 <  }  
134 <  strcpy( simnfo->ensemble, ensemble );
97 >
98  
99 <
100 < //   if( !strcasecmp( ensemble, "NPT" ) ) {
101 < //     the_extendedsystem = new ExtendedSystem( simnfo );
102 < //     the_extendedsystem->setTargetTemp(the_globals->getTargetTemp());
140 < //     if (the_globals->haveTargetPressure())
141 < //       the_extendedsystem->setTargetPressure(the_globals->getTargetPressure());
142 < //     else {
143 < //       sprintf( painCave.errMsg,
144 < //                "SimSetup error: If you use the constant pressure\n"
145 < //                "    ensemble, you must set targetPressure.\n"
146 < //                "    This was found in the BASS file.\n");
147 < //       painCave.isFatal = 1;
148 < //       simError();
149 < //     }
150 <
151 < //     if (the_globals->haveTauThermostat())
152 < //       the_extendedsystem->setTauThermostat(the_globals->getTauThermostat());
153 < //     else if (the_globals->haveQmass())
154 < //       the_extendedsystem->setQmass(the_globals->getQmass());
155 < //     else {
156 < //       sprintf( painCave.errMsg,
157 < //                "SimSetup error: If you use one of the constant temperature\n"
158 < //                "    ensembles, you must set either tauThermostat or qMass.\n"
159 < //                "    Neither of these was found in the BASS file.\n");
160 < //       painCave.isFatal = 1;
161 < //       simError();
162 < //     }
163 <
164 < //     if (the_globals->haveTauBarostat())
165 < //       the_extendedsystem->setTauBarostat(the_globals->getTauBarostat());
166 < //     else {
167 < //       sprintf( painCave.errMsg,
168 < //                "SimSetup error: If you use the constant pressure\n"
169 < //                "    ensemble, you must set tauBarostat.\n"
170 < //                "    This was found in the BASS file.\n");
171 < //       painCave.isFatal = 1;
172 < //       simError();
173 < //     }
174 <
175 < //   } else if ( !strcasecmp( ensemble, "NVT") ) {
176 < //     the_extendedsystem = new ExtendedSystem( simnfo );
177 < //     the_extendedsystem->setTargetTemp(the_globals->getTargetTemp());
178 <
179 < //     if (the_globals->haveTauThermostat())
180 < //       the_extendedsystem->setTauThermostat(the_globals->getTauThermostat());
181 < //     else if (the_globals->haveQmass())
182 < //       the_extendedsystem->setQmass(the_globals->getQmass());
183 < //     else {
184 < //       sprintf( painCave.errMsg,
185 < //                "SimSetup error: If you use one of the constant temperature\n"
186 < //                "    ensembles, you must set either tauThermostat or qMass.\n"
187 < //                "    Neither of these was found in the BASS file.\n");
188 < //       painCave.isFatal = 1;
189 < //       simError();
190 < //     }
191 <
192 <  strcpy( simnfo->mixingRule, the_globals->getMixingRule() );
193 <  simnfo->usePBC = the_globals->getPBC();
194 <          
195 <  int usesDipoles = 0;
196 <  switch( ffCase ){
197 <
198 <  case FF_DUFF:
199 <    the_ff = new DUFF();
200 <    usesDipoles = 1;
201 <    break;
202 <
203 <  case FF_LJ:
204 <    the_ff = new LJFF();
205 <    break;
206 <
207 <  default:
208 <    sprintf( painCave.errMsg,
209 <             "SimSetup Error. Unrecognized force field in case statement.\n");
210 <    painCave.isFatal = 1;
211 <    simError();
212 <  }
213 <
214 < #ifdef IS_MPI
215 <  strcpy( checkPointMsg, "ForceField creation successful" );
216 <  MPIcheckPoint();
217 < #endif // is_mpi
218 <
219 <  // get the components and calculate the tot_nMol and indvidual n_mol
220 <  the_components = the_globals->getComponents();
221 <  components_nmol = new int[n_components];
222 <  comp_stamps = new MoleculeStamp*[n_components];
223 <
224 <  if( !the_globals->haveNMol() ){
225 <    // we don't have the total number of molecules, so we assume it is
226 <    // given in each component
227 <
228 <    tot_nmol = 0;
229 <    for( i=0; i<n_components; i++ ){
230 <
231 <      if( !the_components[i]->haveNMol() ){
232 <        // we have a problem
233 <        sprintf( painCave.errMsg,
234 <                 "SimSetup Error. No global NMol or component NMol"
235 <                 " given. Cannot calculate the number of atoms.\n" );
236 <        painCave.isFatal = 1;
237 <        simError();
238 <      }
239 <
240 <      tot_nmol += the_components[i]->getNMol();
241 <      components_nmol[i] = the_components[i]->getNMol();
242 <    }
243 <  }
244 <  else{
245 <    sprintf( painCave.errMsg,
246 <             "SimSetup error.\n"
247 <             "\tSorry, the ability to specify total"
248 <             " nMols and then give molfractions in the components\n"
249 <             "\tis not currently supported."
250 <             " Please give nMol in the components.\n" );
251 <    painCave.isFatal = 1;
252 <    simError();
253 <    
254 <    
255 <    //     tot_nmol = the_globals->getNMol();
256 <    
257 <    //   //we have the total number of molecules, now we check for molfractions
258 <    //     for( i=0; i<n_components; i++ ){
259 <    
260 <    //       if( !the_components[i]->haveMolFraction() ){
261 <    
262 <    //  if( !the_components[i]->haveNMol() ){
263 <    //    //we have a problem
264 <    //    std::cerr << "SimSetup error. Neither molFraction nor "
265 <    //              << " nMol was given in component
266 <    
99 >  makeMolecules();
100 >  info->identArray = new int[info->n_atoms];
101 >  for(i=0; i<info->n_atoms; i++){
102 >    info->identArray[i] = the_atoms[i]->getIdent();
103    }
268
269 #ifdef IS_MPI
270  strcpy( checkPointMsg, "Have the number of components" );
271  MPIcheckPoint();
272 #endif // is_mpi
273
274  // make an array of molecule stamps that match the components used.
275  // also extract the used stamps out into a separate linked list
276
277  simnfo->nComponents = n_components;
278  simnfo->componentsNmol = components_nmol;
279  simnfo->compStamps = comp_stamps;
280  simnfo->headStamp = new LinkedMolStamp();
104    
282  char* id;
283  LinkedMolStamp* headStamp = simnfo->headStamp;
284  LinkedMolStamp* currentStamp = NULL;
285  for( i=0; i<n_components; i++ ){
105  
106 <    id = the_components[i]->getType();
288 <    comp_stamps[i] = NULL;
289 <    
290 <    // check to make sure the component isn't already in the list
291 <
292 <    comp_stamps[i] = headStamp->match( id );
293 <    if( comp_stamps[i] == NULL ){
294 <      
295 <      // extract the component from the list;
296 <      
297 <      currentStamp = the_stamps->extractMolStamp( id );
298 <      if( currentStamp == NULL ){
299 <        sprintf( painCave.errMsg,
300 <                 "SimSetup error: Component \"%s\" was not found in the "
301 <                 "list of declared molecules\n",
302 <                 id );
303 <        painCave.isFatal = 1;
304 <        simError();
305 <      }
306 <      
307 <      headStamp->add( currentStamp );
308 <      comp_stamps[i] = headStamp->match( id );
309 <    }
310 <  }
311 <
312 < #ifdef IS_MPI
313 <  strcpy( checkPointMsg, "Component stamps successfully extracted\n" );
314 <  MPIcheckPoint();
315 < #endif // is_mpi
106 >  // check on the post processing info
107    
108 +  finalInfoCheck();
109  
110  
111  
320  // caclulate the number of atoms, bonds, bends and torsions
112  
113 <  tot_atoms = 0;
323 <  tot_bonds = 0;
324 <  tot_bends = 0;
325 <  tot_torsions = 0;
326 <  for( i=0; i<n_components; i++ ){
327 <    
328 <    tot_atoms +=    components_nmol[i] * comp_stamps[i]->getNAtoms();
329 <    tot_bonds +=    components_nmol[i] * comp_stamps[i]->getNBonds();
330 <    tot_bends +=    components_nmol[i] * comp_stamps[i]->getNBends();
331 <    tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions();
332 <  }
113 >  // initialize the system coordinates
114  
115 <  tot_SRI = tot_bonds + tot_bends + tot_torsions;
335 <
336 <  simnfo->n_atoms = tot_atoms;
337 <  simnfo->n_bonds = tot_bonds;
338 <  simnfo->n_bends = tot_bends;
339 <  simnfo->n_torsions = tot_torsions;
340 <  simnfo->n_SRI = tot_SRI;
341 <  simnfo->n_mol = tot_nmol;
115 >  initSystemCoords();
116    
343  simnfo->molMembershipArray = new int[tot_atoms];
117  
118 < #ifdef IS_MPI
118 >  // make the output filenames
119  
120 <  // divide the molecules among processors here.
348 <  
349 <  mpiSim = new mpiSimulation( simnfo );
350 <  
351 <  globalIndex = mpiSim->divideLabor();
352 <
353 <  // set up the local variables
354 <  
355 <  int localMol, allMol;
356 <  int local_atoms, local_bonds, local_bends, local_torsions, local_SRI;
357 <
358 <  int* mol2proc = mpiSim->getMolToProcMap();
359 <  int* molCompType = mpiSim->getMolComponentType();
360 <  
361 <  allMol = 0;
362 <  localMol = 0;
363 <  local_atoms = 0;
364 <  local_bonds = 0;
365 <  local_bends = 0;
366 <  local_torsions = 0;
367 <  globalAtomIndex = 0;
368 <
369 <
370 <  for( i=0; i<n_components; i++ ){
371 <
372 <    for( j=0; j<components_nmol[i]; j++ ){
373 <      
374 <      if( mol2proc[allMol] == worldRank ){
375 <        
376 <        local_atoms +=    comp_stamps[i]->getNAtoms();
377 <        local_bonds +=    comp_stamps[i]->getNBonds();
378 <        local_bends +=    comp_stamps[i]->getNBends();
379 <        local_torsions += comp_stamps[i]->getNTorsions();
380 <        localMol++;
381 <      }      
382 <      for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
383 <        simnfo->molMembershipArray[globalAtomIndex] = allMol;
384 <        globalAtomIndex++;
385 <      }
386 <
387 <      allMol++;      
388 <    }
389 <  }
390 <  local_SRI = local_bonds + local_bends + local_torsions;
391 <  
392 <  simnfo->n_atoms = mpiSim->getMyNlocal();  
393 <  
394 <  if( local_atoms != simnfo->n_atoms ){
395 <    sprintf( painCave.errMsg,
396 <             "SimSetup error: mpiSim's localAtom (%d) and SimSetup's"
397 <             " localAtom (%d) are not equal.\n",
398 <             simnfo->n_atoms,
399 <             local_atoms );
400 <    painCave.isFatal = 1;
401 <    simError();
402 <  }
403 <
404 <  simnfo->n_bonds = local_bonds;
405 <  simnfo->n_bends = local_bends;
406 <  simnfo->n_torsions = local_torsions;
407 <  simnfo->n_SRI = local_SRI;
408 <  simnfo->n_mol = localMol;
409 <
410 <  strcpy( checkPointMsg, "Passed nlocal consistency check." );
411 <  MPIcheckPoint();
412 <  
413 <  
414 < #endif // is_mpi
415 <  
416 <
417 <  // create the atom and short range interaction arrays
418 <
419 <  Atom::createArrays(simnfo->n_atoms);
420 <  the_atoms = new Atom*[simnfo->n_atoms];
421 <  the_molecules = new Molecule[simnfo->n_mol];
422 <  int molIndex;
423 <
424 <  // initialize the molecule's stampID's
425 <
426 < #ifdef IS_MPI
427 <  
428 <
429 <  molIndex = 0;
430 <  for(i=0; i<mpiSim->getTotNmol(); i++){
431 <    
432 <    if(mol2proc[i] == worldRank ){
433 <      the_molecules[molIndex].setStampID( molCompType[i] );
434 <      the_molecules[molIndex].setMyIndex( molIndex );
435 <      the_molecules[molIndex].setGlobalIndex( i );
436 <      molIndex++;
437 <    }
438 <  }
439 <
440 < #else // is_mpi
441 <  
442 <  molIndex = 0;
443 <  globalAtomIndex = 0;
444 <  for(i=0; i<n_components; i++){
445 <    for(j=0; j<components_nmol[i]; j++ ){
446 <      the_molecules[molIndex].setStampID( i );
447 <      the_molecules[molIndex].setMyIndex( molIndex );
448 <      the_molecules[molIndex].setGlobalIndex( molIndex );
449 <      for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
450 <        simnfo->molMembershipArray[globalAtomIndex] = molIndex;
451 <        globalAtomIndex++;
452 <      }
453 <      molIndex++;
454 <    }
455 <  }
456 <    
457 <
458 < #endif // is_mpi
459 <
460 <
461 <  if( simnfo->n_SRI ){
462 <    
463 <    Exclude::createArray(simnfo->n_SRI);
464 <    the_excludes = new Exclude*[simnfo->n_SRI];
465 <    for( int ex=0; ex<simnfo->n_SRI; ex++) the_excludes[ex] = new Exclude(ex);
466 <    simnfo->globalExcludes = new int;
467 <    simnfo->n_exclude = simnfo->n_SRI;
468 <  }
469 <  else{
470 <    
471 <    Exclude::createArray( 1 );
472 <    the_excludes = new Exclude*;
473 <    the_excludes[0] = new Exclude(0);
474 <    the_excludes[0]->setPair( 0,0 );
475 <    simnfo->globalExcludes = new int;
476 <    simnfo->globalExcludes[0] = 0;
477 <    simnfo->n_exclude = 0;
478 <  }
479 <
480 <  // set the arrays into the SimInfo object
481 <
482 <  simnfo->atoms = the_atoms;
483 <  simnfo->molecules = the_molecules;
484 <  simnfo->nGlobalExcludes = 0;
485 <  simnfo->excludes = the_excludes;
486 <
487 <
488 <  // get some of the tricky things that may still be in the globals
489 <
490 <  double boxVector[3];
491 <  if( the_globals->haveBox() ){
492 <    boxVector[0] = the_globals->getBox();
493 <    boxVector[1] = the_globals->getBox();
494 <    boxVector[2] = the_globals->getBox();
495 <    
496 <    simnfo->setBox( boxVector );
497 <  }
498 <  else if( the_globals->haveDensity() ){
499 <
500 <    double vol;
501 <    vol = (double)tot_nmol / the_globals->getDensity();
502 <     boxVector[0] = pow( vol, ( 1.0 / 3.0 ) );
503 <     boxVector[1] = boxVector[0];
504 <     boxVector[2] = boxVector[0];
505 <
506 <    simnfo->setBox( boxVector );
507 <  }
508 <  else{
509 <    if( !the_globals->haveBoxX() ){
510 <      sprintf( painCave.errMsg,
511 <               "SimSetup error, no periodic BoxX size given.\n" );
512 <      painCave.isFatal = 1;
513 <      simError();
514 <    }
515 <    boxVector[0] = the_globals->getBoxX();
516 <
517 <    if( !the_globals->haveBoxY() ){
518 <      sprintf( painCave.errMsg,
519 <               "SimSetup error, no periodic BoxY size given.\n" );
520 <      painCave.isFatal = 1;
521 <      simError();
522 <    }
523 <    boxVector[1] = the_globals->getBoxY();
524 <
525 <    if( !the_globals->haveBoxZ() ){
526 <      sprintf( painCave.errMsg,
527 <               "SimSetup error, no periodic BoxZ size given.\n" );
528 <      painCave.isFatal = 1;
529 <      simError();
530 <    }
531 <    boxVector[2] = the_globals->getBoxZ();
532 <
533 <    simnfo->setBox( boxVector );
534 <  }
535 <
536 < #ifdef IS_MPI
537 <  strcpy( checkPointMsg, "Box size set up" );
538 <  MPIcheckPoint();
539 < #endif // is_mpi
540 <
541 <
542 <  // initialize the arrays
543 <
544 <  the_ff->setSimInfo( simnfo );
545 <
546 <  makeMolecules();
547 <  simnfo->identArray = new int[simnfo->n_atoms];
548 <  for(i=0; i<simnfo->n_atoms; i++){
549 <    simnfo->identArray[i] = the_atoms[i]->getIdent();
550 <  }
551 <  
552 <  if (the_globals->getUseRF() ) {
553 <    simnfo->useReactionField = 1;
554 <  
555 <    if( !the_globals->haveECR() ){
556 <      sprintf( painCave.errMsg,
557 <               "SimSetup Warning: using default value of 1/2 the smallest "
558 <               "box length for the electrostaticCutoffRadius.\n"
559 <               "I hope you have a very fast processor!\n");
560 <      painCave.isFatal = 0;
561 <      simError();
562 <      double smallest;
563 <      smallest = simnfo->boxLx;
564 <      if (simnfo->boxLy <= smallest) smallest = simnfo->boxLy;
565 <      if (simnfo->boxLz <= smallest) smallest = simnfo->boxLz;
566 <      simnfo->ecr = 0.5 * smallest;
567 <    } else {
568 <      simnfo->ecr        = the_globals->getECR();
569 <    }
570 <
571 <    if( !the_globals->haveEST() ){
572 <      sprintf( painCave.errMsg,
573 <               "SimSetup Warning: using default value of 0.05 * the "
574 <               "electrostaticCutoffRadius for the electrostaticSkinThickness\n"
575 <               );
576 <      painCave.isFatal = 0;
577 <      simError();
578 <      simnfo->est = 0.05 * simnfo->ecr;
579 <    } else {
580 <      simnfo->est        = the_globals->getEST();
581 <    }
582 <    
583 <    if(!the_globals->haveDielectric() ){
584 <      sprintf( painCave.errMsg,
585 <               "SimSetup Error: You are trying to use Reaction Field without"
586 <               "setting a dielectric constant!\n"
587 <               );
588 <      painCave.isFatal = 1;
589 <      simError();
590 <    }
591 <    simnfo->dielectric = the_globals->getDielectric();  
592 <  } else {
593 <    if (usesDipoles) {
594 <      
595 <      if( !the_globals->haveECR() ){
596 <        sprintf( painCave.errMsg,
597 <                 "SimSetup Warning: using default value of 1/2 the smallest "
598 <                 "box length for the electrostaticCutoffRadius.\n"
599 <                 "I hope you have a very fast processor!\n");
600 <        painCave.isFatal = 0;
601 <        simError();
602 <        double smallest;
603 <        smallest = simnfo->boxLx;
604 <        if (simnfo->boxLy <= smallest) smallest = simnfo->boxLy;
605 <        if (simnfo->boxLz <= smallest) smallest = simnfo->boxLz;
606 <        simnfo->ecr = 0.5 * smallest;
607 <      } else {
608 <        simnfo->ecr        = the_globals->getECR();
609 <      }
610 <      
611 <      if( !the_globals->haveEST() ){
612 <        sprintf( painCave.errMsg,
613 <                 "SimSetup Warning: using default value of 5%% of the "
614 <                 "electrostaticCutoffRadius for the "
615 <                 "electrostaticSkinThickness\n"
616 <                 );
617 <        painCave.isFatal = 0;
618 <        simError();
619 <        simnfo->est = 0.05 * simnfo->ecr;
620 <      } else {
621 <        simnfo->est        = the_globals->getEST();
622 <      }
623 <    }
624 <  }  
625 <
626 < #ifdef IS_MPI
627 <  strcpy( checkPointMsg, "electrostatic parameters check out" );
628 <  MPIcheckPoint();
629 < #endif // is_mpi
630 <
631 < if( the_globals->haveInitialConfig() ){
632 <
633 <     InitializeFromFile* fileInit;
634 < #ifdef IS_MPI // is_mpi
635 <     if( worldRank == 0 ){
636 < #endif //is_mpi
637 <   fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
638 < #ifdef IS_MPI
639 <     }else fileInit = new InitializeFromFile( NULL );
640 < #endif
641 <   fileInit->read_xyz( simnfo ); // default velocities on
642 <
643 <   delete fileInit;
644 < }
645 < else{
646 <
647 < #ifdef IS_MPI
648 <
649 <  // no init from bass
650 <  
651 <  sprintf( painCave.errMsg,
652 <           "Cannot intialize a parallel simulation without an initial configuration file.\n" );
653 <  painCave.isFatal;
654 <  simError();
655 <  
656 < #else
657 <
658 <  initFromBass();
659 <
660 <
661 < #endif
662 < }
663 <
664 < #ifdef IS_MPI
665 <  strcpy( checkPointMsg, "Successfully read in the initial configuration" );
666 <  MPIcheckPoint();
667 < #endif // is_mpi
668 <
669 <
120 >  makeOutNames();
121    
122  
123    
124  
125    
126 < #ifdef IS_MPI
676 <  if( worldRank == 0 ){
677 < #endif // is_mpi
678 <    
679 <    if( the_globals->haveFinalConfig() ){
680 <      strcpy( simnfo->finalName, the_globals->getFinalConfig() );
681 <    }
682 <    else{
683 <      strcpy( simnfo->finalName, inFileName );
684 <      char* endTest;
685 <      int nameLength = strlen( simnfo->finalName );
686 <      endTest = &(simnfo->finalName[nameLength - 5]);
687 <      if( !strcmp( endTest, ".bass" ) ){
688 <        strcpy( endTest, ".eor" );
689 <      }
690 <      else if( !strcmp( endTest, ".BASS" ) ){
691 <        strcpy( endTest, ".eor" );
692 <      }
693 <      else{
694 <        endTest = &(simnfo->finalName[nameLength - 4]);
695 <        if( !strcmp( endTest, ".bss" ) ){
696 <          strcpy( endTest, ".eor" );
697 <        }
698 <        else if( !strcmp( endTest, ".mdl" ) ){
699 <          strcpy( endTest, ".eor" );
700 <        }
701 <        else{
702 <          strcat( simnfo->finalName, ".eor" );
703 <        }
704 <      }
705 <    }
706 <    
707 <    // make the sample and status out names
708 <    
709 <    strcpy( simnfo->sampleName, inFileName );
710 <    char* endTest;
711 <    int nameLength = strlen( simnfo->sampleName );
712 <    endTest = &(simnfo->sampleName[nameLength - 5]);
713 <    if( !strcmp( endTest, ".bass" ) ){
714 <      strcpy( endTest, ".dump" );
715 <    }
716 <    else if( !strcmp( endTest, ".BASS" ) ){
717 <      strcpy( endTest, ".dump" );
718 <    }
719 <    else{
720 <      endTest = &(simnfo->sampleName[nameLength - 4]);
721 <      if( !strcmp( endTest, ".bss" ) ){
722 <        strcpy( endTest, ".dump" );
723 <      }
724 <      else if( !strcmp( endTest, ".mdl" ) ){
725 <        strcpy( endTest, ".dump" );
726 <      }
727 <      else{
728 <        strcat( simnfo->sampleName, ".dump" );
729 <      }
730 <    }
731 <    
732 <    strcpy( simnfo->statusName, inFileName );
733 <    nameLength = strlen( simnfo->statusName );
734 <    endTest = &(simnfo->statusName[nameLength - 5]);
735 <    if( !strcmp( endTest, ".bass" ) ){
736 <      strcpy( endTest, ".stat" );
737 <    }
738 <    else if( !strcmp( endTest, ".BASS" ) ){
739 <      strcpy( endTest, ".stat" );
740 <    }
741 <    else{
742 <      endTest = &(simnfo->statusName[nameLength - 4]);
743 <      if( !strcmp( endTest, ".bss" ) ){
744 <        strcpy( endTest, ".stat" );
745 <      }
746 <      else if( !strcmp( endTest, ".mdl" ) ){
747 <        strcpy( endTest, ".stat" );
748 <      }
749 <      else{
750 <        strcat( simnfo->statusName, ".stat" );
751 <      }
752 <    }
753 <    
754 < #ifdef IS_MPI
755 <  }
756 < #endif // is_mpi
126 >
127    
758  // set the status, sample, and themal kick times
759  
760  if( the_globals->haveSampleTime() ){
761    simnfo->sampleTime = the_globals->getSampleTime();
762    simnfo->statusTime = simnfo->sampleTime;
763    simnfo->thermalTime = simnfo->sampleTime;
764  }
765  else{
766    simnfo->sampleTime = the_globals->getRunTime();
767    simnfo->statusTime = simnfo->sampleTime;
768    simnfo->thermalTime = simnfo->sampleTime;
769  }
128  
771  if( the_globals->haveStatusTime() ){
772    simnfo->statusTime = the_globals->getStatusTime();
773  }
129  
775  if( the_globals->haveThermalTime() ){
776    simnfo->thermalTime = the_globals->getThermalTime();
777  }
778
779  // check for the temperature set flag
780
781  if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet();
782
783
130    // make the integrator
131    
132    
# Line 793 | Line 139 | void SimSetup::createSim( void ){
139    switch( ensembleCase ){
140  
141    case NVE_ENS:
142 <    new NVE( simnfo, the_ff );
142 >    new NVE( info, the_ff );
143      break;
144  
145    case NVT_ENS:
146 <    myNVT = new NVT( simnfo, the_ff );
146 >    myNVT = new NVT( info, the_ff );
147      myNVT->setTargetTemp(the_globals->getTargetTemp());
148  
149      if (the_globals->haveTauThermostat())
# Line 813 | Line 159 | void SimSetup::createSim( void ){
159      break;
160  
161    case NPTi_ENS:
162 <    myNPTi = new NPTi( simnfo, the_ff );
163 <    myNPTi->setTargetTemp( the_globals->getTargetTemp());
162 >    myNPTi = new NPTi( info, the_ff );
163 >    myNPTi->setTargetTemp( the_globals->getTargetTemp() );
164  
165      if (the_globals->haveTargetPressure())
166        myNPTi->setTargetPressure(the_globals->getTargetPressure());
# Line 848 | Line 194 | void SimSetup::createSim( void ){
194      break;
195  
196    case NPTf_ENS:
197 <    myNPTf = new NPTf( simnfo, the_ff );
197 >    myNPTf = new NPTf( info, the_ff );
198      myNPTf->setTargetTemp( the_globals->getTargetTemp());
199  
200      if (the_globals->haveTargetPressure())
# Line 883 | Line 229 | void SimSetup::createSim( void ){
229      break;
230      
231    case NPTim_ENS:
232 <    myNPTim = new NPTim( simnfo, the_ff );
232 >    myNPTim = new NPTim( info, the_ff );
233      myNPTim->setTargetTemp( the_globals->getTargetTemp());
234  
235      if (the_globals->haveTargetPressure())
# Line 918 | Line 264 | void SimSetup::createSim( void ){
264      break;
265  
266    case NPTfm_ENS:
267 <    myNPTfm = new NPTfm( simnfo, the_ff );
267 >    myNPTfm = new NPTfm( info, the_ff );
268      myNPTfm->setTargetTemp( the_globals->getTargetTemp());
269  
270      if (the_globals->haveTargetPressure())
# Line 967 | Line 313 | void SimSetup::createSim( void ){
313    // initialize the Fortran
314  
315  
316 <  simnfo->refreshSim();
316 >  info->refreshSim();
317    
318 <  if( !strcmp( simnfo->mixingRule, "standard") ){
318 >  if( !strcmp( info->mixingRule, "standard") ){
319      the_ff->initForceField( LB_MIXING_RULE );
320    }
321 <  else if( !strcmp( simnfo->mixingRule, "explicit") ){
321 >  else if( !strcmp( info->mixingRule, "explicit") ){
322      the_ff->initForceField( EXPLICIT_MIXING_RULE );
323    }
324    else{
325      sprintf( painCave.errMsg,
326               "SimSetup Error: unknown mixing rule -> \"%s\"\n",
327 <             simnfo->mixingRule );
327 >             info->mixingRule );
328      painCave.isFatal = 1;
329      simError();
330    }
# Line 1020 | Line 366 | void SimSetup::makeMolecules( void ){
366    
367    atomOffset = 0;
368    excludeOffset = 0;
369 <  for(i=0; i<simnfo->n_mol; i++){
369 >  for(i=0; i<info->n_mol; i++){
370      
371      stampID = the_molecules[i].getStampID();
372  
# Line 1048 | Line 394 | void SimSetup::makeMolecules( void ){
394        if( currentAtom->haveOrientation() ){
395          
396          dAtom = new DirectionalAtom(j + atomOffset);
397 <        simnfo->n_oriented++;
397 >        info->n_oriented++;
398          info.myAtoms[j] = dAtom;
399          
400          ux = currentAtom->getOrntX();
# Line 1272 | Line 618 | void SimSetup::initFromBass( void ){
618      have_extra =1;
619  
620      n_cells = (int)temp3 - 1;
621 <    cellx = simnfo->boxLx / temp3;
622 <    celly = simnfo->boxLy / temp3;
623 <    cellz = simnfo->boxLz / temp3;
621 >    cellx = info->boxLx / temp3;
622 >    celly = info->boxLy / temp3;
623 >    cellz = info->boxLz / temp3;
624      n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells );
625      temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) );
626      n_per_extra = (int)ceil( temp1 );
# Line 1289 | Line 635 | void SimSetup::initFromBass( void ){
635    }
636    else{
637      n_cells = (int)temp3;
638 <    cellx = simnfo->boxLx / temp3;
639 <    celly = simnfo->boxLy / temp3;
640 <    cellz = simnfo->boxLz / temp3;
638 >    cellx = info->boxLx / temp3;
639 >    celly = info->boxLy / temp3;
640 >    cellz = info->boxLz / temp3;
641    }
642  
643    current_mol = 0;
# Line 1371 | Line 717 | void SimSetup::initFromBass( void ){
717    }
718  
719  
720 <  for( i=0; i<simnfo->n_atoms; i++ ){
721 <    simnfo->atoms[i]->set_vx( 0.0 );
722 <    simnfo->atoms[i]->set_vy( 0.0 );
723 <    simnfo->atoms[i]->set_vz( 0.0 );
720 >  for( i=0; i<info->n_atoms; i++ ){
721 >    info->atoms[i]->set_vx( 0.0 );
722 >    info->atoms[i]->set_vy( 0.0 );
723 >    info->atoms[i]->set_vz( 0.0 );
724    }
725   }
726  
# Line 1433 | Line 779 | void SimSetup::makeElement( double x, double y, double
779  
780      current_comp_mol = 0;
781      current_comp++;
782 +  }
783 + }
784 +
785 +
786 + void SimSetup::gatherInfo( void ){
787 +
788 +  ensembleCase = -1;
789 +  ffCase = -1;
790 +
791 +  // get the stamps and globals;
792 +  the_stamps = stamps;
793 +  the_globals = globals;
794 +
795 +  // set the easy ones first
796 +  info->target_temp = the_globals->getTargetTemp();
797 +  info->dt = the_globals->getDt();
798 +  info->run_time = the_globals->getRunTime();
799 +  n_components = the_globals->getNComponents();
800 +
801 +
802 +  // get the forceField
803 +
804 +  strcpy( force_field, the_globals->getForceField() );
805 +
806 +  if( !strcasecmp( force_field, "DUFF" )) ffCase = FF_DUFF;
807 +  else if( !strcasecmp( force_field, "LJ" )) ffCase = FF_LJ;
808 +  else{
809 +    sprintf( painCave.errMsg,
810 +             "SimSetup Error. Unrecognized force field -> %s\n",
811 +             force_field );
812 +    painCave.isFatal = 1;
813 +    simError();
814 +  }
815 +
816 +  // get the ensemble
817 +
818 +  strcpy( ensemble, the_globals->getEnsemble() );
819 +
820 +  if( !strcasecmp( ensemble, "NVE" ))      ensembleCase = NVE_ENS;
821 +  else if( !strcasecmp( ensemble, "NVT" )) ensembleCase = NVT_ENS;
822 +  else if( !strcasecmp( ensemble, "NPTi" ) || !strcasecmp( ensemble, "NPT") )
823 +    ensembleCase = NPTi_ENS;
824 +  else if( !strcasecmp( ensemble, "NPTf" )) ensembleCase = NPTf_ENS;
825 +  else if( !strcasecmp( ensemble, "NPTim" )) ensembleCase = NPTim_ENS;
826 +  else if( !strcasecmp( ensemble, "NPTfm" )) ensembleCase = NPTfm_ENS;
827 +  else{
828 +    sprintf( painCave.errMsg,
829 +             "SimSetup Warning. Unrecognized Ensemble -> %s, "
830 +             "reverting to NVE for this simulation.\n",
831 +             ensemble );
832 +    painCave.isFatal = 0;
833 +    simError();
834 +    strcpy( ensemble, "NVE" );
835 +    ensembleCase = NVE_ENS;
836 +  }  
837 +  strcpy( info->ensemble, ensemble );
838 +
839 +  // get the mixing rule
840 +
841 +  strcpy( info->mixingRule, the_globals->getMixingRule() );
842 +  info->usePBC = the_globals->getPBC();
843 +        
844 +  
845 +  // get the components and calculate the tot_nMol and indvidual n_mol
846 +
847 +  the_components = the_globals->getComponents();
848 +  components_nmol = new int[n_components];
849 +
850 +
851 +  if( !the_globals->haveNMol() ){
852 +    // we don't have the total number of molecules, so we assume it is
853 +    // given in each component
854 +
855 +    tot_nmol = 0;
856 +    for( i=0; i<n_components; i++ ){
857 +
858 +      if( !the_components[i]->haveNMol() ){
859 +        // we have a problem
860 +        sprintf( painCave.errMsg,
861 +                 "SimSetup Error. No global NMol or component NMol"
862 +                 " given. Cannot calculate the number of atoms.\n" );
863 +        painCave.isFatal = 1;
864 +        simError();
865 +      }
866 +
867 +      tot_nmol += the_components[i]->getNMol();
868 +      components_nmol[i] = the_components[i]->getNMol();
869 +    }
870 +  }
871 +  else{
872 +    sprintf( painCave.errMsg,
873 +             "SimSetup error.\n"
874 +             "\tSorry, the ability to specify total"
875 +             " nMols and then give molfractions in the components\n"
876 +             "\tis not currently supported."
877 +             " Please give nMol in the components.\n" );
878 +    painCave.isFatal = 1;
879 +    simError();
880 +  }
881 +
882 +  // set the status, sample, and thermal kick times
883 +  
884 +  if( the_globals->haveSampleTime() ){
885 +    info->sampleTime = the_globals->getSampleTime();
886 +    info->statusTime = info->sampleTime;
887 +    info->thermalTime = info->sampleTime;
888 +  }
889 +  else{
890 +    info->sampleTime = the_globals->getRunTime();
891 +    info->statusTime = info->sampleTime;
892 +    info->thermalTime = info->sampleTime;
893 +  }
894 +
895 +  if( the_globals->haveStatusTime() ){
896 +    info->statusTime = the_globals->getStatusTime();
897 +  }
898 +
899 +  if( the_globals->haveThermalTime() ){
900 +    info->thermalTime = the_globals->getThermalTime();
901 +  }
902 +
903 +  // check for the temperature set flag
904 +
905 +  if( the_globals->haveTempSet() ) info->setTemp = the_globals->getTempSet();
906 +
907 +  // get some of the tricky things that may still be in the globals
908 +
909 +  double boxVector[3];
910 +  if( the_globals->haveBox() ){
911 +    boxVector[0] = the_globals->getBox();
912 +    boxVector[1] = the_globals->getBox();
913 +    boxVector[2] = the_globals->getBox();
914 +    
915 +    info->setBox( boxVector );
916 +  }
917 +  else if( the_globals->haveDensity() ){
918 +
919 +    double vol;
920 +    vol = (double)tot_nmol / the_globals->getDensity();
921 +     boxVector[0] = pow( vol, ( 1.0 / 3.0 ) );
922 +     boxVector[1] = boxVector[0];
923 +     boxVector[2] = boxVector[0];
924 +
925 +    info->setBox( boxVector );
926 +  }
927 +  else{
928 +    if( !the_globals->haveBoxX() ){
929 +      sprintf( painCave.errMsg,
930 +               "SimSetup error, no periodic BoxX size given.\n" );
931 +      painCave.isFatal = 1;
932 +      simError();
933 +    }
934 +    boxVector[0] = the_globals->getBoxX();
935 +
936 +    if( !the_globals->haveBoxY() ){
937 +      sprintf( painCave.errMsg,
938 +               "SimSetup error, no periodic BoxY size given.\n" );
939 +      painCave.isFatal = 1;
940 +      simError();
941 +    }
942 +    boxVector[1] = the_globals->getBoxY();
943 +
944 +    if( !the_globals->haveBoxZ() ){
945 +      sprintf( painCave.errMsg,
946 +               "SimSetup error, no periodic BoxZ size given.\n" );
947 +      painCave.isFatal = 1;
948 +      simError();
949 +    }
950 +    boxVector[2] = the_globals->getBoxZ();
951 +
952 +    info->setBox( boxVector );
953    }
954 +
955 +
956 +    
957 + #ifdef IS_MPI
958 +  strcpy( checkPointMsg, "Succesfully gathered all information from Bass\n" );
959 +  MPIcheckPoint();
960 + #endif // is_mpi
961 +
962   }
963 +
964 +
965 + void SimSetup::finalInfoCheck( void ){
966 +  int index;
967 +  int usesDipoles;
968 +  
969 +
970 +  // check electrostatic parameters
971 +  
972 +  index = 0;
973 +  usesDipoles = 0;
974 +  while( (index < info->n_atoms) && !usesDipoles ){
975 +    usesDipoles = ((info->atoms)[index])->hasDipole();
976 +    index++;
977 +  }
978 +  
979 + #ifdef IS_MPI
980 +  int myUse = usesDipoles
981 +  MPI_Allreduce( &myUse, &UsesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
982 + #endif //is_mpi
983 +
984 +
985 +  if (the_globals->getUseRF() ) {
986 +    info->useReactionField = 1;
987 +    
988 +    if( !the_globals->haveECR() ){
989 +      sprintf( painCave.errMsg,
990 +               "SimSetup Warning: using default value of 1/2 the smallest "
991 +               "box length for the electrostaticCutoffRadius.\n"
992 +               "I hope you have a very fast processor!\n");
993 +      painCave.isFatal = 0;
994 +      simError();
995 +      double smallest;
996 +      smallest = info->boxLx;
997 +      if (info->boxLy <= smallest) smallest = info->boxLy;
998 +      if (info->boxLz <= smallest) smallest = info->boxLz;
999 +      info->ecr = 0.5 * smallest;
1000 +    } else {
1001 +      info->ecr        = the_globals->getECR();
1002 +    }
1003 +
1004 +    if( !the_globals->haveEST() ){
1005 +      sprintf( painCave.errMsg,
1006 +               "SimSetup Warning: using default value of 0.05 * the "
1007 +               "electrostaticCutoffRadius for the electrostaticSkinThickness\n"
1008 +               );
1009 +      painCave.isFatal = 0;
1010 +      simError();
1011 +      info->est = 0.05 * info->ecr;
1012 +    } else {
1013 +      info->est        = the_globals->getEST();
1014 +    }
1015 +    
1016 +    if(!the_globals->haveDielectric() ){
1017 +      sprintf( painCave.errMsg,
1018 +               "SimSetup Error: You are trying to use Reaction Field without"
1019 +               "setting a dielectric constant!\n"
1020 +               );
1021 +      painCave.isFatal = 1;
1022 +      simError();
1023 +    }
1024 +    info->dielectric = the_globals->getDielectric();  
1025 +  }
1026 +  else {
1027 +    if (usesDipoles) {
1028 +      
1029 +      if( !the_globals->haveECR() ){
1030 +        sprintf( painCave.errMsg,
1031 +                 "SimSetup Warning: using default value of 1/2 the smallest "
1032 +                 "box length for the electrostaticCutoffRadius.\n"
1033 +                 "I hope you have a very fast processor!\n");
1034 +        painCave.isFatal = 0;
1035 +        simError();
1036 +        double smallest;
1037 +        smallest = info->boxLx;
1038 +        if (info->boxLy <= smallest) smallest = info->boxLy;
1039 +        if (info->boxLz <= smallest) smallest = info->boxLz;
1040 +        info->ecr = 0.5 * smallest;
1041 +      } else {
1042 +        info->ecr        = the_globals->getECR();
1043 +      }
1044 +      
1045 +      if( !the_globals->haveEST() ){
1046 +        sprintf( painCave.errMsg,
1047 +                 "SimSetup Warning: using default value of 5%% of the "
1048 +                 "electrostaticCutoffRadius for the "
1049 +                 "electrostaticSkinThickness\n"
1050 +                 );
1051 +        painCave.isFatal = 0;
1052 +        simError();
1053 +        info->est = 0.05 * info->ecr;
1054 +      } else {
1055 +        info->est        = the_globals->getEST();
1056 +      }
1057 +    }
1058 +  }  
1059 +
1060 + #ifdef IS_MPI
1061 +  strcpy( checkPointMsg, "post processing checks out" );
1062 +  MPIcheckPoint();
1063 + #endif // is_mpi
1064 +
1065 + }
1066 +
1067 + void SimSetup::initSystemCoords( void ){
1068 +
1069 + if( the_globals->haveInitialConfig() ){
1070 +
1071 +     InitializeFromFile* fileInit;
1072 + #ifdef IS_MPI // is_mpi
1073 +     if( worldRank == 0 ){
1074 + #endif //is_mpi
1075 +   fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
1076 + #ifdef IS_MPI
1077 +     }else fileInit = new InitializeFromFile( NULL );
1078 + #endif
1079 +   fileInit->read_xyz( info ); // default velocities on
1080 +
1081 +   delete fileInit;
1082 + }
1083 + else{
1084 +
1085 + #ifdef IS_MPI
1086 +
1087 +  // no init from bass
1088 +  
1089 +  sprintf( painCave.errMsg,
1090 +           "Cannot intialize a parallel simulation without an initial configuration file.\n" );
1091 +  painCave.isFatal;
1092 +  simError();
1093 +  
1094 + #else
1095 +
1096 +  initFromBass();
1097 +
1098 +
1099 + #endif
1100 + }
1101 +
1102 + #ifdef IS_MPI
1103 +  strcpy( checkPointMsg, "Successfully read in the initial configuration" );
1104 +  MPIcheckPoint();
1105 + #endif // is_mpi
1106 +
1107 + }
1108 +
1109 +
1110 + void SimSetup::makeOutNames( void ){
1111 +
1112 + #ifdef IS_MPI
1113 +  if( worldRank == 0 ){
1114 + #endif // is_mpi
1115 +    
1116 +    if( the_globals->haveFinalConfig() ){
1117 +      strcpy( info->finalName, the_globals->getFinalConfig() );
1118 +    }
1119 +    else{
1120 +      strcpy( info->finalName, inFileName );
1121 +      char* endTest;
1122 +      int nameLength = strlen( info->finalName );
1123 +      endTest = &(info->finalName[nameLength - 5]);
1124 +      if( !strcmp( endTest, ".bass" ) ){
1125 +        strcpy( endTest, ".eor" );
1126 +      }
1127 +      else if( !strcmp( endTest, ".BASS" ) ){
1128 +        strcpy( endTest, ".eor" );
1129 +      }
1130 +      else{
1131 +        endTest = &(info->finalName[nameLength - 4]);
1132 +        if( !strcmp( endTest, ".bss" ) ){
1133 +          strcpy( endTest, ".eor" );
1134 +        }
1135 +        else if( !strcmp( endTest, ".mdl" ) ){
1136 +          strcpy( endTest, ".eor" );
1137 +        }
1138 +        else{
1139 +          strcat( info->finalName, ".eor" );
1140 +        }
1141 +      }
1142 +    }
1143 +    
1144 +    // make the sample and status out names
1145 +    
1146 +    strcpy( info->sampleName, inFileName );
1147 +    char* endTest;
1148 +    int nameLength = strlen( info->sampleName );
1149 +    endTest = &(info->sampleName[nameLength - 5]);
1150 +    if( !strcmp( endTest, ".bass" ) ){
1151 +      strcpy( endTest, ".dump" );
1152 +    }
1153 +    else if( !strcmp( endTest, ".BASS" ) ){
1154 +      strcpy( endTest, ".dump" );
1155 +    }
1156 +    else{
1157 +      endTest = &(info->sampleName[nameLength - 4]);
1158 +      if( !strcmp( endTest, ".bss" ) ){
1159 +        strcpy( endTest, ".dump" );
1160 +      }
1161 +      else if( !strcmp( endTest, ".mdl" ) ){
1162 +        strcpy( endTest, ".dump" );
1163 +      }
1164 +      else{
1165 +        strcat( info->sampleName, ".dump" );
1166 +      }
1167 +    }
1168 +    
1169 +    strcpy( info->statusName, inFileName );
1170 +    nameLength = strlen( info->statusName );
1171 +    endTest = &(info->statusName[nameLength - 5]);
1172 +    if( !strcmp( endTest, ".bass" ) ){
1173 +      strcpy( endTest, ".stat" );
1174 +    }
1175 +    else if( !strcmp( endTest, ".BASS" ) ){
1176 +      strcpy( endTest, ".stat" );
1177 +    }
1178 +    else{
1179 +      endTest = &(info->statusName[nameLength - 4]);
1180 +      if( !strcmp( endTest, ".bss" ) ){
1181 +        strcpy( endTest, ".stat" );
1182 +      }
1183 +      else if( !strcmp( endTest, ".mdl" ) ){
1184 +        strcpy( endTest, ".stat" );
1185 +      }
1186 +      else{
1187 +        strcat( info->statusName, ".stat" );
1188 +      }
1189 +    }
1190 +    
1191 + #ifdef IS_MPI
1192 +  }
1193 + #endif // is_mpi
1194 +
1195 + }
1196 +
1197 +
1198 + void SimSetup::sysObjectsCreation( void ){
1199 +
1200 +  // create the forceField
1201 +
1202 +  createFF();
1203 +
1204 +  // extract componentList
1205 +
1206 +  compList();
1207 +
1208 +  // calc the number of atoms, bond, bends, and torsions
1209 +
1210 +  calcSysValues();
1211 +
1212 + #ifdef IS_MPI
1213 +  // divide the molecules among the processors
1214 +  
1215 +  mpiMolDivide();
1216 + #endif //is_mpi
1217 +  
1218 +  // create the atom and SRI arrays. Also initialize Molecule Stamp ID's
1219 +  
1220 +  makeSysArrays();
1221 +
1222 +  
1223 +
1224 +
1225 + }
1226 +
1227 +
1228 + void SimSetup::createFF( void ){
1229 +
1230 +  switch( ffCase ){
1231 +
1232 +  case FF_DUFF:
1233 +    the_ff = new DUFF();
1234 +    break;
1235 +
1236 +  case FF_LJ:
1237 +    the_ff = new LJFF();
1238 +    break;
1239 +
1240 +  default:
1241 +    sprintf( painCave.errMsg,
1242 +             "SimSetup Error. Unrecognized force field in case statement.\n");
1243 +    painCave.isFatal = 1;
1244 +    simError();
1245 +  }
1246 +
1247 + #ifdef IS_MPI
1248 +  strcpy( checkPointMsg, "ForceField creation successful" );
1249 +  MPIcheckPoint();
1250 + #endif // is_mpi
1251 +
1252 + }
1253 +
1254 +
1255 + void SimSetup::compList( void ){
1256 +
1257 +  comp_stamps = new MoleculeStamp*[n_components];
1258 +
1259 +  // make an array of molecule stamps that match the components used.
1260 +  // also extract the used stamps out into a separate linked list
1261 +
1262 +  info->nComponents = n_components;
1263 +  info->componentsNmol = components_nmol;
1264 +  info->compStamps = comp_stamps;
1265 +  info->headStamp = new LinkedMolStamp();
1266 +  
1267 +  char* id;
1268 +  LinkedMolStamp* headStamp = info->headStamp;
1269 +  LinkedMolStamp* currentStamp = NULL;
1270 +  for( i=0; i<n_components; i++ ){
1271 +
1272 +    id = the_components[i]->getType();
1273 +    comp_stamps[i] = NULL;
1274 +    
1275 +    // check to make sure the component isn't already in the list
1276 +
1277 +    comp_stamps[i] = headStamp->match( id );
1278 +    if( comp_stamps[i] == NULL ){
1279 +      
1280 +      // extract the component from the list;
1281 +      
1282 +      currentStamp = the_stamps->extractMolStamp( id );
1283 +      if( currentStamp == NULL ){
1284 +        sprintf( painCave.errMsg,
1285 +                 "SimSetup error: Component \"%s\" was not found in the "
1286 +                 "list of declared molecules\n",
1287 +                 id );
1288 +        painCave.isFatal = 1;
1289 +        simError();
1290 +      }
1291 +      
1292 +      headStamp->add( currentStamp );
1293 +      comp_stamps[i] = headStamp->match( id );
1294 +    }
1295 +  }
1296 +
1297 + #ifdef IS_MPI
1298 +  strcpy( checkPointMsg, "Component stamps successfully extracted\n" );
1299 +  MPIcheckPoint();
1300 + #endif // is_mpi
1301 +
1302 +
1303 + }
1304 +
1305 + void SimSetup::calcSysValues( void ){
1306 +
1307 +  tot_atoms = 0;
1308 +  tot_bonds = 0;
1309 +  tot_bends = 0;
1310 +  tot_torsions = 0;
1311 +  for( i=0; i<n_components; i++ ){
1312 +    
1313 +    tot_atoms +=    components_nmol[i] * comp_stamps[i]->getNAtoms();
1314 +    tot_bonds +=    components_nmol[i] * comp_stamps[i]->getNBonds();
1315 +    tot_bends +=    components_nmol[i] * comp_stamps[i]->getNBends();
1316 +    tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions();
1317 +  }
1318 +
1319 +  tot_SRI = tot_bonds + tot_bends + tot_torsions;
1320 +
1321 +  info->n_atoms = tot_atoms;
1322 +  info->n_bonds = tot_bonds;
1323 +  info->n_bends = tot_bends;
1324 +  info->n_torsions = tot_torsions;
1325 +  info->n_SRI = tot_SRI;
1326 +  info->n_mol = tot_nmol;
1327 +  
1328 +  info->molMembershipArray = new int[tot_atoms];
1329 + }
1330 +
1331 +
1332 + #ifdef IS_MPI
1333 +
1334 + void SimSetup::mpiMolDivide( void ){
1335 +  
1336 +  int localMol, allMol;
1337 +  int local_atoms, local_bonds, local_bends, local_torsions, local_SRI;
1338 +
1339 +  mpiSim = new mpiSimulation( info );
1340 +  
1341 +  globalIndex = mpiSim->divideLabor();
1342 +
1343 +  // set up the local variables
1344 +  
1345 +  mol2proc = mpiSim->getMolToProcMap();
1346 +  molCompType = mpiSim->getMolComponentType();
1347 +  
1348 +  allMol = 0;
1349 +  localMol = 0;
1350 +  local_atoms = 0;
1351 +  local_bonds = 0;
1352 +  local_bends = 0;
1353 +  local_torsions = 0;
1354 +  globalAtomIndex = 0;
1355 +
1356 +
1357 +  for( i=0; i<n_components; i++ ){
1358 +
1359 +    for( j=0; j<components_nmol[i]; j++ ){
1360 +      
1361 +      if( mol2proc[allMol] == worldRank ){
1362 +        
1363 +        local_atoms +=    comp_stamps[i]->getNAtoms();
1364 +        local_bonds +=    comp_stamps[i]->getNBonds();
1365 +        local_bends +=    comp_stamps[i]->getNBends();
1366 +        local_torsions += comp_stamps[i]->getNTorsions();
1367 +        localMol++;
1368 +      }      
1369 +      for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
1370 +        info->molMembershipArray[globalAtomIndex] = allMol;
1371 +        globalAtomIndex++;
1372 +      }
1373 +
1374 +      allMol++;      
1375 +    }
1376 +  }
1377 +  local_SRI = local_bonds + local_bends + local_torsions;
1378 +  
1379 +  info->n_atoms = mpiSim->getMyNlocal();  
1380 +  
1381 +  if( local_atoms != info->n_atoms ){
1382 +    sprintf( painCave.errMsg,
1383 +             "SimSetup error: mpiSim's localAtom (%d) and SimSetup's"
1384 +             " localAtom (%d) are not equal.\n",
1385 +             info->n_atoms,
1386 +             local_atoms );
1387 +    painCave.isFatal = 1;
1388 +    simError();
1389 +  }
1390 +
1391 +  info->n_bonds = local_bonds;
1392 +  info->n_bends = local_bends;
1393 +  info->n_torsions = local_torsions;
1394 +  info->n_SRI = local_SRI;
1395 +  info->n_mol = localMol;
1396 +
1397 +  strcpy( checkPointMsg, "Passed nlocal consistency check." );
1398 +  MPIcheckPoint();
1399 + }
1400 +  
1401 + #endif // is_mpi
1402 +
1403 +
1404 + void SimSetup::makeSysArrays( void ){
1405 +
1406 +  // create the atom and short range interaction arrays
1407 +
1408 +  Atom::createArrays(info->n_atoms);
1409 +  the_atoms = new Atom*[info->n_atoms];
1410 +  the_molecules = new Molecule[info->n_mol];
1411 +  int molIndex;
1412 +
1413 +  // initialize the molecule's stampID's
1414 +
1415 + #ifdef IS_MPI
1416 +  
1417 +
1418 +  molIndex = 0;
1419 +  for(i=0; i<mpiSim->getTotNmol(); i++){
1420 +    
1421 +    if(mol2proc[i] == worldRank ){
1422 +      the_molecules[molIndex].setStampID( molCompType[i] );
1423 +      the_molecules[molIndex].setMyIndex( molIndex );
1424 +      the_molecules[molIndex].setGlobalIndex( i );
1425 +      molIndex++;
1426 +    }
1427 +  }
1428 +
1429 + #else // is_mpi
1430 +  
1431 +  molIndex = 0;
1432 +  globalAtomIndex = 0;
1433 +  for(i=0; i<n_components; i++){
1434 +    for(j=0; j<components_nmol[i]; j++ ){
1435 +      the_molecules[molIndex].setStampID( i );
1436 +      the_molecules[molIndex].setMyIndex( molIndex );
1437 +      the_molecules[molIndex].setGlobalIndex( molIndex );
1438 +      for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
1439 +        info->molMembershipArray[globalAtomIndex] = molIndex;
1440 +        globalAtomIndex++;
1441 +      }
1442 +      molIndex++;
1443 +    }
1444 +  }
1445 +    
1446 +
1447 + #endif // is_mpi
1448 +
1449 +
1450 +  if( info->n_SRI ){
1451 +    
1452 +    Exclude::createArray(info->n_SRI);
1453 +    the_excludes = new Exclude*[info->n_SRI];
1454 +    for( int ex=0; ex<info->n_SRI; ex++) the_excludes[ex] = new Exclude(ex);
1455 +    info->globalExcludes = new int;
1456 +    info->n_exclude = info->n_SRI;
1457 +  }
1458 +  else{
1459 +    
1460 +    Exclude::createArray( 1 );
1461 +    the_excludes = new Exclude*;
1462 +    the_excludes[0] = new Exclude(0);
1463 +    the_excludes[0]->setPair( 0,0 );
1464 +    info->globalExcludes = new int;
1465 +    info->globalExcludes[0] = 0;
1466 +    info->n_exclude = 0;
1467 +  }
1468 +
1469 +  // set the arrays into the SimInfo object
1470 +
1471 +  info->atoms = the_atoms;
1472 +  info->molecules = the_molecules;
1473 +  info->nGlobalExcludes = 0;
1474 +  info->excludes = the_excludes;
1475 +
1476 +  the_ff->setSimInfo( info );
1477 +
1478 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines