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

Comparing trunk/mdtools/interface_implementation/SimSetup.cpp (file contents):
Revision 176 by mmeineke, Thu Nov 14 22:00:44 2002 UTC vs.
Revision 195 by chuckv, Thu Dec 5 18:53:40 2002 UTC

# Line 119 | Line 119 | void SimSetup::createSim( void ){
119  
120        if( !the_components[i]->haveNMol() ){
121          // we have a problem
122 <        std::cerr << "SimSetup Error. No global NMol or component NMol"
123 <                  << " given. Cannot calculate the number of atoms.\n";
124 <        exit( 8 );
122 >        sprintf( painCave.errMsg,
123 >                 "SimSetup Error. No global NMol or component NMol"
124 >                 " given. Cannot calculate the number of atoms.\n" );
125 >        painCave.isFatal = 1;
126 >        simError();
127        }
128  
129        tot_nmol += the_components[i]->getNMol();
# Line 129 | Line 131 | void SimSetup::createSim( void ){
131      }
132    }
133    else{
134 <    std::cerr << "NOT A SUPPORTED FEATURE\n";
135 <
136 < //     tot_nmol = the_globals->getNMol();
137 <
138 < //     //we have the total number of molecules, now we check for molfractions
139 < //     for( i=0; i<n_components; i++ ){
140 <
141 < //       if( !the_components[i]->haveMolFraction() ){
142 <
143 < //      if( !the_components[i]->haveNMol() ){
144 < //        //we have a problem
145 < //        std::cerr << "SimSetup error. Neither molFraction nor "
146 < //                  << " nMol was given in component
147 <
134 >    sprintf( painCave.errMsg,
135 >             "SimSetup error.\n"
136 >             "\tSorry, the ability to specify total"
137 >             " nMols and then give molfractions in the components\n"
138 >             "\tis not currently supported."
139 >             " Please give nMol in the components.\n" );
140 >    painCave.isFatal = 1;
141 >    simError();
142 >    
143 >    
144 >    //     tot_nmol = the_globals->getNMol();
145 >    
146 >    //   //we have the total number of molecules, now we check for molfractions
147 >    //     for( i=0; i<n_components; i++ ){
148 >    
149 >    //       if( !the_components[i]->haveMolFraction() ){
150 >    
151 >    //  if( !the_components[i]->haveNMol() ){
152 >    //    //we have a problem
153 >    //    std::cerr << "SimSetup error. Neither molFraction nor "
154 >    //              << " nMol was given in component
155 >    
156    }
157  
158 + #ifdef IS_MPI
159 +  strcpy( checkPointMsg, "Have the number of components" );
160 +  MPIcheckPoint();
161 + #endif // is_mpi
162 +
163    // make an array of molecule stamps that match the components used.
164  
165    for( i=0; i<n_components; i++ ){
# Line 176 | Line 191 | void SimSetup::createSim( void ){
191    simnfo->n_bends = tot_bends;
192    simnfo->n_torsions = tot_torsions;
193    simnfo->n_SRI = tot_SRI;
194 +  simnfo->n_mol = tot_nmol;
195  
196 +  
197 + #ifdef IS_MPI
198 +
199 +  // divide the molecules among processors here.
200 +  
201 +  new mpiSimulation( simnfo );
202 +  
203 +  simnfo->mpiSim->divideLabor( n_components, comp_stamps, components_nmol );
204 +
205 + #endif // is_mpi
206 +  
207 +
208    // create the atom and short range interaction arrays
209  
210 <  the_atoms = new Atom*[tot_atoms];
211 <  Atom::createArrays(tot_atoms);
212 <  the_molecules = new Molecule[tot_nmol];
210 >  Atom::createArrays(simnfo->n_atoms);
211 >  the_atoms = new Atom*[simnfo->n_atoms];
212 >  the_molecules = new Molecule[simnfo->n_mol];
213  
214  
215 <  if( tot_SRI ){
216 <    the_sris = new SRI*[tot_SRI];
217 <    the_excludes = new ex_pair[tot_SRI];
215 >  if( simnfo->n_SRI ){
216 >    the_sris = new SRI*[simnfo->n_SRI];
217 >    the_excludes = new ex_pair[simnfo->n_SRI];
218    }
219  
220    // set the arrays into the SimInfo object
# Line 215 | Line 243 | void SimSetup::createSim( void ){
243      makeTorsions();
244    }
245  
218  //  makeMolecules();
246  
247    // get some of the tricky things that may still be in the globals
248  
249    if( simnfo->n_dipoles ){
250  
251      if( !the_globals->haveRRF() ){
252 <      std::cerr << "SimSetup Error, system has dipoles, but no rRF was set.\n";
253 <      exit(8);
252 >      sprintf( painCave.errMsg,
253 >               "SimSetup Error, system has dipoles, but no rRF was set.\n");
254 >      painCave.isFatal = 1;
255 >      simError();
256      }
257      if( !the_globals->haveDielectric() ){
258 <      std::cerr << "SimSetup Error, system has dipoles, but no"
259 <                << " dielectric was set.\n";
260 <      exit(8);
258 >      sprintf( painCave.errMsg,
259 >               "SimSetup Error, system has dipoles, but no"
260 >               " dielectric was set.\n" );
261 >      painCave.isFatal = 1;
262 >      simError();
263      }
264  
265      simnfo->rRF        = the_globals->getRRF();
266      simnfo->dielectric = the_globals->getDielectric();
267    }
268  
269 + #ifdef IS_MPI
270 +  strcpy( checkPointMsg, "rRf and dielectric check out" );
271 +  MPIcheckPoint();
272 + #endif // is_mpi
273 +  
274    if( the_globals->haveBox() ){
275      simnfo->box_x = the_globals->getBox();
276      simnfo->box_y = the_globals->getBox();
# Line 250 | Line 286 | void SimSetup::createSim( void ){
286    }
287    else{
288      if( !the_globals->haveBoxX() ){
289 <      std::cerr << "SimSetup error, no periodic BoxX size given.\n";
290 <      exit(8);
289 >      sprintf( painCave.errMsg,
290 >               "SimSetup error, no periodic BoxX size given.\n" );
291 >      painCave.isFatal = 1;
292 >      simError();
293      }
294      simnfo->box_x = the_globals->getBoxX();
295  
296      if( !the_globals->haveBoxY() ){
297 <      std::cerr << "SimSetup error, no periodic BoxY size given.\n";
298 <      exit(8);
297 >      sprintf( painCave.errMsg,
298 >               "SimSetup error, no periodic BoxY size given.\n" );
299 >      painCave.isFatal = 1;
300 >      simError();
301      }
302      simnfo->box_y = the_globals->getBoxY();
303  
304      if( !the_globals->haveBoxZ() ){
305 <      std::cerr << "SimSetup error, no periodic BoxZ size given.\n";
306 <      exit(8);
305 >      sprintf( painCave.errMsg,
306 >               "SimSetup error, no periodic BoxZ size given.\n" );
307 >      painCave.isFatal = 1;
308 >      simError();
309      }
310      simnfo->box_z = the_globals->getBoxZ();
311    }
312  
313 + #ifdef IS_MPI
314 +  strcpy( checkPointMsg, "Box size set up" );
315 +  MPIcheckPoint();
316 + #endif // is_mpi
317  
318 +
319 +
320   //   if( the_globals->haveInitialConfig() ){
321   //        InitializeFromFile* fileInit;
322   //     fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
# Line 279 | Line 327 | void SimSetup::createSim( void ){
327   //   }
328   //   else{
329  
330 <    initFromBass();
330 > #ifdef IS_MPI
331  
332 +  // no init from bass
333 +  
334 +  sprintf( painCave.errMsg,
335 +           "Cannot intialize a parallel simulation without an initial configuration file.\n" );
336 +  painCave.isFatal;
337 +  simError();
338 +  
339 + #else
340  
341 < //   }
341 >  initFromBass();
342  
343 < //   if( the_globals->haveFinalConfig() ){
344 < //     strcpy( simnfo->finalName, the_globals->getFinalConfig() );
345 < //   }
346 < //   else{
347 < //     strcpy( simnfo->finalName, inFileName );
348 < //     char* endTest;
293 < //     int nameLength = strlen( simnfo->finalName );
294 < //     endTest = &(simnfo->finalName[nameLength - 5]);
295 < //     if( !strcmp( endTest, ".bass" ) ){
296 < //       strcpy( endTest, ".eor" );
297 < //     }
298 < //     else if( !strcmp( endTest, ".BASS" ) ){
299 < //       strcpy( endTest, ".eor" );
300 < //     }
301 < //     else{
302 < //       endTest = &(simnfo->finalName[nameLength - 4]);
303 < //       if( !strcmp( endTest, ".bss" ) ){
304 < //      strcpy( endTest, ".eor" );
305 < //       }
306 < //       else if( !strcmp( endTest, ".mdl" ) ){
307 < //      strcpy( endTest, ".eor" );
308 < //       }
309 < //       else{
310 < //      strcat( simnfo->finalName, ".eor" );
311 < //       }
312 < //     }
313 < //   }
314 <
315 < //   // make the sample and status out names
316 <
317 < //   strcpy( simnfo->sampleName, inFileName );
318 < //   char* endTest;
319 < //   int nameLength = strlen( simnfo->sampleName );
320 < //   endTest = &(simnfo->sampleName[nameLength - 5]);
321 < //   if( !strcmp( endTest, ".bass" ) ){
322 < //     strcpy( endTest, ".dump" );
323 < //   }
324 < //   else if( !strcmp( endTest, ".BASS" ) ){
325 < //     strcpy( endTest, ".dump" );
326 < //   }
327 < //   else{
328 < //     endTest = &(simnfo->sampleName[nameLength - 4]);
329 < //     if( !strcmp( endTest, ".bss" ) ){
330 < //       strcpy( endTest, ".dump" );
331 < //     }
332 < //     else if( !strcmp( endTest, ".mdl" ) ){
333 < //       strcpy( endTest, ".dump" );
334 < //     }
335 < //     else{
336 < //       strcat( simnfo->sampleName, ".dump" );
337 < //     }
338 < //   }
343 > #endif // is_mpi
344 >
345 > #ifdef IS_MPI
346 >  strcpy( checkPointMsg, "Successfully read in the initial configuration" );
347 >  MPIcheckPoint();
348 > #endif // is_mpi
349  
340 //   strcpy( simnfo->statusName, inFileName );
341 //   nameLength = strlen( simnfo->statusName );
342 //   endTest = &(simnfo->statusName[nameLength - 5]);
343 //   if( !strcmp( endTest, ".bass" ) ){
344 //     strcpy( endTest, ".stat" );
345 //   }
346 //   else if( !strcmp( endTest, ".BASS" ) ){
347 //     strcpy( endTest, ".stat" );
348 //   }
349 //   else{
350 //     endTest = &(simnfo->statusName[nameLength - 4]);
351 //     if( !strcmp( endTest, ".bss" ) ){
352 //       strcpy( endTest, ".stat" );
353 //     }
354 //     else if( !strcmp( endTest, ".mdl" ) ){
355 //       strcpy( endTest, ".stat" );
356 //     }
357 //     else{
358 //       strcat( simnfo->statusName, ".stat" );
359 //     }
360 //   }
350  
351 <
351 >  
352 >
353 >  
354 >  //   }
355 >  
356 > #ifdef IS_MPI
357 >  if( worldRank == 0 ){
358 > #endif // is_mpi
359 >    
360 >    if( the_globals->haveFinalConfig() ){
361 >      strcpy( simnfo->finalName, the_globals->getFinalConfig() );
362 >    }
363 >    else{
364 >      strcpy( simnfo->finalName, inFileName );
365 >      char* endTest;
366 >      int nameLength = strlen( simnfo->finalName );
367 >      endTest = &(simnfo->finalName[nameLength - 5]);
368 >      if( !strcmp( endTest, ".bass" ) ){
369 >        strcpy( endTest, ".eor" );
370 >      }
371 >      else if( !strcmp( endTest, ".BASS" ) ){
372 >        strcpy( endTest, ".eor" );
373 >      }
374 >      else{
375 >        endTest = &(simnfo->finalName[nameLength - 4]);
376 >        if( !strcmp( endTest, ".bss" ) ){
377 >          strcpy( endTest, ".eor" );
378 >        }
379 >        else if( !strcmp( endTest, ".mdl" ) ){
380 >          strcpy( endTest, ".eor" );
381 >        }
382 >        else{
383 >          strcat( simnfo->finalName, ".eor" );
384 >        }
385 >      }
386 >    }
387 >    
388 >    // make the sample and status out names
389 >    
390 >    strcpy( simnfo->sampleName, inFileName );
391 >    char* endTest;
392 >    int nameLength = strlen( simnfo->sampleName );
393 >    endTest = &(simnfo->sampleName[nameLength - 5]);
394 >    if( !strcmp( endTest, ".bass" ) ){
395 >      strcpy( endTest, ".dump" );
396 >    }
397 >    else if( !strcmp( endTest, ".BASS" ) ){
398 >      strcpy( endTest, ".dump" );
399 >    }
400 >    else{
401 >      endTest = &(simnfo->sampleName[nameLength - 4]);
402 >      if( !strcmp( endTest, ".bss" ) ){
403 >        strcpy( endTest, ".dump" );
404 >      }
405 >      else if( !strcmp( endTest, ".mdl" ) ){
406 >        strcpy( endTest, ".dump" );
407 >      }
408 >      else{
409 >        strcat( simnfo->sampleName, ".dump" );
410 >      }
411 >    }
412 >    
413 >    strcpy( simnfo->statusName, inFileName );
414 >    nameLength = strlen( simnfo->statusName );
415 >    endTest = &(simnfo->statusName[nameLength - 5]);
416 >    if( !strcmp( endTest, ".bass" ) ){
417 >      strcpy( endTest, ".stat" );
418 >    }
419 >    else if( !strcmp( endTest, ".BASS" ) ){
420 >      strcpy( endTest, ".stat" );
421 >    }
422 >    else{
423 >      endTest = &(simnfo->statusName[nameLength - 4]);
424 >      if( !strcmp( endTest, ".bss" ) ){
425 >        strcpy( endTest, ".stat" );
426 >      }
427 >      else if( !strcmp( endTest, ".mdl" ) ){
428 >        strcpy( endTest, ".stat" );
429 >      }
430 >      else{
431 >        strcat( simnfo->statusName, ".stat" );
432 >      }
433 >    }
434 >    
435 > #ifdef IS_MPI
436 >  }
437 > #endif // is_mpi
438 >  
439    // set the status, sample, and themal kick times
440 <
440 >  
441    if( the_globals->haveSampleTime() ){
442      simnfo->sampleTime = the_globals->getSampleTime();
443      simnfo->statusTime = simnfo->sampleTime;
# Line 584 | Line 660 | void SimSetup::initFromBass( void ){
660      n_per_extra = (int)ceil( temp1 );
661  
662      if( n_per_extra > 4){
663 <      std::cerr << "THere has been an error in constructing the non-complete lattice.\n";
664 <      exit(8);
663 >      sprintf( painCave.errMsg,
664 >               "SimSetup error. There has been an error in constructing"
665 >               " the non-complete lattice.\n" );
666 >      painCave.isFatal = 1;
667 >      simError();
668      }
669    }
670    else{
# Line 690 | Line 769 | void SimSetup::makeElement( double x, double y, double
769  
770      current_atom = comp_stamps[current_comp]->getAtom( k );
771      if( !current_atom->havePosition() ){
772 <      std::cerr << "Component " << comp_stamps[current_comp]->getID()
773 <                << ", atom " << current_atom->getType()
774 <                << " does not have a position specified.\n"
775 <                << "The initialization routine is unable to give a start"
776 <                << " position.\n";
777 <      exit(8);
772 >      sprintf( painCave.errMsg,
773 >               "SimSetup:initFromBass error.\n"
774 >               "\tComponent %s, atom %s does not have a position specified.\n"
775 >               "\tThe initialization routine is unable to give a start"
776 >               " position.\n",
777 >               comp_stamps[current_comp]->getID(),
778 >               current_atom->getType() );
779 >      painCave.isFatal = 1;
780 >      simError();
781      }
782  
783      the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines