| 29 |
|
string inputFileName; |
| 30 |
|
string outPrefix; |
| 31 |
|
string outMdFileName; |
| 32 |
+ |
string outInitFileName; |
| 33 |
|
SimInfo* oldInfo; |
| 34 |
|
SimSetup* oldSimSetup; |
| 35 |
|
BaseLattice* simpleLat; |
| 51 |
|
// parse command line arguments |
| 52 |
|
if (cmdline_parser (argc, argv, &args_info) != 0) |
| 53 |
|
exit(1) ; |
| 54 |
+ |
|
| 55 |
+ |
density = args_info.density_arg; |
| 56 |
|
|
| 54 |
– |
//process density |
| 55 |
– |
if(!args_info.density_given && !args_info.ndensity_given){ |
| 56 |
– |
cerr << "SimpleBuilder Error: density or number density must be given" << endl; |
| 57 |
– |
cmdline_parser_print_help(); |
| 58 |
– |
exit(1); |
| 59 |
– |
} |
| 60 |
– |
else if(args_info.density_given){ |
| 61 |
– |
if( args_info.ndensity_given) |
| 62 |
– |
cerr << "SimpleBuilder Warning: both of density and number density are given, use density" << endl; |
| 63 |
– |
|
| 64 |
– |
density = args_info.density_arg; |
| 65 |
– |
} |
| 66 |
– |
else if(args_info.ndensity_given){ |
| 67 |
– |
//convert number density to density |
| 68 |
– |
} |
| 69 |
– |
|
| 70 |
– |
|
| 57 |
|
//get lattice type |
| 58 |
|
latticeType = UpperCase(args_info.latticetype_arg); |
| 59 |
|
if(!LatticeFactory::getInstance()->hasLatticeCreator(latticeType)){ |
| 90 |
|
exit(1); |
| 91 |
|
} |
| 92 |
|
|
| 107 |
– |
//determine the output file names |
| 93 |
|
|
| 109 |
– |
if (args_info.output_given){ |
| 110 |
– |
outPrefix = args_info.output_arg; |
| 111 |
– |
} |
| 112 |
– |
else |
| 113 |
– |
outPrefix = getPrefix(inputFileName.c_str()) + "_" + latticeType; |
| 114 |
– |
|
| 115 |
– |
outMdFileName = outPrefix + ".md"; |
| 116 |
– |
|
| 94 |
|
//parse md file and set up the system |
| 95 |
|
oldInfo = new SimInfo; |
| 96 |
|
if(oldInfo == NULL){ |
| 138 |
|
numMol = nx * ny * nz * numMolPerCell; |
| 139 |
|
|
| 140 |
|
if (oldInfo->n_mol != numMol){ |
| 141 |
< |
//creat new .md file on fly which corrects the number of molecule |
| 141 |
> |
|
| 142 |
> |
outPrefix = getPrefix(inputFileName.c_str()) + "_" + latticeType; |
| 143 |
> |
outMdFileName = outPrefix + ".md"; |
| 144 |
> |
|
| 145 |
> |
//creat new .md file on fly which corrects the number of molecule |
| 146 |
|
createMdFile(inputFileName, outMdFileName, numMol); |
| 147 |
|
cerr << "SimpleBuilder Error: the number of molecule and the density are not matched" <<endl; |
| 148 |
|
cerr << "A new .md file: " << outMdFileName << " is generated, use it to rerun the simpleBuilder" << endl; |
| 149 |
|
exit(1); |
| 150 |
|
} |
| 151 |
< |
|
| 151 |
> |
|
| 152 |
> |
//determine the output file names |
| 153 |
> |
if (args_info.output_given) |
| 154 |
> |
outInitFileName = args_info.output_arg; |
| 155 |
> |
else |
| 156 |
> |
outInitFileName = getPrefix(inputFileName.c_str()) + ".in"; |
| 157 |
> |
|
| 158 |
> |
|
| 159 |
|
//allocat memory for storing pos, vel and etc |
| 160 |
|
oldInfo->getConfiguration()->createArrays(oldInfo->n_atoms); |
| 161 |
|
for (int i = 0; i < oldInfo->n_atoms; i++) |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
//create dumpwriter and write out the coordinates |
| 205 |
+ |
oldInfo->finalName = outInitFileName; |
| 206 |
|
writer = new DumpWriter( oldInfo ); |
| 207 |
|
if(writer == NULL){ |
| 208 |
|
cerr << "error in creating DumpWriter" << endl; |
| 209 |
|
exit(1); |
| 210 |
|
} |
| 211 |
|
writer->writeFinal(0); |
| 212 |
< |
|
| 212 |
> |
cout << "new initial configuration file: " << outInitFileName <<" is generated." << endl; |
| 213 |
|
//delete objects |
| 214 |
|
|
| 215 |
|
//delete oldInfo and oldSimSetup |