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 676 by tim, Mon Aug 11 19:40:06 2003 UTC vs.
Revision 689 by tim, Tue Aug 12 19:56:49 2003 UTC

# Line 5 | Line 5
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"
# Line 96 | Line 97 | void SimSetup::createSim(void){
97    int i, j, k, globalAtomIndex;
98    
99    // gather all of the information from the Bass file
100 <  
100 >
101 >  std::cerr << "gathering info\n";
102 >
103    gatherInfo();
104  
105    // creation of complex system objects
106  
107 +  std::cerr << "creating system objects\n";
108 +
109    sysObjectsCreation();
110  
111    // check on the post processing info
112    
113 +  std::cerr << "performing final info check.\n";
114 +
115    finalInfoCheck();
116  
117    // initialize the system coordinates
118 +
119 +  std::cerr << "about to init coords\n";
120  
121    if( !isInfoArray ) initSystemCoords();  
122  
# Line 888 | Line 897 | void SimSetup::initSystemCoords( void ){
897   void SimSetup::initSystemCoords( void ){
898    int i;
899    
900 +  char* inName;
901 +
902    std::cerr << "Setting atom Coords\n";
903  
904    (info[0].getConfiguration())->createArrays( info[0].n_atoms );
# Line 900 | Line 911 | void SimSetup::initSystemCoords( void ){
911   #ifdef IS_MPI // is_mpi
912      if( worldRank == 0 ){
913   #endif //is_mpi
914 <      fileInit = new InitializeFromFile( globals->getInitialConfig() );
914 >      inName = globals->getInitialConfig();
915 >      fileInit = new InitializeFromFile( inName );
916   #ifdef IS_MPI
917      }else fileInit = new InitializeFromFile( NULL );
918   #endif
# Line 1033 | Line 1045 | void SimSetup::sysObjectsCreation( void ){
1045    int i,k;
1046    
1047    // create the forceField
1048 <  
1048 >
1049    createFF();
1050  
1051    // extract componentList
# Line 1051 | Line 1063 | void SimSetup::sysObjectsCreation( void ){
1063   #endif //is_mpi
1064    
1065    // create the atom and SRI arrays. Also initialize Molecule Stamp ID's
1066 <  
1066 >
1067    makeSysArrays();
1068  
1069    // make and initialize the molecules (all but atomic coordinates)
1070 <  
1070 >
1071    makeMolecules();
1072    
1073    for(k=0; k<nInfo; k++){
# Line 1358 | Line 1370 | void SimSetup::makeIntegrator( void ){
1370      switch( ensembleCase ){
1371        
1372      case NVE_ENS:
1373 <        if (haveZConstraint){
1374 <         setupZConstraint();
1373 >        if (globals->haveZconstraints()){
1374 >         setupZConstraint(info[k]);
1375             new ZConstraint<NVE<RealIntegrator> >( &(info[k]), the_ff );
1376          }
1377  
# Line 1368 | Line 1380 | void SimSetup::makeIntegrator( void ){
1380        break;
1381        
1382      case NVT_ENS:
1383 <        if (haveZConstraint){
1384 <         setupZConstraint();
1383 >        if (globals->haveZconstraints()){
1384 >         setupZConstraint(info[k]);
1385             myNVT = new ZConstraint<NVT<RealIntegrator> >( &(info[k]), the_ff );
1386          }
1387          else
# Line 1390 | Line 1402 | void SimSetup::makeIntegrator( void ){
1402        break;
1403        
1404      case NPTi_ENS:
1405 <        if (haveZConstraint){
1406 <         setupZConstraint();
1405 >        if (globals->haveZconstraints()){
1406 >         setupZConstraint(info[k]);
1407             myNPTi = new ZConstraint<NPTi<RealIntegrator> >( &(info[k]), the_ff );
1408          }
1409          else
# Line 1431 | Line 1443 | void SimSetup::makeIntegrator( void ){
1443        break;
1444        
1445      case NPTf_ENS:
1446 <        if (haveZConstraint){
1447 <         setupZConstraint();
1446 >        if (globals->haveZconstraints()){
1447 >         setupZConstraint(info[k]);
1448             myNPTf = new ZConstraint<NPTf<RealIntegrator> >( &(info[k]), the_ff );
1449          }
1450          else
# Line 1472 | Line 1484 | void SimSetup::makeIntegrator( void ){
1484        break;
1485        
1486      case NPTim_ENS:
1487 <        if (haveZConstraint){
1488 <         setupZConstraint();
1487 >        if (globals->haveZconstraints()){
1488 >         setupZConstraint(info[k]);
1489             myNPTim = new ZConstraint<NPTim<RealIntegrator> >( &(info[k]), the_ff );
1490          }
1491          else
# Line 1513 | Line 1525 | void SimSetup::makeIntegrator( void ){
1525        break;
1526        
1527      case NPTfm_ENS:
1528 <        if (haveZConstraint){
1529 <         setupZConstraint();
1528 >        if (globals->haveZconstraints()){
1529 >         setupZConstraint(info[k]);
1530             myNPTfm = new ZConstraint<NPTfm<RealIntegrator> >( &(info[k]), the_ff );
1531          }
1532          else
# Line 1589 | Line 1601 | void SimSetup::setupZConstraint()
1601  
1602   }
1603  
1604 < void SimSetup::setupZConstraint()
1604 > void SimSetup::setupZConstraint(SimInfo& theInfo)
1605   {
1606 <  int k;
1607 <
1608 <  for(k=0; k<nInfo; k++){
1609 <    
1598 <    if(globals->haveZConsTime()){  
1606 >    int nZConstraints;
1607 >    ZconStamp** zconStamp;
1608 >        
1609 >    if(globals->haveZconstraintTime()){  
1610        
1611        //add sample time of z-constraint  into SimInfo's property list                    
1612        DoubleData* zconsTimeProp = new DoubleData();
1613 <      zconsTimeProp->setID("zconstime");
1614 <      zconsTimeProp->setData(globals->getZConsTime());
1615 <      info[k].addProperty(zconsTimeProp);
1613 >      zconsTimeProp->setID(ZCONSTIME_ID);
1614 >      zconsTimeProp->setData(globals->getZconsTime());
1615 >      theInfo.addProperty(zconsTimeProp);
1616      }
1617      else{
1618        sprintf( painCave.errMsg,
# Line 1610 | Line 1621 | void SimSetup::setupZConstraint()
1621        painCave.isFatal = 1;
1622        simError();      
1623      }
1624 <    
1625 <    if(globals->haveIndexOfAllZConsMols()){
1626 <
1627 <      //add index of z-constraint molecules into SimInfo's property list
1628 <      vector<int> tempIndex = globals->getIndexOfAllZConsMols();
1629 <      
1630 <      //sort the index
1631 <      sort(tempIndex.begin(), tempIndex.end());
1632 <      
1633 <      IndexData* zconsIndex = new IndexData();
1634 <      zconsIndex->setID("zconsindex");
1635 <      zconsIndex->setIndexData(tempIndex);
1636 <      info[k].addProperty(zconsIndex);
1624 >
1625 >    //
1626 >    nZConstraints = globals->getNzConstraints();
1627 >    zconStamp = globals->getZconStamp();
1628 >    ZConsParaItem tempParaItem;
1629 >
1630 >    ZConsParaData* zconsParaData = new ZConsParaData();
1631 >    zconsParaData->setID(ZCONSPARADATA_ID);
1632 >  
1633 >    for(int i = 0; i < nZConstraints; i++){
1634 >    tempParaItem.havingZPos = zconStamp[i]->haveZpos();
1635 >    tempParaItem.zPos = zconStamp[i]->getZpos();
1636 >    tempParaItem.zconsIndex = zconStamp[i]->getMolIndex();
1637 >    tempParaItem.kRatio = zconStamp[i]->getKratio();
1638 >
1639 >    zconsParaData->addItem(tempParaItem);
1640      }
1641 <    else{
1642 <      sprintf( painCave.errMsg,
1643 <               "SimSetup error: If you use an ZConstraint\n"
1644 <               " , you must set index of z-constraint molecules.\n");
1645 <      painCave.isFatal = 1;
1646 <      simError();    
1647 <      
1641 >
1642 >    //sort the parameters by index of molecules
1643 >    zconsParaData->sortByIndex();
1644 >        
1645 >    //push data into siminfo, therefore, we can retrieve later
1646 >    theInfo.addProperty(zconsParaData);
1647 >
1648 >    //push zconsTol into siminfo, if user does not specify
1649 >    //value for zconsTol, a default value will be used
1650 >    DoubleData* zconsTol = new DoubleData();
1651 >    zconsTol->setID(ZCONSTOL_ID);
1652 >    if(globals->haveZconsTol()){
1653 >      zconsTol->setData(globals->getZconsTol());
1654      }
1655 <    
1655 >         else{
1656 >                double defaultZConsTol = 1E-6;
1657 >      sprintf( painCave.errMsg,
1658 >               "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n"
1659 >               " , default value %f is used.\n", defaultZConsTol);
1660 >      painCave.isFatal = 0;
1661 >      simError();      
1662 >
1663 >      zconsTol->setData(defaultZConsTol);
1664 >         }
1665 >    theInfo.addProperty(zconsTol);
1666 >        
1667      //Determine the name of ouput file and add it into SimInfo's property list
1668      //Be careful, do not use inFileName, since it is a pointer which
1669      //point to a string at master node, and slave nodes do not contain that string
1670      
1671 <    string zconsOutput(info[k].finalName);
1671 >    string zconsOutput(theInfo.finalName);
1672      
1673      zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz";
1674      
1675      StringData* zconsFilename = new StringData();
1676 <    zconsFilename->setID("zconsfilename");
1676 >    zconsFilename->setID(ZCONSFILENAME_ID);
1677      zconsFilename->setData(zconsOutput);
1678      
1679 <    info[k].addProperty(zconsFilename);      
1649 <  }
1679 >    theInfo.addProperty(zconsFilename);      
1680   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines