ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-1.0/libmdtools/SimSetup.cpp
(Generate patch)

Comparing trunk/OOPSE-1.0/libmdtools/SimSetup.cpp (file contents):
Revision 1334 by gezelter, Fri Jul 16 18:58:03 2004 UTC vs.
Revision 1415 by gezelter, Mon Jul 26 17:50:57 2004 UTC

# Line 824 | Line 824 | void SimSetup::gatherInfo(void){
824    // set the easy ones first
825  
826    for (i = 0; i < nInfo; i++){
827 <    info[i].target_temp = globals->getTargetTemp();
828 <    info[i].dt = globals->getDt();
829 <    info[i].run_time = globals->getRunTime();
830 <  }
827 >    if (globals->haveTargetTemp()) {
828 >      info[i].target_temp = globals->getTargetTemp();
829 >      info[i].have_target_temp = 1;
830 >    } else {
831 >      info[i].have_target_temp = 0;
832 >    }
833 >    if (globals->haveDt()) {
834 >      info[i].dt = globals->getDt();
835 >    }
836 >    if (globals->haveRunTime()) {
837 >      info[i].run_time = globals->getRunTime();
838 >    }
839 >    }
840    n_components = globals->getNComponents();
841  
842  
# Line 860 | Line 869 | void SimSetup::gatherInfo(void){
869    
870    // get the ensemble
871  
863  strcpy(ensemble, globals->getEnsemble());
872  
873 <  if (!strcasecmp(ensemble, "NVE")){
874 <    ensembleCase = NVE_ENS;
875 <  }
876 <  else if (!strcasecmp(ensemble, "NVT")){
877 <    ensembleCase = NVT_ENS;
878 <  }
879 <  else if (!strcasecmp(ensemble, "NPTi") || !strcasecmp(ensemble, "NPT")){
880 <    ensembleCase = NPTi_ENS;
881 <  }
882 <  else if (!strcasecmp(ensemble, "NPTf")){
883 <    ensembleCase = NPTf_ENS;
884 <  }
885 <  else if (!strcasecmp(ensemble, "NPTxyz")){
886 <    ensembleCase = NPTxyz_ENS;
887 <  }
888 <  else{
889 <    sprintf(painCave.errMsg,
890 <            "SimSetup Warning. Unrecognized Ensemble -> %s \n"
891 <            "\treverting to NVE for this simulation.\n",
892 <            ensemble);
893 <         painCave.isFatal = 0;
894 <         simError();
895 <         strcpy(ensemble, "NVE");
896 <         ensembleCase = NVE_ENS;
897 <  }  
898 <
899 <  for (i = 0; i < nInfo; i++){
900 <    strcpy(info[i].ensemble, ensemble);
873 >  if (globals->haveEnsemble()) {
874 >    
875 >    strcpy(ensemble, globals->getEnsemble());
876 >    
877 >    if (!strcasecmp(ensemble, "NVE")){
878 >      ensembleCase = NVE_ENS;
879 >    }
880 >    else if (!strcasecmp(ensemble, "NVT")){
881 >      ensembleCase = NVT_ENS;
882 >    }
883 >    else if (!strcasecmp(ensemble, "NPTi") || !strcasecmp(ensemble, "NPT")){
884 >      ensembleCase = NPTi_ENS;
885 >    }
886 >    else if (!strcasecmp(ensemble, "NPTf")){
887 >      ensembleCase = NPTf_ENS;
888 >    }
889 >    else if (!strcasecmp(ensemble, "NPTxyz")){
890 >      ensembleCase = NPTxyz_ENS;
891 >    }
892 >    else{
893 >      sprintf(painCave.errMsg,
894 >              "SimSetup Warning. Unrecognized Ensemble -> %s \n"
895 >              "\treverting to NVE for this simulation.\n",
896 >              ensemble);
897 >      painCave.isFatal = 0;
898 >      simError();
899 >      strcpy(ensemble, "NVE");
900 >      ensembleCase = NVE_ENS;
901 >    }  
902 >    
903 >    for (i = 0; i < nInfo; i++)
904 >      strcpy(info[i].ensemble, ensemble);
905 >      
906 >    
907 >    //check whether sample time, status time, thermal time and reset time are divisble by dt
908 >    if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){
909 >      sprintf(painCave.errMsg,
910 >              "Sample time is not divisible by dt.\n"
911 >              "\tThis will result in samples that are not uniformly\n"
912 >              "\tdistributed in time.  If this is a problem, change\n"
913 >              "\tyour sampleTime variable.\n");
914 >      painCave.isFatal = 0;
915 >      simError();    
916 >    }
917 >    
918 >    if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){
919 >      sprintf(painCave.errMsg,
920 >              "Status time is not divisible by dt.\n"
921 >              "\tThis will result in status reports that are not uniformly\n"
922 >              "\tdistributed in time.  If this is a problem, change \n"
923 >              "\tyour statusTime variable.\n");
924 >      painCave.isFatal = 0;
925 >      simError();    
926 >    }
927 >    
928 >    if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){
929 >      sprintf(painCave.errMsg,
930 >              "Thermal time is not divisible by dt.\n"
931 >              "\tThis will result in thermalizations that are not uniformly\n"
932 >              "\tdistributed in time.  If this is a problem, change \n"
933 >              "\tyour thermalTime variable.\n");
934 >      painCave.isFatal = 0;
935 >      simError();    
936 >    }  
937 >    
938 >    if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){
939 >      sprintf(painCave.errMsg,
940 >              "Reset time is not divisible by dt.\n"
941 >              "\tThis will result in integrator resets that are not uniformly\n"
942 >              "\tdistributed in time.  If this is a problem, change\n"
943 >              "\tyour resetTime variable.\n");
944 >      painCave.isFatal = 0;
945 >      simError();    
946 >    }
947 >    
948 >    // set the status, sample, and thermal kick times
949 >    
950 >    for (i = 0; i < nInfo; i++){
951 >      if (globals->haveSampleTime()){
952 >        info[i].sampleTime = globals->getSampleTime();
953 >        info[i].statusTime = info[i].sampleTime;
954 >      }
955 >      else{
956 >        info[i].sampleTime = globals->getRunTime();
957 >        info[i].statusTime = info[i].sampleTime;
958 >      }
959 >      
960 >      if (globals->haveStatusTime()){
961 >        info[i].statusTime = globals->getStatusTime();
962 >      }
963 >      
964 >      if (globals->haveThermalTime()){
965 >        info[i].thermalTime = globals->getThermalTime();
966 >      } else {
967 >        info[i].thermalTime = globals->getRunTime();
968 >      }
969 >      
970 >      info[i].resetIntegrator = 0;
971 >      if( globals->haveResetTime() ){
972 >        info[i].resetTime = globals->getResetTime();
973 >        info[i].resetIntegrator = 1;
974 >      }        
975 >    }
976  
977 +    
978 +    for (i=0; i < nInfo; i++) {
979 +      
980 +      // check for the temperature set flag
981 +      
982 +      if (globals->haveTempSet())
983 +        info[i].setTemp = globals->getTempSet();
984 +      
985 +      // check for the extended State init
986 +      
987 +      info[i].useInitXSstate = globals->getUseInitXSstate();
988 +      info[i].orthoTolerance = globals->getOrthoBoxTolerance();
989 +      
990 +      // check for thermodynamic integration
991 +      if (globals->getUseSolidThermInt() && !globals->getUseLiquidThermInt()) {
992 +        if (globals->haveThermIntLambda() && globals->haveThermIntK()) {
993 +          info[i].useSolidThermInt = globals->getUseSolidThermInt();
994 +          info[i].thermIntLambda = globals->getThermIntLambda();
995 +          info[i].thermIntK = globals->getThermIntK();
996 +          
997 +          Restraints *myRestraint = new Restraints(tot_nmol, info[i].thermIntLambda, info[i].thermIntK);
998 +          info[i].restraint = myRestraint;
999 +        }
1000 +        else {
1001 +          sprintf(painCave.errMsg,
1002 +                  "SimSetup Error:\n"
1003 +                  "\tKeyword useSolidThermInt was set to 'true' but\n"
1004 +                  "\tthermodynamicIntegrationLambda (and/or\n"
1005 +                  "\tthermodynamicIntegrationK) was not specified.\n"
1006 +                  "\tPlease provide a lambda value and k value in your .bass file.\n");
1007 +          painCave.isFatal = 1;
1008 +          simError();    
1009 +        }
1010 +      }
1011 +      else if(globals->getUseLiquidThermInt()) {
1012 +        if (globals->getUseSolidThermInt()) {
1013 +          sprintf( painCave.errMsg,
1014 +                   "SimSetup Warning: It appears that you have both solid and\n"
1015 +                   "\tliquid thermodynamic integration activated in your .bass\n"
1016 +                   "\tfile. To avoid confusion, specify only one technique in\n"
1017 +                   "\tyour .bass file. Liquid-state thermodynamic integration\n"
1018 +                   "\twill be assumed for the current simulation. If this is not\n"
1019 +                   "\twhat you desire, set useSolidThermInt to 'true' and\n"
1020 +                   "\tuseLiquidThermInt to 'false' in your .bass file.\n");
1021 +          painCave.isFatal = 0;
1022 +          simError();
1023 +        }
1024 +        if (globals->haveThermIntLambda() && globals->haveThermIntK()) {
1025 +          info[i].useLiquidThermInt = globals->getUseLiquidThermInt();
1026 +          info[i].thermIntLambda = globals->getThermIntLambda();
1027 +          info[i].thermIntK = globals->getThermIntK();
1028 +        }
1029 +        else {
1030 +          sprintf(painCave.errMsg,
1031 +                  "SimSetup Error:\n"
1032 +                  "\tKeyword useLiquidThermInt was set to 'true' but\n"
1033 +                  "\tthermodynamicIntegrationLambda (and/or\n"
1034 +                  "\tthermodynamicIntegrationK) was not specified.\n"
1035 +                  "\tPlease provide a lambda value and k value in your .bass file.\n");
1036 +          painCave.isFatal = 1;
1037 +          simError();    
1038 +        }
1039 +      }
1040 +      else if(globals->haveThermIntLambda() || globals->haveThermIntK()){
1041 +        sprintf(painCave.errMsg,
1042 +                "SimSetup Warning: If you want to use Thermodynamic\n"
1043 +                "\tIntegration, set useSolidThermInt or useLiquidThermInt to\n"
1044 +                "\t'true' in your .bass file.  These keywords are set to\n"
1045 +                "\t'false' by default, so your lambda and/or k values are\n"
1046 +                "\tbeing ignored.\n");
1047 +        painCave.isFatal = 0;
1048 +        simError();  
1049 +      }
1050 +    }        
1051 +  }
1052 +  
1053 +  for (i = 0; i < nInfo; i++) {
1054      // get the mixing rule
1055 <
1055 >    
1056      strcpy(info[i].mixingRule, globals->getMixingRule());
1057      info[i].usePBC = globals->getPBC();
1058    }
1059 <
1059 >  
1060    // get the components and calculate the tot_nMol and indvidual n_mol
1061 <
1061 >  
1062    the_components = globals->getComponents();
1063    components_nmol = new int[n_components];
1064 <
905 <
1064 >  
1065    if (!globals->haveNMol()){
1066      // we don't have the total number of molecules, so we assume it is
1067      // given in each component
# Line 932 | Line 1091 | void SimSetup::gatherInfo(void){
1091      painCave.isFatal = 1;
1092      simError();
1093    }
1094 +  
1095  
936  //check whether sample time, status time, thermal time and reset time are divisble by dt
937  if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){
938    sprintf(painCave.errMsg,
939            "Sample time is not divisible by dt.\n"
940            "\tThis will result in samples that are not uniformly\n"
941            "\tdistributed in time.  If this is a problem, change\n"
942            "\tyour sampleTime variable.\n");
943    painCave.isFatal = 0;
944    simError();    
945  }
946
947  if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){
948    sprintf(painCave.errMsg,
949            "Status time is not divisible by dt.\n"
950            "\tThis will result in status reports that are not uniformly\n"
951            "\tdistributed in time.  If this is a problem, change \n"
952            "\tyour statusTime variable.\n");
953    painCave.isFatal = 0;
954    simError();    
955  }
956
957  if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){
958    sprintf(painCave.errMsg,
959            "Thermal time is not divisible by dt.\n"
960            "\tThis will result in thermalizations that are not uniformly\n"
961            "\tdistributed in time.  If this is a problem, change \n"
962            "\tyour thermalTime variable.\n");
963    painCave.isFatal = 0;
964    simError();    
965  }  
966
967  if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){
968    sprintf(painCave.errMsg,
969            "Reset time is not divisible by dt.\n"
970            "\tThis will result in integrator resets that are not uniformly\n"
971            "\tdistributed in time.  If this is a problem, change\n"
972            "\tyour resetTime variable.\n");
973    painCave.isFatal = 0;
974    simError();    
975  }
976
977  // set the status, sample, and thermal kick times
978
979  for (i = 0; i < nInfo; i++){
980    if (globals->haveSampleTime()){
981      info[i].sampleTime = globals->getSampleTime();
982      info[i].statusTime = info[i].sampleTime;
983    }
984    else{
985      info[i].sampleTime = globals->getRunTime();
986      info[i].statusTime = info[i].sampleTime;
987    }
988
989    if (globals->haveStatusTime()){
990      info[i].statusTime = globals->getStatusTime();
991    }
992
993    if (globals->haveThermalTime()){
994      info[i].thermalTime = globals->getThermalTime();
995    } else {
996      info[i].thermalTime = globals->getRunTime();
997    }
998
999    info[i].resetIntegrator = 0;
1000    if( globals->haveResetTime() ){
1001      info[i].resetTime = globals->getResetTime();
1002      info[i].resetIntegrator = 1;
1003    }
1004
1005    // check for the temperature set flag
1006    
1007    if (globals->haveTempSet())
1008      info[i].setTemp = globals->getTempSet();
1009
1010    // check for the extended State init
1011
1012    info[i].useInitXSstate = globals->getUseInitXSstate();
1013    info[i].orthoTolerance = globals->getOrthoBoxTolerance();
1096  
1015    // check for thermodynamic integration
1016    if (globals->getUseSolidThermInt() && !globals->getUseLiquidThermInt()) {
1017      if (globals->haveThermIntLambda() && globals->haveThermIntK()) {
1018        info[i].useSolidThermInt = globals->getUseSolidThermInt();
1019        info[i].thermIntLambda = globals->getThermIntLambda();
1020        info[i].thermIntK = globals->getThermIntK();
1021        
1022        Restraints *myRestraint = new Restraints(tot_nmol, info[i].thermIntLambda, info[i].thermIntK);
1023        info[i].restraint = myRestraint;
1024      }
1025      else {
1026        sprintf(painCave.errMsg,
1027                "SimSetup Error:\n"
1028                "\tKeyword useSolidThermInt was set to 'true' but\n"
1029                "\tthermodynamicIntegrationLambda (and/or\n"
1030                "\tthermodynamicIntegrationK) was not specified.\n"
1031                "\tPlease provide a lambda value and k value in your .bass file.\n");
1032        painCave.isFatal = 1;
1033        simError();    
1034      }
1035    }
1036    else if(globals->getUseLiquidThermInt()) {
1037      if (globals->getUseSolidThermInt()) {
1038        sprintf( painCave.errMsg,
1039                 "SimSetup Warning: It appears that you have both solid and\n"
1040                 "\tliquid thermodynamic integration activated in your .bass\n"
1041                 "\tfile. To avoid confusion, specify only one technique in\n"
1042                 "\tyour .bass file. Liquid-state thermodynamic integration\n"
1043                 "\twill be assumed for the current simulation. If this is not\n"
1044                 "\twhat you desire, set useSolidThermInt to 'true' and\n"
1045                 "\tuseLiquidThermInt to 'false' in your .bass file.\n");
1046        painCave.isFatal = 0;
1047        simError();
1048      }
1049      if (globals->haveThermIntLambda() && globals->haveThermIntK()) {
1050        info[i].useLiquidThermInt = globals->getUseLiquidThermInt();
1051        info[i].thermIntLambda = globals->getThermIntLambda();
1052        info[i].thermIntK = globals->getThermIntK();
1053      }
1054      else {
1055        sprintf(painCave.errMsg,
1056                "SimSetup Error:\n"
1057                "\tKeyword useLiquidThermInt was set to 'true' but\n"
1058                "\tthermodynamicIntegrationLambda (and/or\n"
1059                "\tthermodynamicIntegrationK) was not specified.\n"
1060                "\tPlease provide a lambda value and k value in your .bass file.\n");
1061        painCave.isFatal = 1;
1062        simError();    
1063      }
1064    }
1065    else if(globals->haveThermIntLambda() || globals->haveThermIntK()){
1066        sprintf(painCave.errMsg,
1067                "SimSetup Warning: If you want to use Thermodynamic\n"
1068                "\tIntegration, set useSolidThermInt or useLiquidThermInt to\n"
1069                "\t'true' in your .bass file.  These keywords are set to\n"
1070                "\t'false' by default, so your lambda and/or k values are\n"
1071                "\tbeing ignored.\n");
1072        painCave.isFatal = 0;
1073        simError();  
1074    }
1075  }
1097    
1098    //setup seed for random number generator
1099    int seedValue;
# Line 1785 | Line 1806 | void SimSetup::makeIntegrator(void){
1806          else
1807            myNVT = new NVT<RealIntegrator>(&(info[k]), the_ff);
1808  
1809 <        myNVT->setTargetTemp(globals->getTargetTemp());
1809 >        
1810 >        if (globals->haveTargetTemp())
1811 >          myNVT->setTargetTemp(globals->getTargetTemp());
1812 >        else{
1813 >          sprintf(painCave.errMsg,
1814 >                  "SimSetup error: If you use the NVT\n"
1815 >                  "\tensemble, you must set targetTemp.\n");
1816 >          painCave.isFatal = 1;
1817 >          simError();
1818 >        }
1819  
1820          if (globals->haveTauThermostat())
1821            myNVT->setTauThermostat(globals->getTauThermostat());
# Line 1808 | Line 1838 | void SimSetup::makeIntegrator(void){
1838          else
1839            myNPTi = new NPTi<NPT<RealIntegrator> >(&(info[k]), the_ff);
1840  
1841 <        myNPTi->setTargetTemp(globals->getTargetTemp());
1841 >        if (globals->haveTargetTemp())
1842 >          myNPTi->setTargetTemp(globals->getTargetTemp());
1843 >        else{
1844 >          sprintf(painCave.errMsg,
1845 >                  "SimSetup error: If you use a constant pressure\n"
1846 >                  "\tensemble, you must set targetTemp.\n");
1847 >          painCave.isFatal = 1;
1848 >          simError();
1849 >        }
1850  
1851          if (globals->haveTargetPressure())
1852            myNPTi->setTargetPressure(globals->getTargetPressure());
# Line 1851 | Line 1889 | void SimSetup::makeIntegrator(void){
1889          else
1890            myNPTf = new NPTf<NPT <RealIntegrator> >(&(info[k]), the_ff);
1891  
1892 <        myNPTf->setTargetTemp(globals->getTargetTemp());
1892 >        if (globals->haveTargetTemp())
1893 >          myNPTf->setTargetTemp(globals->getTargetTemp());
1894 >        else{
1895 >          sprintf(painCave.errMsg,
1896 >                  "SimSetup error: If you use a constant pressure\n"
1897 >                  "\tensemble, you must set targetTemp.\n");
1898 >          painCave.isFatal = 1;
1899 >          simError();
1900 >        }
1901  
1902          if (globals->haveTargetPressure())
1903            myNPTf->setTargetPressure(globals->getTargetPressure());
# Line 1896 | Line 1942 | void SimSetup::makeIntegrator(void){
1942          else
1943            myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff);
1944  
1945 <        myNPTxyz->setTargetTemp(globals->getTargetTemp());
1945 >        if (globals->haveTargetTemp())
1946 >          myNPTxyz->setTargetTemp(globals->getTargetTemp());
1947 >        else{
1948 >          sprintf(painCave.errMsg,
1949 >                  "SimSetup error: If you use a constant pressure\n"
1950 >                  "\tensemble, you must set targetTemp.\n");
1951 >          painCave.isFatal = 1;
1952 >          simError();
1953 >        }
1954  
1955          if (globals->haveTargetPressure())
1956            myNPTxyz->setTargetPressure(globals->getTargetPressure());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines