--- trunk/OOPSE/utils/sysbuilder/latticeBilayer.cpp 2003/11/06 22:01:37 855 +++ trunk/OOPSE/utils/sysbuilder/latticeBilayer.cpp 2004/01/14 16:28:37 943 @@ -549,7 +549,7 @@ int main(int argC,char* argV[]){ simInit->setSimInfo( mainInfo ); simInit->suspendInit(); simInit->parseFile( inName ); - simInit->createSim(); + simInit->createSim(); delete simInit; @@ -581,7 +581,7 @@ int buildLatticeBilayer(double aLat, double *posX, *posY, *posZ; double pos[3], posA[3], posB[3]; - const double waterFudge = 5.0; + const double waterFudge = 6.0; int i,j,k,l; int nAtoms, atomIndex, molIndex, molID; @@ -597,7 +597,6 @@ int buildLatticeBilayer(double aLat, int targetWaters; Atom** atoms; - SimInfo* simnfo; SimInfo* testInfo; coord testSite; SimState* theConfig; @@ -612,15 +611,9 @@ int buildLatticeBilayer(double aLat, int targetNlipids, targetNwaters; double targetWaterLipidRatio; double maxZ, minZ, zHeight; - double maxY, minY; - double maxX, minX; molStart = NULL; - // create the simInfo objects - - simnfo = new SimInfo; - // set the the lipidStamp foundLipid = 0; @@ -694,11 +687,15 @@ int buildLatticeBilayer(double aLat, } zHeight = maxZ - minZ; - nCells = (int) sqrt( (double)targetNlipids * bLat / (4.0 * aLat) ); + std::cerr << "aLat = " << aLat << "; bLat = " << bLat << "\n"; + + nCells = (int)ceil( sqrt( (double)targetNlipids * bLat / (4.0 * aLat) )); nx = nCells; ny = (int) ((double)nCells * aLat / bLat); + std::cerr << "nx = " << nx << "; ny = " << ny << "\n"; + boxX = nx * aLat; boxY = ny * bLat; @@ -789,35 +786,22 @@ int buildLatticeBilayer(double aLat, atoms[0]->getPos( myPos ); - maxX = myPos[0]; - minX = myPos[0]; - - maxY = myPos[1]; - minY = myPos[1]; - maxZ = myPos[2]; minZ = myPos[2]; for(i=0;igetPos( myPos ); - minX = (minX > myPos[0]) ? myPos[0] : minX; - maxX = (maxX < myPos[0]) ? myPos[0] : maxX; - minY = (minY > myPos[1]) ? myPos[1] : minY; - maxY = (maxY < myPos[1]) ? myPos[1] : maxY; - minZ = (minZ > myPos[2]) ? myPos[2] : minZ; maxZ = (maxZ < myPos[2]) ? myPos[2] : maxZ; } - boxX = (maxX - minX)+2.0; - boxY = (maxY - minY)+2.0; boxZ = (maxZ - minZ)+2.0; double centerX, centerY, centerZ; - centerX = ((maxX - minX) / 2.0) + minX; - centerY = ((maxY - minY) / 2.0) + minY; + centerX = (boxX / 2.0); + centerY = (boxY / 2.0); centerZ = ((maxZ - minZ) / 2.0) + minZ; // set up water coordinates @@ -904,11 +888,12 @@ int buildLatticeBilayer(double aLat, // create the real Atom arrays - theConfig = simnfo->getConfiguration(); + delete[] (mainInfo->atoms); + theConfig = mainInfo->getConfiguration(); theConfig->createArrays( nAtoms ); - simnfo->atoms = new Atom*[nAtoms]; - simnfo->n_atoms = nAtoms; - atoms = simnfo->atoms; + mainInfo->atoms = new Atom*[nAtoms]; + mainInfo->n_atoms = nAtoms; + atoms = mainInfo->atoms; // wrap back to <0,0,0> as center @@ -927,7 +912,6 @@ int buildLatticeBilayer(double aLat, Hmat[2][2] = boxZ; mainInfo->setBoxM( Hmat ); - simnfo->setBoxM( Hmat ); for(j=0;jwrapVector( lipidSites[j].pos ); + mainInfo->wrapVector( lipidSites[j].pos ); } for(j=0;jwrapVector( waterSites[j].pos ); + mainInfo->wrapVector( waterSites[j].pos ); } // initialize lipid positions @@ -966,12 +950,9 @@ int buildLatticeBilayer(double aLat, molIndex++; } - strcpy( simnfo->sampleName, mainInfo->sampleName ); - strcpy( simnfo->finalName, mainInfo->finalName ); - // set up the writer and write out - writer = new DumpWriter( simnfo ); + writer = new DumpWriter( mainInfo ); writer->writeFinal( 0.0 ); std::cout << "\n"