| 35 |
|
* |
| 36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
< |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
| 38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
| 39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
| 41 |
|
*/ |
| 42 |
|
|
| 43 |
|
#include <cstdlib> |
| 72 |
|
|
| 73 |
|
int main(int argc, char *argv []) { |
| 74 |
|
|
| 74 |
– |
//register force fields |
| 75 |
– |
registerForceFields(); |
| 75 |
|
registerLattice(); |
| 76 |
|
|
| 77 |
|
gengetopt_args_info args_info; |
| 78 |
|
std::string latticeType; |
| 79 |
|
std::string inputFileName; |
| 80 |
|
std::string outputFileName; |
| 82 |
– |
|
| 81 |
|
MoLocator* locator; |
| 82 |
|
int nComponents; |
| 83 |
|
double latticeConstant; |
| 86 |
– |
std::vector<double> lc; |
| 87 |
– |
|
| 84 |
|
RealType particleRadius; |
| 89 |
– |
|
| 85 |
|
Mat3x3d hmat; |
| 91 |
– |
std::vector<Vector3d> latticePos; |
| 92 |
– |
std::vector<Vector3d> latticeOrt; |
| 93 |
– |
|
| 86 |
|
DumpWriter *writer; |
| 87 |
|
|
| 88 |
|
// Parse Command Line Arguments |
| 118 |
|
/* Build a lattice and get lattice points for this lattice constant */ |
| 119 |
|
vector<Vector3d> sites = nanoParticle.getSites(); |
| 120 |
|
vector<Vector3d> orientations = nanoParticle.getOrientations(); |
| 121 |
+ |
|
| 122 |
+ |
|
| 123 |
|
std::vector<int> vacancyTargets; |
| 124 |
|
vector<bool> isVacancy; |
| 125 |
|
|
| 126 |
|
Vector3d myLoc; |
| 127 |
|
RealType myR; |
| 128 |
|
|
| 129 |
< |
for (int i = 0; i < sites.size(); i++) |
| 129 |
> |
for (unsigned int i = 0; i < sites.size(); i++) |
| 130 |
|
isVacancy.push_back(false); |
| 131 |
|
|
| 132 |
|
if (args_info.vacancyPercent_given) { |
| 150 |
|
} |
| 151 |
|
if (vIR >= 0.0 && vOR <= particleRadius && vOR >= vIR) { |
| 152 |
|
|
| 153 |
< |
for (int i = 0; i < sites.size(); i++) { |
| 153 |
> |
for (unsigned int i = 0; i < sites.size(); i++) { |
| 154 |
|
myLoc = sites[i]; |
| 155 |
|
myR = myLoc.length(); |
| 156 |
|
if (myR >= vIR && myR <= vOR) { |
| 167 |
|
"\tsites between %lf and %lf.", (int) vacancyTargets.size(), |
| 168 |
|
vIR, vOR); |
| 169 |
|
painCave.isFatal = 0; |
| 170 |
+ |
painCave.severity = OPENMD_INFO; |
| 171 |
|
simError(); |
| 172 |
|
|
| 173 |
|
isVacancy.clear(); |
| 174 |
< |
for (int i = 0; i < sites.size(); i++) { |
| 174 |
> |
for (unsigned int i = 0; i < sites.size(); i++) { |
| 175 |
|
bool vac = false; |
| 176 |
< |
for (int j = 0; j < vacancyTargets.size(); j++) { |
| 176 |
> |
for (unsigned int j = 0; j < vacancyTargets.size(); j++) { |
| 177 |
|
if (i == vacancyTargets[j]) vac = true; |
| 178 |
|
} |
| 179 |
|
isVacancy.push_back(vac); |
| 194 |
|
std::vector<Component*> components = simParams->getComponents(); |
| 195 |
|
std::vector<RealType> molFractions; |
| 196 |
|
std::vector<RealType> shellRadii; |
| 202 |
– |
std::vector<RealType> molecularMasses; |
| 197 |
|
std::vector<int> nMol; |
| 198 |
|
std::map<int, int> componentFromSite; |
| 199 |
|
nComponents = components.size(); |
| 298 |
|
} |
| 299 |
|
} else { |
| 300 |
|
|
| 301 |
< |
for (int i = 0; i < shellRadii.size(); i++) { |
| 301 |
> |
for (unsigned int i = 0; i < shellRadii.size(); i++) { |
| 302 |
|
if (shellRadii.at(i) > particleRadius + 1e-6 ) { |
| 303 |
|
sprintf(painCave.errMsg, "One of the shellRadius values exceeds the particle Radius."); |
| 304 |
|
painCave.isFatal = 1; |
| 316 |
|
if ((int)args_info.molFraction_given){ |
| 317 |
|
sprintf(painCave.errMsg, "Creating a randomized spherical nanoparticle."); |
| 318 |
|
painCave.isFatal = 0; |
| 319 |
+ |
painCave.severity = OPENMD_INFO; |
| 320 |
|
simError(); |
| 321 |
|
/* Random particle is the default case*/ |
| 322 |
|
|
| 323 |
< |
for (int i = 0; i < sites.size(); i++) |
| 323 |
> |
for (unsigned int i = 0; i < sites.size(); i++) |
| 324 |
|
if (!isVacancy[i]) ids.push_back(i); |
| 325 |
|
|
| 326 |
|
std::random_shuffle(ids.begin(), ids.end()); |
| 328 |
|
} else{ |
| 329 |
|
sprintf(painCave.errMsg, "Creating a core-shell spherical nanoparticle."); |
| 330 |
|
painCave.isFatal = 0; |
| 331 |
+ |
painCave.severity = OPENMD_INFO; |
| 332 |
|
simError(); |
| 333 |
|
|
| 334 |
|
RealType smallestSoFar; |
| 336 |
|
nMol.clear(); |
| 337 |
|
nMol.resize(nComponents); |
| 338 |
|
|
| 339 |
< |
for (int i = 0; i < sites.size(); i++) { |
| 339 |
> |
for (unsigned int i = 0; i < sites.size(); i++) { |
| 340 |
|
myLoc = sites[i]; |
| 341 |
|
myR = myLoc.length(); |
| 342 |
|
smallestSoFar = particleRadius; |
| 360 |
|
//creat new .md file on fly which corrects the number of molecule |
| 361 |
|
createMdFile(inputFileName, outputFileName, nMol); |
| 362 |
|
|
| 363 |
< |
if (oldInfo != NULL) |
| 368 |
< |
delete oldInfo; |
| 363 |
> |
delete oldInfo; |
| 364 |
|
|
| 365 |
|
SimCreator newCreator; |
| 366 |
|
SimInfo* NewInfo = newCreator.createSim(outputFileName, false); |
| 371 |
|
mol = NewInfo->beginMolecule(mi); |
| 372 |
|
|
| 373 |
|
int l = 0; |
| 379 |
– |
int whichSite = 0; |
| 374 |
|
|
| 375 |
|
for (int i = 0; i < nComponents; i++){ |
| 376 |
|
locator = new MoLocator(NewInfo->getMoleculeStamp(i), |
| 377 |
|
NewInfo->getForceField()); |
| 378 |
|
|
| 379 |
|
if (!args_info.molFraction_given) { |
| 380 |
< |
for (int n = 0; n < sites.size(); n++) { |
| 380 |
> |
for (unsigned int n = 0; n < sites.size(); n++) { |
| 381 |
|
if (!isVacancy[n]) { |
| 382 |
|
if (componentFromSite[n] == i) { |
| 383 |
|
mol = NewInfo->getMoleculeByGlobalIndex(l); |
| 431 |
|
sprintf(painCave.errMsg, "A new OpenMD file called \"%s\" has been " |
| 432 |
|
"generated.\n", outputFileName.c_str()); |
| 433 |
|
painCave.isFatal = 0; |
| 434 |
+ |
painCave.severity = OPENMD_INFO; |
| 435 |
|
simError(); |
| 436 |
|
return 0; |
| 437 |
|
} |
| 449 |
|
newMdFile.open(newMdFileName.c_str()); |
| 450 |
|
oldMdFile.getline(buffer, MAXLEN); |
| 451 |
|
|
| 452 |
< |
int i = 0; |
| 452 |
> |
unsigned int i = 0; |
| 453 |
|
while (!oldMdFile.eof()) { |
| 454 |
|
|
| 455 |
|
//correct molecule number |