| 5 | 
  | 
#include <string> | 
| 6 | 
  | 
 | 
| 7 | 
  | 
#include "SimSetup.hpp" | 
| 8 | 
+ | 
#include "ReadWrite.hpp" | 
| 9 | 
  | 
#include "parse_me.h" | 
| 10 | 
  | 
#include "Integrator.hpp" | 
| 11 | 
  | 
#include "simError.h" | 
| 97 | 
  | 
  int i, j, k, globalAtomIndex; | 
| 98 | 
  | 
   | 
| 99 | 
  | 
  // gather all of the information from the Bass file | 
| 100 | 
< | 
   | 
| 100 | 
> | 
 | 
| 101 | 
  | 
  gatherInfo(); | 
| 102 | 
  | 
 | 
| 103 | 
  | 
  // creation of complex system objects | 
| 105 | 
  | 
  sysObjectsCreation(); | 
| 106 | 
  | 
 | 
| 107 | 
  | 
  // check on the post processing info | 
| 108 | 
< | 
   | 
| 108 | 
> | 
 | 
| 109 | 
  | 
  finalInfoCheck(); | 
| 110 | 
  | 
 | 
| 111 | 
  | 
  // initialize the system coordinates | 
| 889 | 
  | 
void SimSetup::initSystemCoords( void ){ | 
| 890 | 
  | 
  int i; | 
| 891 | 
  | 
   | 
| 892 | 
< | 
  std::cerr << "Setting atom Coords\n"; | 
| 892 | 
> | 
  char* inName; | 
| 893 | 
  | 
 | 
| 894 | 
+ | 
 | 
| 895 | 
  | 
  (info[0].getConfiguration())->createArrays( info[0].n_atoms ); | 
| 896 | 
  | 
   | 
| 897 | 
  | 
  for(i=0; i<info[0].n_atoms; i++) info[0].atoms[i]->setCoords(); | 
| 902 | 
  | 
#ifdef IS_MPI // is_mpi | 
| 903 | 
  | 
    if( worldRank == 0 ){ | 
| 904 | 
  | 
#endif //is_mpi | 
| 905 | 
< | 
      fileInit = new InitializeFromFile( globals->getInitialConfig() ); | 
| 905 | 
> | 
      inName = globals->getInitialConfig(); | 
| 906 | 
> | 
      double* tempDouble = new double[1000000]; | 
| 907 | 
> | 
      fileInit = new InitializeFromFile( inName ); | 
| 908 | 
  | 
#ifdef IS_MPI | 
| 909 | 
  | 
    }else fileInit = new InitializeFromFile( NULL ); | 
| 910 | 
  | 
#endif | 
| 1037 | 
  | 
  int i,k; | 
| 1038 | 
  | 
   | 
| 1039 | 
  | 
  // create the forceField | 
| 1040 | 
< | 
   | 
| 1040 | 
> | 
 | 
| 1041 | 
  | 
  createFF(); | 
| 1042 | 
  | 
 | 
| 1043 | 
  | 
  // extract componentList | 
| 1055 | 
  | 
#endif //is_mpi | 
| 1056 | 
  | 
   | 
| 1057 | 
  | 
  // create the atom and SRI arrays. Also initialize Molecule Stamp ID's | 
| 1058 | 
< | 
   | 
| 1058 | 
> | 
  | 
| 1059 | 
  | 
  makeSysArrays(); | 
| 1060 | 
  | 
 | 
| 1061 | 
  | 
  // make and initialize the molecules (all but atomic coordinates) | 
| 1062 | 
< | 
   | 
| 1062 | 
> | 
  | 
| 1063 | 
  | 
  makeMolecules(); | 
| 1064 | 
  | 
   | 
| 1065 | 
  | 
  for(k=0; k<nInfo; k++){ | 
| 1362 | 
  | 
    switch( ensembleCase ){ | 
| 1363 | 
  | 
       | 
| 1364 | 
  | 
    case NVE_ENS: | 
| 1365 | 
< | 
        if (haveZConstraint){ | 
| 1366 | 
< | 
         setupZConstraint(); | 
| 1365 | 
> | 
        if (globals->haveZconstraints()){ | 
| 1366 | 
> | 
         setupZConstraint(info[k]); | 
| 1367 | 
  | 
           new ZConstraint<NVE<RealIntegrator> >( &(info[k]), the_ff ); | 
| 1368 | 
  | 
        } | 
| 1369 | 
  | 
 | 
| 1372 | 
  | 
      break; | 
| 1373 | 
  | 
       | 
| 1374 | 
  | 
    case NVT_ENS: | 
| 1375 | 
< | 
        if (haveZConstraint){ | 
| 1376 | 
< | 
         setupZConstraint(); | 
| 1375 | 
> | 
        if (globals->haveZconstraints()){ | 
| 1376 | 
> | 
         setupZConstraint(info[k]); | 
| 1377 | 
  | 
           myNVT = new ZConstraint<NVT<RealIntegrator> >( &(info[k]), the_ff ); | 
| 1378 | 
  | 
        } | 
| 1379 | 
  | 
        else | 
| 1394 | 
  | 
      break; | 
| 1395 | 
  | 
       | 
| 1396 | 
  | 
    case NPTi_ENS: | 
| 1397 | 
< | 
        if (haveZConstraint){ | 
| 1398 | 
< | 
         setupZConstraint(); | 
| 1397 | 
> | 
        if (globals->haveZconstraints()){ | 
| 1398 | 
> | 
         setupZConstraint(info[k]); | 
| 1399 | 
  | 
           myNPTi = new ZConstraint<NPTi<RealIntegrator> >( &(info[k]), the_ff ); | 
| 1400 | 
  | 
        } | 
| 1401 | 
  | 
        else | 
| 1435 | 
  | 
      break; | 
| 1436 | 
  | 
       | 
| 1437 | 
  | 
    case NPTf_ENS: | 
| 1438 | 
< | 
        if (haveZConstraint){ | 
| 1439 | 
< | 
         setupZConstraint(); | 
| 1438 | 
> | 
        if (globals->haveZconstraints()){ | 
| 1439 | 
> | 
         setupZConstraint(info[k]); | 
| 1440 | 
  | 
           myNPTf = new ZConstraint<NPTf<RealIntegrator> >( &(info[k]), the_ff ); | 
| 1441 | 
  | 
        } | 
| 1442 | 
  | 
        else | 
| 1476 | 
  | 
      break; | 
| 1477 | 
  | 
       | 
| 1478 | 
  | 
    case NPTim_ENS: | 
| 1479 | 
< | 
        if (haveZConstraint){ | 
| 1480 | 
< | 
         setupZConstraint(); | 
| 1479 | 
> | 
        if (globals->haveZconstraints()){ | 
| 1480 | 
> | 
         setupZConstraint(info[k]); | 
| 1481 | 
  | 
           myNPTim = new ZConstraint<NPTim<RealIntegrator> >( &(info[k]), the_ff ); | 
| 1482 | 
  | 
        } | 
| 1483 | 
  | 
        else | 
| 1517 | 
  | 
      break; | 
| 1518 | 
  | 
       | 
| 1519 | 
  | 
    case NPTfm_ENS: | 
| 1520 | 
< | 
        if (haveZConstraint){ | 
| 1521 | 
< | 
         setupZConstraint(); | 
| 1520 | 
> | 
        if (globals->haveZconstraints()){ | 
| 1521 | 
> | 
         setupZConstraint(info[k]); | 
| 1522 | 
  | 
           myNPTfm = new ZConstraint<NPTfm<RealIntegrator> >( &(info[k]), the_ff ); | 
| 1523 | 
  | 
        } | 
| 1524 | 
  | 
        else | 
| 1593 | 
  | 
 | 
| 1594 | 
  | 
} | 
| 1595 | 
  | 
 | 
| 1596 | 
< | 
void SimSetup::setupZConstraint() | 
| 1596 | 
> | 
void SimSetup::setupZConstraint(SimInfo& theInfo) | 
| 1597 | 
  | 
{ | 
| 1598 | 
< | 
  int k; | 
| 1599 | 
< | 
 | 
| 1600 | 
< | 
  for(k=0; k<nInfo; k++){ | 
| 1601 | 
< | 
     | 
| 1598 | 
< | 
    if(globals->haveZConsTime()){    | 
| 1598 | 
> | 
    int nZConstraints; | 
| 1599 | 
> | 
    ZconStamp** zconStamp; | 
| 1600 | 
> | 
         | 
| 1601 | 
> | 
    if(globals->haveZconstraintTime()){    | 
| 1602 | 
  | 
       | 
| 1603 | 
  | 
      //add sample time of z-constraint  into SimInfo's property list                     | 
| 1604 | 
  | 
      DoubleData* zconsTimeProp = new DoubleData(); | 
| 1605 | 
< | 
      zconsTimeProp->setID("zconstime"); | 
| 1606 | 
< | 
      zconsTimeProp->setData(globals->getZConsTime()); | 
| 1607 | 
< | 
      info[k].addProperty(zconsTimeProp); | 
| 1605 | 
> | 
      zconsTimeProp->setID(ZCONSTIME_ID); | 
| 1606 | 
> | 
      zconsTimeProp->setData(globals->getZconsTime()); | 
| 1607 | 
> | 
      theInfo.addProperty(zconsTimeProp); | 
| 1608 | 
  | 
    } | 
| 1609 | 
  | 
    else{ | 
| 1610 | 
  | 
      sprintf( painCave.errMsg, | 
| 1613 | 
  | 
      painCave.isFatal = 1; | 
| 1614 | 
  | 
      simError();       | 
| 1615 | 
  | 
    } | 
| 1616 | 
< | 
     | 
| 1617 | 
< | 
    if(globals->haveIndexOfAllZConsMols()){ | 
| 1618 | 
< | 
  | 
| 1619 | 
< | 
      //add index of z-constraint molecules into SimInfo's property list | 
| 1620 | 
< | 
      vector<int> tempIndex = globals->getIndexOfAllZConsMols(); | 
| 1621 | 
< | 
       | 
| 1622 | 
< | 
      //sort the index | 
| 1620 | 
< | 
      sort(tempIndex.begin(), tempIndex.end()); | 
| 1621 | 
< | 
       | 
| 1622 | 
< | 
      IndexData* zconsIndex = new IndexData(); | 
| 1623 | 
< | 
      zconsIndex->setID("zconsindex"); | 
| 1624 | 
< | 
      zconsIndex->setIndexData(tempIndex); | 
| 1625 | 
< | 
      info[k].addProperty(zconsIndex); | 
| 1626 | 
< | 
    } | 
| 1627 | 
< | 
    else{ | 
| 1628 | 
< | 
      sprintf( painCave.errMsg, | 
| 1629 | 
< | 
               "SimSetup error: If you use an ZConstraint\n" | 
| 1630 | 
< | 
               " , you must set index of z-constraint molecules.\n"); | 
| 1631 | 
< | 
      painCave.isFatal = 1; | 
| 1632 | 
< | 
      simError();      | 
| 1633 | 
< | 
       | 
| 1616 | 
> | 
 | 
| 1617 | 
> | 
    //push zconsTol into siminfo, if user does not specify | 
| 1618 | 
> | 
    //value for zconsTol, a default value will be used | 
| 1619 | 
> | 
    DoubleData* zconsTol = new DoubleData(); | 
| 1620 | 
> | 
    zconsTol->setID(ZCONSTOL_ID); | 
| 1621 | 
> | 
    if(globals->haveZconsTol()){ | 
| 1622 | 
> | 
      zconsTol->setData(globals->getZconsTol()); | 
| 1623 | 
  | 
    } | 
| 1624 | 
< | 
     | 
| 1624 | 
> | 
         else{ | 
| 1625 | 
> | 
                double defaultZConsTol = 0.01; | 
| 1626 | 
> | 
      sprintf( painCave.errMsg, | 
| 1627 | 
> | 
               "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" | 
| 1628 | 
> | 
               " , default value %f is used.\n", defaultZConsTol); | 
| 1629 | 
> | 
      painCave.isFatal = 0; | 
| 1630 | 
> | 
      simError();       | 
| 1631 | 
> | 
 | 
| 1632 | 
> | 
      zconsTol->setData(defaultZConsTol); | 
| 1633 | 
> | 
         } | 
| 1634 | 
> | 
    theInfo.addProperty(zconsTol); | 
| 1635 | 
> | 
 | 
| 1636 | 
> | 
    //set Force Substraction Policy | 
| 1637 | 
> | 
    StringData* zconsForcePolicy =  new StringData(); | 
| 1638 | 
> | 
    zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID); | 
| 1639 | 
> | 
                 | 
| 1640 | 
> | 
         if(globals->haveZconsForcePolicy()){ | 
| 1641 | 
> | 
      zconsForcePolicy->setData(globals->getZconsForcePolicy()); | 
| 1642 | 
> | 
         }       | 
| 1643 | 
> | 
         else{ | 
| 1644 | 
> | 
       sprintf( painCave.errMsg, | 
| 1645 | 
> | 
               "ZConstraint Warning: User does not set force substraction policy, " | 
| 1646 | 
> | 
               "average force substraction policy is used\n"); | 
| 1647 | 
> | 
       painCave.isFatal = 0; | 
| 1648 | 
> | 
       simError();  | 
| 1649 | 
> | 
                 zconsForcePolicy->setData("BYNUMBER"); | 
| 1650 | 
> | 
         } | 
| 1651 | 
> | 
          | 
| 1652 | 
> | 
         theInfo.addProperty(zconsForcePolicy); | 
| 1653 | 
> | 
          | 
| 1654 | 
  | 
    //Determine the name of ouput file and add it into SimInfo's property list  | 
| 1655 | 
  | 
    //Be careful, do not use inFileName, since it is a pointer which | 
| 1656 | 
  | 
    //point to a string at master node, and slave nodes do not contain that string | 
| 1657 | 
  | 
     | 
| 1658 | 
< | 
    string zconsOutput(info[k].finalName); | 
| 1658 | 
> | 
    string zconsOutput(theInfo.finalName); | 
| 1659 | 
  | 
     | 
| 1660 | 
  | 
    zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; | 
| 1661 | 
  | 
     | 
| 1662 | 
  | 
    StringData* zconsFilename = new StringData(); | 
| 1663 | 
< | 
    zconsFilename->setID("zconsfilename"); | 
| 1663 | 
> | 
    zconsFilename->setID(ZCONSFILENAME_ID); | 
| 1664 | 
  | 
    zconsFilename->setData(zconsOutput); | 
| 1665 | 
  | 
     | 
| 1666 | 
< | 
    info[k].addProperty(zconsFilename);       | 
| 1667 | 
< | 
  } | 
| 1666 | 
> | 
    theInfo.addProperty(zconsFilename); | 
| 1667 | 
> | 
                 | 
| 1668 | 
> | 
    //setup index, pos and other parameters of z-constraint molecules | 
| 1669 | 
> | 
    nZConstraints = globals->getNzConstraints(); | 
| 1670 | 
> | 
    theInfo.nZconstraints = nZConstraints; | 
| 1671 | 
> | 
         | 
| 1672 | 
> | 
    zconStamp = globals->getZconStamp(); | 
| 1673 | 
> | 
    ZConsParaItem tempParaItem; | 
| 1674 | 
> | 
 | 
| 1675 | 
> | 
    ZConsParaData* zconsParaData = new ZConsParaData(); | 
| 1676 | 
> | 
    zconsParaData->setID(ZCONSPARADATA_ID); | 
| 1677 | 
> | 
    | 
| 1678 | 
> | 
    for(int i = 0; i < nZConstraints; i++){ | 
| 1679 | 
> | 
    tempParaItem.havingZPos = zconStamp[i]->haveZpos(); | 
| 1680 | 
> | 
    tempParaItem.zPos = zconStamp[i]->getZpos(); | 
| 1681 | 
> | 
    tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); | 
| 1682 | 
> | 
    tempParaItem.kRatio = zconStamp[i]->getKratio(); | 
| 1683 | 
> | 
 | 
| 1684 | 
> | 
    zconsParaData->addItem(tempParaItem); | 
| 1685 | 
> | 
    } | 
| 1686 | 
> | 
 | 
| 1687 | 
> | 
    //sort the parameters by index of molecules | 
| 1688 | 
> | 
    zconsParaData->sortByIndex(); | 
| 1689 | 
> | 
         | 
| 1690 | 
> | 
    //push data into siminfo, therefore, we can retrieve later | 
| 1691 | 
> | 
    theInfo.addProperty(zconsParaData); | 
| 1692 | 
> | 
       | 
| 1693 | 
  | 
} |