--- trunk/OOPSE-1.0/utils/sysbuilder/simpleBuilder.cpp 2004/07/28 04:59:35 1424 +++ trunk/OOPSE-1.0/utils/sysbuilder/simpleBuilder.cpp 2004/07/28 18:42:59 1427 @@ -14,6 +14,7 @@ #include "simpleBuilderCmd.hpp" #include "StringUtils.hpp" #include "LatticeFactory.hpp" +#include "Vector3d.hpp" using namespace std; @@ -33,14 +34,14 @@ int main( int argc, char* argv[]){ BaseLattice* simpleLat; int numMol; double latticeConstant; + vector lc; double mass; double density; int nx, ny, nz; double Hmat[3][3]; MoLocator *locator; - double* posX; - double* posY; - double* posZ; + vector latticePos; + vector latticeOrt; int numMolPerCell; int curMolIndex; DumpWriter* writer; @@ -125,7 +126,7 @@ int main( int argc, char* argv[]){ } //creat lattice - simpleLat = LatticeFactory::getInstance() ->createLattice(latticeType); + simpleLat = LatticeFactory::getInstance()->createLattice(latticeType); if(simpleLat == NULL){ cerr << "Error in creating lattice" << endl; exit(1); @@ -137,7 +138,8 @@ int main( int argc, char* argv[]){ latticeConstant = pow(numMolPerCell * mass /density, 1.0/3.0); //set lattice constant - simpleLat->setLatticeConstant(latticeConstant); + lc.push_back(latticeConstant); + simpleLat->setLatticeConstant(lc); //calculate the total numMol = args_info.nx_arg * args_info.ny_arg * args_info.nz_arg * numMolPerCell; @@ -175,7 +177,7 @@ int main( int argc, char* argv[]){ newSimSetup->parseFile(&outMdFileName[0] ); newSimSetup->createSim(); - //set Hamt + //set Hmat newInfo->setBoxM(Hmat); //allocat memory for storing pos, vel and etc @@ -184,39 +186,25 @@ int main( int argc, char* argv[]){ newInfo.atoms[i]->setCoords(); //creat Molocator - locator = new MoLocator(newInfo->compStamps[0]); - - //allocate memory for posX, posY, posZ - - posX = new doule[numMolPerCell]; - if(posX == NULL){ - cerr << "memory allocation error" << endl; - exit(1); - } - - posY = new doule[numMolPerCell]; - if(posX == NULL){ - cerr << "memory allocation error" << endl; - exit(1); - } + locator = new MoLocator(newInfo->compStamps[0], newSimSetup->the_ff); - posZ = new doule[numMolPerCell]; - if(posX == NULL){ - cerr << "memory allocation error" << endl; - exit(1); - } - //place the molecules curMolIndex = 0; + + //get the orientation of the cell sites + //for the same type of molecule in same lattice, it will not change + latticeOrt = simpleLat->getLatticePointsOrt(); + for(int i =0; i < nx; i++){ for(int j=0; j < ny; j++){ for(int k = 0; k < nz; k++){ - - simpleLat->getLatticePoints(&posX, &posY, &posZ, i, j, k); + //get the position of the cell sites + simpleLat->getLatticePointsPos(latticePos, i, j, k); + for(int l = 0; l < numMolPerCell; l++) - locator->placeMol(posX[l], posY[l], posZ[l], newInfo->molecules[curMolIndex++]); + locator->placeMol(latticePos[l], latticeOrt[l], newInfo->molecules[curMolIndex++]); } } } @@ -243,15 +231,6 @@ int main( int argc, char* argv[]){ if(!newSimSetup) delete newSimSetup; - if (posX) - delete[] posX; - - if (posY) - delete[] posY; - - if (posZ) - delete[] posZ; - if (writer != NULL) delete writer; return 0;