| 66 | 
  | 
 | 
| 67 | 
  | 
  MakeStamps *the_stamps; | 
| 68 | 
  | 
  Globals* the_globals; | 
| 69 | 
+ | 
  ExtendedSystem* the_extendedsystem; | 
| 70 | 
  | 
  int i, j; | 
| 71 | 
  | 
 | 
| 72 | 
  | 
  // get the stamps and globals; | 
| 81 | 
  | 
  // get the ones we know are there, yet still may need some work. | 
| 82 | 
  | 
  n_components = the_globals->getNComponents(); | 
| 83 | 
  | 
  strcpy( force_field, the_globals->getForceField() ); | 
| 84 | 
+ | 
 | 
| 85 | 
+ | 
  // get the ensemble and set up an extended system if we need it: | 
| 86 | 
  | 
  strcpy( ensemble, the_globals->getEnsemble() ); | 
| 87 | 
+ | 
  if( !strcasecmp( ensemble, "NPT" ) ) { | 
| 88 | 
+ | 
    the_extendedsystem = new ExtendedSystem( simnfo ); | 
| 89 | 
+ | 
    the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); | 
| 90 | 
+ | 
    the_extendedsystem->setTargetPressure(the_globals->getTargetPressure()); | 
| 91 | 
+ | 
    the_extendedsystem->setQmass(the_globals->getQmass()); | 
| 92 | 
+ | 
    the_extendedsystem->setTauRelax(the_globals->getTauRelax()); | 
| 93 | 
+ | 
  } else if ( !strcasecmp( ensemble, "NVT") ) { | 
| 94 | 
+ | 
    the_extendedsystem = new ExtendedSystem( simnfo ); | 
| 95 | 
+ | 
    the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); | 
| 96 | 
+ | 
    the_extendedsystem->setQmass(the_globals->getQmass());     | 
| 97 | 
+ | 
  } else if ( !strcasecmp( ensemble, "NVE") ) { | 
| 98 | 
+ | 
  } else { | 
| 99 | 
+ | 
    sprintf( painCave.errMsg, | 
| 100 | 
+ | 
             "SimSetup Warning. Unrecognized Ensemble -> %s, " | 
| 101 | 
+ | 
             "reverting to NVE for this simulation.\n", | 
| 102 | 
+ | 
             ensemble ); | 
| 103 | 
+ | 
    painCave.isFatal = 0; | 
| 104 | 
+ | 
    simError(); | 
| 105 | 
+ | 
    strcpy( ensemble, "NVE" ); | 
| 106 | 
+ | 
  }   | 
| 107 | 
  | 
  strcpy( simnfo->ensemble, ensemble ); | 
| 108 | 
  | 
 | 
| 109 | 
  | 
  strcpy( simnfo->mixingRule, the_globals->getMixingRule() ); | 
| 110 | 
  | 
  simnfo->usePBC = the_globals->getPBC(); | 
| 111 | 
  | 
           | 
| 112 | 
< | 
 | 
| 113 | 
< | 
 | 
| 114 | 
< | 
  if( !strcmp( force_field, "TraPPE" ) ) the_ff = new TraPPEFF(); | 
| 115 | 
< | 
  else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); | 
| 116 | 
< | 
  else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); | 
| 117 | 
< | 
  else if( !strcmp( force_field, "LJ" ) ) the_ff = new LJ_FF(); | 
| 112 | 
> | 
  int usesDipoles = 0; | 
| 113 | 
> | 
  if( !strcmp( force_field, "TraPPE_Ex" ) ){ | 
| 114 | 
> | 
    the_ff = new TraPPE_ExFF(); | 
| 115 | 
> | 
    usesDipoles = 1; | 
| 116 | 
> | 
  } | 
| 117 | 
> | 
  else if( !strcasecmp( force_field, "LJ" ) ) the_ff = new LJ_FF(); | 
| 118 | 
  | 
  else{ | 
| 119 | 
  | 
    sprintf( painCave.errMsg, | 
| 120 | 
  | 
             "SimSetup Error. Unrecognized force field -> %s\n", | 
| 265 | 
  | 
 | 
| 266 | 
  | 
  globalIndex = mpiSim->divideLabor(); | 
| 267 | 
  | 
 | 
| 245 | 
– | 
 | 
| 246 | 
– | 
 | 
| 268 | 
  | 
  // set up the local variables  | 
| 269 | 
  | 
   | 
| 270 | 
  | 
  int localMol, allMol; | 
| 271 | 
  | 
  int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; | 
| 272 | 
+ | 
 | 
| 273 | 
+ | 
  int* mol2proc = mpiSim->getMolToProcMap(); | 
| 274 | 
+ | 
  int* molCompType = mpiSim->getMolComponentType(); | 
| 275 | 
  | 
   | 
| 276 | 
  | 
  allMol = 0; | 
| 277 | 
  | 
  localMol = 0; | 
| 283 | 
  | 
 | 
| 284 | 
  | 
    for( j=0; j<components_nmol[i]; j++ ){ | 
| 285 | 
  | 
       | 
| 286 | 
< | 
      if( mpiSim->getMyMolStart() <= allMol && | 
| 263 | 
< | 
          allMol <= mpiSim->getMyMolEnd() ){ | 
| 286 | 
> | 
      if( mol2proc[j] == worldRank ){ | 
| 287 | 
  | 
         | 
| 288 | 
  | 
        local_atoms +=    comp_stamps[i]->getNAtoms(); | 
| 289 | 
  | 
        local_bonds +=    comp_stamps[i]->getNBonds(); | 
| 302 | 
  | 
  if( local_atoms != simnfo->n_atoms ){ | 
| 303 | 
  | 
    sprintf( painCave.errMsg, | 
| 304 | 
  | 
             "SimSetup error: mpiSim's localAtom (%d) and SimSetup's" | 
| 305 | 
< | 
             " localAtom (%d) are note equal.\n", | 
| 305 | 
> | 
             " localAtom (%d) are not equal.\n", | 
| 306 | 
  | 
             simnfo->n_atoms, | 
| 307 | 
  | 
             local_atoms ); | 
| 308 | 
  | 
    painCave.isFatal = 1; | 
| 327 | 
  | 
  Atom::createArrays(simnfo->n_atoms); | 
| 328 | 
  | 
  the_atoms = new Atom*[simnfo->n_atoms]; | 
| 329 | 
  | 
  the_molecules = new Molecule[simnfo->n_mol]; | 
| 330 | 
+ | 
  int molIndex; | 
| 331 | 
  | 
 | 
| 332 | 
+ | 
  // initialize the molecule's stampID's | 
| 333 | 
  | 
 | 
| 334 | 
+ | 
#ifdef IS_MPI | 
| 335 | 
+ | 
   | 
| 336 | 
+ | 
 | 
| 337 | 
+ | 
  molIndex = 0; | 
| 338 | 
+ | 
  for(i=0; i<mpiSim->getTotNmol(); i++){ | 
| 339 | 
+ | 
     | 
| 340 | 
+ | 
    if(mol2proc[i] == worldRank ){ | 
| 341 | 
+ | 
      the_molecules[molIndex].setStampID( molCompType[i] ); | 
| 342 | 
+ | 
      the_molecules[molIndex].setMyIndex( molIndex ); | 
| 343 | 
+ | 
      molIndex++; | 
| 344 | 
+ | 
    } | 
| 345 | 
+ | 
  } | 
| 346 | 
+ | 
 | 
| 347 | 
+ | 
#else // is_mpi | 
| 348 | 
+ | 
   | 
| 349 | 
+ | 
  molIndex = 0; | 
| 350 | 
+ | 
  for(i=0; i<n_components; i++){ | 
| 351 | 
+ | 
    for(j=0; j<components_nmol[i]; j++ ){ | 
| 352 | 
+ | 
      the_molecules[molIndex].setStampID( i ); | 
| 353 | 
+ | 
      the_molecules[molIndex].setMyIndex( molIndex ); | 
| 354 | 
+ | 
      molIndex++; | 
| 355 | 
+ | 
    } | 
| 356 | 
+ | 
  } | 
| 357 | 
+ | 
     | 
| 358 | 
+ | 
 | 
| 359 | 
+ | 
#endif // is_mpi | 
| 360 | 
+ | 
 | 
| 361 | 
+ | 
 | 
| 362 | 
  | 
  if( simnfo->n_SRI ){ | 
| 363 | 
+ | 
     | 
| 364 | 
  | 
    Exclude::createArray(simnfo->n_SRI); | 
| 365 | 
  | 
    the_excludes = new Exclude*[simnfo->n_SRI]; | 
| 366 | 
+ | 
    for( int ex=0; ex<simnfo->n_SRI; ex++) the_excludes[ex] = new Exclude(ex); | 
| 367 | 
  | 
    simnfo->globalExcludes = new int; | 
| 368 | 
< | 
    simnfo->n_exclude = tot_SRI; | 
| 368 | 
> | 
    simnfo->n_exclude = simnfo->n_SRI; | 
| 369 | 
  | 
  } | 
| 370 | 
  | 
  else{ | 
| 371 | 
  | 
     | 
| 381 | 
  | 
  // set the arrays into the SimInfo object | 
| 382 | 
  | 
 | 
| 383 | 
  | 
  simnfo->atoms = the_atoms; | 
| 384 | 
< | 
  simnfo->sr_interactions = the_sris; | 
| 384 | 
> | 
  simnfo->molecules = the_molecules; | 
| 385 | 
  | 
  simnfo->nGlobalExcludes = 0; | 
| 386 | 
  | 
  simnfo->excludes = the_excludes; | 
| 387 | 
  | 
 | 
| 438 | 
  | 
 | 
| 439 | 
  | 
  the_ff->setSimInfo( simnfo ); | 
| 440 | 
  | 
 | 
| 441 | 
< | 
  makeAtoms(); | 
| 441 | 
> | 
  makeMolecules(); | 
| 442 | 
  | 
  simnfo->identArray = new int[simnfo->n_atoms]; | 
| 443 | 
  | 
  for(i=0; i<simnfo->n_atoms; i++){ | 
| 444 | 
  | 
    simnfo->identArray[i] = the_atoms[i]->getIdent(); | 
| 445 | 
  | 
  } | 
| 446 | 
  | 
   | 
| 392 | 
– | 
  if( tot_bonds ){ | 
| 393 | 
– | 
    makeBonds(); | 
| 394 | 
– | 
  } | 
| 395 | 
– | 
 | 
| 396 | 
– | 
  if( tot_bends ){ | 
| 397 | 
– | 
    makeBends(); | 
| 398 | 
– | 
  } | 
| 399 | 
– | 
 | 
| 400 | 
– | 
  if( tot_torsions ){ | 
| 401 | 
– | 
    makeTorsions(); | 
| 402 | 
– | 
  } | 
| 403 | 
– | 
 | 
| 404 | 
– | 
 | 
| 447 | 
  | 
  if (the_globals->getUseRF() ) { | 
| 448 | 
  | 
    simnfo->useReactionField = 1; | 
| 449 | 
  | 
   | 
| 485 | 
  | 
    } | 
| 486 | 
  | 
    simnfo->dielectric = the_globals->getDielectric();   | 
| 487 | 
  | 
  } else { | 
| 488 | 
< | 
    if (simnfo->n_dipoles) { | 
| 488 | 
> | 
    if (usesDipoles) { | 
| 489 | 
  | 
       | 
| 490 | 
  | 
      if( !the_globals->haveECR() ){ | 
| 491 | 
  | 
        sprintf( painCave.errMsg, | 
| 492 | 
< | 
                 "SimSetup Warning: using default value of 1/2 the smallest" | 
| 492 | 
> | 
                 "SimSetup Warning: using default value of 1/2 the smallest " | 
| 493 | 
  | 
                 "box length for the electrostaticCutoffRadius.\n" | 
| 494 | 
  | 
                 "I hope you have a very fast processor!\n"); | 
| 495 | 
  | 
        painCave.isFatal = 0; | 
| 505 | 
  | 
       | 
| 506 | 
  | 
      if( !the_globals->haveEST() ){ | 
| 507 | 
  | 
        sprintf( painCave.errMsg, | 
| 508 | 
< | 
                 "SimSetup Warning: using default value of 5% of the" | 
| 508 | 
> | 
                 "SimSetup Warning: using default value of 5%% of the " | 
| 509 | 
  | 
                 "electrostaticCutoffRadius for the " | 
| 510 | 
  | 
                 "electrostaticSkinThickness\n" | 
| 511 | 
  | 
                 ); | 
| 680 | 
  | 
 | 
| 681 | 
  | 
//   new AllLong( simnfo ); | 
| 682 | 
  | 
 | 
| 641 | 
– | 
  if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo, the_ff ); | 
| 642 | 
– | 
  if( !strcmp( force_field, "DipoleTest" ) ) new Symplectic( simnfo, the_ff ); | 
| 643 | 
– | 
  if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic( simnfo, the_ff ); | 
| 644 | 
– | 
  if( !strcmp( force_field, "LJ" ) ) new Verlet( *simnfo, the_ff ); | 
| 683 | 
  | 
 | 
| 684 | 
< | 
 | 
| 684 | 
> | 
  if( !strcmp( force_field, "TraPPE_Ex" ) ){ | 
| 685 | 
> | 
    new Symplectic(simnfo, the_ff, the_extendedsystem); | 
| 686 | 
> | 
    std::cerr << "called new Symplecic\n"; | 
| 687 | 
> | 
    fprintf( stderr, "called new Symplectic. stderr\n" ); | 
| 688 | 
> | 
  } | 
| 689 | 
> | 
  else if( !strcmp( force_field, "LJ" ) ){ | 
| 690 | 
> | 
    new Verlet( *simnfo, the_ff, the_extendedsystem ); | 
| 691 | 
> | 
    std::cerr << "called new Verlet\n"; | 
| 692 | 
> | 
    fprintf( stderr, "called new Verlet. stderr\n" ); | 
| 693 | 
> | 
  } | 
| 694 | 
> | 
  else { | 
| 695 | 
> | 
    std::cerr << "I'm a bug.\n"; | 
| 696 | 
> | 
    fprintf( stderr, "Ima bug. stderr %s\n", force_field); | 
| 697 | 
> | 
  } | 
| 698 | 
> | 
#ifdef IS_MPI | 
| 699 | 
> | 
  mpiSim->mpiRefresh(); | 
| 700 | 
> | 
#endif | 
| 701 | 
  | 
 | 
| 702 | 
  | 
  // initialize the Fortran | 
| 703 | 
< | 
   | 
| 703 | 
> | 
 | 
| 704 | 
> | 
 | 
| 705 | 
  | 
  simnfo->refreshSim(); | 
| 706 | 
  | 
   | 
| 707 | 
  | 
  if( !strcmp( simnfo->mixingRule, "standard") ){ | 
| 738 | 
  | 
  BondStamp* currentBond; | 
| 739 | 
  | 
  BendStamp* currentBend; | 
| 740 | 
  | 
  TorsionStamp* currentTorsion; | 
| 741 | 
+ | 
 | 
| 742 | 
+ | 
  bond_pair* theBonds; | 
| 743 | 
+ | 
  bend_set* theBends; | 
| 744 | 
+ | 
  torsion_set* theTorsions; | 
| 745 | 
+ | 
 | 
| 746 | 
  | 
   | 
| 747 | 
  | 
  //init the forceField paramters | 
| 748 | 
  | 
 | 
| 749 | 
  | 
  the_ff->readParams(); | 
| 750 | 
  | 
 | 
| 751 | 
  | 
   | 
| 752 | 
< | 
  // init the molecules | 
| 752 | 
> | 
  // init the atoms | 
| 753 | 
  | 
 | 
| 754 | 
+ | 
  double ux, uy, uz, u, uSqr; | 
| 755 | 
+ | 
   | 
| 756 | 
  | 
  atomOffset = 0; | 
| 757 | 
  | 
  excludeOffset = 0; | 
| 758 | 
  | 
  for(i=0; i<simnfo->n_mol; i++){ | 
| 769 | 
  | 
    info.myExcludes = &the_excludes[excludeOffset]; | 
| 770 | 
  | 
    info.myBonds = new Bond*[info.nBonds]; | 
| 771 | 
  | 
    info.myBends = new Bend*[info.nBends]; | 
| 772 | 
< | 
    info.myTorsions = new Torsions*[info.nTorsions]; | 
| 772 | 
> | 
    info.myTorsions = new Torsion*[info.nTorsions]; | 
| 773 | 
  | 
 | 
| 774 | 
  | 
    theBonds = new bond_pair[info.nBonds]; | 
| 775 | 
  | 
    theBends = new bend_set[info.nBends]; | 
| 779 | 
  | 
     | 
| 780 | 
  | 
    for(j=0; j<info.nAtoms; j++){ | 
| 781 | 
  | 
       | 
| 782 | 
< | 
      currentAtom = theComponents[stampID]->getAtom( j ); | 
| 782 | 
> | 
      currentAtom = comp_stamps[stampID]->getAtom( j ); | 
| 783 | 
  | 
      if( currentAtom->haveOrientation() ){ | 
| 784 | 
  | 
         | 
| 785 | 
  | 
        dAtom = new DirectionalAtom(j + atomOffset); | 
| 820 | 
  | 
      theBonds[j].a = currentBond->getA() + atomOffset; | 
| 821 | 
  | 
      theBonds[j].b = currentBond->getB() + atomOffset; | 
| 822 | 
  | 
 | 
| 823 | 
< | 
      exI = theBonds[i].a; | 
| 824 | 
< | 
      exJ = theBonds[i].b; | 
| 823 | 
> | 
      exI = theBonds[j].a; | 
| 824 | 
> | 
      exJ = theBonds[j].b; | 
| 825 | 
  | 
 | 
| 826 | 
  | 
      // exclude_I must always be the smaller of the pair | 
| 827 | 
  | 
      if( exI > exJ ){ | 
| 837 | 
  | 
       | 
| 838 | 
  | 
      the_excludes[j+excludeOffset]->setPair( exI, exJ ); | 
| 839 | 
  | 
#else  // isn't MPI | 
| 840 | 
+ | 
 | 
| 841 | 
  | 
      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); | 
| 842 | 
  | 
#endif  //is_mpi | 
| 843 | 
  | 
    } | 
| 853 | 
  | 
           | 
| 854 | 
  | 
      if( currentBend->haveExtras() ){ | 
| 855 | 
  | 
             | 
| 856 | 
< | 
        extras = current_bend->getExtras(); | 
| 856 | 
> | 
        extras = currentBend->getExtras(); | 
| 857 | 
  | 
        current_extra = extras; | 
| 858 | 
  | 
             | 
| 859 | 
  | 
        while( current_extra != NULL ){ | 
| 875 | 
  | 
               | 
| 876 | 
  | 
            default: | 
| 877 | 
  | 
              sprintf( painCave.errMsg, | 
| 878 | 
< | 
                       "SimSetup Error: ghostVectorSource was neiter a " | 
| 878 | 
> | 
                       "SimSetup Error: ghostVectorSource was neither a " | 
| 879 | 
  | 
                       "double nor an int.\n" | 
| 880 | 
  | 
                       "-->Bend[%d] in %s\n", | 
| 881 | 
  | 
                       j, comp_stamps[stampID]->getID() ); | 
| 969 | 
  | 
 | 
| 970 | 
  | 
 | 
| 971 | 
  | 
    the_molecules[i].initialize( info ); | 
| 972 | 
+ | 
 | 
| 973 | 
+ | 
 | 
| 974 | 
  | 
    atomOffset += info.nAtoms; | 
| 975 | 
+ | 
    delete[] theBonds; | 
| 976 | 
+ | 
    delete[] theBends; | 
| 977 | 
+ | 
    delete[] theTorsions; | 
| 978 | 
  | 
  } | 
| 979 | 
  | 
 | 
| 980 | 
+ | 
#ifdef IS_MPI | 
| 981 | 
+ | 
  sprintf( checkPointMsg, "all molecules initialized succesfully" ); | 
| 982 | 
+ | 
  MPIcheckPoint(); | 
| 983 | 
+ | 
#endif // is_mpi | 
| 984 | 
+ | 
 | 
| 985 | 
  | 
  // clean up the forcefield | 
| 986 | 
  | 
  the_ff->calcRcut(); | 
| 987 | 
  | 
  the_ff->cleanMe(); | 
| 988 | 
+ | 
 | 
| 989 | 
  | 
} | 
| 990 | 
  | 
 | 
| 991 | 
  | 
void SimSetup::initFromBass( void ){ |