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 2448 by tim, Wed Nov 16 23:10:02 2005 UTC vs.
Revision 2463 by gezelter, Mon Nov 21 22:59:21 2005 UTC

# Line 59 | Line 59
59   #include "UseTheForce/DarkSide/fSwitchingFunctionType.h"
60   #include "UseTheForce/doForces_interface.h"
61   #include "UseTheForce/DarkSide/electrostatic_interface.h"
62 #include "UseTheForce/notifyCutoffs_interface.h"
62   #include "UseTheForce/DarkSide/switcheroo_interface.h"
63   #include "utils/MemoryUtils.hpp"
64   #include "utils/simError.h"
# Line 922 | Line 921 | namespace oopse {
921    }
922  
923   #endif
925
926  double SimInfo::calcMaxCutoffRadius() {
927
928
929    std::set<AtomType*> atomTypes;
930    std::set<AtomType*>::iterator i;
931    std::vector<double> cutoffRadius;
932
933    //get the unique atom types
934    atomTypes = getUniqueAtomTypes();
924  
925 <    //query the max cutoff radius among these atom types
937 <    for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
938 <      cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i));
939 <    }
940 <
941 <    double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end()));
942 < #ifdef IS_MPI
943 <    //pick the max cutoff radius among the processors
944 < #endif
945 <
946 <    return maxCutoffRadius;
947 <  }
948 <
949 <  void SimInfo::getCutoff(double& rcut, double& rsw) {
925 >  void SimInfo::setupCutoff() {          
926      
927 <    if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
952 <        
953 <      if (!simParams_->haveCutoffRadius()){
954 <        sprintf(painCave.errMsg,
955 <                "SimCreator Warning: No value was set for the cutoffRadius.\n"
956 <                "\tOOPSE will use a default value of 15.0 angstroms"
957 <                "\tfor the cutoffRadius.\n");
958 <        painCave.isFatal = 0;
959 <        simError();
960 <        rcut = 15.0;
961 <      } else{
962 <        rcut = simParams_->getCutoffRadius();
963 <      }
964 <
965 <      if (!simParams_->haveSwitchingRadius()){
966 <        sprintf(painCave.errMsg,
967 <                "SimCreator Warning: No value was set for switchingRadius.\n"
968 <                "\tOOPSE will use a default value of\n"
969 <                "\t0.85 * cutoffRadius for the switchingRadius\n");
970 <        painCave.isFatal = 0;
971 <        simError();
972 <        rsw = 0.85 * rcut;
973 <      } else{
974 <        rsw = simParams_->getSwitchingRadius();
975 <      }
976 <
977 <    } else {
978 <      // if charge, dipole or reaction field is not used and the cutofff radius is not specified in
979 <      //meta-data file, the maximum cutoff radius calculated from forcefiled will be used
980 <        
981 <      if (simParams_->haveCutoffRadius()) {
982 <        rcut = simParams_->getCutoffRadius();
983 <      } else {
984 <        //set cutoff radius to the maximum cutoff radius based on atom types in the whole system
985 <        rcut = calcMaxCutoffRadius();
986 <      }
987 <
988 <      if (simParams_->haveSwitchingRadius()) {
989 <        rsw  = simParams_->getSwitchingRadius();
990 <      } else {
991 <        rsw = rcut;
992 <      }
993 <    
994 <    }
995 <  }
996 <
997 <  void SimInfo::setupCutoff() {    
998 <    getCutoff(rcut_, rsw_);    
999 <    double rnblist = rcut_ + 1; // skin of neighbor list
1000 <
1001 <    //Pass these cutoff radius etc. to fortran. This function should be called once and only once
1002 <    
927 >    // Check the cutoff policy
928      int cp =  TRADITIONAL_CUTOFF_POLICY;
929      if (simParams_->haveCutoffPolicy()) {
930        std::string myPolicy = simParams_->getCutoffPolicy();
# Line 1021 | Line 946 | namespace oopse {
946            }    
947          }          
948        }
949 <    }
949 >    }          
950 >    notifyFortranCutoffPolicy(&cp);
951  
952 <
952 >    // Check the Skin Thickness for neighborlists
953 >    double skin;
954      if (simParams_->haveSkinThickness()) {
955 <      double skinThickness = simParams_->getSkinThickness();
956 <    }
955 >      skin = simParams_->getSkinThickness();
956 >      notifyFortranSkinThickness(&skin);
957 >    }            
958 >        
959 >    // Check if the cutoff was set explicitly:
960 >    if (simParams_->haveCutoffRadius()) {
961 >      rcut_ = simParams_->getCutoffRadius();
962 >      if (simParams_->haveSwitchingRadius()) {
963 >        rsw_  = simParams_->getSwitchingRadius();
964 >      } else {
965 >        rsw_ = rcut_;
966 >      }
967 >      notifyFortranCutoffs(&rcut_, &rsw_);
968 >      
969 >    } else {
970 >      
971 >      // For electrostatic atoms, we'll assume a large safe value:
972 >      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
973 >        sprintf(painCave.errMsg,
974 >                "SimCreator Warning: No value was set for the cutoffRadius.\n"
975 >                "\tOOPSE will use a default value of 15.0 angstroms"
976 >                "\tfor the cutoffRadius.\n");
977 >        painCave.isFatal = 0;
978 >        simError();
979 >        rcut_ = 15.0;
980 >      
981 >        if (simParams_->haveElectrostaticSummationMethod()) {
982 >          std::string myMethod = simParams_->getElectrostaticSummationMethod();
983 >          toUpper(myMethod);
984 >          if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") {
985 >            if (simParams_->haveSwitchingRadius()){
986 >              sprintf(painCave.errMsg,
987 >                      "SimInfo Warning: A value was set for the switchingRadius\n"
988 >                      "\teven though the electrostaticSummationMethod was\n"
989 >                      "\tset to %s\n", myMethod.c_str());
990 >              painCave.isFatal = 1;
991 >              simError();            
992 >            }
993 >          }
994 >        }
995 >      
996 >        if (simParams_->haveSwitchingRadius()){
997 >          rsw_ = simParams_->getSwitchingRadius();
998 >        } else {        
999 >          sprintf(painCave.errMsg,
1000 >                  "SimCreator Warning: No value was set for switchingRadius.\n"
1001 >                  "\tOOPSE will use a default value of\n"
1002 >                  "\t0.85 * cutoffRadius for the switchingRadius\n");
1003 >          painCave.isFatal = 0;
1004 >          simError();
1005 >          rsw_ = 0.85 * rcut_;
1006 >        }
1007 >        notifyFortranCutoffs(&rcut_, &rsw_);
1008 >      } else {
1009 >        // We didn't set rcut explicitly, and we don't have electrostatic atoms, so
1010 >        // We'll punt and let fortran figure out the cutoffs later.
1011 >        
1012 >        notifyFortranYouAreOnYourOwn();
1013  
1014 <    notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp);
1015 <    // also send cutoff notification to electrostatics
1033 <    setElectrostaticCutoffRadius(&rcut_, &rsw_);
1014 >      }
1015 >    }
1016    }
1017  
1018    void SimInfo::setupElectrostaticSummationMethod( int isError ) {    
# Line 1065 | Line 1047 | namespace oopse {
1047                } else {
1048                  // throw error        
1049                  sprintf( painCave.errMsg,
1050 <                         "SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"shifted_potential\", \"shifted_force\", or \"reaction_field\".", myMethod.c_str() );
1050 >                         "SimInfo error: Unknown electrostaticSummationMethod.\n"
1051 >                         "\t(Input file specified %s .)\n"
1052 >                         "\telectrostaticSummationMethod must be one of: \"none\",\n"
1053 >                         "\t\"shifted_potential\", \"shifted_force\", or \n"
1054 >                         "\t\"reaction_field\".\n", myMethod.c_str() );
1055                  painCave.isFatal = 1;
1056                  simError();
1057                }    
# Line 1086 | Line 1072 | namespace oopse {
1072            if (!simParams_->haveDampingAlpha()) {
1073              //throw error
1074              sprintf( painCave.errMsg,
1075 <                     "SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used.", alphaVal);
1075 >                     "SimInfo warning: dampingAlpha was not specified in the input file.\n"
1076 >                     "\tA default value of %f (1/ang) will be used.\n", alphaVal);
1077              painCave.isFatal = 0;
1078              simError();
1079            }
1080          } else {
1081            // throw error        
1082            sprintf( painCave.errMsg,
1083 <                   "SimInfo error: Unknown electrostaticScreeningMethod. (Input file specified %s .)\n\telectrostaticScreeningMethod must be one of: \"undamped\" or \"damped\".", myScreen.c_str() );
1083 >                   "SimInfo error: Unknown electrostaticScreeningMethod.\n"
1084 >                   "\t(Input file specified %s .)\n"
1085 >                   "\telectrostaticScreeningMethod must be one of: \"undamped\"\n"
1086 >                   "or \"damped\".\n", myScreen.c_str() );
1087            painCave.isFatal = 1;
1088            simError();
1089          }
# Line 1102 | Line 1092 | namespace oopse {
1092      
1093      // let's pass some summation method variables to fortran
1094      setElectrostaticSummationMethod( &esm );
1095 +    notifyFortranElectrostaticMethod( &esm );
1096      setScreeningMethod( &sm );
1097      setDampingAlpha( &alphaVal );
1098      setReactionFieldDielectric( &dielectric );
1099 <    initFortranFF( &esm, &errorOut );
1099 >    initFortranFF( &errorOut );
1100    }
1101  
1102    void SimInfo::setupSwitchingFunction() {    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines