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 850 by mmeineke, Mon Nov 3 22:07:17 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines