ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/brains/SimInfo.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/brains/SimInfo.cpp (file contents):
Revision 2252 by chuckv, Mon May 30 14:01:52 2005 UTC vs.
Revision 2305 by chrisfen, Fri Sep 16 19:35:14 2005 UTC

# Line 52 | Line 52
52   #include "brains/SimInfo.hpp"
53   #include "math/Vector3.hpp"
54   #include "primitives/Molecule.hpp"
55 + #include "UseTheForce/fCutoffPolicy.h"
56 + #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
57   #include "UseTheForce/doForces_interface.h"
58   #include "UseTheForce/notifyCutoffs_interface.h"
59   #include "utils/MemoryUtils.hpp"
# Line 462 | Line 464 | namespace oopse {
464      //setup fortran force field
465      /** @deprecate */    
466      int isError = 0;
467 <    initFortranFF( &fInfo_.SIM_uses_RF , &isError );
467 >    
468 >    setupElectrostaticSummationMethod( isError );
469 >
470      if(isError){
471        sprintf( painCave.errMsg,
472                 "ForceField error: There was an error initializing the forceField in fortran.\n" );
# Line 518 | Line 522 | namespace oopse {
522      int useElectrostatics = 0;
523      //usePBC and useRF are from simParams
524      int usePBC = simParams_->getPBC();
521    int useRF = simParams_->getUseRF();
525  
526      //loop over all of the atom types
527      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
# Line 581 | Line 584 | namespace oopse {
584      temp = useFLARB;
585      MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
586  
584    temp = useRF;
585    MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
586    
587   #endif
588  
589      fInfo_.SIM_uses_PBC = usePBC;    
# Line 598 | Line 598 | namespace oopse {
598      fInfo_.SIM_uses_EAM = useEAM;
599      fInfo_.SIM_uses_Shapes = useShape;
600      fInfo_.SIM_uses_FLARB = useFLARB;
601    fInfo_.SIM_uses_RF = useRF;
601  
602      if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) {
603  
# Line 830 | Line 829 | namespace oopse {
829      }
830    }
831  
832 <  void SimInfo::setupCutoff() {
832 >  void SimInfo::setupCutoff() {    
833      getCutoff(rcut_, rsw_);    
834      double rnblist = rcut_ + 1; // skin of neighbor list
835  
836      //Pass these cutoff radius etc. to fortran. This function should be called once and only once
837 <    notifyFortranCutoffs(&rcut_, &rsw_, &rnblist);
837 >    
838 >    int cp =  TRADITIONAL_CUTOFF_POLICY;
839 >    if (simParams_->haveCutoffPolicy()) {
840 >      std::string myPolicy = simParams_->getCutoffPolicy();
841 >      if (myPolicy == "MIX") {
842 >        cp = MIX_CUTOFF_POLICY;
843 >      } else {
844 >        if (myPolicy == "MAX") {
845 >          cp = MAX_CUTOFF_POLICY;
846 >        } else {
847 >          if (myPolicy == "TRADITIONAL") {            
848 >            cp = TRADITIONAL_CUTOFF_POLICY;
849 >          } else {
850 >            // throw error        
851 >            sprintf( painCave.errMsg,
852 >                     "SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() );
853 >            painCave.isFatal = 1;
854 >            simError();
855 >          }    
856 >        }          
857 >      }
858 >    }
859 >    notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp);
860 >  }
861 >
862 >  void SimInfo::setupElectrostaticSummationMethod( int isError ) {    
863 >    
864 >    int errorOut;
865 >    int esm =  NONE;
866 >    double alphaVal;
867 >
868 >    errorOut = isError;
869 >
870 >    if (simParams_->haveElectrostaticSummationMethod()) {
871 >      std::string myMethod = simParams_->getElectrostaticSummationMethod();
872 >      if (myMethod == "NONE") {
873 >        esm = NONE;
874 >      } else {
875 >        if (myMethod == "UNDAMPED_WOLF") {
876 >          esm = UNDAMPED_WOLF;
877 >        } else {
878 >          if (myMethod == "DAMPED_WOLF") {            
879 >            esm = DAMPED_WOLF;
880 >            if (!simParams_->haveDampingAlpha()) {
881 >              //throw error
882 >              sprintf( painCave.errMsg,
883 >                       "SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used for the Damped Wolf Method.", simParams_->getDampingAlpha());
884 >              painCave.isFatal = 0;
885 >              simError();
886 >            }
887 >            alphaVal = simParams_->getDampingAlpha();
888 >          } else {
889 >            if (myMethod == "REACTION_FIELD") {
890 >              esm = REACTION_FIELD;
891 >            } else {
892 >              // throw error        
893 >              sprintf( painCave.errMsg,
894 >                       "SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"undamped_wolf\", \"damped_wolf\", or \"reaction_field\".", myMethod.c_str() );
895 >              painCave.isFatal = 1;
896 >              simError();
897 >            }    
898 >          }          
899 >        }
900 >      }
901 >    }
902 >    initFortranFF( &fInfo_.SIM_uses_RF, &esm, &alphaVal, &errorOut );
903    }
904  
905    void SimInfo::addProperty(GenericData* genData) {
# Line 981 | Line 1045 | namespace oopse {
1045    
1046     /*
1047     Return intertia tensor for entire system and angular momentum Vector.
1048 +
1049 +
1050 +       [  Ixx -Ixy  -Ixz ]
1051 +  J =| -Iyx  Iyy  -Iyz |
1052 +       [ -Izx -Iyz   Izz ]
1053      */
1054  
1055     void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){
# Line 1032 | Line 1101 | namespace oopse {
1101        inertiaTensor(0,1) = -xy;
1102        inertiaTensor(0,2) = -xz;
1103        inertiaTensor(1,0) = -xy;
1104 <      inertiaTensor(2,0) = xx + zz;
1104 >      inertiaTensor(1,1) = xx + zz;
1105        inertiaTensor(1,2) = -yz;
1106        inertiaTensor(2,0) = -xz;
1107        inertiaTensor(2,1) = -yz;
# Line 1060 | Line 1129 | namespace oopse {
1129        SimInfo::MoleculeIterator i;
1130        Molecule* mol;
1131        
1132 <      Vector3d thisq(0.0);
1133 <      Vector3d thisv(0.0);
1132 >      Vector3d thisr(0.0);
1133 >      Vector3d thisp(0.0);
1134        
1135 <      double thisMass = 0.0;
1135 >      double thisMass;
1136        
1137        for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {        
1138 <         thisq = mol->getCom()-com;
1139 <         thisv = mol->getComVel()-comVel;
1140 <         thisMass = mol->getMass();
1072 <         angularMomentum += cross( thisq, thisv ) * thisMass;
1138 >        thisMass = mol->getMass();
1139 >        thisr = mol->getCom()-com;
1140 >        thisp = (mol->getComVel()-comVel)*thisMass;
1141          
1142 +        angularMomentum += cross( thisr, thisp );
1143 +        
1144        }  
1145        
1146   #ifdef IS_MPI

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines