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

Comparing:
trunk/OOPSE/libmdtools/SimSetup.cpp (file contents), Revision 736 by tim, Thu Aug 28 21:09:47 2003 UTC vs.
branches/new-templateless/OOPSE/libmdtools/SimSetup.cpp (file contents), Revision 849 by mmeineke, Fri Oct 31 21:06:47 2003 UTC

# Line 1 | Line 1
1   #include <algorithm>
2 < #include <cstdlib>
2 > #include <stdlib.h>
3   #include <iostream>
4 < #include <cmath>
4 > #include <math.h>
5   #include <string>
6   #include <sprng.h>
7
7   #include "SimSetup.hpp"
8   #include "ReadWrite.hpp"
9   #include "parse_me.h"
# Line 22 | Line 21
21   #define NVT_ENS        1
22   #define NPTi_ENS       2
23   #define NPTf_ENS       3
24 < #define NPTim_ENS      4
26 < #define NPTfm_ENS      5
24 > #define NPTxyz_ENS     4
25  
26 +
27   #define FF_DUFF 0
28   #define FF_LJ   1
29   #define FF_EAM  2
# Line 32 | Line 31 | SimSetup::SimSetup(){
31   using namespace std;
32  
33   SimSetup::SimSetup(){
34 +  
35 +  initSuspend = false;
36    isInfoArray = 0;
37    nInfo = 1;
38  
# Line 54 | Line 55 | void SimSetup::setSimInfo(SimInfo* the_info, int theNi
55    info = the_info;
56    nInfo = theNinfo;
57    isInfoArray = 1;
58 +  initSuspend = true;
59   }
60  
61  
# Line 92 | Line 94 | void SimSetup::createSim(void){
94   #endif // is_mpi
95  
96   void SimSetup::createSim(void){
95  int i, j, k, globalAtomIndex;
97  
98    // gather all of the information from the Bass file
99  
# Line 101 | Line 102 | void SimSetup::createSim(void){
102    // creation of complex system objects
103  
104    sysObjectsCreation();
104
105  // check on the post processing info
106
107  finalInfoCheck();
105  
106    // initialize the system coordinates
107  
108 <  if (!isInfoArray){
108 >  if ( !initSuspend ){
109      initSystemCoords();
110 +
111 +    if( !(globals->getUseInitTime()) )
112 +      info[0].currentTime = 0.0;
113    }  
114 +
115 +  // check on the post processing info
116  
117 +  finalInfoCheck();
118 +
119    // make the output filenames
120  
121    makeOutNames();
# Line 131 | Line 135 | void SimSetup::makeMolecules(void){
135  
136  
137   void SimSetup::makeMolecules(void){
138 <  int k, l;
138 >  int k;
139    int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset;
140    molInit molInfo;
141    DirectionalAtom* dAtom;
# Line 553 | Line 557 | void SimSetup::gatherInfo(void){
557  
558  
559   void SimSetup::gatherInfo(void){
560 <  int i, j, k;
560 >  int i;
561  
562    ensembleCase = -1;
563    ffCase = -1;
# Line 604 | Line 608 | void SimSetup::gatherInfo(void){
608    else if (!strcasecmp(ensemble, "NPTf")){
609      ensembleCase = NPTf_ENS;
610    }
611 <  else if (!strcasecmp(ensemble, "NPTim")){
612 <    ensembleCase = NPTim_ENS;
611 >  else if (!strcasecmp(ensemble, "NPTxyz")){
612 >    ensembleCase = NPTxyz_ENS;
613    }
610  else if (!strcasecmp(ensemble, "NPTfm")){
611    ensembleCase = NPTfm_ENS;
612  }
614    else{
615      sprintf(painCave.errMsg,
616              "SimSetup Warning. Unrecognized Ensemble -> %s, "
# Line 688 | Line 689 | void SimSetup::gatherInfo(void){
689        info[i].thermalTime = globals->getThermalTime();
690      }
691  
692 <    // check for the temperature set flag
692 >    info[i].resetIntegrator = 0;
693 >    if( globals->haveResetTime() ){
694 >      info[i].resetTime = globals->getResetTime();
695 >      info[i].resetIntegrator = 1;
696 >    }
697  
698 +    // check for the temperature set flag
699 +    
700      if (globals->haveTempSet())
701        info[i].setTemp = globals->getTempSet();
702 <
696 <    // get some of the tricky things that may still be in the globals
697 <
698 <    double boxVector[3];
699 <    if (globals->haveBox()){
700 <      boxVector[0] = globals->getBox();
701 <      boxVector[1] = globals->getBox();
702 <      boxVector[2] = globals->getBox();
703 <
704 <      info[i].setBox(boxVector);
705 <    }
706 <    else if (globals->haveDensity()){
707 <      double vol;
708 <      vol = (double) tot_nmol / globals->getDensity();
709 <      boxVector[0] = pow(vol, (1.0 / 3.0));
710 <      boxVector[1] = boxVector[0];
711 <      boxVector[2] = boxVector[0];
712 <
713 <      info[i].setBox(boxVector);
714 <    }
715 <    else{
716 <      if (!globals->haveBoxX()){
717 <        sprintf(painCave.errMsg,
718 <                "SimSetup error, no periodic BoxX size given.\n");
719 <        painCave.isFatal = 1;
720 <        simError();
721 <      }
722 <      boxVector[0] = globals->getBoxX();
723 <
724 <      if (!globals->haveBoxY()){
725 <        sprintf(painCave.errMsg,
726 <                "SimSetup error, no periodic BoxY size given.\n");
727 <        painCave.isFatal = 1;
728 <        simError();
729 <      }
730 <      boxVector[1] = globals->getBoxY();
731 <
732 <      if (!globals->haveBoxZ()){
733 <        sprintf(painCave.errMsg,
734 <                "SimSetup error, no periodic BoxZ size given.\n");
735 <        painCave.isFatal = 1;
736 <        simError();
737 <      }
738 <      boxVector[2] = globals->getBoxZ();
739 <
740 <      info[i].setBox(boxVector);
741 <    }
702 >    
703    }
704 <
704 >  
705    //setup seed for random number generator
706    int seedValue;
707  
# Line 844 | Line 805 | void SimSetup::finalInfoCheck(void){
805          theEst = globals->getEST();
806        }
807  
808 <      info[i].setEcr(theEcr, theEst);
808 >      info[i].setDefaultEcr(theEcr, theEst);
809  
810        if (!globals->haveDielectric()){
811          sprintf(painCave.errMsg,
# Line 889 | Line 850 | void SimSetup::finalInfoCheck(void){
850            theEst = globals->getEST();
851          }
852  
853 <        info[i].setEcr(theEcr, theEst);
853 >        info[i].setDefaultEcr(theEcr, theEst);
854        }
855      }
856 +    info[i].checkCutOffs();
857    }
858  
859   #ifdef IS_MPI
# Line 916 | Line 878 | void SimSetup::initSystemCoords(void){
878      if (worldRank == 0){
879   #endif //is_mpi
880        inName = globals->getInitialConfig();
919      double* tempDouble = new double[1000000];
881        fileInit = new InitializeFromFile(inName);
882   #ifdef IS_MPI
883      }
# Line 934 | Line 895 | void SimSetup::initSystemCoords(void){
895  
896      sprintf(painCave.errMsg,
897              "Cannot intialize a parallel simulation without an initial configuration file.\n");
898 <    painCave.isFatal;
898 >    painCave.isFatal = 1;;
899      simError();
900  
901   #else
# Line 1160 | Line 1121 | void SimSetup::calcSysValues(void){
1121   }
1122  
1123   void SimSetup::calcSysValues(void){
1124 <  int i, j, k;
1124 >  int i;
1125  
1126    int* molMembershipArray;
1127  
# Line 1259 | Line 1220 | void SimSetup::makeSysArrays(void){
1220  
1221  
1222   void SimSetup::makeSysArrays(void){
1223 <  int i, j, k, l;
1223 >
1224 > #ifndef IS_MPI
1225 >  int k, j;
1226 > #endif // is_mpi
1227 >  int i, l;
1228  
1229    Atom** the_atoms;
1230    Molecule* the_molecules;
# Line 1342 | Line 1307 | void SimSetup::makeIntegrator(void){
1307   void SimSetup::makeIntegrator(void){
1308    int k;
1309  
1310 <  NVT<RealIntegrator>* myNVT = NULL;
1311 <  NPTi<RealIntegrator>* myNPTi = NULL;
1312 <  NPTf<RealIntegrator>* myNPTf = NULL;
1313 <  NPTim<RealIntegrator>* myNPTim = NULL;
1314 <  NPTfm<RealIntegrator>* myNPTfm = NULL;
1310 >  NVE* myNVE = NULL;
1311 >  NVT* myNVT = NULL;
1312 >  NPTi* myNPTi = NULL;
1313 >  NPTf* myNPTf = NULL;
1314 >  NPTxyz* myNPTxyz = NULL;
1315    
1316    for (k = 0; k < nInfo; k++){
1317      switch (ensembleCase){
1318 <      case NVE_ENS:
1319 <        if (globals->haveZconstraints()){
1320 <          setupZConstraint(info[k]);
1321 <          new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff);
1322 <        }
1323 <        else
1324 <          new NVE<RealIntegrator>(&(info[k]), the_ff);
1318 >    case NVE_ENS:
1319 >      if (globals->haveZconstraints()){
1320 >        
1321 >        std::cerr << "ZConstraint is temporarily disabled\n";
1322 >        
1323 >        //      setupZConstraint(info[k]);
1324 >        //      myNVE = new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff);
1325 >      }
1326 >      
1327 > //       else{
1328 >        myNVE = new NVE<RealIntegrator>(&(info[k]), the_ff);
1329 > //       }
1330 >        
1331 >        info->the_integrator = myNVE;
1332          break;
1333 +        
1334 +    case NVT_ENS:
1335 +      if (globals->haveZconstraints()){
1336  
1337 <      case NVT_ENS:
1338 <        if (globals->haveZconstraints()){
1339 <          setupZConstraint(info[k]);
1340 <          myNVT = new ZConstraint<NVT<RealIntegrator> >(&(info[k]), the_ff);
1341 <        }
1337 >        std::cerr << "ZConstraint is temporarily disabled\n";
1338 >
1339 > //      setupZConstraint(info[k]);
1340 > //      myNVT = new ZConstraint<NVT<RealIntegrator> >(&(info[k]), the_ff);
1341 >      }
1342          else
1343            myNVT = new NVT<RealIntegrator>(&(info[k]), the_ff);
1344  
# Line 1378 | Line 1353 | void SimSetup::makeIntegrator(void){
1353            painCave.isFatal = 1;
1354            simError();
1355          }
1356 +
1357 +        info->the_integrator = myNVT;
1358          break;
1359  
1360        case NPTi_ENS:
1361          if (globals->haveZconstraints()){
1362            setupZConstraint(info[k]);
1363 <          myNPTi = new ZConstraint<NPTi<RealIntegrator> >(&(info[k]), the_ff);
1363 >          myNPTi = new ZConstraint<NPTi<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1364          }
1365          else
1366 <          myNPTi = new NPTi<RealIntegrator>(&(info[k]), the_ff);
1366 >          myNPTi = new NPTi<NPT<RealIntegrator> >(&(info[k]), the_ff);
1367  
1368          myNPTi->setTargetTemp(globals->getTargetTemp());
1369  
# Line 1419 | Line 1396 | void SimSetup::makeIntegrator(void){
1396            painCave.isFatal = 1;
1397            simError();
1398          }
1399 +
1400 +        info->the_integrator = myNPTi;
1401          break;
1402  
1403        case NPTf_ENS:
1404          if (globals->haveZconstraints()){
1405            setupZConstraint(info[k]);
1406 <          myNPTf = new ZConstraint<NPTf<RealIntegrator> >(&(info[k]), the_ff);
1406 >          myNPTf = new ZConstraint<NPTf<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1407          }
1408          else
1409 <          myNPTf = new NPTf<RealIntegrator>(&(info[k]), the_ff);
1409 >          myNPTf = new NPTf<NPT <RealIntegrator> >(&(info[k]), the_ff);
1410  
1411          myNPTf->setTargetTemp(globals->getTargetTemp());
1412  
# Line 1443 | Line 1422 | void SimSetup::makeIntegrator(void){
1422  
1423          if (globals->haveTauThermostat())
1424            myNPTf->setTauThermostat(globals->getTauThermostat());
1425 +
1426          else{
1427            sprintf(painCave.errMsg,
1428                    "SimSetup error: If you use an NPT\n"
# Line 1453 | Line 1433 | void SimSetup::makeIntegrator(void){
1433  
1434          if (globals->haveTauBarostat())
1435            myNPTf->setTauBarostat(globals->getTauBarostat());
1456        else{
1457          sprintf(painCave.errMsg,
1458                  "SimSetup error: If you use an NPT\n"
1459                  "    ensemble, you must set tauBarostat.\n");
1460          painCave.isFatal = 1;
1461          simError();
1462        }
1463        break;
1464
1465      case NPTim_ENS:
1466        if (globals->haveZconstraints()){
1467          setupZConstraint(info[k]);
1468          myNPTim = new ZConstraint<NPTim<RealIntegrator> >(&(info[k]), the_ff);
1469        }
1470        else
1471          myNPTim = new NPTim<RealIntegrator>(&(info[k]), the_ff);
1436  
1473        myNPTim->setTargetTemp(globals->getTargetTemp());
1474
1475        if (globals->haveTargetPressure())
1476          myNPTim->setTargetPressure(globals->getTargetPressure());
1437          else{
1438            sprintf(painCave.errMsg,
1479                  "SimSetup error: If you use a constant pressure\n"
1480                  "    ensemble, you must set targetPressure in the BASS file.\n");
1481          painCave.isFatal = 1;
1482          simError();
1483        }
1484
1485        if (globals->haveTauThermostat())
1486          myNPTim->setTauThermostat(globals->getTauThermostat());
1487        else{
1488          sprintf(painCave.errMsg,
1439                    "SimSetup error: If you use an NPT\n"
1490                  "    ensemble, you must set tauThermostat.\n");
1491          painCave.isFatal = 1;
1492          simError();
1493        }
1494
1495        if (globals->haveTauBarostat())
1496          myNPTim->setTauBarostat(globals->getTauBarostat());
1497        else{
1498          sprintf(painCave.errMsg,
1499                  "SimSetup error: If you use an NPT\n"
1440                    "    ensemble, you must set tauBarostat.\n");
1441            painCave.isFatal = 1;
1442            simError();
1443          }
1444 +
1445 +        info->the_integrator = myNPTf;
1446          break;
1447  
1448 <      case NPTfm_ENS:
1448 >      case NPTxyz_ENS:
1449          if (globals->haveZconstraints()){
1450            setupZConstraint(info[k]);
1451 <          myNPTfm = new ZConstraint<NPTfm<RealIntegrator> >(&(info[k]), the_ff);
1451 >          myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1452          }
1453          else
1454 <          myNPTfm = new NPTfm<RealIntegrator>(&(info[k]), the_ff);
1454 >          myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff);
1455  
1456 <        myNPTfm->setTargetTemp(globals->getTargetTemp());
1456 >        myNPTxyz->setTargetTemp(globals->getTargetTemp());
1457  
1458          if (globals->haveTargetPressure())
1459 <          myNPTfm->setTargetPressure(globals->getTargetPressure());
1459 >          myNPTxyz->setTargetPressure(globals->getTargetPressure());
1460          else{
1461            sprintf(painCave.errMsg,
1462                    "SimSetup error: If you use a constant pressure\n"
1463                    "    ensemble, you must set targetPressure in the BASS file.\n");
1464            painCave.isFatal = 1;
1465            simError();
1466 <        }
1466 >        }    
1467  
1468          if (globals->haveTauThermostat())
1469 <          myNPTfm->setTauThermostat(globals->getTauThermostat());
1469 >          myNPTxyz->setTauThermostat(globals->getTauThermostat());
1470          else{
1471            sprintf(painCave.errMsg,
1472                    "SimSetup error: If you use an NPT\n"
# Line 1534 | Line 1476 | void SimSetup::makeIntegrator(void){
1476          }
1477  
1478          if (globals->haveTauBarostat())
1479 <          myNPTfm->setTauBarostat(globals->getTauBarostat());
1479 >          myNPTxyz->setTauBarostat(globals->getTauBarostat());
1480          else{
1481            sprintf(painCave.errMsg,
1482                    "SimSetup error: If you use an NPT\n"
# Line 1542 | Line 1484 | void SimSetup::makeIntegrator(void){
1484            painCave.isFatal = 1;
1485            simError();
1486          }
1487 +
1488 +        info->the_integrator = myNPTxyz;
1489          break;
1490  
1491        default:
# Line 1615 | Line 1559 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1559    }
1560    theInfo.addProperty(zconsTol);
1561  
1562 <  //set Force Substraction Policy
1562 >  //set Force Subtraction Policy
1563    StringData* zconsForcePolicy = new StringData();
1564    zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID);
1565  
# Line 1624 | Line 1568 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1568    }
1569    else{
1570      sprintf(painCave.errMsg,
1571 <            "ZConstraint Warning: User does not set force substraction policy, "
1571 >            "ZConstraint Warning: User does not set force Subtraction policy, "
1572              "PolicyByMass is used\n");
1573      painCave.isFatal = 0;
1574      simError();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines