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

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 780 by mmeineke, Mon Sep 22 21:23:25 2003 UTC vs.
Revision 845 by gezelter, Thu Oct 30 18:59:20 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 NPTxyz_ENS     4
25  
26 +
27   #define FF_DUFF 0
28   #define FF_LJ   1
29   #define FF_EAM  2
# Line 30 | Line 31 | SimSetup::SimSetup(){
31   using namespace std;
32  
33   SimSetup::SimSetup(){
34 +  
35 +  initSuspend = false;
36    isInfoArray = 0;
37    nInfo = 1;
38  
# Line 52 | 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 90 | Line 94 | void SimSetup::createSim(void){
94   #endif // is_mpi
95  
96   void SimSetup::createSim(void){
93  int i, j, k, globalAtomIndex;
97  
98    // gather all of the information from the Bass file
99  
# Line 100 | Line 103 | void SimSetup::createSim(void){
103  
104    sysObjectsCreation();
105  
103  // check on the post processing info
104
105  finalInfoCheck();
106
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 129 | 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 551 | 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 601 | Line 607 | void SimSetup::gatherInfo(void){
607    }
608    else if (!strcasecmp(ensemble, "NPTf")){
609      ensembleCase = NPTf_ENS;
610 +  }
611 +  else if (!strcasecmp(ensemble, "NPTxyz")){
612 +    ensembleCase = NPTxyz_ENS;
613    }
614    else{
615      sprintf(painCave.errMsg,
# Line 687 | Line 696 | void SimSetup::gatherInfo(void){
696      }
697  
698      // check for the temperature set flag
699 <
699 >    
700      if (globals->haveTempSet())
701        info[i].setTemp = globals->getTempSet();
702 <
694 <    // get some of the tricky things that may still be in the globals
695 <
696 <    double boxVector[3];
697 <    if (globals->haveBox()){
698 <      boxVector[0] = globals->getBox();
699 <      boxVector[1] = globals->getBox();
700 <      boxVector[2] = globals->getBox();
701 <
702 <      info[i].setBox(boxVector);
703 <    }
704 <    else if (globals->haveDensity()){
705 <      double vol;
706 <      vol = (double) tot_nmol / globals->getDensity();
707 <      boxVector[0] = pow(vol, (1.0 / 3.0));
708 <      boxVector[1] = boxVector[0];
709 <      boxVector[2] = boxVector[0];
710 <
711 <      info[i].setBox(boxVector);
712 <    }
713 <    else{
714 <      if (!globals->haveBoxX()){
715 <        sprintf(painCave.errMsg,
716 <                "SimSetup error, no periodic BoxX size given.\n");
717 <        painCave.isFatal = 1;
718 <        simError();
719 <      }
720 <      boxVector[0] = globals->getBoxX();
721 <
722 <      if (!globals->haveBoxY()){
723 <        sprintf(painCave.errMsg,
724 <                "SimSetup error, no periodic BoxY size given.\n");
725 <        painCave.isFatal = 1;
726 <        simError();
727 <      }
728 <      boxVector[1] = globals->getBoxY();
729 <
730 <      if (!globals->haveBoxZ()){
731 <        sprintf(painCave.errMsg,
732 <                "SimSetup error, no periodic BoxZ size given.\n");
733 <        painCave.isFatal = 1;
734 <        simError();
735 <      }
736 <      boxVector[2] = globals->getBoxZ();
737 <
738 <      info[i].setBox(boxVector);
739 <    }
702 >    
703    }
704 <
704 >  
705    //setup seed for random number generator
706    int seedValue;
707  
# Line 842 | 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 887 | 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 914 | Line 878 | void SimSetup::initSystemCoords(void){
878      if (worldRank == 0){
879   #endif //is_mpi
880        inName = globals->getInitialConfig();
917      double* tempDouble = new double[1000000];
881        fileInit = new InitializeFromFile(inName);
882   #ifdef IS_MPI
883      }
# Line 932 | 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 1158 | 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 1257 | 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 1340 | Line 1307 | void SimSetup::makeIntegrator(void){
1307   void SimSetup::makeIntegrator(void){
1308    int k;
1309  
1310 +  NVE<RealIntegrator>* myNVE = NULL;
1311    NVT<RealIntegrator>* myNVT = NULL;
1312    NPTi<NPT<RealIntegrator> >* myNPTi = NULL;
1313    NPTf<NPT<RealIntegrator> >* myNPTf = NULL;
1314 +  NPTxyz<NPT<RealIntegrator> >* 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);
1321 >          myNVE = new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff);
1322          }
1323 <        else
1324 <          new NVE<RealIntegrator>(&(info[k]), the_ff);
1323 >        else{
1324 >          myNVE = new NVE<RealIntegrator>(&(info[k]), the_ff);
1325 >        }
1326 >        
1327 >        info->the_integrator = myNVE;
1328          break;
1329  
1330        case NVT_ENS:
# Line 1374 | Line 1346 | void SimSetup::makeIntegrator(void){
1346            painCave.isFatal = 1;
1347            simError();
1348          }
1349 +
1350 +        info->the_integrator = myNVT;
1351          break;
1352  
1353        case NPTi_ENS:
# Line 1415 | Line 1389 | void SimSetup::makeIntegrator(void){
1389            painCave.isFatal = 1;
1390            simError();
1391          }
1392 +
1393 +        info->the_integrator = myNPTi;
1394          break;
1395  
1396        case NPTf_ENS:
# Line 1439 | Line 1415 | void SimSetup::makeIntegrator(void){
1415  
1416          if (globals->haveTauThermostat())
1417            myNPTf->setTauThermostat(globals->getTauThermostat());
1418 +
1419          else{
1420            sprintf(painCave.errMsg,
1421                    "SimSetup error: If you use an NPT\n"
# Line 1449 | Line 1426 | void SimSetup::makeIntegrator(void){
1426  
1427          if (globals->haveTauBarostat())
1428            myNPTf->setTauBarostat(globals->getTauBarostat());
1429 +
1430          else{
1431            sprintf(painCave.errMsg,
1432                    "SimSetup error: If you use an NPT\n"
# Line 1456 | Line 1434 | void SimSetup::makeIntegrator(void){
1434            painCave.isFatal = 1;
1435            simError();
1436          }
1437 +
1438 +        info->the_integrator = myNPTf;
1439          break;
1440  
1441 +      case NPTxyz_ENS:
1442 +        if (globals->haveZconstraints()){
1443 +          setupZConstraint(info[k]);
1444 +          myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1445 +        }
1446 +        else
1447 +          myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff);
1448 +
1449 +        myNPTxyz->setTargetTemp(globals->getTargetTemp());
1450 +
1451 +        if (globals->haveTargetPressure())
1452 +          myNPTxyz->setTargetPressure(globals->getTargetPressure());
1453 +        else{
1454 +          sprintf(painCave.errMsg,
1455 +                  "SimSetup error: If you use a constant pressure\n"
1456 +                  "    ensemble, you must set targetPressure in the BASS file.\n");
1457 +          painCave.isFatal = 1;
1458 +          simError();
1459 +        }    
1460 +
1461 +        if (globals->haveTauThermostat())
1462 +          myNPTxyz->setTauThermostat(globals->getTauThermostat());
1463 +        else{
1464 +          sprintf(painCave.errMsg,
1465 +                  "SimSetup error: If you use an NPT\n"
1466 +                  "    ensemble, you must set tauThermostat.\n");
1467 +          painCave.isFatal = 1;
1468 +          simError();
1469 +        }
1470 +
1471 +        if (globals->haveTauBarostat())
1472 +          myNPTxyz->setTauBarostat(globals->getTauBarostat());
1473 +        else{
1474 +          sprintf(painCave.errMsg,
1475 +                  "SimSetup error: If you use an NPT\n"
1476 +                  "    ensemble, you must set tauBarostat.\n");
1477 +          painCave.isFatal = 1;
1478 +          simError();
1479 +        }
1480 +
1481 +        info->the_integrator = myNPTxyz;
1482 +        break;
1483 +
1484        default:
1485          sprintf(painCave.errMsg,
1486                  "SimSetup Error. Unrecognized ensemble in case statement.\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines