| 29 | 
  | 
  string inputFileName; | 
| 30 | 
  | 
  string outPrefix; | 
| 31 | 
  | 
  string outMdFileName; | 
| 32 | 
– | 
  string outInitFileName; | 
| 32 | 
  | 
  SimInfo* oldInfo; | 
| 34 | 
– | 
  SimInfo* newInfo; | 
| 33 | 
  | 
  SimSetup* oldSimSetup; | 
| 36 | 
– | 
  SimSetup* newSimSetup; | 
| 34 | 
  | 
  BaseLattice* simpleLat; | 
| 35 | 
  | 
  int numMol; | 
| 36 | 
  | 
  double latticeConstant; | 
| 113 | 
  | 
    outPrefix = getPrefix(inputFileName.c_str()) + "_" + latticeType; | 
| 114 | 
  | 
   | 
| 115 | 
  | 
  outMdFileName = outPrefix + ".md"; | 
| 119 | 
– | 
  outInitFileName = outPrefix + ".in"; | 
| 116 | 
  | 
 | 
| 117 | 
  | 
  //parse md file and set up the system | 
| 118 | 
  | 
  oldInfo = new SimInfo; | 
| 126 | 
  | 
     cerr << "error in creating SimSetup" << endl; | 
| 127 | 
  | 
     exit(1); | 
| 128 | 
  | 
  } | 
| 129 | 
< | 
     | 
| 129 | 
> | 
 | 
| 130 | 
> | 
  oldSimSetup->suspendInit(); | 
| 131 | 
  | 
  oldSimSetup->setSimInfo(oldInfo ); | 
| 132 | 
  | 
  oldSimSetup->parseFile(&inputFileName[0] ); | 
| 133 | 
  | 
  oldSimSetup->createSim();  | 
| 134 | 
+ | 
   | 
| 135 | 
  | 
  if(oldInfo->nComponents >=2){ | 
| 136 | 
  | 
      cerr << "can not build the system with more than two components" << endl; | 
| 137 | 
  | 
      exit(1); | 
| 138 | 
  | 
  } | 
| 141 | 
– | 
 | 
| 139 | 
  | 
   | 
| 140 | 
  | 
  //get mass of molecule.  | 
| 141 | 
  | 
  //Due to the design of OOPSE, given atom type, we have to query forcefiled to get the mass | 
| 158 | 
  | 
  simpleLat->setLatticeConstant(lc); | 
| 159 | 
  | 
   | 
| 160 | 
  | 
  //calculate the total number of molecules | 
| 161 | 
< | 
  numMol = args_info.nx_arg * args_info.ny_arg * args_info.nz_arg * numMolPerCell; | 
| 165 | 
< | 
   | 
| 166 | 
< | 
  //creat new .md file on fly  | 
| 167 | 
< | 
  createMdFile(inputFileName, outMdFileName, numMol); | 
| 161 | 
> | 
  numMol = nx * ny * nz * numMolPerCell; | 
| 162 | 
  | 
 | 
| 163 | 
< | 
  //parse new .md file and set up the system | 
| 164 | 
< | 
  newInfo = new SimInfo; | 
| 165 | 
< | 
  if(newInfo == NULL){ | 
| 166 | 
< | 
     cerr << "error in creating SimInfo" << endl; | 
| 167 | 
< | 
     exit(1); | 
| 163 | 
> | 
  if (oldInfo->n_mol != numMol){ | 
| 164 | 
> | 
    //creat new .md file on fly which corrects the number of molecule  | 
| 165 | 
> | 
    createMdFile(inputFileName, outMdFileName, numMol); | 
| 166 | 
> | 
    cerr << "SimpleBuilder Error: the number of molecule and the density are not matched" <<endl; | 
| 167 | 
> | 
    cerr << "A new .md file: " << outMdFileName << " is generated, use it to rerun the simpleBuilder" << endl; | 
| 168 | 
> | 
    exit(1); | 
| 169 | 
  | 
  } | 
| 175 | 
– | 
   | 
| 176 | 
– | 
  newSimSetup = new SimSetup();   | 
| 177 | 
– | 
  if(newSimSetup == NULL){ | 
| 178 | 
– | 
     cerr << "error in creating SimSetup" << endl; | 
| 179 | 
– | 
     exit(1); | 
| 180 | 
– | 
  } | 
| 181 | 
– | 
     | 
| 182 | 
– | 
  newSimSetup->setSimInfo(newInfo ); | 
| 183 | 
– | 
  newSimSetup->parseFile(&outMdFileName[0] ); | 
| 184 | 
– | 
  newSimSetup->createSim();  | 
| 170 | 
  | 
 | 
| 171 | 
  | 
  //allocat memory for storing pos, vel and etc | 
| 172 | 
< | 
  newInfo->getConfiguration()->createArrays(newInfo->n_atoms); | 
| 173 | 
< | 
  for (int i = 0; i < newInfo->n_atoms; i++) | 
| 174 | 
< | 
    newInfo->atoms[i]->setCoords();   | 
| 172 | 
> | 
  oldInfo->getConfiguration()->createArrays(oldInfo->n_atoms); | 
| 173 | 
> | 
  for (int i = 0; i < oldInfo->n_atoms; i++) | 
| 174 | 
> | 
    oldInfo->atoms[i]->setCoords();   | 
| 175 | 
  | 
 | 
| 176 | 
  | 
  //creat Molocator | 
| 177 | 
< | 
  locator = new MoLocator(newInfo->compStamps[0], newSimSetup->getForceField()); | 
| 177 | 
> | 
  locator = new MoLocator(oldInfo->compStamps[0], oldSimSetup->getForceField()); | 
| 178 | 
  | 
 | 
| 179 | 
  | 
  //fill Hmat | 
| 180 | 
  | 
  Hmat[0][0] = nx * latticeConstant; | 
| 181 | 
  | 
  Hmat[0][1] = 0.0; | 
| 182 | 
  | 
  Hmat[0][2] = 0.0; | 
| 183 | 
  | 
 | 
| 184 | 
< | 
  Hmat[1][0] = ny * latticeConstant; | 
| 185 | 
< | 
  Hmat[1][1] = 0.0; | 
| 184 | 
> | 
  Hmat[1][0] = 0.0; | 
| 185 | 
> | 
  Hmat[1][1] = ny * latticeConstant; | 
| 186 | 
  | 
  Hmat[1][2] = 0.0; | 
| 187 | 
  | 
 | 
| 188 | 
< | 
  Hmat[2][0] = nz * latticeConstant; | 
| 188 | 
> | 
  Hmat[2][0] = 0.0; | 
| 189 | 
  | 
  Hmat[2][1] = 0.0; | 
| 190 | 
< | 
  Hmat[2][2] = 0.0; | 
| 190 | 
> | 
  Hmat[2][2] = nz * latticeConstant ; | 
| 191 | 
  | 
 | 
| 192 | 
  | 
  //set Hmat | 
| 193 | 
< | 
  newInfo->setBoxM(Hmat); | 
| 193 | 
> | 
  oldInfo->setBoxM(Hmat); | 
| 194 | 
  | 
   | 
| 195 | 
  | 
  //place the molecules | 
| 196 | 
  | 
 | 
| 208 | 
  | 
          simpleLat->getLatticePointsPos(latticePos, i, j, k); | 
| 209 | 
  | 
 | 
| 210 | 
  | 
          for(int l = 0; l < numMolPerCell; l++) | 
| 211 | 
< | 
            locator->placeMol(latticePos[l], latticeOrt[l], &(newInfo->molecules[curMolIndex++])); | 
| 211 | 
> | 
            locator->placeMol(latticePos[l], latticeOrt[l], &(oldInfo->molecules[curMolIndex++])); | 
| 212 | 
  | 
       } | 
| 213 | 
  | 
    } | 
| 214 | 
  | 
  } | 
| 215 | 
  | 
 | 
| 216 | 
  | 
  //create dumpwriter and write out the coordinates | 
| 217 | 
< | 
  writer = new DumpWriter( newInfo ); | 
| 217 | 
> | 
  writer = new DumpWriter( oldInfo ); | 
| 218 | 
  | 
  if(writer == NULL){ | 
| 219 | 
  | 
    cerr << "error in creating DumpWriter" << endl; | 
| 220 | 
  | 
    exit(1);     | 
| 222 | 
  | 
  writer->writeFinal(0); | 
| 223 | 
  | 
   | 
| 224 | 
  | 
  //delete objects | 
| 225 | 
< | 
  if(!oldInfo) | 
| 225 | 
> | 
 | 
| 226 | 
> | 
  //delete oldInfo and oldSimSetup | 
| 227 | 
> | 
  if(oldInfo != NULL) | 
| 228 | 
  | 
     delete oldInfo; | 
| 229 | 
  | 
   | 
| 230 | 
< | 
  if(!oldSimSetup) | 
| 231 | 
< | 
     delete oldSimSetup; | 
| 245 | 
< | 
 | 
| 246 | 
< | 
  if(!newInfo) | 
| 247 | 
< | 
     delete newInfo; | 
| 230 | 
> | 
  if(oldSimSetup != NULL) | 
| 231 | 
> | 
     delete oldSimSetup;  | 
| 232 | 
  | 
   | 
| 249 | 
– | 
  if(!newSimSetup) | 
| 250 | 
– | 
     delete newSimSetup; | 
| 251 | 
– | 
 | 
| 233 | 
  | 
  if (writer != NULL) | 
| 234 | 
  | 
    delete writer; | 
| 235 | 
  | 
  return 0; | 
| 240 | 
  | 
  ofstream newMdFile; | 
| 241 | 
  | 
  const int MAXLEN = 65535; | 
| 242 | 
  | 
  char buffer[MAXLEN]; | 
| 262 | 
– | 
  string line; | 
| 243 | 
  | 
 | 
| 244 | 
  | 
  //create new .md file based on old .md file | 
| 245 | 
  | 
  oldMdFile.open(oldMdFileName.c_str()); | 
| 248 | 
  | 
  oldMdFile.getline(buffer, MAXLEN); | 
| 249 | 
  | 
  while(!oldMdFile.eof()){ | 
| 250 | 
  | 
 | 
| 251 | 
< | 
    if(line.find("nMol") < line.size()){ | 
| 252 | 
< | 
       | 
| 251 | 
> | 
    //correct molecule number | 
| 252 | 
> | 
    if(strstr(buffer, "nMol") !=NULL){       | 
| 253 | 
  | 
      sprintf(buffer, "\t\tnMol = %d;", numMol); | 
| 254 | 
  | 
      newMdFile << buffer << endl; | 
| 255 | 
  | 
    } |