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 658 by tim, Thu Jul 31 15:35:07 2003 UTC vs.
Revision 661 by tim, Fri Aug 1 16:18:13 2003 UTC

# Line 16 | Line 16
16  
17   // some defines for ensemble and Forcefield  cases
18  
19 < #define NVE_ENS   0
20 < #define NVT_ENS   1
21 < #define NPTi_ENS  2
22 < #define NPTf_ENS  3
23 < #define NPTim_ENS 4
24 < #define NPTfm_ENS 5
25 < #define NVEZCONS_ENS 6
26 <
19 > #define NVE_ENS        0
20 > #define NVT_ENS        1
21 > #define NPTi_ENS       2
22 > #define NPTf_ENS       3
23 > #define NPTim_ENS      4
24 > #define NPTfm_ENS      5
25 > #define NVEZCONS_ENS   6
26 > #define NVTZCONS_ENS   7
27 > #define NPTiZCONS_ENS  8
28 > #define NPTfZCONS_ENS  9
29 > #define NPTimZCONS_ENS 10
30 > #define NPTfmZCONS_ENS 11
31  
32   #define FF_DUFF 0
33   #define FF_LJ   1
# Line 623 | Line 627 | void SimSetup::gatherInfo( void ){
627    else if( !strcasecmp( ensemble, "NPTf" )) ensembleCase = NPTf_ENS;
628    else if( !strcasecmp( ensemble, "NPTim" )) ensembleCase = NPTim_ENS;
629    else if( !strcasecmp( ensemble, "NPTfm" )) ensembleCase = NPTfm_ENS;
630 +
631    else if( !strcasecmp( ensemble, "NVEZCONS")) ensembleCase = NVEZCONS_ENS;
632 +  else if( !strcasecmp( ensemble, "NVTZCONS"))  ensembleCase = NVTZCONS_ENS;
633 +  else if( !strcasecmp( ensemble, "NPTiZCONS") || !strcasecmp( ensemble, "NPTZCONS"))
634 +    ensembleCase = NPTiZCONS_ENS;
635 +  else if( !strcasecmp( ensemble, "NPTfZCONS"))  ensembleCase = NPTfZCONS_ENS;
636 +  else if( !strcasecmp( ensemble, "NPTimZCONS"))  ensembleCase = NPTimZCONS_ENS;
637 +  else if( !strcasecmp( ensemble, "NPTfmZCONS"))  ensembleCase = NPTfmZCONS_ENS;
638 +  
639    else{
640      sprintf( painCave.errMsg,
641               "SimSetup Warning. Unrecognized Ensemble -> %s, "
# Line 1310 | Line 1322 | void SimSetup::makeIntegrator( void ){
1322    NPTim<RealIntegrator>* myNPTim = NULL;
1323    NPTfm<RealIntegrator>* myNPTfm = NULL;
1324    ZConstraint<NVE<RealIntegrator> >* myNVEZCons = NULL;
1325 <      
1326 <  cerr << "setting integrator" <<endl;    
1327 <  
1325 >  ZConstraint<NVT<RealIntegrator> >* myNVTZCons = NULL;
1326 >  ZConstraint<NPTi<RealIntegrator> >* myNPTiZCons = NULL;
1327 >  ZConstraint<NPTf<RealIntegrator> >* myNPTfZCons = NULL;
1328 >  ZConstraint<NPTim<RealIntegrator> >* myNPTimZCons = NULL;
1329 >  ZConstraint<NPTfm<RealIntegrator> >* myNPTfmZCons = NULL;
1330 >        
1331    switch( ensembleCase ){
1332  
1333    case NVE_ENS:
# Line 1476 | Line 1491 | void SimSetup::makeIntegrator( void ){
1491      break;
1492      
1493    case NVEZCONS_ENS:
1479    {
1494  
1495 <      if(globals->haveZConsTime()){  
1496 <
1497 <        //add sample time of z-constraint  into SimInfo's property list                    
1498 <        DoubleData* zconsTimeProp = new DoubleData();
1499 <        zconsTimeProp->setID("zconstime");
1486 <        zconsTimeProp->setData(globals->getZConsTime());
1487 <        info->addProperty(zconsTimeProp);
1488 <      }
1489 <      else{
1490 <        sprintf( painCave.errMsg,
1491 <                 "ZConstraint error: If you use an ZConstraint\n"
1492 <                 " , you must set sample time.\n");
1493 <        painCave.isFatal = 1;
1494 <        simError();      
1495 <      }
1495 >
1496 >    //setup index of z-constraint molecules, z-constraint sampel time
1497 >    //and z-constraint force output name. These parameter should be known
1498 >    //before constructing the z-constraint integrator
1499 >    setupZConstraint();
1500        
1501 <      if(globals->haveIndexOfAllZConsMols()){
1502 <
1503 <        //add index of z-constraint molecules into SimInfo's property list
1504 <        vector<int> tempIndex = globals->getIndexOfAllZConsMols();
1505 <        sort(tempIndex.begin(), tempIndex.end());
1506 <        
1507 <        IndexData* zconsIndex = new IndexData();
1508 <        zconsIndex->setID("zconsindex");
1509 <        zconsIndex->setIndexData(tempIndex);
1510 <        info->addProperty(zconsIndex);
1511 <      }
1512 <      else{
1513 <        sprintf( painCave.errMsg,
1514 <                 "SimSetup error: If you use an ZConstraint\n"
1515 <                 " , you must set index of z-constraint molecules.\n");
1516 <        painCave.isFatal = 1;
1517 <        simError();    
1518 <      
1519 <      }
1520 <
1521 <      //Determine the name of ouput file and add it into SimInfo's property list
1522 <      //Be careful, do not use inFileName, since it is a pointer which
1523 <      //point to a string at master node, and slave nodes do not contain that string
1501 >    myNVEZCons = new ZConstraint<NVE<RealIntegrator> >( info, the_ff );
1502 >        
1503 >    break;
1504 >    
1505 >    
1506 >  case NVTZCONS_ENS:
1507 >  
1508 >    setupZConstraint();
1509 >    
1510 >    myNVTZCons = new ZConstraint<NVT<RealIntegrator> >( info, the_ff );
1511 >    myNVTZCons->setTargetTemp(globals->getTargetTemp());
1512 >
1513 >    if (globals->haveTauThermostat())
1514 >      myNVTZCons->setTauThermostat(globals->getTauThermostat());
1515 >
1516 >    else {
1517 >      sprintf( painCave.errMsg,
1518 >               "SimSetup error: If you use the NVT\n"
1519 >               "    ensemble, you must set tauThermostat.\n");
1520 >      painCave.isFatal = 1;
1521 >      simError();
1522 >    }    
1523 >    break;    
1524 >    
1525 >  case NPTiZCONS_ENS:
1526 >  
1527 >    setupZConstraint();
1528 >    
1529 >    myNPTiZCons = new ZConstraint<NPTi<RealIntegrator> >( info, the_ff );
1530 >    myNPTiZCons->setTargetTemp( globals->getTargetTemp() );
1531 >
1532 >    if (globals->haveTargetPressure())
1533 >      myNPTiZCons->setTargetPressure(globals->getTargetPressure());
1534 >    else {
1535 >      sprintf( painCave.errMsg,
1536 >               "SimSetup error: If you use a constant pressure\n"
1537 >               "    ensemble, you must set targetPressure in the BASS file.\n");
1538 >      painCave.isFatal = 1;
1539 >      simError();
1540 >    }
1541 >    
1542 >    if( globals->haveTauThermostat() )
1543 >      myNPTiZCons->setTauThermostat( globals->getTauThermostat() );
1544 >    else{
1545 >      sprintf( painCave.errMsg,
1546 >               "SimSetup error: If you use an NPT\n"
1547 >               "    ensemble, you must set tauThermostat.\n");
1548 >      painCave.isFatal = 1;
1549 >      simError();
1550 >    }
1551 >
1552 >    if( globals->haveTauBarostat() )
1553 >      myNPTiZCons->setTauBarostat( globals->getTauBarostat() );
1554 >    else{
1555 >      sprintf( painCave.errMsg,
1556 >               "SimSetup error: If you use an NPT\n"
1557 >               "    ensemble, you must set tauBarostat.\n");
1558 >      painCave.isFatal = 1;
1559 >      simError();
1560 >    }  
1561 >    
1562 >    break;
1563      
1564 <      string zconsOutput(info->finalName);
1565 <            
1566 <      zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1567 <                
1568 <      StringData* zconsFilename = new StringData();
1569 <      zconsFilename->setID("zconsfilename");
1527 <      zconsFilename->setData(zconsOutput);
1564 >  case NPTfZCONS_ENS:
1565 >  
1566 >    setupZConstraint();
1567 >  
1568 >    myNPTfZCons = new ZConstraint<NPTf<RealIntegrator> >( info, the_ff );
1569 >    myNPTfZCons->setTargetTemp( globals->getTargetTemp());
1570  
1571 <      info->addProperty(zconsFilename);      
1571 >    if (globals->haveTargetPressure())
1572 >      myNPTfZCons->setTargetPressure(globals->getTargetPressure());
1573 >    else {
1574 >      sprintf( painCave.errMsg,
1575 >               "SimSetup error: If you use a constant pressure\n"
1576 >               "    ensemble, you must set targetPressure in the BASS file.\n");
1577 >      painCave.isFatal = 1;
1578 >      simError();
1579 >    }    
1580 >
1581 >    if( globals->haveTauThermostat() )
1582 >      myNPTfZCons->setTauThermostat( globals->getTauThermostat() );
1583 >    else{
1584 >      sprintf( painCave.errMsg,
1585 >               "SimSetup error: If you use an NPT\n"
1586 >               "    ensemble, you must set tauThermostat.\n");
1587 >      painCave.isFatal = 1;
1588 >      simError();
1589 >    }
1590 >
1591 >    if( globals->haveTauBarostat() )
1592 >      myNPTfZCons->setTauBarostat( globals->getTauBarostat() );
1593 >    else{
1594 >      sprintf( painCave.errMsg,
1595 >               "SimSetup error: If you use an NPT\n"
1596 >               "    ensemble, you must set tauBarostat.\n");
1597 >      painCave.isFatal = 1;
1598 >      simError();
1599 >    }  
1600 >    
1601 >    break;  
1602        
1603 <      myNVEZCons = new ZConstraint<NVE<RealIntegrator> >( info, the_ff );
1604 <        
1603 >  case NPTimZCONS_ENS:
1604 >  
1605 >    setupZConstraint();
1606 >  
1607 >    myNPTimZCons = new ZConstraint<NPTim<RealIntegrator> >( info, the_ff );
1608 >    myNPTimZCons->setTargetTemp( globals->getTargetTemp());
1609 >
1610 >    if (globals->haveTargetPressure())
1611 >      myNPTimZCons->setTargetPressure(globals->getTargetPressure());
1612 >    else {
1613 >      sprintf( painCave.errMsg,
1614 >               "SimSetup error: If you use a constant pressure\n"
1615 >               "    ensemble, you must set targetPressure in the BASS file.\n");
1616 >      painCave.isFatal = 1;
1617 >      simError();
1618 >    }
1619 >    
1620 >    if( globals->haveTauThermostat() )
1621 >      myNPTimZCons->setTauThermostat( globals->getTauThermostat() );
1622 >    else{
1623 >      sprintf( painCave.errMsg,
1624 >               "SimSetup error: If you use an NPT\n"
1625 >               "    ensemble, you must set tauThermostat.\n");
1626 >      painCave.isFatal = 1;
1627 >      simError();
1628 >    }
1629 >
1630 >    if( globals->haveTauBarostat() )
1631 >      myNPTimZCons->setTauBarostat( globals->getTauBarostat() );
1632 >    else{
1633 >      sprintf( painCave.errMsg,
1634 >               "SimSetup error: If you use an NPT\n"
1635 >               "    ensemble, you must set tauBarostat.\n");
1636 >      painCave.isFatal = 1;
1637 >      simError();
1638 >    }  
1639 >    
1640      break;
1641 +    
1642 +  case NPTfmZCONS_ENS:
1643 +  
1644 +    setupZConstraint();
1645 +    
1646 +    myNPTfmZCons = new ZConstraint<NPTfm<RealIntegrator> >( info, the_ff );
1647 +    myNPTfmZCons->setTargetTemp( globals->getTargetTemp());
1648 +
1649 +    if (globals->haveTargetPressure())
1650 +      myNPTfmZCons->setTargetPressure(globals->getTargetPressure());
1651 +    else {
1652 +      sprintf( painCave.errMsg,
1653 +               "SimSetup error: If you use a constant pressure\n"
1654 +               "    ensemble, you must set targetPressure in the BASS file.\n");
1655 +      painCave.isFatal = 1;
1656 +      simError();
1657      }
1658      
1659 +    if( globals->haveTauThermostat() )
1660 +      myNPTfmZCons->setTauThermostat( globals->getTauThermostat() );
1661 +    else{
1662 +      sprintf( painCave.errMsg,
1663 +               "SimSetup error: If you use an NPT\n"
1664 +               "    ensemble, you must set tauThermostat.\n");
1665 +      painCave.isFatal = 1;
1666 +      simError();
1667 +    }
1668 +
1669 +    if( globals->haveTauBarostat() )
1670 +      myNPTfmZCons->setTauBarostat( globals->getTauBarostat() );
1671 +    else{
1672 +      sprintf( painCave.errMsg,
1673 +               "SimSetup error: If you use an NPT\n"
1674 +               "    ensemble, you must set tauBarostat.\n");
1675 +      painCave.isFatal = 1;
1676 +      simError();
1677 +    }    
1678 +    break;      
1679 +      
1680 +  
1681 +    
1682    default:
1683      sprintf( painCave.errMsg,
1684               "SimSetup Error. Unrecognized ensemble in case statement.\n");
# Line 1568 | Line 1714 | void SimSetup::initFortran( void ){
1714   #endif // is_mpi
1715  
1716   }
1717 +
1718 + void SimSetup::setupZConstraint()
1719 + {
1720 +  if(globals->haveZConsTime()){  
1721 +
1722 +  //add sample time of z-constraint  into SimInfo's property list                    
1723 +  DoubleData* zconsTimeProp = new DoubleData();
1724 +  zconsTimeProp->setID("zconstime");
1725 +  zconsTimeProp->setData(globals->getZConsTime());
1726 +  info->addProperty(zconsTimeProp);
1727 +  }
1728 +  else{
1729 +    sprintf( painCave.errMsg,
1730 +             "ZConstraint error: If you use an ZConstraint\n"
1731 +             " , you must set sample time.\n");
1732 +    painCave.isFatal = 1;
1733 +    simError();      
1734 +  }
1735 +      
1736 +  if(globals->haveIndexOfAllZConsMols()){
1737 +
1738 +        //add index of z-constraint molecules into SimInfo's property list
1739 +        vector<int> tempIndex = globals->getIndexOfAllZConsMols();
1740 +        
1741 +        //sort the index
1742 +        sort(tempIndex.begin(), tempIndex.end());
1743 +        
1744 +        IndexData* zconsIndex = new IndexData();
1745 +        zconsIndex->setID("zconsindex");
1746 +        zconsIndex->setIndexData(tempIndex);
1747 +        info->addProperty(zconsIndex);
1748 +  }
1749 +  else{
1750 +    sprintf( painCave.errMsg,
1751 +             "SimSetup error: If you use an ZConstraint\n"
1752 +             " , you must set index of z-constraint molecules.\n");
1753 +    painCave.isFatal = 1;
1754 +    simError();    
1755 +      
1756 +  }
1757 +
1758 +  //Determine the name of ouput file and add it into SimInfo's property list
1759 +  //Be careful, do not use inFileName, since it is a pointer which
1760 +  //point to a string at master node, and slave nodes do not contain that string
1761 +    
1762 +  string zconsOutput(info->finalName);
1763 +            
1764 +  zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1765 +                
1766 +  StringData* zconsFilename = new StringData();
1767 +  zconsFilename->setID("zconsfilename");
1768 +  zconsFilename->setData(zconsOutput);
1769 +
1770 +  info->addProperty(zconsFilename);      
1771 +
1772 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines