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 378 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
Revision 422 by mmeineke, Thu Mar 27 19:21:42 2003 UTC

# Line 248 | Line 248 | void SimSetup::createSim( void ){
248    
249    int localMol, allMol;
250    int local_atoms, local_bonds, local_bends, local_torsions, local_SRI;
251 +
252 +  int* mol2proc = mpiSim->getMolToProcMap();
253 +  int* molCompType = mpiSim->getMolComponentType();
254    
255    allMol = 0;
256    localMol = 0;
# Line 259 | Line 262 | void SimSetup::createSim( void ){
262  
263      for( j=0; j<components_nmol[i]; j++ ){
264        
265 <      if( mpiSim->getMyMolStart() <= allMol &&
263 <          allMol <= mpiSim->getMyMolEnd() ){
265 >      if( mol2proc[j] == worldRank ){
266          
267          local_atoms +=    comp_stamps[i]->getNAtoms();
268          local_bonds +=    comp_stamps[i]->getNBonds();
# Line 279 | Line 281 | void SimSetup::createSim( void ){
281    if( local_atoms != simnfo->n_atoms ){
282      sprintf( painCave.errMsg,
283               "SimSetup error: mpiSim's localAtom (%d) and SimSetup's"
284 <             " localAtom (%d) are note equal.\n",
284 >             " localAtom (%d) are not equal.\n",
285               simnfo->n_atoms,
286               local_atoms );
287      painCave.isFatal = 1;
# Line 304 | Line 306 | void SimSetup::createSim( void ){
306    Atom::createArrays(simnfo->n_atoms);
307    the_atoms = new Atom*[simnfo->n_atoms];
308    the_molecules = new Molecule[simnfo->n_mol];
309 +  int molIndex;
310 +
311 +  // initialize the molecule's stampID's
312 +
313 + #ifdef IS_MPI
314 +  
315  
316 +  molIndex = 0;
317 +  for(i=0; i<mpiSim->getTotNmol(); i++){
318 +    
319 +    if(mol2proc[i] == worldRank ){
320 +      the_molecules[molIndex].setStampID( molCompType[i] );
321 +      molIndex++;
322 +    }
323 +  }
324  
325 + #else // is_mpi
326 +  
327 +  molIndex = 0;
328 +  for(i=0; i<n_components; i++){
329 +    for(j=0; j<components_nmol[i]; j++ ){
330 +      the_molecules[molIndex].setStampID( i );
331 +      molIndex++;
332 +    }
333 +  }
334 +    
335 +
336 + #endif // is_mpi
337 +
338 +
339    if( simnfo->n_SRI ){
340 <    the_sris = new SRI*[simnfo->n_SRI];
341 <    the_excludes = new int[2 * simnfo->n_SRI];
340 >    Exclude::createArray(simnfo->n_SRI);
341 >    the_excludes = new Exclude*[simnfo->n_SRI];
342      simnfo->globalExcludes = new int;
343      simnfo->n_exclude = tot_SRI;
344    }
345    else{
346      
347 <    the_excludes = new int[2];
348 <    the_excludes[0] = 0;
349 <    the_excludes[1] = 0;
347 >    Exclude::createArray( 1 );
348 >    the_excludes = new Exclude*;
349 >    the_excludes[0] = new Exclude(0);
350 >    the_excludes[0]->setPair( 0,0 );
351      simnfo->globalExcludes = new int;
352      simnfo->globalExcludes[0] = 0;
353 <
323 <    simnfo->n_exclude = 1;
353 >    simnfo->n_exclude = 0;
354    }
355  
356    // set the arrays into the SimInfo object
357  
358    simnfo->atoms = the_atoms;
329  simnfo->sr_interactions = the_sris;
359    simnfo->nGlobalExcludes = 0;
360    simnfo->excludes = the_excludes;
361  
362  
363    // get some of the tricky things that may still be in the globals
364  
336  if( simnfo->n_dipoles ){
337
338    if( !the_globals->haveRRF() ){
339      sprintf( painCave.errMsg,
340               "SimSetup Error, system has dipoles, but no rRF was set.\n");
341      painCave.isFatal = 1;
342      simError();
343    }
344    if( !the_globals->haveDielectric() ){
345      sprintf( painCave.errMsg,
346               "SimSetup Error, system has dipoles, but no"
347               " dielectric was set.\n" );
348      painCave.isFatal = 1;
349      simError();
350    }
351
352    simnfo->rRF        = the_globals->getRRF();
353    simnfo->dielectric = the_globals->getDielectric();
354  }
355
356 #ifdef IS_MPI
357  strcpy( checkPointMsg, "rRf and dielectric check out" );
358  MPIcheckPoint();
359 #endif // is_mpi
365    
366    if( the_globals->haveBox() ){
367      simnfo->box_x = the_globals->getBox();
# Line 407 | Line 412 | void SimSetup::createSim( void ){
412  
413    the_ff->setSimInfo( simnfo );
414  
415 <  makeAtoms();
415 >  makeMolecules();
416    simnfo->identArray = new int[simnfo->n_atoms];
417    for(i=0; i<simnfo->n_atoms; i++){
418      simnfo->identArray[i] = the_atoms[i]->getIdent();
419    }
420    
421 <  if( tot_bonds ){
422 <    makeBonds();
423 <  }
424 <
425 <  if( tot_bends ){
426 <    makeBends();
427 <  }
428 <
429 <  if( tot_torsions ){
430 <    makeTorsions();
431 <  }
432 <
433 <
434 <
421 >  if (the_globals->getUseRF() ) {
422 >    simnfo->useReactionField = 1;
423 >  
424 >    if( !the_globals->haveECR() ){
425 >      sprintf( painCave.errMsg,
426 >               "SimSetup Warning: using default value of 1/2 the smallest "
427 >               "box length for the electrostaticCutoffRadius.\n"
428 >               "I hope you have a very fast processor!\n");
429 >      painCave.isFatal = 0;
430 >      simError();
431 >      double smallest;
432 >      smallest = simnfo->box_x;
433 >      if (simnfo->box_y <= smallest) smallest = simnfo->box_y;
434 >      if (simnfo->box_z <= smallest) smallest = simnfo->box_z;
435 >      simnfo->ecr = 0.5 * smallest;
436 >    } else {
437 >      simnfo->ecr        = the_globals->getECR();
438 >    }
439  
440 +    if( !the_globals->haveEST() ){
441 +      sprintf( painCave.errMsg,
442 +               "SimSetup Warning: using default value of 0.05 * the "
443 +               "electrostaticCutoffRadius for the electrostaticSkinThickness\n"
444 +               );
445 +      painCave.isFatal = 0;
446 +      simError();
447 +      simnfo->est = 0.05 * simnfo->ecr;
448 +    } else {
449 +      simnfo->est        = the_globals->getEST();
450 +    }
451 +    
452 +    if(!the_globals->haveDielectric() ){
453 +      sprintf( painCave.errMsg,
454 +               "SimSetup Error: You are trying to use Reaction Field without"
455 +               "setting a dielectric constant!\n"
456 +               );
457 +      painCave.isFatal = 1;
458 +      simError();
459 +    }
460 +    simnfo->dielectric = the_globals->getDielectric();  
461 +  } else {
462 +    if (simnfo->n_dipoles) {
463 +      
464 +      if( !the_globals->haveECR() ){
465 +        sprintf( painCave.errMsg,
466 +                 "SimSetup Warning: using default value of 1/2 the smallest"
467 +                 "box length for the electrostaticCutoffRadius.\n"
468 +                 "I hope you have a very fast processor!\n");
469 +        painCave.isFatal = 0;
470 +        simError();
471 +        double smallest;
472 +        smallest = simnfo->box_x;
473 +        if (simnfo->box_y <= smallest) smallest = simnfo->box_y;
474 +        if (simnfo->box_z <= smallest) smallest = simnfo->box_z;
475 +        simnfo->ecr = 0.5 * smallest;
476 +      } else {
477 +        simnfo->ecr        = the_globals->getECR();
478 +      }
479 +      
480 +      if( !the_globals->haveEST() ){
481 +        sprintf( painCave.errMsg,
482 +                 "SimSetup Warning: using default value of 5% of the"
483 +                 "electrostaticCutoffRadius for the "
484 +                 "electrostaticSkinThickness\n"
485 +                 );
486 +        painCave.isFatal = 0;
487 +        simError();
488 +        simnfo->est = 0.05 * simnfo->ecr;
489 +      } else {
490 +        simnfo->est        = the_globals->getEST();
491 +      }
492 +    }
493 +  }  
494  
495 + #ifdef IS_MPI
496 +  strcpy( checkPointMsg, "electrostatic parameters check out" );
497 +  MPIcheckPoint();
498 + #endif // is_mpi
499  
500   if( the_globals->haveInitialConfig() ){
501  
# Line 620 | Line 687 | void SimSetup::makeAtoms( void ){
687   #endif // is_mpi
688   }
689  
623 void SimSetup::makeAtoms( void ){
690  
691 <  int i, j, k, index;
626 <  double ux, uy, uz, uSqr, u;
627 <  AtomStamp* current_atom;
691 > void SimSetup::makeMolecules( void ){
692  
693 +  int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset;
694 +  molInit info;
695    DirectionalAtom* dAtom;
696 <  int molIndex, molStart, molEnd, nMemb, lMolIndex;
697 <
698 <  lMolIndex = 0;
699 <  molIndex = 0;
700 <  index = 0;
701 <  for( i=0; i<n_components; i++ ){
696 >  LinkedAssign* extras;
697 >  LinkedAssign* current_extra;
698 >  AtomStamp* currentAtom;
699 >  BondStamp* currentBond;
700 >  BendStamp* currentBend;
701 >  TorsionStamp* currentTorsion;
702 >  
703 >  //init the forceField paramters
704  
705 <    for( j=0; j<components_nmol[i]; j++ ){
705 >  the_ff->readParams();
706  
707 < #ifdef IS_MPI
708 <      if( mpiSim->getMyMolStart() <= molIndex &&
641 <          molIndex <= mpiSim->getMyMolEnd() ){
642 < #endif // is_mpi        
707 >  
708 >  // init the molecules
709  
710 <        molStart = index;
711 <        nMemb = comp_stamps[i]->getNAtoms();
712 <        for( k=0; k<comp_stamps[i]->getNAtoms(); k++ ){
647 <          
648 <          current_atom = comp_stamps[i]->getAtom( k );
649 <          if( current_atom->haveOrientation() ){
650 <            
651 <            dAtom = new DirectionalAtom(index);
652 <            simnfo->n_oriented++;
653 <            the_atoms[index] = dAtom;
654 <            
655 <            ux = current_atom->getOrntX();
656 <            uy = current_atom->getOrntY();
657 <            uz = current_atom->getOrntZ();
658 <            
659 <            uSqr = (ux * ux) + (uy * uy) + (uz * uz);
660 <            
661 <            u = sqrt( uSqr );
662 <            ux = ux / u;
663 <            uy = uy / u;
664 <            uz = uz / u;
665 <            
666 <            dAtom->setSUx( ux );
667 <            dAtom->setSUy( uy );
668 <            dAtom->setSUz( uz );
669 <          }
670 <          else{
671 <            the_atoms[index] = new GeneralAtom(index);
672 <          }
673 <          the_atoms[index]->setType( current_atom->getType() );
674 <          the_atoms[index]->setIndex( index );
675 <          
676 <          // increment the index and repeat;
677 <          index++;
678 <        }
679 <        
680 <        molEnd = index -1;
681 <        the_molecules[lMolIndex].setNMembers( nMemb );
682 <        the_molecules[lMolIndex].setStartAtom( molStart );
683 <        the_molecules[lMolIndex].setEndAtom( molEnd );
684 <        the_molecules[lMolIndex].setStampID( i );
685 <        lMolIndex++;
686 <
687 < #ifdef IS_MPI
688 <      }
689 < #endif //is_mpi
690 <      
691 <      molIndex++;
692 <    }
693 <  }
694 <
695 < #ifdef IS_MPI
696 <    for( i=0; i<mpiSim->getMyNlocal(); i++ ) the_atoms[i]->setGlobalIndex( globalIndex[i] );
710 >  atomOffset = 0;
711 >  excludeOffset = 0;
712 >  for(i=0; i<simnfo->n_mol; i++){
713      
714 <    delete[] globalIndex;
714 >    stampID = the_molecules[i].getStampID();
715  
716 <    mpiSim->mpiRefresh();
717 < #endif //IS_MPI
718 <          
719 <  the_ff->initializeAtoms();
720 < }
716 >    info.nAtoms    = comp_stamps[stampID]->getNAtoms();
717 >    info.nBonds    = comp_stamps[stampID]->getNBonds();
718 >    info.nBends    = comp_stamps[stampID]->getNBends();
719 >    info.nTorsions = comp_stamps[stampID]->getNTorsions();
720 >    info.nExcludes = info.nBonds + info.nBends + info.nTorsions;
721  
722 < void SimSetup::makeBonds( void ){
722 >    info.myAtoms = &the_atoms[atomOffset];
723 >    info.myExcludes = &the_excludes[excludeOffset];
724 >    info.myBonds = new Bond*[info.nBonds];
725 >    info.myBends = new Bend*[info.nBends];
726 >    info.myTorsions = new Torsions*[info.nTorsions];
727  
728 <  int i, j, k, index, offset, molIndex, exI, exJ, tempEx;
729 <  bond_pair* the_bonds;
730 <  BondStamp* current_bond;
731 <
732 <  the_bonds = new bond_pair[tot_bonds];
733 <  index = 0;
734 <  offset = 0;
735 <  molIndex = 0;
736 <
737 <  for( i=0; i<n_components; i++ ){
718 <
719 <    for( j=0; j<components_nmol[i]; j++ ){
720 <
721 < #ifdef IS_MPI
722 <      if( mpiSim->getMyMolStart() <= molIndex &&
723 <          molIndex <= mpiSim->getMyMolEnd() ){
724 < #endif // is_mpi        
728 >    theBonds = new bond_pair[info.nBonds];
729 >    theBends = new bend_set[info.nBends];
730 >    theTorsions = new torsion_set[info.nTorsions];
731 >    
732 >    // make the Atoms
733 >    
734 >    for(j=0; j<info.nAtoms; j++){
735 >      
736 >      currentAtom = theComponents[stampID]->getAtom( j );
737 >      if( currentAtom->haveOrientation() ){
738          
739 <        for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){
740 <          
741 <          current_bond = comp_stamps[i]->getBond( k );
742 <          the_bonds[index].a = current_bond->getA() + offset;
743 <          the_bonds[index].b = current_bond->getB() + offset;
744 <
745 <          exI = the_bonds[index].a;
746 <          exJ = the_bonds[index].b;
747 <
748 <          // exclude_I must always be the smaller of the pair
749 <          if( exI > exJ ){
750 <            tempEx = exI;
751 <            exI = exJ;
752 <            exJ = tempEx;
753 <          }
754 <
755 <          
739 >        dAtom = new DirectionalAtom(j + atomOffset);
740 >        simnfo->n_oriented++;
741 >        info.myAtoms[j] = dAtom;
742 >        
743 >        ux = currentAtom->getOrntX();
744 >        uy = currentAtom->getOrntY();
745 >        uz = currentAtom->getOrntZ();
746 >        
747 >        uSqr = (ux * ux) + (uy * uy) + (uz * uz);
748 >        
749 >        u = sqrt( uSqr );
750 >        ux = ux / u;
751 >        uy = uy / u;
752 >        uz = uz / u;
753 >        
754 >        dAtom->setSUx( ux );
755 >        dAtom->setSUy( uy );
756 >        dAtom->setSUz( uz );
757 >      }
758 >      else{
759 >        info.myAtoms[j] = new GeneralAtom(j + atomOffset);
760 >      }
761 >      info.myAtoms[j]->setType( currentAtom->getType() );
762 >    
763   #ifdef IS_MPI
764 <
765 <          the_excludes[index*2] =    
766 <            the_atoms[exI]->getGlobalIndex() + 1;
767 <          the_excludes[index*2 + 1] =
768 <            the_atoms[exJ]->getGlobalIndex() + 1;
769 <
770 < #else  // isn't MPI
771 <          
752 <          the_excludes[index*2] =     exI + 1;
753 <          the_excludes[index*2 + 1] = exJ + 1;
754 <          // fortran index from 1 (hence the +1 in the indexing)
755 < #endif  //is_mpi
756 <          
757 <          // increment the index and repeat;
758 <          index++;
759 <        }
760 <        offset += comp_stamps[i]->getNAtoms();
761 <        
762 < #ifdef IS_MPI
763 <      }
764 < #endif //is_mpi
764 >      
765 >      info.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] );
766 >      
767 > #endif // is_mpi
768 >    }
769 >    
770 >    // make the bonds
771 >    for(j=0; j<info.nBonds; j++){
772        
773 <      molIndex++;
774 <    }      
775 <  }
773 >      currentBond = comp_stamps[stampID]->getBond( j );
774 >      theBonds[j].a = currentBond->getA() + atomOffset;
775 >      theBonds[j].b = currentBond->getB() + atomOffset;
776  
777 <  the_ff->initializeBonds( the_bonds );
778 < }
777 >      exI = theBonds[i].a;
778 >      exJ = theBonds[i].b;
779  
780 < void SimSetup::makeBends( void ){
781 <
782 <  int i, j, k, index, offset, molIndex, exI, exJ, tempEx;
783 <  bend_set* the_bends;
784 <  BendStamp* current_bend;
785 <  LinkedAssign* extras;
779 <  LinkedAssign* current_extra;
780 <  
781 <
782 <  the_bends = new bend_set[tot_bends];
783 <  index = 0;
784 <  offset = 0;
785 <  molIndex = 0;
786 <  for( i=0; i<n_components; i++ ){
787 <
788 <    for( j=0; j<components_nmol[i]; j++ ){
789 <
780 >      // exclude_I must always be the smaller of the pair
781 >      if( exI > exJ ){
782 >        tempEx = exI;
783 >        exI = exJ;
784 >        exJ = tempEx;
785 >      }
786   #ifdef IS_MPI
787 <      if( mpiSim->getMyMolStart() <= molIndex &&
788 <          molIndex <= mpiSim->getMyMolEnd() ){
789 < #endif // is_mpi        
787 >      tempEx = exI;
788 >      exI = the_atoms[tempEx]->getGlobalIndex() + 1;
789 >      tempEx = exJ;
790 >      exJ = the_atoms[tempEx]->getGlobalIndex() + 1;
791 >      
792 >      the_excludes[j+excludeOffset]->setPair( exI, exJ );
793 > #else  // isn't MPI
794 >      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
795 > #endif  //is_mpi
796 >    }
797 >    excludeOffset += info.nBonds;
798  
799 <        for( k=0; k<comp_stamps[i]->getNBends(); k++ ){
799 >    //make the bends
800 >    for(j=0; j<info.nBends; j++){
801 >      
802 >      currentBend = comp_stamps[stampID]->getBend( j );
803 >      theBends[j].a = currentBend->getA() + atomOffset;
804 >      theBends[j].b = currentBend->getB() + atomOffset;
805 >      theBends[j].c = currentBend->getC() + atomOffset;
806            
807 <          current_bend = comp_stamps[i]->getBend( k );
798 <          the_bends[index].a = current_bend->getA() + offset;
799 <          the_bends[index].b = current_bend->getB() + offset;
800 <          the_bends[index].c = current_bend->getC() + offset;
801 <          
802 <          if( current_bend->haveExtras() ){
807 >      if( currentBend->haveExtras() ){
808              
809 <            extras = current_bend->getExtras();
810 <            current_extra = extras;
809 >        extras = current_bend->getExtras();
810 >        current_extra = extras;
811              
812 <            while( current_extra != NULL ){
813 <              if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){
812 >        while( current_extra != NULL ){
813 >          if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){
814                  
815 <                switch( current_extra->getType() ){
815 >            switch( current_extra->getType() ){
816 >              
817 >            case 0:
818 >              theBends[j].ghost =
819 >                current_extra->getInt() + atomOffset;
820 >              theBends[j].isGhost = 1;
821 >              break;
822                    
823 <                case 0:
824 <                  the_bends[index].ghost =
825 <                    current_extra->getInt() + offset;
826 <                  the_bends[index].isGhost = 1;
827 <                  break;
817 <                  
818 <                case 1:
819 <                  the_bends[index].ghost =
820 <                    (int)current_extra->getDouble() + offset;
821 <                  the_bends[index].isGhost = 1;
822 <                  break;
823 <                  
824 <                default:
825 <                  sprintf( painCave.errMsg,
826 <                           "SimSetup Error: ghostVectorSource was neiter a "
827 <                           "double nor an int.\n"
828 <                           "-->Bend[%d] in %s\n",
829 <                           k, comp_stamps[i]->getID() );
830 <                  painCave.isFatal = 1;
831 <                  simError();
832 <                }
833 <              }
823 >            case 1:
824 >              theBends[j].ghost =
825 >                (int)current_extra->getDouble() + atomOffset;
826 >              theBends[j].isGhost = 1;
827 >              break;
828                
829 <              else{
830 <                
831 <                sprintf( painCave.errMsg,
832 <                         "SimSetup Error: unhandled bend assignment:\n"
833 <                         "    -->%s in Bend[%d] in %s\n",
834 <                         current_extra->getlhs(),
835 <                         k, comp_stamps[i]->getID() );
836 <                painCave.isFatal = 1;
843 <                simError();
844 <              }
845 <              
846 <              current_extra = current_extra->getNext();
829 >            default:
830 >              sprintf( painCave.errMsg,
831 >                       "SimSetup Error: ghostVectorSource was neiter a "
832 >                       "double nor an int.\n"
833 >                       "-->Bend[%d] in %s\n",
834 >                       j, comp_stamps[stampID]->getID() );
835 >              painCave.isFatal = 1;
836 >              simError();
837              }
838            }
839            
850          if( !the_bends[index].isGhost ){
851            
852            exI = the_bends[index].a;
853            exJ = the_bends[index].c;
854          }
840            else{
841              
842 <            exI = the_bends[index].a;
843 <            exJ = the_bends[index].b;
842 >            sprintf( painCave.errMsg,
843 >                     "SimSetup Error: unhandled bend assignment:\n"
844 >                     "    -->%s in Bend[%d] in %s\n",
845 >                     current_extra->getlhs(),
846 >                     j, comp_stamps[stampID]->getID() );
847 >            painCave.isFatal = 1;
848 >            simError();
849            }
850            
851 <          // exclude_I must always be the smaller of the pair
852 <          if( exI > exJ ){
853 <            tempEx = exI;
854 <            exI = exJ;
855 <            exJ = tempEx;
856 <          }
857 <
858 <
851 >          current_extra = current_extra->getNext();
852 >        }
853 >      }
854 >          
855 >      if( !theBends[j].isGhost ){
856 >            
857 >        exI = theBends[j].a;
858 >        exJ = theBends[j].c;
859 >      }
860 >      else{
861 >        
862 >        exI = theBends[j].a;
863 >        exJ = theBends[j].b;
864 >      }
865 >      
866 >      // exclude_I must always be the smaller of the pair
867 >      if( exI > exJ ){
868 >        tempEx = exI;
869 >        exI = exJ;
870 >        exJ = tempEx;
871 >      }
872   #ifdef IS_MPI
873 <
874 <          the_excludes[(index + tot_bonds)*2] =    
875 <            the_atoms[exI]->getGlobalIndex() + 1;
876 <          the_excludes[(index + tot_bonds)*2 + 1] =
877 <            the_atoms[exJ]->getGlobalIndex() + 1;
878 <          
873 >      tempEx = exI;
874 >      exI = the_atoms[tempEx]->getGlobalIndex() + 1;
875 >      tempEx = exJ;
876 >      exJ = the_atoms[tempEx]->getGlobalIndex() + 1;
877 >      
878 >      the_excludes[j+excludeOffset]->setPair( exI, exJ );
879   #else  // isn't MPI
880 <          
878 <          the_excludes[(index + tot_bonds)*2] =     exI + 1;
879 <          the_excludes[(index + tot_bonds)*2 + 1] = exJ + 1;
880 <          // fortran index from 1 (hence the +1 in the indexing)
880 >      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
881   #endif  //is_mpi
882          
883          
884          // increment the index and repeat;
885          index++;
886        }
887        offset += comp_stamps[i]->getNAtoms();
888        
889 #ifdef IS_MPI
890      }
891 #endif //is_mpi
892
893      molIndex++;
882      }
883 <  }
883 >    excludeOffset += info.nBends;
884  
885 < #ifdef IS_MPI
886 <  sprintf( checkPointMsg,
887 <           "Successfully created the bends list.\n" );
888 <  MPIcheckPoint();
889 < #endif // is_mpi
890 <  
891 <
892 <  the_ff->initializeBends( the_bends );
893 < }
894 <
907 < void SimSetup::makeTorsions( void ){
908 <
909 <  int i, j, k, index, offset, molIndex, exI, exJ, tempEx;
910 <  torsion_set* the_torsions;
911 <  TorsionStamp* current_torsion;
912 <
913 <  the_torsions = new torsion_set[tot_torsions];
914 <  index = 0;
915 <  offset = 0;
916 <  molIndex = 0;
917 <  for( i=0; i<n_components; i++ ){
918 <
919 <    for( j=0; j<components_nmol[i]; j++ ){
885 >    for(j=0; j<info.nTorsions; j++){
886 >      
887 >      currentTorsion = comp_stamps[stampID]->getTorsion( j );
888 >      theTorsions[j].a = currentTorsion->getA() + atomOffset;
889 >      theTorsions[j].b = currentTorsion->getB() + atomOffset;
890 >      theTorsions[j].c = currentTorsion->getC() + atomOffset;
891 >      theTorsions[j].d = currentTorsion->getD() + atomOffset;
892 >      
893 >      exI = theTorsions[j].a;
894 >      exJ = theTorsions[j].d;
895  
896 +      // exclude_I must always be the smaller of the pair
897 +      if( exI > exJ ){
898 +        tempEx = exI;
899 +        exI = exJ;
900 +        exJ = tempEx;
901 +      }
902   #ifdef IS_MPI
903 <      if( mpiSim->getMyMolStart() <= molIndex &&
904 <          molIndex <= mpiSim->getMyMolEnd() ){
905 < #endif // is_mpi        
906 <
907 <      for( k=0; k<comp_stamps[i]->getNTorsions(); k++ ){
908 <
928 <        current_torsion = comp_stamps[i]->getTorsion( k );
929 <        the_torsions[index].a = current_torsion->getA() + offset;
930 <        the_torsions[index].b = current_torsion->getB() + offset;
931 <        the_torsions[index].c = current_torsion->getC() + offset;
932 <        the_torsions[index].d = current_torsion->getD() + offset;
933 <
934 <        exI = the_torsions[index].a;
935 <        exJ = the_torsions[index].d;
936 <
937 <        
938 <        // exclude_I must always be the smaller of the pair
939 <        if( exI > exJ ){
940 <          tempEx = exI;
941 <          exI = exJ;
942 <          exJ = tempEx;
943 <        }
944 <
945 <
946 < #ifdef IS_MPI
947 <        
948 <        the_excludes[(index + tot_bonds + tot_bends)*2] =    
949 <          the_atoms[exI]->getGlobalIndex() + 1;
950 <        the_excludes[(index + tot_bonds + tot_bends)*2 + 1] =
951 <          the_atoms[exJ]->getGlobalIndex() + 1;
952 <        
903 >      tempEx = exI;
904 >      exI = the_atoms[tempEx]->getGlobalIndex() + 1;
905 >      tempEx = exJ;
906 >      exJ = the_atoms[tempEx]->getGlobalIndex() + 1;
907 >      
908 >      the_excludes[j+excludeOffset]->setPair( exI, exJ );
909   #else  // isn't MPI
910 <        
955 <        the_excludes[(index + tot_bonds + tot_bends)*2] =     exI + 1;
956 <        the_excludes[(index + tot_bonds + tot_bends)*2 + 1] = exJ + 1;
957 <        // fortran indexes from 1 (hence the +1 in the indexing)
910 >      the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) );
911   #endif  //is_mpi
912 <        
912 >    }
913 >    excludeOffset += info.nTorsions;
914  
915 <        // increment the index and repeat;
916 <        index++;
963 <      }
964 <      offset += comp_stamps[i]->getNAtoms();
915 >    
916 >    // send the arrays off to the forceField for init.
917  
918 < #ifdef IS_MPI
919 <      }
920 < #endif //is_mpi      
918 >    the_ff->initializeAtoms( info.nAtoms, info.myAtoms );
919 >    the_ff->initializeBonds( info.nBonds, info.myBonds, theBonds );
920 >    the_ff->initializeBends( info.nBends, info.myBends, theBends );
921 >    the_ff->initializeTorsions( info.nTorsions, info.myTorsions, theTorsions );
922  
923 <      molIndex++;
924 <    }
923 >
924 >    the_molecules[i].initialize( info );
925 >    atomOffset += info.nAtoms;
926    }
927  
928 <  the_ff->initializeTorsions( the_torsions );
928 >  // clean up the forcefield
929 >  the_ff->calcRcut();
930 >  the_ff->cleanMe();
931   }
932  
933   void SimSetup::initFromBass( void ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines