ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/randomBuilder/randomBuilder.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/applications/randomBuilder/randomBuilder.cpp (file contents):
Revision 2738 by chuckv, Tue Apr 25 22:59:27 2006 UTC vs.
Revision 3035 by gezelter, Mon Oct 9 22:16:44 2006 UTC

# Line 42 | Line 42
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.1 2006-04-25 22:59:27 chuckv Exp $
45 > *  @version $Id: randomBuilder.cpp,v 1.3 2006-10-09 22:16:44 gezelter Exp $
46   *
47   */
48  
# Line 86 | Line 86 | int main(int argc, char *argv []) {
86    std::string inputFileName;
87    std::string outPrefix;
88    std::string outMdFileName;
89  std::string outInitFileName;
89    Lattice *simpleLat;
90    int* numMol;
91 <  double latticeConstant;
92 <  std::vector<double> lc;
93 <  double mass;
94 <  const double rhoConvertConst = 1.661;
95 <  double density;
91 >  RealType latticeConstant;
92 >  std::vector<RealType> lc;
93 >  RealType mass;
94 >  const RealType rhoConvertConst = 1.661;
95 >  RealType density;
96    int nx,
97      ny,
98      nz;
# Line 160 | Line 159 | int main(int argc, char *argv []) {
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);
# Line 182 | Line 181 | int main(int argc, char *argv []) {
181  
182    //calculate lattice constant (in Angstrom)
183    latticeConstant = pow(rhoConvertConst * numMolPerCell * mass / density,
184 <                        1.0 / 3.0);
184 >                        (RealType)(1.0 / 3.0));
185  
186    //set lattice constant
187    lc.push_back(latticeConstant);
# Line 217 | Line 216 | int main(int argc, char *argv []) {
216    }
217    int totComponents = 0;
218    for (int i = 0;i<nComponents-1;i++){ /* Figure out Percent for each component */
219 <    numMol[i] = int((double)numSites * args_info.molFraction_arg[i]);
219 >    numMol[i] = int((RealType)numSites * args_info.molFraction_arg[i]);
220      std::cout<<numMol[i]<<std::endl;
221      totComponents += numMol[i];
222    }
# Line 228 | Line 227 | int main(int argc, char *argv []) {
227    outMdFileName = outPrefix + ".md";
228  
229    //creat new .md file on fly which corrects the number of molecule    
230 <  createMdFile(inputFileName, outMdFileName, nComponents,numMol);
230 >  createMdFile(inputFileName, outMdFileName, nComponents, numMol);
231  
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  }
241
232    //fill Hmat
233    hmat(0, 0)= nx * latticeConstant;
234    hmat(0, 1) = 0.0;
# Line 267 | Line 257 | int main(int argc, char *argv []) {
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines