| 7 |
|
#include <map> |
| 8 |
|
#include <fstream> |
| 9 |
|
|
| 10 |
– |
#include "simError.h" |
| 10 |
|
#include "Globals.hpp" |
| 11 |
|
#include "SimInfo.hpp" |
| 12 |
|
#include "SimSetup.hpp" |
| 13 |
< |
#include "simpleBuilderCmd.hpp" |
| 13 |
> |
#include "simpleBuilderCmd.h" |
| 14 |
|
#include "StringUtils.hpp" |
| 15 |
|
#include "LatticeFactory.hpp" |
| 16 |
|
#include "Vector3d.hpp" |
| 17 |
+ |
#include "MoLocator.hpp" |
| 18 |
+ |
#include "Lattice.hpp" |
| 19 |
|
|
| 20 |
|
using namespace std; |
| 21 |
|
|
| 22 |
+ |
void createMdFile(const string& oldMdFileName, const string& newMdFileName, int numMol); |
| 23 |
|
|
| 24 |
|
int main( int argc, char* argv[]){ |
| 25 |
|
|
| 36 |
|
BaseLattice* simpleLat; |
| 37 |
|
int numMol; |
| 38 |
|
double latticeConstant; |
| 39 |
< |
vector lc; |
| 39 |
> |
vector<double> lc; |
| 40 |
|
double mass; |
| 41 |
|
double density; |
| 42 |
|
int nx, ny, nz; |
| 61 |
|
latticeType = UpperCase(args_info.latticetype_arg); |
| 62 |
|
if(!LatticeFactory::getInstance()->hasLatticeCreator(latticeType)){ |
| 63 |
|
cerr << latticeType << " is an invalid lattice type" << endl; |
| 64 |
< |
cerr << LatticeFactory::getInstance()->oString << endl; |
| 64 |
> |
cerr << LatticeFactory::getInstance()->toString() << endl; |
| 65 |
|
exit(1); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
< |
nx = args_info.nx_args; |
| 68 |
> |
nx = args_info.nx_arg; |
| 69 |
|
if(nx <= 0){ |
| 70 |
|
cerr << "The number of unit cell in h direction must be greater than 0" << endl; |
| 71 |
|
exit(1); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
< |
nx = args_info.nx_args; |
| 75 |
< |
if(nx <= 0){ |
| 74 |
> |
ny = args_info.ny_arg; |
| 75 |
> |
if(ny <= 0){ |
| 76 |
|
cerr << "The number of unit cell in l direction must be greater than 0" << endl; |
| 77 |
|
exit(1); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
< |
nx = args_info.nx_args; |
| 81 |
< |
if(nx <= 0){ |
| 80 |
> |
nz = args_info.nz_arg; |
| 81 |
> |
if(nz <= 0){ |
| 82 |
|
cerr << "The number of unit cell in k direction must be greater than 0" << endl; |
| 83 |
|
exit(1); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
//get input file name |
| 87 |
< |
if (args_info.inputs_num) { |
| 87 |
> |
if (args_info.inputs_num) |
| 88 |
|
inputFileName = args_info.inputs[0]; |
| 87 |
– |
cerr << in_name << "\n"; } |
| 89 |
|
else { |
| 90 |
|
cerr <<"You must specify a input file name.\n" << endl; |
| 91 |
|
cmdline_parser_print_help(); |
| 110 |
|
exit(1); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
< |
oldSimSetup = new SimSetup(oldInfo); |
| 113 |
> |
oldSimSetup = new SimSetup(); |
| 114 |
|
if(oldSimSetup == NULL){ |
| 115 |
|
cerr << "error in creating SimSetup" << endl; |
| 116 |
|
exit(1); |
| 118 |
|
|
| 119 |
|
oldSimSetup->setSimInfo(oldInfo ); |
| 120 |
|
oldSimSetup->parseFile(&inputFileName[0] ); |
| 120 |
– |
oldSimSetup->createSim(); |
| 121 |
|
|
| 122 |
|
|
| 123 |
< |
if(oldInfo->nComponets >=2){ |
| 123 |
> |
if(oldInfo->nComponents >=2){ |
| 124 |
|
cerr << "can not build the system with more than two components" << endl; |
| 125 |
|
exit(1); |
| 126 |
|
} |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
< |
numMolPerCell = simpleLat->getNpoints(); |
| 136 |
> |
numMolPerCell = simpleLat->getNumSitesPerCell(); |
| 137 |
|
//calculate lattice constant |
| 138 |
|
latticeConstant = pow(numMolPerCell * mass /density, 1.0/3.0); |
| 139 |
|
|
| 167 |
|
exit(1); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
< |
newSimSetup = new SimSetup(newInfo); |
| 170 |
> |
newSimSetup = new SimSetup(); |
| 171 |
|
if(newSimSetup == NULL){ |
| 172 |
|
cerr << "error in creating SimSetup" << endl; |
| 173 |
|
exit(1); |
| 181 |
|
newInfo->setBoxM(Hmat); |
| 182 |
|
|
| 183 |
|
//allocat memory for storing pos, vel and etc |
| 184 |
< |
newInfo.getConfiguration()->createArrays(newInfo.n_atoms); |
| 185 |
< |
for (int i = 0; i < newInfo.n_atoms; i++) |
| 186 |
< |
newInfo.atoms[i]->setCoords(); |
| 184 |
> |
newInfo->getConfiguration()->createArrays(newInfo->n_atoms); |
| 185 |
> |
for (int i = 0; i < newInfo->n_atoms; i++) |
| 186 |
> |
newInfo->atoms[i]->setCoords(); |
| 187 |
|
|
| 188 |
|
//creat Molocator |
| 189 |
< |
locator = new MoLocator(newInfo->compStamps[0], newSimSetup->the_ff); |
| 189 |
> |
locator = new MoLocator(newInfo->compStamps[0], newSimSetup->getForceField()); |
| 190 |
|
|
| 191 |
|
//place the molecules |
| 192 |
|
|
| 204 |
|
simpleLat->getLatticePointsPos(latticePos, i, j, k); |
| 205 |
|
|
| 206 |
|
for(int l = 0; l < numMolPerCell; l++) |
| 207 |
< |
locator->placeMol(latticePos[l], latticeOrt[l], newInfo->molecules[curMolIndex++]); |
| 207 |
> |
locator->placeMol(latticePos[l], latticeOrt[l], &(newInfo->molecules[curMolIndex++])); |
| 208 |
|
} |
| 209 |
|
} |
| 210 |
|
} |
| 215 |
|
cerr << "error in creating DumpWriter" << endl; |
| 216 |
|
exit(1); |
| 217 |
|
} |
| 218 |
< |
writer->writeFinal(); |
| 218 |
> |
writer->writeFinal(0); |
| 219 |
|
|
| 220 |
|
|
| 221 |
|
//delete objects |
| 241 |
|
ofstream newMdFile; |
| 242 |
|
const int MAXLEN = 65535; |
| 243 |
|
char buffer[MAXLEN]; |
| 244 |
+ |
string line; |
| 245 |
|
|
| 245 |
– |
|
| 246 |
|
//create new .md file based on old .md file |
| 247 |
< |
oldMdFile.open(oldMdFileName.c_str()) |
| 248 |
< |
newMdFile.open(newMdFileName); |
| 247 |
> |
oldMdFile.open(oldMdFileName.c_str()); |
| 248 |
> |
newMdFile.open(newMdFileName.c_str()); |
| 249 |
|
|
| 250 |
|
oldMdFile.getline(buffer, MAXLEN); |
| 251 |
|
while(!oldMdFile.eof()){ |
| 252 |
|
|
| 253 |
< |
if(line.find("nMol") < line.size()) |
| 254 |
< |
sprintf(buffer, "nMol = %s;", numMol); |
| 253 |
> |
if(line.find("nMol") < line.size()){ |
| 254 |
> |
|
| 255 |
> |
sprintf(buffer, "\t\tnMol = %d;", numMol); |
| 256 |
> |
newMdFile << buffer << endl; |
| 257 |
> |
} |
| 258 |
|
else |
| 259 |
|
newMdFile << buffer << endl; |
| 260 |
|
|