ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/brains/SimCreator.cpp
(Generate patch)

Comparing trunk/src/brains/SimCreator.cpp (file contents):
Revision 1810 by gezelter, Thu Nov 8 14:23:43 2012 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
# Line 44 | Line 44
44   * @file SimCreator.cpp
45   * @author tlin
46   * @date 11/03/2004
47 * @time 13:51am
47   * @version 1.0
48   */
49   #include <exception>
# Line 112 | Line 111 | namespace OpenMD {
111          //brocasting the stream size
112          streamSize = ppStream.str().size() +1;
113          MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode);
114 <        MPI::COMM_WORLD.Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())),
115 <                              streamSize, MPI::CHAR, masterNode);
117 <                
114 >        MPI::COMM_WORLD.Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), streamSize, MPI::CHAR, masterNode);
115 >                          
116        } else {
119
117          MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode);
118  
119          //get stream size
# Line 130 | Line 127 | namespace OpenMD {
127                  
128          ppStream.str(buf);
129          delete [] buf;
133
130        }
131   #endif            
132        // Create a scanner that reads from the input stream
# Line 256 | Line 252 | namespace OpenMD {
252      int metaDataBlockStart = -1;
253      int metaDataBlockEnd = -1;
254      int i, j;
255 <    streamoff mdOffset(0);
255 >    streamoff mdOffset;
256      int mdFileVersion;
257  
258      // Create a string for embedding the version information in the MetaData
# Line 515 | Line 511 | namespace OpenMD {
511    
512   #ifdef IS_MPI
513    void SimCreator::divideMolecules(SimInfo *info) {
518    RealType numerator;
519    RealType denominator;
520    RealType precast;
521    RealType x;
522    RealType y;
514      RealType a;
524    int old_atoms;
525    int add_atoms;
526    int new_atoms;
527    int nTarget;
528    int done;
529    int i;
530    int loops;
531    int which_proc;
515      int nProcessors;
516      std::vector<int> atomsPerProc;
517      int nGlobalMols = info->getNGlobalMolecules();
518 <    std::vector<int> molToProcMap(nGlobalMols, -1); // default to an error condition:
518 >    std::vector<int> molToProcMap(nGlobalMols, -1); // default to an
519 >                                                    // error
520 >                                                    // condition:
521      
522      nProcessors = MPI::COMM_WORLD.Get_size();
523      
# Line 543 | Line 528 | namespace OpenMD {
528                "\tthe number of molecules.  This will not result in a \n"
529                "\tusable division of atoms for force decomposition.\n"
530                "\tEither try a smaller number of processors, or run the\n"
531 <              "\tsingle-processor version of OpenMD.\n", nProcessors, nGlobalMols);
531 >              "\tsingle-processor version of OpenMD.\n", nProcessors,
532 >              nGlobalMols);
533        
534        painCave.isFatal = 1;
535        simError();
536      }
537      
552    int seedValue;
538      Globals * simParams = info->getSimParams();
539 <    SeqRandNumGen* myRandom; //divide labor does not need Parallel random number generator
539 >    SeqRandNumGen* myRandom; //divide labor does not need Parallel
540 >                             //random number generator
541      if (simParams->haveSeed()) {
542 <      seedValue = simParams->getSeed();
542 >      int seedValue = simParams->getSeed();
543        myRandom = new SeqRandNumGen(seedValue);
544      }else {
545        myRandom = new SeqRandNumGen();
# Line 566 | Line 552 | namespace OpenMD {
552      atomsPerProc.insert(atomsPerProc.end(), nProcessors, 0);
553      
554      if (worldRank == 0) {
555 <      numerator = info->getNGlobalAtoms();
556 <      denominator = nProcessors;
557 <      precast = numerator / denominator;
558 <      nTarget = (int)(precast + 0.5);
559 <      
560 <      for(i = 0; i < nGlobalMols; i++) {
555 >      RealType numerator = info->getNGlobalAtoms();
556 >      RealType denominator = nProcessors;
557 >      RealType precast = numerator / denominator;
558 >      int nTarget = (int)(precast + 0.5);
559 >      
560 >      for(int i = 0; i < nGlobalMols; i++) {
561  
562 <        done = 0;
563 <        loops = 0;
562 >        int done = 0;
563 >        int loops = 0;
564          
565          while (!done) {
566            loops++;
567            
568            // Pick a processor at random
569            
570 <          which_proc = (int) (myRandom->rand() * nProcessors);
570 >          int which_proc = (int) (myRandom->rand() * nProcessors);
571            
572            //get the molecule stamp first
573            int stampId = info->getMoleculeStampId(i);
574            MoleculeStamp * moleculeStamp = info->getMoleculeStamp(stampId);
575            
576            // How many atoms does this processor have so far?
577 <          old_atoms = atomsPerProc[which_proc];
578 <          add_atoms = moleculeStamp->getNAtoms();
579 <          new_atoms = old_atoms + add_atoms;
577 >          int old_atoms = atomsPerProc[which_proc];
578 >          int add_atoms = moleculeStamp->getNAtoms();
579 >          int new_atoms = old_atoms + add_atoms;
580            
581            // If we've been through this loop too many times, we need
582            // to just give up and assign the molecule to this processor
# Line 634 | Line 620 | namespace OpenMD {
620            //           Pacc(x) = exp(- a * x)
621            // where a = penalty / (average atoms per molecule)
622            
623 <          x = (RealType)(new_atoms - nTarget);
624 <          y = myRandom->rand();
623 >          RealType x = (RealType)(new_atoms - nTarget);
624 >          RealType y = myRandom->rand();
625            
626            if (y < exp(- a * x)) {
627              molToProcMap[i] = which_proc;
# Line 704 | Line 690 | namespace OpenMD {
690      set<AtomType*>::iterator i;
691      bool hasDirectionalAtoms = false;
692      bool hasFixedCharge = false;
693 <    bool hasMultipoles = false;    
693 >    bool hasDipoles = false;    
694 >    bool hasQuadrupoles = false;    
695      bool hasPolarizable = false;    
696      bool hasFluctuatingCharge = false;    
697      bool hasMetallic = false;
# Line 726 | Line 713 | namespace OpenMD {
713        if (da.isDirectional()){
714          hasDirectionalAtoms = true;
715        }
716 <      if (ma.isMultipole()){
717 <        hasMultipoles = true;
716 >      if (ma.isDipole()){
717 >        hasDipoles = true;
718        }
719 +      if (ma.isQuadrupole()){
720 +        hasQuadrupoles = true;
721 +      }
722        if (ea.isEAM() || sca.isSuttonChen()){
723          hasMetallic = true;
724        }
# Line 752 | Line 742 | namespace OpenMD {
742          storageLayout |= DataStorage::dslTorque;
743        }
744      }
745 <    if (hasMultipoles) {
746 <      storageLayout |= DataStorage::dslElectroFrame;
745 >    if (hasDipoles) {
746 >      storageLayout |= DataStorage::dslDipole;
747 >    }
748 >    if (hasQuadrupoles) {
749 >      storageLayout |= DataStorage::dslQuadrupole;
750      }
751      if (hasFixedCharge || hasFluctuatingCharge) {
752        storageLayout |= DataStorage::dslSkippedCharge;
# Line 789 | Line 782 | namespace OpenMD {
782        }
783      }
784  
785 <    if (simParams->getOutputElectricField()) {
785 >    if (simParams->getOutputElectricField() | simParams->haveElectricField()) {
786        storageLayout |= DataStorage::dslElectricField;
787      }
788 +
789      if (simParams->getOutputFluctuatingCharges()) {
790        storageLayout |= DataStorage::dslFlucQPosition;
791        storageLayout |= DataStorage::dslFlucQVelocity;
792        storageLayout |= DataStorage::dslFlucQForce;
793      }
794  
795 +    info->setStorageLayout(storageLayout);
796 +
797      return storageLayout;
798    }
799  
# Line 960 | Line 956 | namespace OpenMD {
956    }
957    
958    void SimCreator::loadCoordinates(SimInfo* info, const std::string& mdFileName) {
959 <
959 >    
960      DumpReader reader(info, mdFileName);
961      int nframes = reader.getNFrames();
962 <
962 >    
963      if (nframes > 0) {
964        reader.readFrame(nframes - 1);
965      } else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines