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

Comparing branches/new-templateless/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 849 by mmeineke, Fri Oct 31 21:06:47 2003 UTC vs.
Revision 851 by mmeineke, Wed Nov 5 19:18:17 2003 UTC

# Line 1 | Line 1
1 #include <algorithm>
1   #include <stdlib.h>
2   #include <iostream>
3   #include <math.h>
4 < #include <string>
4 > #include <string.h>
5   #include <sprng.h>
6 +
7   #include "SimSetup.hpp"
8   #include "ReadWrite.hpp"
9   #include "parse_me.h"
# Line 1324 | Line 1324 | void SimSetup::makeIntegrator(void){
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 <        
1327 >      //       else{
1328 >      myNVE = new NVE(&(info[k]), the_ff);
1329 >      //       }
1330 >      
1331 >      info->the_integrator = myNVE;
1332 >      break;
1333 >      
1334      case NVT_ENS:
1335 +      if (globals->haveZconstraints()){
1336 +        
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(&(info[k]), the_ff);
1344 +      
1345 +      myNVT->setTargetTemp(globals->getTargetTemp());
1346 +      
1347 +      if (globals->haveTauThermostat())
1348 +        myNVT->setTauThermostat(globals->getTauThermostat());
1349 +      else{
1350 +        sprintf(painCave.errMsg,
1351 +                "SimSetup error: If you use the NVT\n"
1352 +                "    ensemble, you must set tauThermostat.\n");
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 +        
1363 +        std::cerr << "ZConstraint is temporarily disabled\n";
1364 +        
1365 +        //        setupZConstraint(info[k]);
1366 +        //           myNPTi = new ZConstraint<NPTi<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1367 +      }
1368 +      // else
1369 +      myNPTi = new NPTi(&(info[k]), the_ff);
1370 +      
1371 +      myNPTi->setTargetTemp(globals->getTargetTemp());
1372 +      
1373 +      if (globals->haveTargetPressure())
1374 +        myNPTi->setTargetPressure(globals->getTargetPressure());
1375 +      else{
1376 +        sprintf(painCave.errMsg,
1377 +                "SimSetup error: If you use a constant pressure\n"
1378 +                "    ensemble, you must set targetPressure in the BASS file.\n");
1379 +        painCave.isFatal = 1;
1380 +        simError();
1381 +      }
1382 +      
1383 +      if (globals->haveTauThermostat())
1384 +        myNPTi->setTauThermostat(globals->getTauThermostat());
1385 +      else{
1386 +        sprintf(painCave.errMsg,
1387 +                "SimSetup error: If you use an NPT\n"
1388 +                "    ensemble, you must set tauThermostat.\n");
1389 +        painCave.isFatal = 1;
1390 +        simError();
1391 +      }
1392 +      
1393 +      if (globals->haveTauBarostat())
1394 +        myNPTi->setTauBarostat(globals->getTauBarostat());
1395 +      else{
1396 +        sprintf(painCave.errMsg,
1397 +                "SimSetup error: If you use an NPT\n"
1398 +                "    ensemble, you must set tauBarostat.\n");
1399 +        painCave.isFatal = 1;
1400 +        simError();
1401 +      }
1402 +      
1403 +      info->the_integrator = myNPTi;
1404 +      break;
1405 +      
1406 +    case NPTf_ENS:
1407 +      if (globals->haveZconstraints()){
1408  
1409          std::cerr << "ZConstraint is temporarily disabled\n";
1410  
1411   //      setupZConstraint(info[k]);
1412 < //      myNVT = new ZConstraint<NVT<RealIntegrator> >(&(info[k]), the_ff);
1412 > //      myNPTf = new ZConstraint<NPTf<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1413        }
1414 <        else
1415 <          myNVT = new NVT<RealIntegrator>(&(info[k]), the_ff);
1416 <
1417 <        myNVT->setTargetTemp(globals->getTargetTemp());
1418 <
1419 <        if (globals->haveTauThermostat())
1420 <          myNVT->setTauThermostat(globals->getTauThermostat());
1421 <        else{
1422 <          sprintf(painCave.errMsg,
1423 <                  "SimSetup error: If you use the NVT\n"
1424 <                  "    ensemble, you must set tauThermostat.\n");
1425 <          painCave.isFatal = 1;
1426 <          simError();
1427 <        }
1428 <
1429 <        info->the_integrator = myNVT;
1430 <        break;
1431 <
1432 <      case NPTi_ENS:
1433 <        if (globals->haveZconstraints()){
1434 <          setupZConstraint(info[k]);
1435 <          myNPTi = new ZConstraint<NPTi<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1436 <        }
1437 <        else
1438 <          myNPTi = new NPTi<NPT<RealIntegrator> >(&(info[k]), the_ff);
1439 <
1440 <        myNPTi->setTargetTemp(globals->getTargetTemp());
1441 <
1442 <        if (globals->haveTargetPressure())
1443 <          myNPTi->setTargetPressure(globals->getTargetPressure());
1444 <        else{
1445 <          sprintf(painCave.errMsg,
1446 <                  "SimSetup error: If you use a constant pressure\n"
1447 <                  "    ensemble, you must set targetPressure in the BASS file.\n");
1448 <          painCave.isFatal = 1;
1449 <          simError();
1450 <        }
1451 <
1452 <        if (globals->haveTauThermostat())
1453 <          myNPTi->setTauThermostat(globals->getTauThermostat());
1454 <        else{
1455 <          sprintf(painCave.errMsg,
1456 <                  "SimSetup error: If you use an NPT\n"
1457 <                  "    ensemble, you must set tauThermostat.\n");
1458 <          painCave.isFatal = 1;
1459 <          simError();
1460 <        }
1461 <
1462 <        if (globals->haveTauBarostat())
1463 <          myNPTi->setTauBarostat(globals->getTauBarostat());
1392 <        else{
1393 <          sprintf(painCave.errMsg,
1394 <                  "SimSetup error: If you use an NPT\n"
1395 <                  "    ensemble, you must set tauBarostat.\n");
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<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1407 <        }
1408 <        else
1409 <          myNPTf = new NPTf<NPT <RealIntegrator> >(&(info[k]), the_ff);
1410 <
1411 <        myNPTf->setTargetTemp(globals->getTargetTemp());
1412 <
1413 <        if (globals->haveTargetPressure())
1414 <          myNPTf->setTargetPressure(globals->getTargetPressure());
1415 <        else{
1416 <          sprintf(painCave.errMsg,
1417 <                  "SimSetup error: If you use a constant pressure\n"
1418 <                  "    ensemble, you must set targetPressure in the BASS file.\n");
1419 <          painCave.isFatal = 1;
1420 <          simError();
1421 <        }    
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"
1429 <                  "    ensemble, you must set tauThermostat.\n");
1430 <          painCave.isFatal = 1;
1431 <          simError();
1432 <        }
1433 <
1434 <        if (globals->haveTauBarostat())
1435 <          myNPTf->setTauBarostat(globals->getTauBarostat());
1436 <
1437 <        else{
1438 <          sprintf(painCave.errMsg,
1439 <                  "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 NPTxyz_ENS:
1449 <        if (globals->haveZconstraints()){
1450 <          setupZConstraint(info[k]);
1451 <          myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1452 <        }
1453 <        else
1454 <          myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff);
1455 <
1456 <        myNPTxyz->setTargetTemp(globals->getTargetTemp());
1457 <
1458 <        if (globals->haveTargetPressure())
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 <        }    
1467 <
1468 <        if (globals->haveTauThermostat())
1469 <          myNPTxyz->setTauThermostat(globals->getTauThermostat());
1470 <        else{
1471 <          sprintf(painCave.errMsg,
1472 <                  "SimSetup error: If you use an NPT\n"
1473 <                  "    ensemble, you must set tauThermostat.\n");
1474 <          painCave.isFatal = 1;
1475 <          simError();
1476 <        }
1477 <
1478 <        if (globals->haveTauBarostat())
1479 <          myNPTxyz->setTauBarostat(globals->getTauBarostat());
1480 <        else{
1481 <          sprintf(painCave.errMsg,
1482 <                  "SimSetup error: If you use an NPT\n"
1483 <                  "    ensemble, you must set tauBarostat.\n");
1484 <          painCave.isFatal = 1;
1485 <          simError();
1486 <        }
1487 <
1488 <        info->the_integrator = myNPTxyz;
1489 <        break;
1414 > //       else
1415 >      myNPTf = new NPTf(&(info[k]), the_ff);
1416 >      
1417 >      myNPTf->setTargetTemp(globals->getTargetTemp());
1418 >      
1419 >      if (globals->haveTargetPressure())
1420 >        myNPTf->setTargetPressure(globals->getTargetPressure());
1421 >      else{
1422 >        sprintf(painCave.errMsg,
1423 >                "SimSetup error: If you use a constant pressure\n"
1424 >                "    ensemble, you must set targetPressure in the BASS file.\n");
1425 >        painCave.isFatal = 1;
1426 >        simError();
1427 >      }    
1428 >      
1429 >      if (globals->haveTauThermostat())
1430 >        myNPTf->setTauThermostat(globals->getTauThermostat());
1431 >      
1432 >      else{
1433 >        sprintf(painCave.errMsg,
1434 >                "SimSetup error: If you use an NPT\n"
1435 >                "    ensemble, you must set tauThermostat.\n");
1436 >        painCave.isFatal = 1;
1437 >        simError();
1438 >      }
1439 >      
1440 >      if (globals->haveTauBarostat())
1441 >        myNPTf->setTauBarostat(globals->getTauBarostat());
1442 >      
1443 >      else{
1444 >        sprintf(painCave.errMsg,
1445 >                "SimSetup error: If you use an NPT\n"
1446 >                "    ensemble, you must set tauBarostat.\n");
1447 >        painCave.isFatal = 1;
1448 >        simError();
1449 >      }
1450 >      
1451 >      info->the_integrator = myNPTf;
1452 >      break;
1453 >      
1454 >    case NPTxyz_ENS:
1455 >      if (globals->haveZconstraints()){
1456 >        
1457 >        std::cerr << "ZConstraint is temporarily disabled\n";
1458 >        
1459 >        //      setupZConstraint(info[k]);
1460 >        //      myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1461 >      }
1462 > //       else
1463 >      myNPTxyz = new NPTxyz(&(info[k]), the_ff);
1464  
1465 <      default:
1466 <        sprintf(painCave.errMsg,
1467 <                "SimSetup Error. Unrecognized ensemble in case statement.\n");
1468 <        painCave.isFatal = 1;
1469 <        simError();
1465 >      myNPTxyz->setTargetTemp(globals->getTargetTemp());
1466 >      
1467 >      if (globals->haveTargetPressure())
1468 >        myNPTxyz->setTargetPressure(globals->getTargetPressure());
1469 >      else{
1470 >        sprintf(painCave.errMsg,
1471 >                "SimSetup error: If you use a constant pressure\n"
1472 >                "    ensemble, you must set targetPressure in the BASS file.\n");
1473 >        painCave.isFatal = 1;
1474 >        simError();
1475 >      }    
1476 >      
1477 >      if (globals->haveTauThermostat())
1478 >        myNPTxyz->setTauThermostat(globals->getTauThermostat());
1479 >      else{
1480 >        sprintf(painCave.errMsg,
1481 >                "SimSetup error: If you use an NPT\n"
1482 >                "    ensemble, you must set tauThermostat.\n");
1483 >        painCave.isFatal = 1;
1484 >        simError();
1485 >      }
1486 >      
1487 >      if (globals->haveTauBarostat())
1488 >        myNPTxyz->setTauBarostat(globals->getTauBarostat());
1489 >      else{
1490 >        sprintf(painCave.errMsg,
1491 >                "SimSetup error: If you use an NPT\n"
1492 >                "    ensemble, you must set tauBarostat.\n");
1493 >        painCave.isFatal = 1;
1494 >        simError();
1495 >      }
1496 >      
1497 >      info->the_integrator = myNPTxyz;
1498 >      break;
1499 >      
1500 >    default:
1501 >      sprintf(painCave.errMsg,
1502 >              "SimSetup Error. Unrecognized ensemble in case statement.\n");
1503 >      painCave.isFatal = 1;
1504 >      simError();
1505      }
1506    }
1507   }
# Line 1520 | Line 1529 | void SimSetup::initFortran(void){
1529   #endif // is_mpi
1530   }
1531  
1532 < void SimSetup::setupZConstraint(SimInfo& theInfo){
1533 <  int nZConstraints;
1534 <  ZconStamp** zconStamp;
1532 > // void SimSetup::setupZConstraint(SimInfo& theInfo){
1533 > //   int nZConstraints;
1534 > //   ZconStamp** zconStamp;
1535  
1536 <  if (globals->haveZconstraintTime()){
1537 <    //add sample time of z-constraint  into SimInfo's property list                    
1538 <    DoubleData* zconsTimeProp = new DoubleData();
1539 <    zconsTimeProp->setID(ZCONSTIME_ID);
1540 <    zconsTimeProp->setData(globals->getZconsTime());
1541 <    theInfo.addProperty(zconsTimeProp);
1542 <  }
1543 <  else{
1544 <    sprintf(painCave.errMsg,
1545 <            "ZConstraint error: If you use an ZConstraint\n"
1546 <            " , you must set sample time.\n");
1547 <    painCave.isFatal = 1;
1548 <    simError();
1549 <  }
1536 > //   if (globals->haveZconstraintTime()){
1537 > //     //add sample time of z-constraint  into SimInfo's property list                    
1538 > //     DoubleData* zconsTimeProp = new DoubleData();
1539 > //     zconsTimeProp->setID(ZCONSTIME_ID);
1540 > //     zconsTimeProp->setData(globals->getZconsTime());
1541 > //     theInfo.addProperty(zconsTimeProp);
1542 > //   }
1543 > //   else{
1544 > //     sprintf(painCave.errMsg,
1545 > //             "ZConstraint error: If you use an ZConstraint\n"
1546 > //             " , you must set sample time.\n");
1547 > //     painCave.isFatal = 1;
1548 > //     simError();
1549 > //   }
1550  
1551 <  //push zconsTol into siminfo, if user does not specify
1552 <  //value for zconsTol, a default value will be used
1553 <  DoubleData* zconsTol = new DoubleData();
1554 <  zconsTol->setID(ZCONSTOL_ID);
1555 <  if (globals->haveZconsTol()){
1556 <    zconsTol->setData(globals->getZconsTol());
1557 <  }
1558 <  else{
1559 <    double defaultZConsTol = 0.01;
1560 <    sprintf(painCave.errMsg,
1561 <            "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n"
1562 <            " , default value %f is used.\n",
1563 <            defaultZConsTol);
1564 <    painCave.isFatal = 0;
1565 <    simError();      
1551 > //   //push zconsTol into siminfo, if user does not specify
1552 > //   //value for zconsTol, a default value will be used
1553 > //   DoubleData* zconsTol = new DoubleData();
1554 > //   zconsTol->setID(ZCONSTOL_ID);
1555 > //   if (globals->haveZconsTol()){
1556 > //     zconsTol->setData(globals->getZconsTol());
1557 > //   }
1558 > //   else{
1559 > //     double defaultZConsTol = 0.01;
1560 > //     sprintf(painCave.errMsg,
1561 > //             "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n"
1562 > //             " , default value %f is used.\n",
1563 > //             defaultZConsTol);
1564 > //     painCave.isFatal = 0;
1565 > //     simError();      
1566  
1567 <    zconsTol->setData(defaultZConsTol);
1568 <  }
1569 <  theInfo.addProperty(zconsTol);
1567 > //     zconsTol->setData(defaultZConsTol);
1568 > //   }
1569 > //   theInfo.addProperty(zconsTol);
1570  
1571 <  //set Force Subtraction Policy
1572 <  StringData* zconsForcePolicy = new StringData();
1573 <  zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID);
1571 > //   //set Force Subtraction Policy
1572 > //   StringData* zconsForcePolicy = new StringData();
1573 > //   zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID);
1574  
1575 <  if (globals->haveZconsForcePolicy()){
1576 <    zconsForcePolicy->setData(globals->getZconsForcePolicy());
1577 <  }
1578 <  else{
1579 <    sprintf(painCave.errMsg,
1580 <            "ZConstraint Warning: User does not set force Subtraction policy, "
1581 <            "PolicyByMass is used\n");
1582 <    painCave.isFatal = 0;
1583 <    simError();
1584 <    zconsForcePolicy->setData("BYMASS");
1585 <  }
1575 > //   if (globals->haveZconsForcePolicy()){
1576 > //     zconsForcePolicy->setData(globals->getZconsForcePolicy());
1577 > //   }
1578 > //   else{
1579 > //     sprintf(painCave.errMsg,
1580 > //             "ZConstraint Warning: User does not set force Subtraction policy, "
1581 > //             "PolicyByMass is used\n");
1582 > //     painCave.isFatal = 0;
1583 > //     simError();
1584 > //     zconsForcePolicy->setData("BYMASS");
1585 > //   }
1586  
1587 <  theInfo.addProperty(zconsForcePolicy);
1587 > //   theInfo.addProperty(zconsForcePolicy);
1588  
1589 <  //Determine the name of ouput file and add it into SimInfo's property list
1590 <  //Be careful, do not use inFileName, since it is a pointer which
1591 <  //point to a string at master node, and slave nodes do not contain that string
1589 > //   //Determine the name of ouput file and add it into SimInfo's property list
1590 > //   //Be careful, do not use inFileName, since it is a pointer which
1591 > //   //point to a string at master node, and slave nodes do not contain that string
1592  
1593 <  string zconsOutput(theInfo.finalName);
1593 > //   string zconsOutput(theInfo.finalName);
1594  
1595 <  zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1595 > //   zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1596  
1597 <  StringData* zconsFilename = new StringData();
1598 <  zconsFilename->setID(ZCONSFILENAME_ID);
1599 <  zconsFilename->setData(zconsOutput);
1597 > //   StringData* zconsFilename = new StringData();
1598 > //   zconsFilename->setID(ZCONSFILENAME_ID);
1599 > //   zconsFilename->setData(zconsOutput);
1600  
1601 <  theInfo.addProperty(zconsFilename);
1601 > //   theInfo.addProperty(zconsFilename);
1602  
1603 <  //setup index, pos and other parameters of z-constraint molecules
1604 <  nZConstraints = globals->getNzConstraints();
1605 <  theInfo.nZconstraints = nZConstraints;
1603 > //   //setup index, pos and other parameters of z-constraint molecules
1604 > //   nZConstraints = globals->getNzConstraints();
1605 > //   theInfo.nZconstraints = nZConstraints;
1606  
1607 <  zconStamp = globals->getZconStamp();
1608 <  ZConsParaItem tempParaItem;
1607 > //   zconStamp = globals->getZconStamp();
1608 > //   ZConsParaItem tempParaItem;
1609  
1610 <  ZConsParaData* zconsParaData = new ZConsParaData();
1611 <  zconsParaData->setID(ZCONSPARADATA_ID);
1610 > //   ZConsParaData* zconsParaData = new ZConsParaData();
1611 > //   zconsParaData->setID(ZCONSPARADATA_ID);
1612  
1613 <  for (int i = 0; i < nZConstraints; i++){
1614 <    tempParaItem.havingZPos = zconStamp[i]->haveZpos();
1615 <    tempParaItem.zPos = zconStamp[i]->getZpos();
1616 <    tempParaItem.zconsIndex = zconStamp[i]->getMolIndex();
1617 <    tempParaItem.kRatio = zconStamp[i]->getKratio();
1613 > //   for (int i = 0; i < nZConstraints; i++){
1614 > //     tempParaItem.havingZPos = zconStamp[i]->haveZpos();
1615 > //     tempParaItem.zPos = zconStamp[i]->getZpos();
1616 > //     tempParaItem.zconsIndex = zconStamp[i]->getMolIndex();
1617 > //     tempParaItem.kRatio = zconStamp[i]->getKratio();
1618  
1619 <    zconsParaData->addItem(tempParaItem);
1620 <  }
1619 > //     zconsParaData->addItem(tempParaItem);
1620 > //   }
1621  
1622 <  //check the uniqueness of index  
1623 <  if(!zconsParaData->isIndexUnique()){
1624 <    sprintf(painCave.errMsg,
1625 <            "ZConstraint Error: molIndex is not unique\n");
1626 <    painCave.isFatal = 1;
1627 <    simError();
1628 <  }
1622 > //   //check the uniqueness of index  
1623 > //   if(!zconsParaData->isIndexUnique()){
1624 > //     sprintf(painCave.errMsg,
1625 > //             "ZConstraint Error: molIndex is not unique\n");
1626 > //     painCave.isFatal = 1;
1627 > //     simError();
1628 > //   }
1629  
1630 <  //sort the parameters by index of molecules
1631 <  zconsParaData->sortByIndex();
1630 > //   //sort the parameters by index of molecules
1631 > //   zconsParaData->sortByIndex();
1632    
1633 <  //push data into siminfo, therefore, we can retrieve later
1634 <  theInfo.addProperty(zconsParaData);
1635 < }
1633 > //   //push data into siminfo, therefore, we can retrieve later
1634 > //   theInfo.addProperty(zconsParaData);
1635 > // }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines