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 661 by tim, Fri Aug 1 16:18:13 2003 UTC vs.
Revision 670 by mmeineke, Thu Aug 7 21:47:18 2003 UTC

# Line 59 | Line 59 | void SimSetup::setSimInfo( SimInfo* the_info, int theN
59      info = the_info;
60      nInfo = theNinfo;
61      isInfoArray = 1;
62 <  }
62 > }
63  
64  
65   void SimSetup::parseFile( char* fileName ){
# Line 97 | Line 97 | void SimSetup::createSim( void ){
97  
98   #endif // is_mpi
99  
100 < void SimSetup::createSim( void ){
100 > void SimSetup::createSim(void){
101  
102    int i, j, k, globalAtomIndex;
103    
# Line 115 | Line 115 | void SimSetup::createSim( void ){
115  
116    // initialize the system coordinates
117  
118 <  initSystemCoords();
119 <  
118 >  if( !isInfoArray ) initSystemCoords();  
119  
120    // make the output filenames
121  
# Line 141 | Line 140 | void SimSetup::makeMolecules( void ){
140  
141   void SimSetup::makeMolecules( void ){
142  
143 +  int k,l;
144    int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset;
145    molInit molInfo;
146    DirectionalAtom* dAtom;
# Line 165 | Line 165 | void SimSetup::makeMolecules( void ){
165  
166    double ux, uy, uz, u, uSqr;
167    
168 <  atomOffset = 0;
169 <  excludeOffset = 0;
170 <  for(i=0; i<info->n_mol; i++){
168 >  for(k=0; k<nInfo; k++){
169      
170 <    stampID = the_molecules[i].getStampID();
170 >    the_ff->setSimInfo( &(info[k]) );
171  
172 <    molInfo.nAtoms    = comp_stamps[stampID]->getNAtoms();
173 <    molInfo.nBonds    = comp_stamps[stampID]->getNBonds();
174 <    molInfo.nBends    = comp_stamps[stampID]->getNBends();
175 <    molInfo.nTorsions = comp_stamps[stampID]->getNTorsions();
176 <    molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions;
172 >    atomOffset = 0;
173 >    excludeOffset = 0;
174 >    for(i=0; i<info[k].n_mol; i++){
175 >    
176 >      stampID = info[k].molecules[i].getStampID();
177  
178 <    molInfo.myAtoms = &the_atoms[atomOffset];
179 <    molInfo.myExcludes = &the_excludes[excludeOffset];
180 <    molInfo.myBonds = new Bond*[molInfo.nBonds];
181 <    molInfo.myBends = new Bend*[molInfo.nBends];
182 <    molInfo.myTorsions = new Torsion*[molInfo.nTorsions];
178 >      molInfo.nAtoms    = comp_stamps[stampID]->getNAtoms();
179 >      molInfo.nBonds    = comp_stamps[stampID]->getNBonds();
180 >      molInfo.nBends    = comp_stamps[stampID]->getNBends();
181 >      molInfo.nTorsions = comp_stamps[stampID]->getNTorsions();
182 >      molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions;
183 >      
184 >      molInfo.myAtoms = &(info[k].atoms[atomOffset]);
185 >      molInfo.myExcludes = &(info[k].excludes[excludeOffset]);
186 >      molInfo.myBonds = new Bond*[molInfo.nBonds];
187 >      molInfo.myBends = new Bend*[molInfo.nBends];
188 >      molInfo.myTorsions = new Torsion*[molInfo.nTorsions];
189  
190 <    theBonds = new bond_pair[molInfo.nBonds];
191 <    theBends = new bend_set[molInfo.nBends];
192 <    theTorsions = new torsion_set[molInfo.nTorsions];
190 >      theBonds = new bond_pair[molInfo.nBonds];
191 >      theBends = new bend_set[molInfo.nBends];
192 >      theTorsions = new torsion_set[molInfo.nTorsions];
193      
194 <    // make the Atoms
194 >      // make the Atoms
195      
196 <    for(j=0; j<molInfo.nAtoms; j++){
193 <      
194 <      currentAtom = comp_stamps[stampID]->getAtom( j );
195 <      if( currentAtom->haveOrientation() ){
196 >      for(j=0; j<molInfo.nAtoms; j++){
197          
198 <        dAtom = new DirectionalAtom(j + atomOffset);
199 <        info->n_oriented++;
200 <        molInfo.myAtoms[j] = dAtom;
201 <        
202 <        ux = currentAtom->getOrntX();
203 <        uy = currentAtom->getOrntY();
204 <        uz = currentAtom->getOrntZ();
205 <        
206 <        uSqr = (ux * ux) + (uy * uy) + (uz * uz);
207 <        
208 <        u = sqrt( uSqr );
209 <        ux = ux / u;
210 <        uy = uy / u;
211 <        uz = uz / u;
212 <        
213 <        dAtom->setSUx( ux );
214 <        dAtom->setSUy( uy );
215 <        dAtom->setSUz( uz );
216 <      }
217 <      else{
218 <        molInfo.myAtoms[j] = new GeneralAtom(j + atomOffset);
219 <      }
220 <      molInfo.myAtoms[j]->setType( currentAtom->getType() );
198 >        currentAtom = comp_stamps[stampID]->getAtom( j );
199 >        if( currentAtom->haveOrientation() ){
200 >          
201 >          dAtom = new DirectionalAtom( (j + atomOffset),
202 >                                       info[k].getConfiguration() );
203 >          info[k].n_oriented++;
204 >          molInfo.myAtoms[j] = dAtom;
205 >          
206 >          ux = currentAtom->getOrntX();
207 >          uy = currentAtom->getOrntY();
208 >          uz = currentAtom->getOrntZ();
209 >          
210 >          uSqr = (ux * ux) + (uy * uy) + (uz * uz);
211 >          
212 >          u = sqrt( uSqr );
213 >          ux = ux / u;
214 >          uy = uy / u;
215 >          uz = uz / u;
216 >          
217 >          dAtom->setSUx( ux );
218 >          dAtom->setSUy( uy );
219 >          dAtom->setSUz( uz );
220 >        }
221 >        else{
222 >          molInfo.myAtoms[j] = new GeneralAtom( (j + atomOffset),
223 >                                                info[k].getConfiguration() );
224 >        }
225 >        molInfo.myAtoms[j]->setType( currentAtom->getType() );
226      
227   #ifdef IS_MPI
228        
229 <      molInfo.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] );
229 >        molInfo.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] );
230        
231   #endif // is_mpi
232 <    }
232 >      }
233      
234      // make the bonds
235 <    for(j=0; j<molInfo.nBonds; j++){
235 >      for(j=0; j<molInfo.nBonds; j++){
236        
237 <      currentBond = comp_stamps[stampID]->getBond( j );
238 <      theBonds[j].a = currentBond->getA() + atomOffset;
239 <      theBonds[j].b = currentBond->getB() + atomOffset;
240 <
241 <      exI = theBonds[j].a;
242 <      exJ = theBonds[j].b;
243 <
244 <      // exclude_I must always be the smaller of the pair
245 <      if( exI > exJ ){
246 <        tempEx = exI;
247 <        exI = exJ;
248 <        exJ = tempEx;
249 <      }
237 >        currentBond = comp_stamps[stampID]->getBond( j );
238 >        theBonds[j].a = currentBond->getA() + atomOffset;
239 >        theBonds[j].b = currentBond->getB() + atomOffset;
240 >        
241 >        exI = theBonds[j].a;
242 >        exJ = theBonds[j].b;
243 >        
244 >        // exclude_I must always be the smaller of the pair
245 >        if( exI > exJ ){
246 >          tempEx = exI;
247 >          exI = exJ;
248 >          exJ = tempEx;
249 >        }
250   #ifdef IS_MPI
251 <      tempEx = exI;
252 <      exI = the_atoms[tempEx]->getGlobalIndex() + 1;
253 <      tempEx = exJ;
254 <      exJ = the_atoms[tempEx]->getGlobalIndex() + 1;
255 <      
256 <      the_excludes[j+excludeOffset]->setPair( exI, exJ );
257 < #else  // isn't MPI
258 <
259 <      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
251 >        tempEx = exI;
252 >        exI = info[k].atoms[tempEx]->getGlobalIndex() + 1;
253 >        tempEx = exJ;
254 >        exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1;
255 >        
256 >        info[k].excludes[j+excludeOffset]->setPair( exI, exJ );
257 > #else  // isn't MPI
258 >        
259 >        info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
260   #endif  //is_mpi
261 <    }
262 <    excludeOffset += molInfo.nBonds;
257 <
258 <    //make the bends
259 <    for(j=0; j<molInfo.nBends; j++){
261 >      }
262 >      excludeOffset += molInfo.nBonds;
263        
264 <      currentBend = comp_stamps[stampID]->getBend( j );
265 <      theBends[j].a = currentBend->getA() + atomOffset;
266 <      theBends[j].b = currentBend->getB() + atomOffset;
267 <      theBends[j].c = currentBend->getC() + atomOffset;
264 >      //make the bends
265 >      for(j=0; j<molInfo.nBends; j++){
266 >        
267 >        currentBend = comp_stamps[stampID]->getBend( j );
268 >        theBends[j].a = currentBend->getA() + atomOffset;
269 >        theBends[j].b = currentBend->getB() + atomOffset;
270 >        theBends[j].c = currentBend->getC() + atomOffset;
271 >        
272 >        if( currentBend->haveExtras() ){
273            
274 <      if( currentBend->haveExtras() ){
275 <            
276 <        extras = currentBend->getExtras();
277 <        current_extra = extras;
278 <            
279 <        while( current_extra != NULL ){
280 <          if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){
274 >          extras = currentBend->getExtras();
275 >          current_extra = extras;
276 >          
277 >          while( current_extra != NULL ){
278 >            if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){
279 >              
280 >              switch( current_extra->getType() ){
281                  
282 <            switch( current_extra->getType() ){
282 >              case 0:
283 >                theBends[j].ghost =
284 >                  current_extra->getInt() + atomOffset;
285 >                theBends[j].isGhost = 1;
286 >                break;
287 >                
288 >              case 1:
289 >                theBends[j].ghost =
290 >                  (int)current_extra->getDouble() + atomOffset;
291 >                theBends[j].isGhost = 1;
292 >                break;
293 >                
294 >              default:
295 >                sprintf( painCave.errMsg,
296 >                         "SimSetup Error: ghostVectorSource was neither a "
297 >                         "double nor an int.\n"
298 >                         "-->Bend[%d] in %s\n",
299 >                         j, comp_stamps[stampID]->getID() );
300 >                painCave.isFatal = 1;
301 >                simError();
302 >              }
303 >            }
304 >            
305 >            else{
306                
276            case 0:
277              theBends[j].ghost =
278                current_extra->getInt() + atomOffset;
279              theBends[j].isGhost = 1;
280              break;
281                  
282            case 1:
283              theBends[j].ghost =
284                (int)current_extra->getDouble() + atomOffset;
285              theBends[j].isGhost = 1;
286              break;
287              
288            default:
307                sprintf( painCave.errMsg,
308 <                       "SimSetup Error: ghostVectorSource was neither a "
309 <                       "double nor an int.\n"
310 <                       "-->Bend[%d] in %s\n",
308 >                       "SimSetup Error: unhandled bend assignment:\n"
309 >                       "    -->%s in Bend[%d] in %s\n",
310 >                       current_extra->getlhs(),
311                         j, comp_stamps[stampID]->getID() );
312                painCave.isFatal = 1;
313                simError();
314              }
297          }
298          
299          else{
315              
316 <            sprintf( painCave.errMsg,
302 <                     "SimSetup Error: unhandled bend assignment:\n"
303 <                     "    -->%s in Bend[%d] in %s\n",
304 <                     current_extra->getlhs(),
305 <                     j, comp_stamps[stampID]->getID() );
306 <            painCave.isFatal = 1;
307 <            simError();
316 >            current_extra = current_extra->getNext();
317            }
318 +        }
319 +        
320 +        if( !theBends[j].isGhost ){
321            
322 <          current_extra = current_extra->getNext();
322 >          exI = theBends[j].a;
323 >          exJ = theBends[j].c;
324          }
325 <      }
325 >        else{
326            
327 <      if( !theBends[j].isGhost ){
328 <            
329 <        exI = theBends[j].a;
317 <        exJ = theBends[j].c;
318 <      }
319 <      else{
327 >          exI = theBends[j].a;
328 >          exJ = theBends[j].b;
329 >        }
330          
331 <        exI = theBends[j].a;
332 <        exJ = theBends[j].b;
333 <      }
334 <      
335 <      // exclude_I must always be the smaller of the pair
336 <      if( exI > exJ ){
327 <        tempEx = exI;
328 <        exI = exJ;
329 <        exJ = tempEx;
330 <      }
331 >        // exclude_I must always be the smaller of the pair
332 >        if( exI > exJ ){
333 >          tempEx = exI;
334 >          exI = exJ;
335 >          exJ = tempEx;
336 >        }
337   #ifdef IS_MPI
338 <      tempEx = exI;
339 <      exI = the_atoms[tempEx]->getGlobalIndex() + 1;
340 <      tempEx = exJ;
341 <      exJ = the_atoms[tempEx]->getGlobalIndex() + 1;
338 >        tempEx = exI;
339 >        exI = info[k].atoms[tempEx]->getGlobalIndex() + 1;
340 >        tempEx = exJ;
341 >        exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1;
342        
343 <      the_excludes[j+excludeOffset]->setPair( exI, exJ );
343 >        info[k].excludes[j+excludeOffset]->setPair( exI, exJ );
344   #else  // isn't MPI
345 <      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
345 >        info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
346   #endif  //is_mpi
341    }
342    excludeOffset += molInfo.nBends;
343
344    for(j=0; j<molInfo.nTorsions; j++){
345      
346      currentTorsion = comp_stamps[stampID]->getTorsion( j );
347      theTorsions[j].a = currentTorsion->getA() + atomOffset;
348      theTorsions[j].b = currentTorsion->getB() + atomOffset;
349      theTorsions[j].c = currentTorsion->getC() + atomOffset;
350      theTorsions[j].d = currentTorsion->getD() + atomOffset;
351      
352      exI = theTorsions[j].a;
353      exJ = theTorsions[j].d;
354
355      // exclude_I must always be the smaller of the pair
356      if( exI > exJ ){
357        tempEx = exI;
358        exI = exJ;
359        exJ = tempEx;
347        }
348 < #ifdef IS_MPI
362 <      tempEx = exI;
363 <      exI = the_atoms[tempEx]->getGlobalIndex() + 1;
364 <      tempEx = exJ;
365 <      exJ = the_atoms[tempEx]->getGlobalIndex() + 1;
348 >      excludeOffset += molInfo.nBends;
349        
350 <      the_excludes[j+excludeOffset]->setPair( exI, exJ );
350 >      for(j=0; j<molInfo.nTorsions; j++){
351 >        
352 >        currentTorsion = comp_stamps[stampID]->getTorsion( j );
353 >        theTorsions[j].a = currentTorsion->getA() + atomOffset;
354 >        theTorsions[j].b = currentTorsion->getB() + atomOffset;
355 >        theTorsions[j].c = currentTorsion->getC() + atomOffset;
356 >        theTorsions[j].d = currentTorsion->getD() + atomOffset;
357 >        
358 >        exI = theTorsions[j].a;
359 >        exJ = theTorsions[j].d;
360 >        
361 >        // exclude_I must always be the smaller of the pair
362 >        if( exI > exJ ){
363 >          tempEx = exI;
364 >          exI = exJ;
365 >          exJ = tempEx;
366 >        }
367 > #ifdef IS_MPI
368 >        tempEx = exI;
369 >        exI = info[k].atoms[tempEx]->getGlobalIndex() + 1;
370 >        tempEx = exJ;
371 >        exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1;
372 >        
373 >        info[k].excludes[j+excludeOffset]->setPair( exI, exJ );
374   #else  // isn't MPI
375 <      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
375 >        info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
376   #endif  //is_mpi
377 <    }
378 <    excludeOffset += molInfo.nTorsions;
377 >      }
378 >      excludeOffset += molInfo.nTorsions;
379 >      
380 >      
381 >      // send the arrays off to the forceField for init.
382 >      
383 >      the_ff->initializeAtoms( molInfo.nAtoms, molInfo.myAtoms );
384 >      the_ff->initializeBonds( molInfo.nBonds, molInfo.myBonds, theBonds );
385 >      the_ff->initializeBends( molInfo.nBends, molInfo.myBends, theBends );
386 >      the_ff->initializeTorsions( molInfo.nTorsions, molInfo.myTorsions, theTorsions );
387 >      
388 >      
389 >      info[k].molecules[i].initialize( molInfo );
390  
391 <    
392 <    // send the arrays off to the forceField for init.
393 <
394 <    the_ff->initializeAtoms( molInfo.nAtoms, molInfo.myAtoms );
395 <    the_ff->initializeBonds( molInfo.nBonds, molInfo.myBonds, theBonds );
396 <    the_ff->initializeBends( molInfo.nBends, molInfo.myBends, theBends );
380 <    the_ff->initializeTorsions( molInfo.nTorsions, molInfo.myTorsions, theTorsions );
381 <
382 <
383 <    the_molecules[i].initialize( molInfo );
384 <
385 <
386 <    atomOffset += molInfo.nAtoms;
387 <    delete[] theBonds;
388 <    delete[] theBends;
389 <    delete[] theTorsions;
391 >      
392 >      atomOffset += molInfo.nAtoms;
393 >      delete[] theBonds;
394 >      delete[] theBends;
395 >      delete[] theTorsions;
396 >    }
397    }
398 <
398 >  
399   #ifdef IS_MPI
400    sprintf( checkPointMsg, "all molecules initialized succesfully" );
401    MPIcheckPoint();
402   #endif // is_mpi
403 <
403 >  
404    // clean up the forcefield
405 +
406    the_ff->calcRcut();
407    the_ff->cleanMe();
408 <
408 >  
409   }
410  
411   void SimSetup::initFromBass( void ){
# Line 410 | Line 418 | void SimSetup::initFromBass( void ){
418    int n_extra;
419    int have_extra, done;
420  
421 +  double vel[3];
422 +  vel[0] = 0.0;
423 +  vel[1] = 0.0;
424 +  vel[2] = 0.0;
425 +
426    temp1 = (double)tot_nmol / 4.0;
427    temp2 = pow( temp1, ( 1.0 / 3.0 ) );
428    temp3 = ceil( temp2 );
# Line 419 | Line 432 | void SimSetup::initFromBass( void ){
432      have_extra =1;
433  
434      n_cells = (int)temp3 - 1;
435 <    cellx = info->boxL[0] / temp3;
436 <    celly = info->boxL[1] / temp3;
437 <    cellz = info->boxL[2] / temp3;
435 >    cellx = info[0].boxL[0] / temp3;
436 >    celly = info[0].boxL[1] / temp3;
437 >    cellz = info[0].boxL[2] / temp3;
438      n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells );
439      temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) );
440      n_per_extra = (int)ceil( temp1 );
# Line 436 | Line 449 | void SimSetup::initFromBass( void ){
449    }
450    else{
451      n_cells = (int)temp3;
452 <    cellx = info->boxL[0] / temp3;
453 <    celly = info->boxL[1] / temp3;
454 <    cellz = info->boxL[2] / temp3;
452 >    cellx = info[0].boxL[0] / temp3;
453 >    celly = info[0].boxL[1] / temp3;
454 >    cellz = info[0].boxL[2] / temp3;
455    }
456  
457    current_mol = 0;
# Line 517 | Line 530 | void SimSetup::initFromBass( void ){
530      }
531    }
532  
533 <
534 <  for( i=0; i<info->n_atoms; i++ ){
522 <    info->atoms[i]->set_vx( 0.0 );
523 <    info->atoms[i]->set_vy( 0.0 );
524 <    info->atoms[i]->set_vz( 0.0 );
533 >  for( i=0; i<info[0].n_atoms; i++ ){
534 >    info[0].atoms[i]->setVel( vel );
535    }
536   }
537  
# Line 531 | Line 541 | void SimSetup::makeElement( double x, double y, double
541    AtomStamp* current_atom;
542    DirectionalAtom* dAtom;
543    double rotMat[3][3];
544 +  double pos[3];
545  
546    for( k=0; k<comp_stamps[current_comp]->getNAtoms(); k++ ){
547  
# Line 546 | Line 557 | void SimSetup::makeElement( double x, double y, double
557        painCave.isFatal = 1;
558        simError();
559      }
560 +    
561 +    pos[0] = x + current_atom->getPosX();
562 +    pos[1] = y + current_atom->getPosY();
563 +    pos[2] = z + current_atom->getPosZ();
564 +    
565 +    info[0].atoms[current_atom_ndx]->setPos( pos );
566  
567 <    the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() );
551 <    the_atoms[current_atom_ndx]->setY( y + current_atom->getPosY() );
552 <    the_atoms[current_atom_ndx]->setZ( z + current_atom->getPosZ() );
567 >    if( info[0].atoms[current_atom_ndx]->isDirectional() ){
568  
569 <    if( the_atoms[current_atom_ndx]->isDirectional() ){
569 >      dAtom = (DirectionalAtom *)info[0].atoms[current_atom_ndx];
570  
556      dAtom = (DirectionalAtom *)the_atoms[current_atom_ndx];
557
571        rotMat[0][0] = 1.0;
572        rotMat[0][1] = 0.0;
573        rotMat[0][2] = 0.0;
# Line 590 | Line 603 | void SimSetup::gatherInfo( void ){
603    ensembleCase = -1;
604    ffCase = -1;
605  
593  // get the stamps and globals;
594  stamps = stamps;
595  globals = globals;
596
606    // set the easy ones first
607 <  info->target_temp = globals->getTargetTemp();
608 <  info->dt = globals->getDt();
609 <  info->run_time = globals->getRunTime();
607 >
608 >  for( i=0; i<nInfo; i++){
609 >    info[i].target_temp = globals->getTargetTemp();
610 >    info[i].dt = globals->getDt();
611 >    info[i].run_time = globals->getRunTime();
612 >  }
613    n_components = globals->getNComponents();
614  
615  
# Line 646 | Line 658 | void SimSetup::gatherInfo( void ){
658      strcpy( ensemble, "NVE" );
659      ensembleCase = NVE_ENS;
660    }  
661 <  strcpy( info->ensemble, ensemble );
661 >  
662 >  for(i=0; i<nInfo; i++){
663 >    
664 >    strcpy( info[i].ensemble, ensemble );
665  
666 <  // get the mixing rule
666 >    // get the mixing rule
667  
668 <  strcpy( info->mixingRule, globals->getMixingRule() );
669 <  info->usePBC = globals->getPBC();
670 <        
668 >    strcpy( info[i].mixingRule, globals->getMixingRule() );
669 >    info[i].usePBC = globals->getPBC();
670 >  }
671    
672    // get the components and calculate the tot_nMol and indvidual n_mol
673  
# Line 693 | Line 708 | void SimSetup::gatherInfo( void ){
708  
709    // set the status, sample, and thermal kick times
710    
711 <  if( globals->haveSampleTime() ){
697 <    info->sampleTime = globals->getSampleTime();
698 <    info->statusTime = info->sampleTime;
699 <    info->thermalTime = info->sampleTime;
700 <  }
701 <  else{
702 <    info->sampleTime = globals->getRunTime();
703 <    info->statusTime = info->sampleTime;
704 <    info->thermalTime = info->sampleTime;
705 <  }
711 >  for(i=0; i<nInfo; i++){
712  
713 <  if( globals->haveStatusTime() ){
714 <    info->statusTime = globals->getStatusTime();
715 <  }
716 <
717 <  if( globals->haveThermalTime() ){
718 <    info->thermalTime = globals->getThermalTime();
719 <  }
720 <
721 <  // check for the temperature set flag
722 <
717 <  if( globals->haveTempSet() ) info->setTemp = globals->getTempSet();
718 <
719 <  // get some of the tricky things that may still be in the globals
720 <
721 <  double boxVector[3];
722 <  if( globals->haveBox() ){
723 <    boxVector[0] = globals->getBox();
724 <    boxVector[1] = globals->getBox();
725 <    boxVector[2] = globals->getBox();
713 >    if( globals->haveSampleTime() ){
714 >      info[i].sampleTime = globals->getSampleTime();
715 >      info[i].statusTime = info[i].sampleTime;
716 >      info[i].thermalTime = info[i].sampleTime;
717 >    }
718 >    else{
719 >      info[i].sampleTime = globals->getRunTime();
720 >      info[i].statusTime = info[i].sampleTime;
721 >      info[i].thermalTime = info[i].sampleTime;
722 >    }
723      
724 <    info->setBox( boxVector );
725 <  }
726 <  else if( globals->haveDensity() ){
724 >    if( globals->haveStatusTime() ){
725 >      info[i].statusTime = globals->getStatusTime();
726 >    }
727 >    
728 >    if( globals->haveThermalTime() ){
729 >      info[i].thermalTime = globals->getThermalTime();
730 >    }
731  
732 <    double vol;
732 <    vol = (double)tot_nmol / globals->getDensity();
733 <     boxVector[0] = pow( vol, ( 1.0 / 3.0 ) );
734 <     boxVector[1] = boxVector[0];
735 <     boxVector[2] = boxVector[0];
732 >    // check for the temperature set flag
733  
734 <    info->setBox( boxVector );
734 >    if( globals->haveTempSet() ) info[i].setTemp = globals->getTempSet();
735 >    
736 >    // get some of the tricky things that may still be in the globals
737 >    
738 >    double boxVector[3];
739 >    if( globals->haveBox() ){
740 >      boxVector[0] = globals->getBox();
741 >      boxVector[1] = globals->getBox();
742 >      boxVector[2] = globals->getBox();
743 >      
744 >      info[i].setBox( boxVector );
745 >    }
746 >    else if( globals->haveDensity() ){
747 >      
748 >      double vol;
749 >      vol = (double)tot_nmol / globals->getDensity();
750 >      boxVector[0] = pow( vol, ( 1.0 / 3.0 ) );
751 >      boxVector[1] = boxVector[0];
752 >      boxVector[2] = boxVector[0];
753 >      
754 >      info[i].setBox( boxVector );
755    }
756 <  else{
757 <    if( !globals->haveBoxX() ){
758 <      sprintf( painCave.errMsg,
759 <               "SimSetup error, no periodic BoxX size given.\n" );
760 <      painCave.isFatal = 1;
761 <      simError();
756 >    else{
757 >      if( !globals->haveBoxX() ){
758 >        sprintf( painCave.errMsg,
759 >                 "SimSetup error, no periodic BoxX size given.\n" );
760 >        painCave.isFatal = 1;
761 >        simError();
762 >      }
763 >      boxVector[0] = globals->getBoxX();
764 >      
765 >      if( !globals->haveBoxY() ){
766 >        sprintf( painCave.errMsg,
767 >                 "SimSetup error, no periodic BoxY size given.\n" );
768 >        painCave.isFatal = 1;
769 >        simError();
770 >      }
771 >      boxVector[1] = globals->getBoxY();
772 >      
773 >      if( !globals->haveBoxZ() ){
774 >        sprintf( painCave.errMsg,
775 >                 "SimSetup error, no periodic BoxZ size given.\n" );
776 >        painCave.isFatal = 1;
777 >        simError();
778 >      }
779 >      boxVector[2] = globals->getBoxZ();
780 >      
781 >      info[i].setBox( boxVector );
782      }
746    boxVector[0] = globals->getBoxX();
783  
748    if( !globals->haveBoxY() ){
749      sprintf( painCave.errMsg,
750               "SimSetup error, no periodic BoxY size given.\n" );
751      painCave.isFatal = 1;
752      simError();
753    }
754    boxVector[1] = globals->getBoxY();
755
756    if( !globals->haveBoxZ() ){
757      sprintf( painCave.errMsg,
758               "SimSetup error, no periodic BoxZ size given.\n" );
759      painCave.isFatal = 1;
760      simError();
761    }
762    boxVector[2] = globals->getBoxZ();
763
764    info->setBox( boxVector );
784    }
766
767
785      
786   #ifdef IS_MPI
787    strcpy( checkPointMsg, "Succesfully gathered all information from Bass\n" );
# Line 777 | Line 794 | void SimSetup::finalInfoCheck( void ){
794   void SimSetup::finalInfoCheck( void ){
795    int index;
796    int usesDipoles;
797 <  
797 >  int i;
798  
799 <  // check electrostatic parameters
800 <  
784 <  index = 0;
785 <  usesDipoles = 0;
786 <  while( (index < info->n_atoms) && !usesDipoles ){
787 <    usesDipoles = ((info->atoms)[index])->hasDipole();
788 <    index++;
789 <  }
790 <  
791 < #ifdef IS_MPI
792 <  int myUse = usesDipoles;
793 <  MPI_Allreduce( &myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
794 < #endif //is_mpi
795 <
796 <  double theEcr, theEst;
797 <
798 <  if (globals->getUseRF() ) {
799 <    info->useReactionField = 1;
799 >  for(i=0; i<nInfo; i++){
800 >    // check electrostatic parameters
801      
802 <    if( !globals->haveECR() ){
803 <      sprintf( painCave.errMsg,
804 <               "SimSetup Warning: using default value of 1/2 the smallest "
805 <               "box length for the electrostaticCutoffRadius.\n"
806 <               "I hope you have a very fast processor!\n");
806 <      painCave.isFatal = 0;
807 <      simError();
808 <      double smallest;
809 <      smallest = info->boxL[0];
810 <      if (info->boxL[1] <= smallest) smallest = info->boxL[1];
811 <      if (info->boxL[2] <= smallest) smallest = info->boxL[2];
812 <      theEcr = 0.5 * smallest;
813 <    } else {
814 <      theEcr = globals->getECR();
802 >    index = 0;
803 >    usesDipoles = 0;
804 >    while( (index < info[i].n_atoms) && !usesDipoles ){
805 >      usesDipoles = (info[i].atoms[index])->hasDipole();
806 >      index++;
807      }
816
817    if( !globals->haveEST() ){
818      sprintf( painCave.errMsg,
819               "SimSetup Warning: using default value of 0.05 * the "
820               "electrostaticCutoffRadius for the electrostaticSkinThickness\n"
821               );
822      painCave.isFatal = 0;
823      simError();
824      theEst = 0.05 * theEcr;
825    } else {
826      theEst= globals->getEST();
827    }
828
829    info->setEcr( theEcr, theEst );
808      
809 <    if(!globals->haveDielectric() ){
810 <      sprintf( painCave.errMsg,
811 <               "SimSetup Error: You are trying to use Reaction Field without"
812 <               "setting a dielectric constant!\n"
813 <               );
814 <      painCave.isFatal = 1;
815 <      simError();
816 <    }
817 <    info->dielectric = globals->getDielectric();  
840 <  }
841 <  else {
842 <    if (usesDipoles) {
809 > #ifdef IS_MPI
810 >    int myUse = usesDipoles;
811 >    MPI_Allreduce( &myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
812 > #endif //is_mpi
813 >    
814 >    double theEcr, theEst;
815 >  
816 >    if (globals->getUseRF() ) {
817 >      info[i].useReactionField = 1;
818        
819        if( !globals->haveECR() ){
820          sprintf( painCave.errMsg,
# Line 849 | Line 824 | void SimSetup::finalInfoCheck( void ){
824          painCave.isFatal = 0;
825          simError();
826          double smallest;
827 <        smallest = info->boxL[0];
828 <        if (info->boxL[1] <= smallest) smallest = info->boxL[1];
829 <        if (info->boxL[2] <= smallest) smallest = info->boxL[2];
827 >        smallest = info[i].boxL[0];
828 >        if (info[i].boxL[1] <= smallest) smallest = info[i].boxL[1];
829 >        if (info[i].boxL[2] <= smallest) smallest = info[i].boxL[2];
830          theEcr = 0.5 * smallest;
831        } else {
832          theEcr = globals->getECR();
# Line 860 | Line 835 | void SimSetup::finalInfoCheck( void ){
835        if( !globals->haveEST() ){
836          sprintf( painCave.errMsg,
837                   "SimSetup Warning: using default value of 0.05 * the "
838 <                 "electrostaticCutoffRadius for the "
864 <                 "electrostaticSkinThickness\n"
838 >                 "electrostaticCutoffRadius for the electrostaticSkinThickness\n"
839                   );
840          painCave.isFatal = 0;
841          simError();
# Line 869 | Line 843 | void SimSetup::finalInfoCheck( void ){
843        } else {
844          theEst= globals->getEST();
845        }
846 +      
847 +      info[i].setEcr( theEcr, theEst );
848 +      
849 +      if(!globals->haveDielectric() ){
850 +        sprintf( painCave.errMsg,
851 +                 "SimSetup Error: You are trying to use Reaction Field without"
852 +                 "setting a dielectric constant!\n"
853 +                 );
854 +        painCave.isFatal = 1;
855 +        simError();
856 +      }
857 +      info[i].dielectric = globals->getDielectric();  
858 +    }
859 +    else {
860 +      if (usesDipoles) {
861 +        
862 +        if( !globals->haveECR() ){
863 +          sprintf( painCave.errMsg,
864 +                   "SimSetup Warning: using default value of 1/2 the smallest "
865 +                   "box length for the electrostaticCutoffRadius.\n"
866 +                   "I hope you have a very fast processor!\n");
867 +          painCave.isFatal = 0;
868 +          simError();
869 +          double smallest;
870 +          smallest = info[i].boxL[0];
871 +          if (info[i].boxL[1] <= smallest) smallest = info[i].boxL[1];
872 +          if (info[i].boxL[2] <= smallest) smallest = info[i].boxL[2];
873 +          theEcr = 0.5 * smallest;
874 +        } else {
875 +          theEcr = globals->getECR();
876 +        }
877 +        
878 +        if( !globals->haveEST() ){
879 +          sprintf( painCave.errMsg,
880 +                   "SimSetup Warning: using default value of 0.05 * the "
881 +                   "electrostaticCutoffRadius for the "
882 +                   "electrostaticSkinThickness\n"
883 +                   );
884 +          painCave.isFatal = 0;
885 +          simError();
886 +          theEst = 0.05 * theEcr;
887 +        } else {
888 +          theEst= globals->getEST();
889 +        }
890 +        
891 +        info[i].setEcr( theEcr, theEst );
892 +      }
893 +    }  
894 +  }
895  
873      info->setEcr( theEcr, theEst );
874    }
875  }  
876
896   #ifdef IS_MPI
897    strcpy( checkPointMsg, "post processing checks out" );
898    MPIcheckPoint();
# Line 882 | Line 901 | void SimSetup::initSystemCoords( void ){
901   }
902  
903   void SimSetup::initSystemCoords( void ){
904 +  int i;
905 +  
906 +  std::cerr << "Setting atom Coords\n";
907  
908 < if( globals->haveInitialConfig() ){
909 <
910 <     InitializeFromFile* fileInit;
908 >  (info[0].getConfiguration())->createArrays( info[0].n_atoms );
909 >  
910 >  for(i=0; i<info[0].n_atoms; i++) info[0].atoms[i]->setCoords();
911 >  
912 >  if( globals->haveInitialConfig() ){
913 >    
914 >    InitializeFromFile* fileInit;
915   #ifdef IS_MPI // is_mpi
916 <     if( worldRank == 0 ){
916 >    if( worldRank == 0 ){
917   #endif //is_mpi
918 <   fileInit = new InitializeFromFile( globals->getInitialConfig() );
918 >      fileInit = new InitializeFromFile( globals->getInitialConfig() );
919   #ifdef IS_MPI
920 <     }else fileInit = new InitializeFromFile( NULL );
920 >    }else fileInit = new InitializeFromFile( NULL );
921   #endif
922 <   fileInit->readInit( info ); // default velocities on
923 <
924 <   delete fileInit;
925 < }
926 < else{
927 <
922 >    fileInit->readInit( info ); // default velocities on
923 >    
924 >    delete fileInit;
925 >  }
926 >  else{
927 >    
928   #ifdef IS_MPI
929 <
930 <  // no init from bass
931 <  
932 <  sprintf( painCave.errMsg,
933 <           "Cannot intialize a parallel simulation without an initial configuration file.\n" );
934 <  painCave.isFatal;
935 <  simError();
936 <  
929 >    
930 >    // no init from bass
931 >    
932 >    sprintf( painCave.errMsg,
933 >             "Cannot intialize a parallel simulation without an initial configuration file.\n" );
934 >    painCave.isFatal;
935 >    simError();
936 >    
937   #else
938 <
939 <  initFromBass();
940 <
941 <
938 >    
939 >    initFromBass();
940 >    
941 >    
942   #endif
943 < }
944 <
943 >  }
944 >  
945   #ifdef IS_MPI
946    strcpy( checkPointMsg, "Successfully read in the initial configuration" );
947    MPIcheckPoint();
948   #endif // is_mpi
949 <
949 >  
950   }
951  
952  
953   void SimSetup::makeOutNames( void ){
954 +  
955 +  int k;
956  
957 +  
958 +  for(k=0; k<nInfo; k++){
959 +
960   #ifdef IS_MPI
961 <  if( worldRank == 0 ){
961 >    if( worldRank == 0 ){
962   #endif // is_mpi
963 <    
964 <    if( globals->haveFinalConfig() ){
965 <      strcpy( info->finalName, globals->getFinalConfig() );
935 <    }
936 <    else{
937 <      strcpy( info->finalName, inFileName );
938 <      char* endTest;
939 <      int nameLength = strlen( info->finalName );
940 <      endTest = &(info->finalName[nameLength - 5]);
941 <      if( !strcmp( endTest, ".bass" ) ){
942 <        strcpy( endTest, ".eor" );
963 >      
964 >      if( globals->haveFinalConfig() ){
965 >        strcpy( info[k].finalName, globals->getFinalConfig() );
966        }
944      else if( !strcmp( endTest, ".BASS" ) ){
945        strcpy( endTest, ".eor" );
946      }
967        else{
968 <        endTest = &(info->finalName[nameLength - 4]);
969 <        if( !strcmp( endTest, ".bss" ) ){
968 >        strcpy( info[k].finalName, inFileName );
969 >        char* endTest;
970 >        int nameLength = strlen( info[k].finalName );
971 >        endTest = &(info[k].finalName[nameLength - 5]);
972 >        if( !strcmp( endTest, ".bass" ) ){
973            strcpy( endTest, ".eor" );
974          }
975 <        else if( !strcmp( endTest, ".mdl" ) ){
975 >        else if( !strcmp( endTest, ".BASS" ) ){
976            strcpy( endTest, ".eor" );
977          }
978          else{
979 <          strcat( info->finalName, ".eor" );
979 >          endTest = &(info[k].finalName[nameLength - 4]);
980 >          if( !strcmp( endTest, ".bss" ) ){
981 >            strcpy( endTest, ".eor" );
982 >          }
983 >          else if( !strcmp( endTest, ".mdl" ) ){
984 >            strcpy( endTest, ".eor" );
985 >          }
986 >          else{
987 >            strcat( info[k].finalName, ".eor" );
988 >          }
989          }
990        }
991 <    }
992 <    
993 <    // make the sample and status out names
994 <    
995 <    strcpy( info->sampleName, inFileName );
996 <    char* endTest;
997 <    int nameLength = strlen( info->sampleName );
998 <    endTest = &(info->sampleName[nameLength - 5]);
967 <    if( !strcmp( endTest, ".bass" ) ){
968 <      strcpy( endTest, ".dump" );
969 <    }
970 <    else if( !strcmp( endTest, ".BASS" ) ){
971 <      strcpy( endTest, ".dump" );
972 <    }
973 <    else{
974 <      endTest = &(info->sampleName[nameLength - 4]);
975 <      if( !strcmp( endTest, ".bss" ) ){
991 >      
992 >      // make the sample and status out names
993 >      
994 >      strcpy( info[k].sampleName, inFileName );
995 >      char* endTest;
996 >      int nameLength = strlen( info[k].sampleName );
997 >      endTest = &(info[k].sampleName[nameLength - 5]);
998 >      if( !strcmp( endTest, ".bass" ) ){
999          strcpy( endTest, ".dump" );
1000        }
1001 <      else if( !strcmp( endTest, ".mdl" ) ){
1001 >      else if( !strcmp( endTest, ".BASS" ) ){
1002          strcpy( endTest, ".dump" );
1003        }
1004        else{
1005 <        strcat( info->sampleName, ".dump" );
1005 >        endTest = &(info[k].sampleName[nameLength - 4]);
1006 >        if( !strcmp( endTest, ".bss" ) ){
1007 >          strcpy( endTest, ".dump" );
1008 >        }
1009 >        else if( !strcmp( endTest, ".mdl" ) ){
1010 >          strcpy( endTest, ".dump" );
1011 >        }
1012 >        else{
1013 >          strcat( info[k].sampleName, ".dump" );
1014 >        }
1015        }
1016 <    }
1017 <    
1018 <    strcpy( info->statusName, inFileName );
1019 <    nameLength = strlen( info->statusName );
1020 <    endTest = &(info->statusName[nameLength - 5]);
989 <    if( !strcmp( endTest, ".bass" ) ){
990 <      strcpy( endTest, ".stat" );
991 <    }
992 <    else if( !strcmp( endTest, ".BASS" ) ){
993 <      strcpy( endTest, ".stat" );
994 <    }
995 <    else{
996 <      endTest = &(info->statusName[nameLength - 4]);
997 <      if( !strcmp( endTest, ".bss" ) ){
1016 >      
1017 >      strcpy( info[k].statusName, inFileName );
1018 >      nameLength = strlen( info[k].statusName );
1019 >      endTest = &(info[k].statusName[nameLength - 5]);
1020 >      if( !strcmp( endTest, ".bass" ) ){
1021          strcpy( endTest, ".stat" );
1022        }
1023 <      else if( !strcmp( endTest, ".mdl" ) ){
1023 >      else if( !strcmp( endTest, ".BASS" ) ){
1024          strcpy( endTest, ".stat" );
1025        }
1026        else{
1027 <        strcat( info->statusName, ".stat" );
1027 >        endTest = &(info[k].statusName[nameLength - 4]);
1028 >        if( !strcmp( endTest, ".bss" ) ){
1029 >          strcpy( endTest, ".stat" );
1030 >        }
1031 >        else if( !strcmp( endTest, ".mdl" ) ){
1032 >          strcpy( endTest, ".stat" );
1033 >        }
1034 >        else{
1035 >          strcat( info[k].statusName, ".stat" );
1036 >        }
1037        }
1038 <    }
1007 <    
1038 >      
1039   #ifdef IS_MPI
1040 <  }
1040 >    }
1041   #endif // is_mpi
1042 <
1042 >  }
1043   }
1044  
1045  
1046   void SimSetup::sysObjectsCreation( void ){
1047 <
1048 <  int i;
1049 <
1047 >  
1048 >  int i,k;
1049 >  
1050    // create the forceField
1051 <
1051 >  
1052    createFF();
1053  
1054    // extract componentList
# Line 1041 | Line 1072 | void SimSetup::sysObjectsCreation( void ){
1072    // make and initialize the molecules (all but atomic coordinates)
1073    
1074    makeMolecules();
1044  info->identArray = new int[info->n_atoms];
1045  for(i=0; i<info->n_atoms; i++){
1046    info->identArray[i] = the_atoms[i]->getIdent();
1047  }
1075    
1076 <
1077 <
1076 >  for(k=0; k<nInfo; k++){
1077 >    info[k].identArray = new int[info[k].n_atoms];
1078 >    for(i=0; i<info[k].n_atoms; i++){
1079 >      info[k].identArray[i] = info[k].atoms[i]->getIdent();
1080 >    }
1081 >  }
1082   }
1083  
1084  
# Line 1085 | Line 1116 | void SimSetup::compList( void ){
1116   void SimSetup::compList( void ){
1117  
1118    int i;
1119 <
1119 >  char* id;
1120 >  LinkedMolStamp* headStamp = new LinkedMolStamp();
1121 >  LinkedMolStamp* currentStamp = NULL;
1122    comp_stamps = new MoleculeStamp*[n_components];
1123 <
1123 >  
1124    // make an array of molecule stamps that match the components used.
1125    // also extract the used stamps out into a separate linked list
1093
1094  info->nComponents = n_components;
1095  info->componentsNmol = components_nmol;
1096  info->compStamps = comp_stamps;
1097  info->headStamp = new LinkedMolStamp();
1126    
1127 <  char* id;
1128 <  LinkedMolStamp* headStamp = info->headStamp;
1129 <  LinkedMolStamp* currentStamp = NULL;
1127 >  for(i=0; i<nInfo; i++){
1128 >    info[i].nComponents = n_components;
1129 >    info[i].componentsNmol = components_nmol;
1130 >    info[i].compStamps = comp_stamps;
1131 >    info[i].headStamp = headStamp;
1132 >  }
1133 >  
1134 >
1135    for( i=0; i<n_components; i++ ){
1136  
1137      id = the_components[i]->getType();
# Line 1136 | Line 1169 | void SimSetup::calcSysValues( void ){
1169  
1170   void SimSetup::calcSysValues( void ){
1171    int i, j, k;
1172 <
1173 <
1172 >  
1173 >  int *molMembershipArray;
1174 >  
1175    tot_atoms = 0;
1176    tot_bonds = 0;
1177    tot_bends = 0;
# Line 1149 | Line 1183 | void SimSetup::calcSysValues( void ){
1183      tot_bends +=    components_nmol[i] * comp_stamps[i]->getNBends();
1184      tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions();
1185    }
1186 <
1186 >  
1187    tot_SRI = tot_bonds + tot_bends + tot_torsions;
1188 <
1155 <  info->n_atoms = tot_atoms;
1156 <  info->n_bonds = tot_bonds;
1157 <  info->n_bends = tot_bends;
1158 <  info->n_torsions = tot_torsions;
1159 <  info->n_SRI = tot_SRI;
1160 <  info->n_mol = tot_nmol;
1188 >  molMembershipArray = new int[tot_atoms];
1189    
1190 <  info->molMembershipArray = new int[tot_atoms];
1190 >  for(i=0; i<nInfo; i++){
1191 >    info[i].n_atoms = tot_atoms;
1192 >    info[i].n_bonds = tot_bonds;
1193 >    info[i].n_bends = tot_bends;
1194 >    info[i].n_torsions = tot_torsions;
1195 >    info[i].n_SRI = tot_SRI;
1196 >    info[i].n_mol = tot_nmol;
1197 >    
1198 >    info[i].molMembershipArray = molMembershipArray;
1199 >  }
1200   }
1201  
1165
1202   #ifdef IS_MPI
1203  
1204   void SimSetup::mpiMolDivide( void ){
# Line 1202 | Line 1238 | void SimSetup::mpiMolDivide( void ){
1238          localMol++;
1239        }      
1240        for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
1241 <        info->molMembershipArray[globalAtomIndex] = allMol;
1241 >        info[0].molMembershipArray[globalAtomIndex] = allMol;
1242          globalAtomIndex++;
1243        }
1244  
# Line 1211 | Line 1247 | void SimSetup::mpiMolDivide( void ){
1247    }
1248    local_SRI = local_bonds + local_bends + local_torsions;
1249    
1250 <  info->n_atoms = mpiSim->getMyNlocal();  
1250 >  info[0].n_atoms = mpiSim->getMyNlocal();  
1251    
1252 <  if( local_atoms != info->n_atoms ){
1252 >  if( local_atoms != info[0].n_atoms ){
1253      sprintf( painCave.errMsg,
1254               "SimSetup error: mpiSim's localAtom (%d) and SimSetup's"
1255               " localAtom (%d) are not equal.\n",
1256 <             info->n_atoms,
1256 >             info[0].n_atoms,
1257               local_atoms );
1258      painCave.isFatal = 1;
1259      simError();
1260    }
1261  
1262 <  info->n_bonds = local_bonds;
1263 <  info->n_bends = local_bends;
1264 <  info->n_torsions = local_torsions;
1265 <  info->n_SRI = local_SRI;
1266 <  info->n_mol = localMol;
1262 >  info[0].n_bonds = local_bonds;
1263 >  info[0].n_bends = local_bends;
1264 >  info[0].n_torsions = local_torsions;
1265 >  info[0].n_SRI = local_SRI;
1266 >  info[0].n_mol = localMol;
1267  
1268    strcpy( checkPointMsg, "Passed nlocal consistency check." );
1269    MPIcheckPoint();
1270   }
1271 <  
1271 >
1272   #endif // is_mpi
1273  
1274  
1275   void SimSetup::makeSysArrays( void ){
1276 <  int i, j, k;
1276 >  int i, j, k, l;
1277  
1278 +  Atom** the_atoms;
1279 +  Molecule* the_molecules;
1280 +  Exclude** the_excludes;
1281  
1243  // create the atom and short range interaction arrays
1244
1245  Atom::createArrays(info->n_atoms);
1246  the_atoms = new Atom*[info->n_atoms];
1247  the_molecules = new Molecule[info->n_mol];
1248  int molIndex;
1249
1250  // initialize the molecule's stampID's
1251
1252 #ifdef IS_MPI
1282    
1283 +  for(l=0; l<nInfo; l++){
1284 +    
1285 +    // create the atom and short range interaction arrays
1286 +    
1287 +    the_atoms = new Atom*[info[l].n_atoms];
1288 +    the_molecules = new Molecule[info[l].n_mol];
1289 +    int molIndex;
1290  
1291 <  molIndex = 0;
1256 <  for(i=0; i<mpiSim->getTotNmol(); i++){
1291 >    // initialize the molecule's stampID's
1292      
1293 <    if(mol2proc[i] == worldRank ){
1294 <      the_molecules[molIndex].setStampID( molCompType[i] );
1295 <      the_molecules[molIndex].setMyIndex( molIndex );
1296 <      the_molecules[molIndex].setGlobalIndex( i );
1297 <      molIndex++;
1293 > #ifdef IS_MPI
1294 >    
1295 >    
1296 >    molIndex = 0;
1297 >    for(i=0; i<mpiSim->getTotNmol(); i++){
1298 >    
1299 >      if(mol2proc[i] == worldRank ){
1300 >        the_molecules[molIndex].setStampID( molCompType[i] );
1301 >        the_molecules[molIndex].setMyIndex( molIndex );
1302 >        the_molecules[molIndex].setGlobalIndex( i );
1303 >        molIndex++;
1304 >      }
1305      }
1306 <  }
1265 <
1306 >    
1307   #else // is_mpi
1308 <  
1309 <  molIndex = 0;
1310 <  globalAtomIndex = 0;
1311 <  for(i=0; i<n_components; i++){
1312 <    for(j=0; j<components_nmol[i]; j++ ){
1313 <      the_molecules[molIndex].setStampID( i );
1314 <      the_molecules[molIndex].setMyIndex( molIndex );
1315 <      the_molecules[molIndex].setGlobalIndex( molIndex );
1316 <      for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
1317 <        info->molMembershipArray[globalAtomIndex] = molIndex;
1318 <        globalAtomIndex++;
1308 >    
1309 >    molIndex = 0;
1310 >    globalAtomIndex = 0;
1311 >    for(i=0; i<n_components; i++){
1312 >      for(j=0; j<components_nmol[i]; j++ ){
1313 >        the_molecules[molIndex].setStampID( i );
1314 >        the_molecules[molIndex].setMyIndex( molIndex );
1315 >        the_molecules[molIndex].setGlobalIndex( molIndex );
1316 >        for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) {
1317 >          info[l].molMembershipArray[globalAtomIndex] = molIndex;
1318 >          globalAtomIndex++;
1319 >        }
1320 >        molIndex++;
1321        }
1279      molIndex++;
1322      }
1281  }
1323      
1324 <
1324 >    
1325   #endif // is_mpi
1326  
1327  
1328 <  if( info->n_SRI ){
1328 >    if( info[l].n_SRI ){
1329      
1330 <    Exclude::createArray(info->n_SRI);
1331 <    the_excludes = new Exclude*[info->n_SRI];
1332 <    for( int ex=0; ex<info->n_SRI; ex++) the_excludes[ex] = new Exclude(ex);
1333 <    info->globalExcludes = new int;
1334 <    info->n_exclude = info->n_SRI;
1335 <  }
1336 <  else{
1330 >      Exclude::createArray(info[l].n_SRI);
1331 >      the_excludes = new Exclude*[info[l].n_SRI];
1332 >      for( int ex=0; ex<info[l].n_SRI; ex++){
1333 >        the_excludes[ex] = new Exclude(ex);
1334 >      }
1335 >      info[l].globalExcludes = new int;
1336 >      info[l].n_exclude = info[l].n_SRI;
1337 >    }
1338 >    else{
1339      
1340 <    Exclude::createArray( 1 );
1341 <    the_excludes = new Exclude*;
1342 <    the_excludes[0] = new Exclude(0);
1343 <    the_excludes[0]->setPair( 0,0 );
1344 <    info->globalExcludes = new int;
1345 <    info->globalExcludes[0] = 0;
1346 <    info->n_exclude = 0;
1347 <  }
1340 >      Exclude::createArray( 1 );
1341 >      the_excludes = new Exclude*;
1342 >      the_excludes[0] = new Exclude(0);
1343 >      the_excludes[0]->setPair( 0,0 );
1344 >      info[l].globalExcludes = new int;
1345 >      info[l].globalExcludes[0] = 0;
1346 >      info[l].n_exclude = 0;
1347 >    }
1348  
1349 <  // set the arrays into the SimInfo object
1349 >    // set the arrays into the SimInfo object
1350  
1351 <  info->atoms = the_atoms;
1352 <  info->molecules = the_molecules;
1353 <  info->nGlobalExcludes = 0;
1354 <  info->excludes = the_excludes;
1351 >    info[l].atoms = the_atoms;
1352 >    info[l].molecules = the_molecules;
1353 >    info[l].nGlobalExcludes = 0;
1354 >    info[l].excludes = the_excludes;
1355  
1356 <  the_ff->setSimInfo( info );
1357 <
1356 >    the_ff->setSimInfo( info );
1357 >    
1358 >  }
1359   }
1360  
1361   void SimSetup::makeIntegrator( void ){
1362  
1363 +  int k;
1364 +
1365    NVT<RealIntegrator>*  myNVT = NULL;
1366    NPTi<RealIntegrator>* myNPTi = NULL;
1367    NPTf<RealIntegrator>* myNPTf = NULL;
# Line 1328 | Line 1374 | void SimSetup::makeIntegrator( void ){
1374    ZConstraint<NPTim<RealIntegrator> >* myNPTimZCons = NULL;
1375    ZConstraint<NPTfm<RealIntegrator> >* myNPTfmZCons = NULL;
1376          
1377 <  switch( ensembleCase ){
1332 <
1333 <  case NVE_ENS:
1334 <    new NVE<RealIntegrator>( info, the_ff );
1335 <    break;
1336 <
1337 <  case NVT_ENS:
1338 <    myNVT = new NVT<RealIntegrator>( info, the_ff );
1339 <    myNVT->setTargetTemp(globals->getTargetTemp());
1340 <
1341 <    if (globals->haveTauThermostat())
1342 <      myNVT->setTauThermostat(globals->getTauThermostat());
1343 <
1344 <    else {
1345 <      sprintf( painCave.errMsg,
1346 <               "SimSetup error: If you use the NVT\n"
1347 <               "    ensemble, you must set tauThermostat.\n");
1348 <      painCave.isFatal = 1;
1349 <      simError();
1350 <    }
1351 <    break;
1352 <
1353 <  case NPTi_ENS:
1354 <    myNPTi = new NPTi<RealIntegrator>( info, the_ff );
1355 <    myNPTi->setTargetTemp( globals->getTargetTemp() );
1356 <
1357 <    if (globals->haveTargetPressure())
1358 <      myNPTi->setTargetPressure(globals->getTargetPressure());
1359 <    else {
1360 <      sprintf( painCave.errMsg,
1361 <               "SimSetup error: If you use a constant pressure\n"
1362 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1363 <      painCave.isFatal = 1;
1364 <      simError();
1365 <    }
1377 >  for(k=0; k<nInfo; k++){
1378      
1379 <    if( globals->haveTauThermostat() )
1368 <      myNPTi->setTauThermostat( globals->getTauThermostat() );
1369 <    else{
1370 <      sprintf( painCave.errMsg,
1371 <               "SimSetup error: If you use an NPT\n"
1372 <               "    ensemble, you must set tauThermostat.\n");
1373 <      painCave.isFatal = 1;
1374 <      simError();
1375 <    }
1376 <
1377 <    if( globals->haveTauBarostat() )
1378 <      myNPTi->setTauBarostat( globals->getTauBarostat() );
1379 <    else{
1380 <      sprintf( painCave.errMsg,
1381 <               "SimSetup error: If you use an NPT\n"
1382 <               "    ensemble, you must set tauBarostat.\n");
1383 <      painCave.isFatal = 1;
1384 <      simError();
1385 <    }
1386 <    break;
1387 <
1388 <  case NPTf_ENS:
1389 <    myNPTf = new NPTf<RealIntegrator>( info, the_ff );
1390 <    myNPTf->setTargetTemp( globals->getTargetTemp());
1391 <
1392 <    if (globals->haveTargetPressure())
1393 <      myNPTf->setTargetPressure(globals->getTargetPressure());
1394 <    else {
1395 <      sprintf( painCave.errMsg,
1396 <               "SimSetup error: If you use a constant pressure\n"
1397 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1398 <      painCave.isFatal = 1;
1399 <      simError();
1400 <    }    
1401 <
1402 <    if( globals->haveTauThermostat() )
1403 <      myNPTf->setTauThermostat( globals->getTauThermostat() );
1404 <    else{
1405 <      sprintf( painCave.errMsg,
1406 <               "SimSetup error: If you use an NPT\n"
1407 <               "    ensemble, you must set tauThermostat.\n");
1408 <      painCave.isFatal = 1;
1409 <      simError();
1410 <    }
1411 <
1412 <    if( globals->haveTauBarostat() )
1413 <      myNPTf->setTauBarostat( globals->getTauBarostat() );
1414 <    else{
1415 <      sprintf( painCave.errMsg,
1416 <               "SimSetup error: If you use an NPT\n"
1417 <               "    ensemble, you must set tauBarostat.\n");
1418 <      painCave.isFatal = 1;
1419 <      simError();
1420 <    }
1421 <    break;
1422 <    
1423 <  case NPTim_ENS:
1424 <    myNPTim = new NPTim<RealIntegrator>( info, the_ff );
1425 <    myNPTim->setTargetTemp( globals->getTargetTemp());
1426 <
1427 <    if (globals->haveTargetPressure())
1428 <      myNPTim->setTargetPressure(globals->getTargetPressure());
1429 <    else {
1430 <      sprintf( painCave.errMsg,
1431 <               "SimSetup error: If you use a constant pressure\n"
1432 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1433 <      painCave.isFatal = 1;
1434 <      simError();
1435 <    }
1436 <    
1437 <    if( globals->haveTauThermostat() )
1438 <      myNPTim->setTauThermostat( globals->getTauThermostat() );
1439 <    else{
1440 <      sprintf( painCave.errMsg,
1441 <               "SimSetup error: If you use an NPT\n"
1442 <               "    ensemble, you must set tauThermostat.\n");
1443 <      painCave.isFatal = 1;
1444 <      simError();
1445 <    }
1446 <
1447 <    if( globals->haveTauBarostat() )
1448 <      myNPTim->setTauBarostat( globals->getTauBarostat() );
1449 <    else{
1450 <      sprintf( painCave.errMsg,
1451 <               "SimSetup error: If you use an NPT\n"
1452 <               "    ensemble, you must set tauBarostat.\n");
1453 <      painCave.isFatal = 1;
1454 <      simError();
1455 <    }
1456 <    break;
1457 <
1458 <  case NPTfm_ENS:
1459 <    myNPTfm = new NPTfm<RealIntegrator>( info, the_ff );
1460 <    myNPTfm->setTargetTemp( globals->getTargetTemp());
1461 <
1462 <    if (globals->haveTargetPressure())
1463 <      myNPTfm->setTargetPressure(globals->getTargetPressure());
1464 <    else {
1465 <      sprintf( painCave.errMsg,
1466 <               "SimSetup error: If you use a constant pressure\n"
1467 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1468 <      painCave.isFatal = 1;
1469 <      simError();
1470 <    }
1471 <    
1472 <    if( globals->haveTauThermostat() )
1473 <      myNPTfm->setTauThermostat( globals->getTauThermostat() );
1474 <    else{
1475 <      sprintf( painCave.errMsg,
1476 <               "SimSetup error: If you use an NPT\n"
1477 <               "    ensemble, you must set tauThermostat.\n");
1478 <      painCave.isFatal = 1;
1479 <      simError();
1480 <    }
1481 <
1482 <    if( globals->haveTauBarostat() )
1483 <      myNPTfm->setTauBarostat( globals->getTauBarostat() );
1484 <    else{
1485 <      sprintf( painCave.errMsg,
1486 <               "SimSetup error: If you use an NPT\n"
1487 <               "    ensemble, you must set tauBarostat.\n");
1488 <      painCave.isFatal = 1;
1489 <      simError();
1490 <    }
1491 <    break;
1492 <    
1493 <  case NVEZCONS_ENS:
1494 <
1495 <
1496 <    //setup index of z-constraint molecules, z-constraint sampel time
1497 <    //and z-constraint force output name. These parameter should be known
1498 <    //before constructing the z-constraint integrator
1499 <    setupZConstraint();
1379 >    switch( ensembleCase ){
1380        
1381 <    myNVEZCons = new ZConstraint<NVE<RealIntegrator> >( info, the_ff );
1382 <        
1383 <    break;
1504 <    
1505 <    
1506 <  case NVTZCONS_ENS:
1507 <  
1508 <    setupZConstraint();
1509 <    
1510 <    myNVTZCons = new ZConstraint<NVT<RealIntegrator> >( info, the_ff );
1511 <    myNVTZCons->setTargetTemp(globals->getTargetTemp());
1512 <
1513 <    if (globals->haveTauThermostat())
1514 <      myNVTZCons->setTauThermostat(globals->getTauThermostat());
1515 <
1516 <    else {
1517 <      sprintf( painCave.errMsg,
1518 <               "SimSetup error: If you use the NVT\n"
1519 <               "    ensemble, you must set tauThermostat.\n");
1520 <      painCave.isFatal = 1;
1521 <      simError();
1522 <    }    
1523 <    break;    
1524 <    
1525 <  case NPTiZCONS_ENS:
1526 <  
1527 <    setupZConstraint();
1528 <    
1529 <    myNPTiZCons = new ZConstraint<NPTi<RealIntegrator> >( info, the_ff );
1530 <    myNPTiZCons->setTargetTemp( globals->getTargetTemp() );
1531 <
1532 <    if (globals->haveTargetPressure())
1533 <      myNPTiZCons->setTargetPressure(globals->getTargetPressure());
1534 <    else {
1535 <      sprintf( painCave.errMsg,
1536 <               "SimSetup error: If you use a constant pressure\n"
1537 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1538 <      painCave.isFatal = 1;
1539 <      simError();
1540 <    }
1541 <    
1542 <    if( globals->haveTauThermostat() )
1543 <      myNPTiZCons->setTauThermostat( globals->getTauThermostat() );
1544 <    else{
1545 <      sprintf( painCave.errMsg,
1546 <               "SimSetup error: If you use an NPT\n"
1547 <               "    ensemble, you must set tauThermostat.\n");
1548 <      painCave.isFatal = 1;
1549 <      simError();
1550 <    }
1551 <
1552 <    if( globals->haveTauBarostat() )
1553 <      myNPTiZCons->setTauBarostat( globals->getTauBarostat() );
1554 <    else{
1555 <      sprintf( painCave.errMsg,
1556 <               "SimSetup error: If you use an NPT\n"
1557 <               "    ensemble, you must set tauBarostat.\n");
1558 <      painCave.isFatal = 1;
1559 <      simError();
1560 <    }  
1561 <    
1562 <    break;
1563 <    
1564 <  case NPTfZCONS_ENS:
1565 <  
1566 <    setupZConstraint();
1567 <  
1568 <    myNPTfZCons = new ZConstraint<NPTf<RealIntegrator> >( info, the_ff );
1569 <    myNPTfZCons->setTargetTemp( globals->getTargetTemp());
1570 <
1571 <    if (globals->haveTargetPressure())
1572 <      myNPTfZCons->setTargetPressure(globals->getTargetPressure());
1573 <    else {
1574 <      sprintf( painCave.errMsg,
1575 <               "SimSetup error: If you use a constant pressure\n"
1576 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1577 <      painCave.isFatal = 1;
1578 <      simError();
1579 <    }    
1580 <
1581 <    if( globals->haveTauThermostat() )
1582 <      myNPTfZCons->setTauThermostat( globals->getTauThermostat() );
1583 <    else{
1584 <      sprintf( painCave.errMsg,
1585 <               "SimSetup error: If you use an NPT\n"
1586 <               "    ensemble, you must set tauThermostat.\n");
1587 <      painCave.isFatal = 1;
1588 <      simError();
1589 <    }
1590 <
1591 <    if( globals->haveTauBarostat() )
1592 <      myNPTfZCons->setTauBarostat( globals->getTauBarostat() );
1593 <    else{
1594 <      sprintf( painCave.errMsg,
1595 <               "SimSetup error: If you use an NPT\n"
1596 <               "    ensemble, you must set tauBarostat.\n");
1597 <      painCave.isFatal = 1;
1598 <      simError();
1599 <    }  
1600 <    
1601 <    break;  
1381 >    case NVE_ENS:
1382 >      new NVE<RealIntegrator>( &(info[k]), the_ff );
1383 >      break;
1384        
1385 <  case NPTimZCONS_ENS:
1386 <  
1387 <    setupZConstraint();
1388 <  
1389 <    myNPTimZCons = new ZConstraint<NPTim<RealIntegrator> >( info, the_ff );
1390 <    myNPTimZCons->setTargetTemp( globals->getTargetTemp());
1391 <
1392 <    if (globals->haveTargetPressure())
1393 <      myNPTimZCons->setTargetPressure(globals->getTargetPressure());
1394 <    else {
1395 <      sprintf( painCave.errMsg,
1396 <               "SimSetup error: If you use a constant pressure\n"
1397 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1398 <      painCave.isFatal = 1;
1399 <      simError();
1400 <    }
1401 <    
1402 <    if( globals->haveTauThermostat() )
1403 <      myNPTimZCons->setTauThermostat( globals->getTauThermostat() );
1404 <    else{
1405 <      sprintf( painCave.errMsg,
1406 <               "SimSetup error: If you use an NPT\n"
1385 >    case NVT_ENS:
1386 >      myNVT = new NVT<RealIntegrator>( &(info[k]), the_ff );
1387 >      myNVT->setTargetTemp(globals->getTargetTemp());
1388 >      
1389 >      if (globals->haveTauThermostat())
1390 >        myNVT->setTauThermostat(globals->getTauThermostat());
1391 >      
1392 >      else {
1393 >        sprintf( painCave.errMsg,
1394 >                 "SimSetup error: If you use the NVT\n"
1395 >                 "    ensemble, you must set tauThermostat.\n");
1396 >        painCave.isFatal = 1;
1397 >        simError();
1398 >      }
1399 >      break;
1400 >      
1401 >    case NPTi_ENS:
1402 >      myNPTi = new NPTi<RealIntegrator>( &(info[k]), the_ff );
1403 >      myNPTi->setTargetTemp( globals->getTargetTemp() );
1404 >      
1405 >      if (globals->haveTargetPressure())
1406 >        myNPTi->setTargetPressure(globals->getTargetPressure());
1407 >      else {
1408 >        sprintf( painCave.errMsg,
1409 >                 "SimSetup error: If you use a constant pressure\n"
1410 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1411 >        painCave.isFatal = 1;
1412 >        simError();
1413 >      }
1414 >      
1415 >      if( globals->haveTauThermostat() )
1416 >        myNPTi->setTauThermostat( globals->getTauThermostat() );
1417 >      else{
1418 >        sprintf( painCave.errMsg,
1419 >                 "SimSetup error: If you use an NPT\n"
1420 >                 "    ensemble, you must set tauThermostat.\n");
1421 >        painCave.isFatal = 1;
1422 >        simError();
1423 >      }
1424 >      
1425 >      if( globals->haveTauBarostat() )
1426 >        myNPTi->setTauBarostat( globals->getTauBarostat() );
1427 >      else{
1428 >        sprintf( painCave.errMsg,
1429 >                 "SimSetup error: If you use an NPT\n"
1430 >                 "    ensemble, you must set tauBarostat.\n");
1431 >        painCave.isFatal = 1;
1432 >        simError();
1433 >      }
1434 >      break;
1435 >      
1436 >    case NPTf_ENS:
1437 >      myNPTf = new NPTf<RealIntegrator>( &(info[k]), the_ff );
1438 >      myNPTf->setTargetTemp( globals->getTargetTemp());
1439 >      
1440 >      if (globals->haveTargetPressure())
1441 >        myNPTf->setTargetPressure(globals->getTargetPressure());
1442 >      else {
1443 >        sprintf( painCave.errMsg,
1444 >                 "SimSetup error: If you use a constant pressure\n"
1445 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1446 >        painCave.isFatal = 1;
1447 >        simError();
1448 >      }    
1449 >      
1450 >      if( globals->haveTauThermostat() )
1451 >        myNPTf->setTauThermostat( globals->getTauThermostat() );
1452 >      else{
1453 >        sprintf( painCave.errMsg,
1454 >                 "SimSetup error: If you use an NPT\n"
1455                 "    ensemble, you must set tauThermostat.\n");
1456 <      painCave.isFatal = 1;
1457 <      simError();
1458 <    }
1459 <
1460 <    if( globals->haveTauBarostat() )
1461 <      myNPTimZCons->setTauBarostat( globals->getTauBarostat() );
1462 <    else{
1456 >        painCave.isFatal = 1;
1457 >        simError();
1458 >      }
1459 >      
1460 >      if( globals->haveTauBarostat() )
1461 >        myNPTf->setTauBarostat( globals->getTauBarostat() );
1462 >      else{
1463 >        sprintf( painCave.errMsg,
1464 >                 "SimSetup error: If you use an NPT\n"
1465 >                 "    ensemble, you must set tauBarostat.\n");
1466 >        painCave.isFatal = 1;
1467 >        simError();
1468 >      }
1469 >      break;
1470 >      
1471 >    case NPTim_ENS:
1472 >      myNPTim = new NPTim<RealIntegrator>( &(info[k]), the_ff );
1473 >      myNPTim->setTargetTemp( globals->getTargetTemp());
1474 >      
1475 >      if (globals->haveTargetPressure())
1476 >        myNPTim->setTargetPressure(globals->getTargetPressure());
1477 >      else {
1478 >        sprintf( painCave.errMsg,
1479 >                 "SimSetup error: If you use a constant pressure\n"
1480 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1481 >        painCave.isFatal = 1;
1482 >        simError();
1483 >      }
1484 >      
1485 >      if( globals->haveTauThermostat() )
1486 >        myNPTim->setTauThermostat( globals->getTauThermostat() );
1487 >      else{
1488 >        sprintf( painCave.errMsg,
1489 >                 "SimSetup error: If you use an NPT\n"
1490 >                 "    ensemble, you must set tauThermostat.\n");
1491 >        painCave.isFatal = 1;
1492 >        simError();
1493 >      }
1494 >      
1495 >      if( globals->haveTauBarostat() )
1496 >        myNPTim->setTauBarostat( globals->getTauBarostat() );
1497 >      else{
1498        sprintf( painCave.errMsg,
1499                 "SimSetup error: If you use an NPT\n"
1500                 "    ensemble, you must set tauBarostat.\n");
1501        painCave.isFatal = 1;
1502        simError();
1503 <    }  
1504 <    
1505 <    break;
1506 <    
1507 <  case NPTfmZCONS_ENS:
1508 <  
1509 <    setupZConstraint();
1510 <    
1511 <    myNPTfmZCons = new ZConstraint<NPTfm<RealIntegrator> >( info, the_ff );
1512 <    myNPTfmZCons->setTargetTemp( globals->getTargetTemp());
1513 <
1514 <    if (globals->haveTargetPressure())
1515 <      myNPTfmZCons->setTargetPressure(globals->getTargetPressure());
1516 <    else {
1517 <      sprintf( painCave.errMsg,
1518 <               "SimSetup error: If you use a constant pressure\n"
1519 <               "    ensemble, you must set targetPressure in the BASS file.\n");
1520 <      painCave.isFatal = 1;
1521 <      simError();
1522 <    }
1523 <    
1524 <    if( globals->haveTauThermostat() )
1525 <      myNPTfmZCons->setTauThermostat( globals->getTauThermostat() );
1526 <    else{
1503 >      }
1504 >      break;
1505 >      
1506 >    case NPTfm_ENS:
1507 >      myNPTfm = new NPTfm<RealIntegrator>( &(info[k]), the_ff );
1508 >      myNPTfm->setTargetTemp( globals->getTargetTemp());
1509 >      
1510 >      if (globals->haveTargetPressure())
1511 >        myNPTfm->setTargetPressure(globals->getTargetPressure());
1512 >      else {
1513 >        sprintf( painCave.errMsg,
1514 >                 "SimSetup error: If you use a constant pressure\n"
1515 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1516 >        painCave.isFatal = 1;
1517 >        simError();
1518 >      }
1519 >      
1520 >      if( globals->haveTauThermostat() )
1521 >        myNPTfm->setTauThermostat( globals->getTauThermostat() );
1522 >      else{
1523 >        sprintf( painCave.errMsg,
1524 >                 "SimSetup error: If you use an NPT\n"
1525 >                 "    ensemble, you must set tauThermostat.\n");
1526 >        painCave.isFatal = 1;
1527 >        simError();
1528 >      }
1529 >      
1530 >      if( globals->haveTauBarostat() )
1531 >        myNPTfm->setTauBarostat( globals->getTauBarostat() );
1532 >      else{
1533 >        sprintf( painCave.errMsg,
1534 >                 "SimSetup error: If you use an NPT\n"
1535 >                 "    ensemble, you must set tauBarostat.\n");
1536 >        painCave.isFatal = 1;
1537 >        simError();
1538 >      }
1539 >      break;
1540 >      
1541 >    case NVEZCONS_ENS:
1542 >      
1543 >      
1544 >      //setup index of z-constraint molecules, z-constraint sampel time
1545 >      //and z-constraint force output name. These parameter should be known
1546 >      //before constructing the z-constraint integrator
1547 >      setupZConstraint();
1548 >      
1549 >      myNVEZCons = new ZConstraint<NVE<RealIntegrator> >( &(info[k]), the_ff );
1550 >      
1551 >      break;
1552 >      
1553 >      
1554 >    case NVTZCONS_ENS:
1555 >      
1556 >      setupZConstraint();
1557 >      
1558 >      myNVTZCons = new ZConstraint<NVT<RealIntegrator> >( &(info[k]), the_ff );
1559 >      myNVTZCons->setTargetTemp(globals->getTargetTemp());
1560 >      
1561 >      if (globals->haveTauThermostat())
1562 >        myNVTZCons->setTauThermostat(globals->getTauThermostat());
1563 >      
1564 >      else {
1565 >        sprintf( painCave.errMsg,
1566 >                 "SimSetup error: If you use the NVT\n"
1567 >                 "    ensemble, you must set tauThermostat.\n");
1568 >        painCave.isFatal = 1;
1569 >        simError();
1570 >      }    
1571 >      break;    
1572 >      
1573 >    case NPTiZCONS_ENS:
1574 >      
1575 >      setupZConstraint();
1576 >      
1577 >      myNPTiZCons = new ZConstraint<NPTi<RealIntegrator> >( &(info[k]), the_ff );
1578 >      myNPTiZCons->setTargetTemp( globals->getTargetTemp() );
1579 >      
1580 >      if (globals->haveTargetPressure())
1581 >        myNPTiZCons->setTargetPressure(globals->getTargetPressure());
1582 >      else {
1583 >        sprintf( painCave.errMsg,
1584 >                 "SimSetup error: If you use a constant pressure\n"
1585 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1586 >        painCave.isFatal = 1;
1587 >        simError();
1588 >      }
1589 >      
1590 >      if( globals->haveTauThermostat() )
1591 >        myNPTiZCons->setTauThermostat( globals->getTauThermostat() );
1592 >      else{
1593 >        sprintf( painCave.errMsg,
1594 >                 "SimSetup error: If you use an NPT\n"
1595 >                 "    ensemble, you must set tauThermostat.\n");
1596 >        painCave.isFatal = 1;
1597 >        simError();
1598 >      }
1599 >      
1600 >      if( globals->haveTauBarostat() )
1601 >        myNPTiZCons->setTauBarostat( globals->getTauBarostat() );
1602 >      else{
1603 >        sprintf( painCave.errMsg,
1604 >                 "SimSetup error: If you use an NPT\n"
1605 >                 "    ensemble, you must set tauBarostat.\n");
1606 >        painCave.isFatal = 1;
1607 >        simError();
1608 >      }  
1609 >      
1610 >      break;
1611 >      
1612 >    case NPTfZCONS_ENS:
1613 >      
1614 >      setupZConstraint();
1615 >      
1616 >      myNPTfZCons = new ZConstraint<NPTf<RealIntegrator> >( &(info[k]), the_ff );
1617 >      myNPTfZCons->setTargetTemp( globals->getTargetTemp());
1618 >      
1619 >      if (globals->haveTargetPressure())
1620 >        myNPTfZCons->setTargetPressure(globals->getTargetPressure());
1621 >      else {
1622 >        sprintf( painCave.errMsg,
1623 >                 "SimSetup error: If you use a constant pressure\n"
1624 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1625 >        painCave.isFatal = 1;
1626 >        simError();
1627 >      }    
1628 >      
1629 >      if( globals->haveTauThermostat() )
1630 >        myNPTfZCons->setTauThermostat( globals->getTauThermostat() );
1631 >      else{
1632 >        sprintf( painCave.errMsg,
1633 >                 "SimSetup error: If you use an NPT\n"
1634 >                 "    ensemble, you must set tauThermostat.\n");
1635 >        painCave.isFatal = 1;
1636 >        simError();
1637 >      }
1638 >      
1639 >      if( globals->haveTauBarostat() )
1640 >        myNPTfZCons->setTauBarostat( globals->getTauBarostat() );
1641 >      else{
1642 >        sprintf( painCave.errMsg,
1643 >                 "SimSetup error: If you use an NPT\n"
1644 >                 "    ensemble, you must set tauBarostat.\n");
1645 >        painCave.isFatal = 1;
1646 >        simError();
1647 >      }  
1648 >      
1649 >      break;  
1650 >      
1651 >    case NPTimZCONS_ENS:
1652 >      
1653 >      setupZConstraint();
1654 >      
1655 >      myNPTimZCons = new ZConstraint<NPTim<RealIntegrator> >( &(info[k]), the_ff );
1656 >      myNPTimZCons->setTargetTemp( globals->getTargetTemp());
1657 >      
1658 >      if (globals->haveTargetPressure())
1659 >        myNPTimZCons->setTargetPressure(globals->getTargetPressure());
1660 >      else {
1661 >        sprintf( painCave.errMsg,
1662 >                 "SimSetup error: If you use a constant pressure\n"
1663 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1664 >        painCave.isFatal = 1;
1665 >        simError();
1666 >      }
1667 >      
1668 >      if( globals->haveTauThermostat() )
1669 >        myNPTimZCons->setTauThermostat( globals->getTauThermostat() );
1670 >      else{
1671 >        sprintf( painCave.errMsg,
1672 >                 "SimSetup error: If you use an NPT\n"
1673 >                 "    ensemble, you must set tauThermostat.\n");
1674 >        painCave.isFatal = 1;
1675 >        simError();
1676 >      }
1677 >      
1678 >      if( globals->haveTauBarostat() )
1679 >        myNPTimZCons->setTauBarostat( globals->getTauBarostat() );
1680 >      else{
1681 >        sprintf( painCave.errMsg,
1682 >                 "SimSetup error: If you use an NPT\n"
1683 >                 "    ensemble, you must set tauBarostat.\n");
1684 >        painCave.isFatal = 1;
1685 >        simError();
1686 >      }  
1687 >      
1688 >      break;
1689 >      
1690 >    case NPTfmZCONS_ENS:
1691 >      
1692 >      setupZConstraint();
1693 >      
1694 >      myNPTfmZCons = new ZConstraint<NPTfm<RealIntegrator> >( &(info[k]), the_ff );
1695 >      myNPTfmZCons->setTargetTemp( globals->getTargetTemp());
1696 >      
1697 >      if (globals->haveTargetPressure())
1698 >        myNPTfmZCons->setTargetPressure(globals->getTargetPressure());
1699 >      else {
1700 >        sprintf( painCave.errMsg,
1701 >                 "SimSetup error: If you use a constant pressure\n"
1702 >                 "    ensemble, you must set targetPressure in the BASS file.\n");
1703 >        painCave.isFatal = 1;
1704 >        simError();
1705 >      }
1706 >      
1707 >      if( globals->haveTauThermostat() )
1708 >        myNPTfmZCons->setTauThermostat( globals->getTauThermostat() );
1709 >      else{
1710 >        sprintf( painCave.errMsg,
1711 >                 "SimSetup error: If you use an NPT\n"
1712 >                 "    ensemble, you must set tauThermostat.\n");
1713 >        painCave.isFatal = 1;
1714 >        simError();
1715 >      }
1716 >      
1717 >      if( globals->haveTauBarostat() )
1718 >        myNPTfmZCons->setTauBarostat( globals->getTauBarostat() );
1719 >      else{
1720 >        sprintf( painCave.errMsg,
1721 >                 "SimSetup error: If you use an NPT\n"
1722 >                 "    ensemble, you must set tauBarostat.\n");
1723 >        painCave.isFatal = 1;
1724 >        simError();
1725 >      }    
1726 >      break;      
1727 >      
1728 >      
1729 >      
1730 >    default:
1731        sprintf( painCave.errMsg,
1732 <               "SimSetup error: If you use an NPT\n"
1664 <               "    ensemble, you must set tauThermostat.\n");
1732 >               "SimSetup Error. Unrecognized ensemble in case statement.\n");
1733        painCave.isFatal = 1;
1734        simError();
1735      }
1668
1669    if( globals->haveTauBarostat() )
1670      myNPTfmZCons->setTauBarostat( globals->getTauBarostat() );
1671    else{
1672      sprintf( painCave.errMsg,
1673               "SimSetup error: If you use an NPT\n"
1674               "    ensemble, you must set tauBarostat.\n");
1675      painCave.isFatal = 1;
1676      simError();
1677    }    
1678    break;      
1679      
1680  
1681    
1682  default:
1683    sprintf( painCave.errMsg,
1684             "SimSetup Error. Unrecognized ensemble in case statement.\n");
1685    painCave.isFatal = 1;
1686    simError();
1736    }
1688
1737   }
1738  
1739   void SimSetup::initFortran( void ){
1740  
1741 <  info->refreshSim();
1741 >  info[0].refreshSim();
1742    
1743 <  if( !strcmp( info->mixingRule, "standard") ){
1743 >  if( !strcmp( info[0].mixingRule, "standard") ){
1744      the_ff->initForceField( LB_MIXING_RULE );
1745    }
1746 <  else if( !strcmp( info->mixingRule, "explicit") ){
1746 >  else if( !strcmp( info[0].mixingRule, "explicit") ){
1747      the_ff->initForceField( EXPLICIT_MIXING_RULE );
1748    }
1749    else{
1750      sprintf( painCave.errMsg,
1751               "SimSetup Error: unknown mixing rule -> \"%s\"\n",
1752 <             info->mixingRule );
1752 >             info[0].mixingRule );
1753      painCave.isFatal = 1;
1754      simError();
1755    }
# Line 1717 | Line 1765 | void SimSetup::setupZConstraint()
1765  
1766   void SimSetup::setupZConstraint()
1767   {
1768 <  if(globals->haveZConsTime()){  
1769 <
1770 <  //add sample time of z-constraint  into SimInfo's property list                    
1771 <  DoubleData* zconsTimeProp = new DoubleData();
1772 <  zconsTimeProp->setID("zconstime");
1725 <  zconsTimeProp->setData(globals->getZConsTime());
1726 <  info->addProperty(zconsTimeProp);
1727 <  }
1728 <  else{
1729 <    sprintf( painCave.errMsg,
1730 <             "ZConstraint error: If you use an ZConstraint\n"
1731 <             " , you must set sample time.\n");
1732 <    painCave.isFatal = 1;
1733 <    simError();      
1734 <  }
1768 >  int k;
1769 >
1770 >  for(k=0; k<nInfo; k++){
1771 >    
1772 >    if(globals->haveZConsTime()){  
1773        
1774 <  if(globals->haveIndexOfAllZConsMols()){
1774 >      //add sample time of z-constraint  into SimInfo's property list                    
1775 >      DoubleData* zconsTimeProp = new DoubleData();
1776 >      zconsTimeProp->setID("zconstime");
1777 >      zconsTimeProp->setData(globals->getZConsTime());
1778 >      info[k].addProperty(zconsTimeProp);
1779 >    }
1780 >    else{
1781 >      sprintf( painCave.errMsg,
1782 >               "ZConstraint error: If you use an ZConstraint\n"
1783 >               " , you must set sample time.\n");
1784 >      painCave.isFatal = 1;
1785 >      simError();      
1786 >    }
1787 >    
1788 >    if(globals->haveIndexOfAllZConsMols()){
1789  
1790 <        //add index of z-constraint molecules into SimInfo's property list
1791 <        vector<int> tempIndex = globals->getIndexOfAllZConsMols();
1740 <        
1741 <        //sort the index
1742 <        sort(tempIndex.begin(), tempIndex.end());
1743 <        
1744 <        IndexData* zconsIndex = new IndexData();
1745 <        zconsIndex->setID("zconsindex");
1746 <        zconsIndex->setIndexData(tempIndex);
1747 <        info->addProperty(zconsIndex);
1748 <  }
1749 <  else{
1750 <    sprintf( painCave.errMsg,
1751 <             "SimSetup error: If you use an ZConstraint\n"
1752 <             " , you must set index of z-constraint molecules.\n");
1753 <    painCave.isFatal = 1;
1754 <    simError();    
1790 >      //add index of z-constraint molecules into SimInfo's property list
1791 >      vector<int> tempIndex = globals->getIndexOfAllZConsMols();
1792        
1793 +      //sort the index
1794 +      sort(tempIndex.begin(), tempIndex.end());
1795 +      
1796 +      IndexData* zconsIndex = new IndexData();
1797 +      zconsIndex->setID("zconsindex");
1798 +      zconsIndex->setIndexData(tempIndex);
1799 +      info[k].addProperty(zconsIndex);
1800 +    }
1801 +    else{
1802 +      sprintf( painCave.errMsg,
1803 +               "SimSetup error: If you use an ZConstraint\n"
1804 +               " , you must set index of z-constraint molecules.\n");
1805 +      painCave.isFatal = 1;
1806 +      simError();    
1807 +      
1808 +    }
1809 +    
1810 +    //Determine the name of ouput file and add it into SimInfo's property list
1811 +    //Be careful, do not use inFileName, since it is a pointer which
1812 +    //point to a string at master node, and slave nodes do not contain that string
1813 +    
1814 +    string zconsOutput(info[k].finalName);
1815 +    
1816 +    zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1817 +    
1818 +    StringData* zconsFilename = new StringData();
1819 +    zconsFilename->setID("zconsfilename");
1820 +    zconsFilename->setData(zconsOutput);
1821 +    
1822 +    info[k].addProperty(zconsFilename);      
1823    }
1757
1758  //Determine the name of ouput file and add it into SimInfo's property list
1759  //Be careful, do not use inFileName, since it is a pointer which
1760  //point to a string at master node, and slave nodes do not contain that string
1761    
1762  string zconsOutput(info->finalName);
1763            
1764  zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1765                
1766  StringData* zconsFilename = new StringData();
1767  zconsFilename->setID("zconsfilename");
1768  zconsFilename->setData(zconsOutput);
1769
1770  info->addProperty(zconsFilename);      
1771
1824   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines