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 |
> |
fileInit = new InitializeFromFile( inName ); |
907 |
|
#ifdef IS_MPI |
908 |
|
}else fileInit = new InitializeFromFile( NULL ); |
909 |
|
#endif |
1036 |
|
int i,k; |
1037 |
|
|
1038 |
|
// create the forceField |
1039 |
< |
|
1039 |
> |
|
1040 |
|
createFF(); |
1041 |
|
|
1042 |
|
// extract componentList |
1054 |
|
#endif //is_mpi |
1055 |
|
|
1056 |
|
// create the atom and SRI arrays. Also initialize Molecule Stamp ID's |
1057 |
< |
|
1057 |
> |
|
1058 |
|
makeSysArrays(); |
1059 |
|
|
1060 |
|
// make and initialize the molecules (all but atomic coordinates) |
1061 |
< |
|
1061 |
> |
|
1062 |
|
makeMolecules(); |
1063 |
|
|
1064 |
|
for(k=0; k<nInfo; k++){ |
1361 |
|
switch( ensembleCase ){ |
1362 |
|
|
1363 |
|
case NVE_ENS: |
1364 |
< |
if (haveZConstraint){ |
1365 |
< |
setupZConstraint(); |
1364 |
> |
if (globals->haveZconstraints()){ |
1365 |
> |
setupZConstraint(info[k]); |
1366 |
|
new ZConstraint<NVE<RealIntegrator> >( &(info[k]), the_ff ); |
1367 |
|
} |
1368 |
|
|
1371 |
|
break; |
1372 |
|
|
1373 |
|
case NVT_ENS: |
1374 |
< |
if (haveZConstraint){ |
1375 |
< |
setupZConstraint(); |
1374 |
> |
if (globals->haveZconstraints()){ |
1375 |
> |
setupZConstraint(info[k]); |
1376 |
|
myNVT = new ZConstraint<NVT<RealIntegrator> >( &(info[k]), the_ff ); |
1377 |
|
} |
1378 |
|
else |
1393 |
|
break; |
1394 |
|
|
1395 |
|
case NPTi_ENS: |
1396 |
< |
if (haveZConstraint){ |
1397 |
< |
setupZConstraint(); |
1396 |
> |
if (globals->haveZconstraints()){ |
1397 |
> |
setupZConstraint(info[k]); |
1398 |
|
myNPTi = new ZConstraint<NPTi<RealIntegrator> >( &(info[k]), the_ff ); |
1399 |
|
} |
1400 |
|
else |
1434 |
|
break; |
1435 |
|
|
1436 |
|
case NPTf_ENS: |
1437 |
< |
if (haveZConstraint){ |
1438 |
< |
setupZConstraint(); |
1437 |
> |
if (globals->haveZconstraints()){ |
1438 |
> |
setupZConstraint(info[k]); |
1439 |
|
myNPTf = new ZConstraint<NPTf<RealIntegrator> >( &(info[k]), the_ff ); |
1440 |
|
} |
1441 |
|
else |
1475 |
|
break; |
1476 |
|
|
1477 |
|
case NPTim_ENS: |
1478 |
< |
if (haveZConstraint){ |
1479 |
< |
setupZConstraint(); |
1478 |
> |
if (globals->haveZconstraints()){ |
1479 |
> |
setupZConstraint(info[k]); |
1480 |
|
myNPTim = new ZConstraint<NPTim<RealIntegrator> >( &(info[k]), the_ff ); |
1481 |
|
} |
1482 |
|
else |
1516 |
|
break; |
1517 |
|
|
1518 |
|
case NPTfm_ENS: |
1519 |
< |
if (haveZConstraint){ |
1520 |
< |
setupZConstraint(); |
1519 |
> |
if (globals->haveZconstraints()){ |
1520 |
> |
setupZConstraint(info[k]); |
1521 |
|
myNPTfm = new ZConstraint<NPTfm<RealIntegrator> >( &(info[k]), the_ff ); |
1522 |
|
} |
1523 |
|
else |
1592 |
|
|
1593 |
|
} |
1594 |
|
|
1595 |
< |
void SimSetup::setupZConstraint() |
1595 |
> |
void SimSetup::setupZConstraint(SimInfo& theInfo) |
1596 |
|
{ |
1597 |
< |
int k; |
1598 |
< |
|
1599 |
< |
for(k=0; k<nInfo; k++){ |
1600 |
< |
|
1598 |
< |
if(globals->haveZConsTime()){ |
1597 |
> |
int nZConstraints; |
1598 |
> |
ZconStamp** zconStamp; |
1599 |
> |
|
1600 |
> |
if(globals->haveZconstraintTime()){ |
1601 |
|
|
1602 |
|
//add sample time of z-constraint into SimInfo's property list |
1603 |
|
DoubleData* zconsTimeProp = new DoubleData(); |
1604 |
< |
zconsTimeProp->setID("zconstime"); |
1605 |
< |
zconsTimeProp->setData(globals->getZConsTime()); |
1606 |
< |
info[k].addProperty(zconsTimeProp); |
1604 |
> |
zconsTimeProp->setID(ZCONSTIME_ID); |
1605 |
> |
zconsTimeProp->setData(globals->getZconsTime()); |
1606 |
> |
theInfo.addProperty(zconsTimeProp); |
1607 |
|
} |
1608 |
|
else{ |
1609 |
|
sprintf( painCave.errMsg, |
1612 |
|
painCave.isFatal = 1; |
1613 |
|
simError(); |
1614 |
|
} |
1615 |
< |
|
1616 |
< |
if(globals->haveIndexOfAllZConsMols()){ |
1617 |
< |
|
1618 |
< |
//add index of z-constraint molecules into SimInfo's property list |
1619 |
< |
vector<int> tempIndex = globals->getIndexOfAllZConsMols(); |
1620 |
< |
|
1621 |
< |
//sort the index |
1622 |
< |
sort(tempIndex.begin(), tempIndex.end()); |
1623 |
< |
|
1624 |
< |
IndexData* zconsIndex = new IndexData(); |
1625 |
< |
zconsIndex->setID("zconsindex"); |
1626 |
< |
zconsIndex->setIndexData(tempIndex); |
1627 |
< |
info[k].addProperty(zconsIndex); |
1615 |
> |
|
1616 |
> |
// |
1617 |
> |
nZConstraints = globals->getNzConstraints(); |
1618 |
> |
zconStamp = globals->getZconStamp(); |
1619 |
> |
ZConsParaItem tempParaItem; |
1620 |
> |
|
1621 |
> |
ZConsParaData* zconsParaData = new ZConsParaData(); |
1622 |
> |
zconsParaData->setID(ZCONSPARADATA_ID); |
1623 |
> |
|
1624 |
> |
for(int i = 0; i < nZConstraints; i++){ |
1625 |
> |
tempParaItem.havingZPos = zconStamp[i]->haveZpos(); |
1626 |
> |
tempParaItem.zPos = zconStamp[i]->getZpos(); |
1627 |
> |
tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); |
1628 |
> |
tempParaItem.kRatio = zconStamp[i]->getKratio(); |
1629 |
> |
|
1630 |
> |
zconsParaData->addItem(tempParaItem); |
1631 |
|
} |
1632 |
< |
else{ |
1633 |
< |
sprintf( painCave.errMsg, |
1634 |
< |
"SimSetup error: If you use an ZConstraint\n" |
1635 |
< |
" , you must set index of z-constraint molecules.\n"); |
1636 |
< |
painCave.isFatal = 1; |
1637 |
< |
simError(); |
1638 |
< |
|
1632 |
> |
|
1633 |
> |
//sort the parameters by index of molecules |
1634 |
> |
zconsParaData->sortByIndex(); |
1635 |
> |
|
1636 |
> |
//push data into siminfo, therefore, we can retrieve later |
1637 |
> |
theInfo.addProperty(zconsParaData); |
1638 |
> |
|
1639 |
> |
//push zconsTol into siminfo, if user does not specify |
1640 |
> |
//value for zconsTol, a default value will be used |
1641 |
> |
DoubleData* zconsTol = new DoubleData(); |
1642 |
> |
zconsTol->setID(ZCONSTOL_ID); |
1643 |
> |
if(globals->haveZconsTol()){ |
1644 |
> |
zconsTol->setData(globals->getZconsTol()); |
1645 |
|
} |
1646 |
< |
|
1646 |
> |
else{ |
1647 |
> |
double defaultZConsTol = 1E-6; |
1648 |
> |
sprintf( painCave.errMsg, |
1649 |
> |
"ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" |
1650 |
> |
" , default value %f is used.\n", defaultZConsTol); |
1651 |
> |
painCave.isFatal = 0; |
1652 |
> |
simError(); |
1653 |
> |
|
1654 |
> |
zconsTol->setData(defaultZConsTol); |
1655 |
> |
} |
1656 |
> |
theInfo.addProperty(zconsTol); |
1657 |
> |
|
1658 |
|
//Determine the name of ouput file and add it into SimInfo's property list |
1659 |
|
//Be careful, do not use inFileName, since it is a pointer which |
1660 |
|
//point to a string at master node, and slave nodes do not contain that string |
1661 |
|
|
1662 |
< |
string zconsOutput(info[k].finalName); |
1662 |
> |
string zconsOutput(theInfo.finalName); |
1663 |
|
|
1664 |
|
zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; |
1665 |
|
|
1666 |
|
StringData* zconsFilename = new StringData(); |
1667 |
< |
zconsFilename->setID("zconsfilename"); |
1667 |
> |
zconsFilename->setID(ZCONSFILENAME_ID); |
1668 |
|
zconsFilename->setData(zconsOutput); |
1669 |
|
|
1670 |
< |
info[k].addProperty(zconsFilename); |
1649 |
< |
} |
1670 |
> |
theInfo.addProperty(zconsFilename); |
1671 |
|
} |