| 42 | 
  | 
 * | 
| 43 | 
  | 
 *  Created by Charles F. Vardeman II on 10 Apr 2006. | 
| 44 | 
  | 
 *  @author  Charles F. Vardeman II | 
| 45 | 
< | 
 *  @version $Id: randomBuilder.cpp,v 1.2 2006-05-17 21:51:42 tim Exp $ | 
| 45 | 
> | 
 *  @version $Id: randomBuilder.cpp,v 1.3 2006-10-09 22:16:44 gezelter Exp $ | 
| 46 | 
  | 
 * | 
| 47 | 
  | 
 */ | 
| 48 | 
  | 
 | 
| 86 | 
  | 
  std::string inputFileName; | 
| 87 | 
  | 
  std::string outPrefix; | 
| 88 | 
  | 
  std::string outMdFileName; | 
| 89 | 
– | 
  std::string outInitFileName; | 
| 89 | 
  | 
  Lattice *simpleLat; | 
| 90 | 
  | 
  int* numMol; | 
| 91 | 
  | 
  RealType latticeConstant; | 
| 159 | 
  | 
  Globals* simParams = oldInfo->getSimParams(); | 
| 160 | 
  | 
 | 
| 161 | 
  | 
  int nComponents =simParams->getNComponents(); | 
| 162 | 
< | 
  if (oldInfo->getNMoleculeStamp()>= 2) { | 
| 162 | 
> | 
  if (oldInfo->getNMoleculeStamp() > 2) { | 
| 163 | 
  | 
    std::cerr << "can not build the system with more than two components" | 
| 164 | 
  | 
              << std::endl; | 
| 165 | 
  | 
    exit(1); | 
| 227 | 
  | 
  outMdFileName = outPrefix + ".md"; | 
| 228 | 
  | 
 | 
| 229 | 
  | 
  //creat new .md file on fly which corrects the number of molecule      | 
| 230 | 
< | 
  createMdFile(inputFileName, outMdFileName, nComponents,numMol); | 
| 232 | 
< | 
 | 
| 233 | 
< | 
 | 
| 234 | 
< | 
 | 
| 235 | 
< | 
  //determine the output file names   | 
| 236 | 
< | 
  if (args_info.output_given){ | 
| 237 | 
< | 
    outInitFileName = args_info.output_arg; | 
| 238 | 
< | 
  }else{ | 
| 239 | 
< | 
    outInitFileName = getPrefix(inputFileName.c_str()) + ".in"; | 
| 240 | 
< | 
  } | 
| 230 | 
> | 
  createMdFile(inputFileName, outMdFileName, nComponents, numMol); | 
| 231 | 
  | 
 | 
| 232 | 
  | 
  //fill Hmat | 
| 233 | 
  | 
  hmat(0, 0)= nx * latticeConstant; | 
| 257 | 
  | 
  /* Randomize position vector */ | 
| 258 | 
  | 
  std::random_shuffle(latticeSites.begin(), latticeSites.end()); | 
| 259 | 
  | 
 | 
| 270 | 
– | 
 | 
| 260 | 
  | 
  if (oldInfo != NULL) | 
| 261 | 
  | 
    delete oldInfo; | 
| 262 | 
< | 
   | 
| 274 | 
< | 
   | 
| 262 | 
> | 
 | 
| 263 | 
  | 
  // We need to read in new siminfo object.      | 
| 264 | 
< | 
  //parse md file and set up the system | 
| 265 | 
< | 
  //SimCreator NewCreator; | 
| 264 | 
> | 
  // parse md file and set up the system | 
| 265 | 
> | 
 | 
| 266 | 
  | 
  SimCreator newCreator; | 
| 267 | 
< | 
  SimInfo* NewInfo = newCreator.createSim(outMdFileName, false); | 
| 267 | 
> | 
  SimInfo* newInfo = newCreator.createSim(outMdFileName, false); | 
| 268 | 
  | 
   | 
| 269 | 
  | 
  /* create Molocators */ | 
| 270 | 
< | 
  locator = new MoLocator(NewInfo->getMoleculeStamp(0), NewInfo->getForceField()); | 
| 270 | 
> | 
  locator = new MoLocator(newInfo->getMoleculeStamp(0), newInfo->getForceField()); | 
| 271 | 
  | 
   | 
| 272 | 
  | 
   | 
| 273 | 
  | 
   | 
| 274 | 
  | 
  Molecule* mol; | 
| 275 | 
  | 
  SimInfo::MoleculeIterator mi; | 
| 276 | 
< | 
  mol = NewInfo->beginMolecule(mi); | 
| 276 | 
> | 
  mol = newInfo->beginMolecule(mi); | 
| 277 | 
  | 
  int l = 0; | 
| 278 | 
< | 
  for (mol = NewInfo->beginMolecule(mi); mol != NULL; mol = NewInfo->nextMolecule(mi)) { | 
| 278 | 
> | 
  for (mol = newInfo->beginMolecule(mi); mol != NULL; mol = newInfo->nextMolecule(mi)) { | 
| 279 | 
  | 
    locator->placeMol(latticeSites[l], latticeOrt[l], mol); | 
| 280 | 
  | 
    l++; | 
| 281 | 
  | 
  } | 
| 282 | 
  | 
 | 
| 295 | 
– | 
 | 
| 296 | 
– | 
 | 
| 283 | 
  | 
  //create dumpwriter and write out the coordinates | 
| 284 | 
< | 
  oldInfo->setFinalConfigFileName(outInitFileName); | 
| 285 | 
< | 
  writer = new DumpWriter(oldInfo); | 
| 284 | 
> | 
  newInfo->setFinalConfigFileName(outMdFileName); | 
| 285 | 
> | 
  writer = new DumpWriter(newInfo); | 
| 286 | 
  | 
 | 
| 287 | 
  | 
  if (writer == NULL) { | 
| 288 | 
  | 
    std::cerr << "error in creating DumpWriter" << std::endl; | 
| 289 | 
  | 
    exit(1); | 
| 290 | 
  | 
  } | 
| 291 | 
  | 
 | 
| 292 | 
< | 
  writer->writeDump(); | 
| 293 | 
< | 
  std::cout << "new initial configuration file: " << outInitFileName | 
| 294 | 
< | 
            << " is generated." << std::endl; | 
| 309 | 
< | 
 | 
| 310 | 
< | 
  //delete objects | 
| 311 | 
< | 
 | 
| 312 | 
< | 
  //delete oldInfo and oldSimSetup | 
| 313 | 
< | 
  if (oldInfo != NULL) | 
| 314 | 
< | 
    delete oldInfo; | 
| 315 | 
< | 
 | 
| 316 | 
< | 
  if (writer != NULL) | 
| 317 | 
< | 
    delete writer; | 
| 318 | 
< | 
     | 
| 319 | 
< | 
  delete simpleLat; | 
| 320 | 
< | 
 | 
| 292 | 
> | 
  writer->writeEor(); | 
| 293 | 
> | 
  std::cout << "new OOPSE MD file: " << outMdFileName | 
| 294 | 
> | 
            << " has been generated." << std::endl; | 
| 295 | 
  | 
  return 0; | 
| 296 | 
  | 
} | 
| 297 | 
  | 
 |