| 78 |
|
gengetopt_args_info args_info; |
| 79 |
|
std::string latticeType; |
| 80 |
|
std::string inputFileName; |
| 81 |
– |
std::string outPrefix; |
| 81 |
|
std::string outputFileName; |
| 83 |
– |
std::string outInitFileName; |
| 82 |
|
|
| 85 |
– |
|
| 86 |
– |
|
| 83 |
|
Lattice *simpleLat; |
| 84 |
|
MoLocator* locator; |
| 85 |
|
int* numMol; |
| 87 |
|
double latticeConstant; |
| 88 |
|
std::vector<double> lc; |
| 89 |
|
double mass; |
| 94 |
– |
|
| 90 |
|
const double rhoConvertConst = 1.661; |
| 91 |
|
double density; |
| 92 |
|
double particleRadius; |
| 98 |
– |
|
| 99 |
– |
|
| 93 |
|
|
| 94 |
|
Mat3x3d hmat; |
| 95 |
|
std::vector<Vector3d> latticePos; |
| 97 |
|
int numMolPerCell; |
| 98 |
|
int nShells; /* Number of shells in nanoparticle*/ |
| 99 |
|
|
| 107 |
– |
|
| 100 |
|
DumpWriter *writer; |
| 101 |
|
|
| 102 |
|
// Parse Command Line Arguments |
| 103 |
|
if (cmdline_parser(argc, argv, &args_info) != 0) |
| 104 |
|
exit(1); |
| 105 |
< |
|
| 114 |
< |
|
| 115 |
< |
|
| 105 |
> |
|
| 106 |
|
/* get lattice type */ |
| 107 |
|
latticeType = "FCC"; |
| 108 |
|
|
| 121 |
|
SimCreator oldCreator; |
| 122 |
|
SimInfo* oldInfo = oldCreator.createSim(inputFileName, false); |
| 123 |
|
|
| 134 |
– |
|
| 124 |
|
latticeConstant = args_info.latticeCnst_arg; |
| 125 |
|
particleRadius = args_info.radius_arg; |
| 126 |
|
Globals* simParams = oldInfo->getSimParams(); |
| 127 |
|
|
| 139 |
– |
|
| 140 |
– |
/* create Molocators */ |
| 141 |
– |
locator = new MoLocator(oldInfo->getMoleculeStamp(0), oldInfo->getForceField()); |
| 142 |
– |
|
| 128 |
|
/* Create nanoparticle */ |
| 129 |
< |
shapedLatticeSpherical nanoParticle(latticeConstant,latticeType,particleRadius); |
| 129 |
> |
shapedLatticeSpherical nanoParticle(latticeConstant, latticeType, |
| 130 |
> |
particleRadius); |
| 131 |
|
|
| 132 |
|
/* Build a lattice and get lattice points for this lattice constant */ |
| 133 |
< |
vector<Vector3d> sites = nanoParticle.getPoints(); |
| 134 |
< |
vector<Vector3d> orientations = nanoParticle.getPointsOrt(); |
| 133 |
> |
vector<Vector3d> sites = nanoParticle.getSites(); |
| 134 |
> |
vector<Vector3d> orientations = nanoParticle.getOrientations(); |
| 135 |
|
|
| 136 |
|
std::cout <<"nSites: " << sites.size() << std::endl; |
| 137 |
|
|
| 138 |
|
/* Get number of lattice sites */ |
| 139 |
|
int nSites = sites.size(); |
| 154 |
– |
|
| 140 |
|
|
| 156 |
– |
|
| 157 |
– |
|
| 141 |
|
std::vector<Component*> components = simParams->getComponents(); |
| 142 |
|
std::vector<RealType> molFractions; |
| 143 |
|
std::vector<RealType> molecularMasses; |
| 144 |
|
std::vector<int> nMol; |
| 145 |
|
nComponents = components.size(); |
| 163 |
– |
|
| 146 |
|
|
| 165 |
– |
|
| 147 |
|
if (nComponents == 1) { |
| 148 |
|
molFractions.push_back(1.0); |
| 149 |
|
} else { |
| 150 |
< |
if (args_info.molFraction_given == nComponents) { |
| 151 |
< |
for (int i = 0; i < nComponents; i++) { |
| 152 |
< |
molFractions.push_back(args_info.molFraction_arg[i]); |
| 153 |
< |
} |
| 150 |
> |
if (args_info.molFraction_given == nComponents) { |
| 151 |
> |
for (int i = 0; i < nComponents; i++) { |
| 152 |
> |
molFractions.push_back(args_info.molFraction_arg[i]); |
| 153 |
> |
} |
| 154 |
|
} else if (args_info.molFraction_given == nComponents-1) { |
| 155 |
< |
RealType remainingFraction = 1.0; |
| 156 |
< |
for (int i = 0; i < nComponents-1; i++) { |
| 157 |
< |
molFractions.push_back(args_info.molFraction_arg[i]); |
| 158 |
< |
remainingFraction -= molFractions[i]; |
| 159 |
< |
} |
| 160 |
< |
molFractions.push_back(remainingFraction); |
| 161 |
< |
} else { |
| 162 |
< |
sprintf(painCave.errMsg, "nanoparticleBuilder can't figure out molFractions " |
| 163 |
< |
"for all of the components in the <MetaData> block."); |
| 164 |
< |
painCave.isFatal = 1; |
| 165 |
< |
simError(); |
| 166 |
< |
} |
| 167 |
< |
} |
| 168 |
< |
|
| 155 |
> |
RealType remainingFraction = 1.0; |
| 156 |
> |
for (int i = 0; i < nComponents-1; i++) { |
| 157 |
> |
molFractions.push_back(args_info.molFraction_arg[i]); |
| 158 |
> |
remainingFraction -= molFractions[i]; |
| 159 |
> |
} |
| 160 |
> |
molFractions.push_back(remainingFraction); |
| 161 |
> |
} else { |
| 162 |
> |
sprintf(painCave.errMsg, "nanoparticleBuilder can't figure out molFractions " |
| 163 |
> |
"for all of the components in the <MetaData> block."); |
| 164 |
> |
painCave.isFatal = 1; |
| 165 |
> |
simError(); |
| 166 |
> |
} |
| 167 |
> |
} |
| 168 |
> |
|
| 169 |
|
RealType totalFraction = 0.0; |
| 170 |
< |
|
| 170 |
> |
|
| 171 |
|
/* Do some simple sanity checking*/ |
| 172 |
|
|
| 192 |
– |
|
| 193 |
– |
|
| 173 |
|
for (int i = 0; i < nComponents; i++) { |
| 174 |
|
if (molFractions.at(i) < 0.0) { |
| 175 |
|
sprintf(painCave.errMsg, "One of the requested molFractions was" |
| 220 |
|
simError(); |
| 221 |
|
} |
| 222 |
|
|
| 244 |
– |
|
| 245 |
– |
|
| 246 |
– |
|
| 223 |
|
vector<int> ids; |
| 224 |
|
for (int i = 0; i < sites.size(); i++) ids.push_back(i); |
| 225 |
|
/* Random particle is the default case*/ |
| 293 |
|
|
| 294 |
|
|
| 295 |
|
//create dumpwriter and write out the coordinates |
| 296 |
< |
writer = new DumpWriter(NewInfo,outputFileName); |
| 296 |
> |
writer = new DumpWriter(NewInfo, outputFileName); |
| 297 |
|
|
| 298 |
|
if (writer == NULL) { |
| 299 |
|
sprintf(painCave.errMsg, "Error in creating dumpwrite object "); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
writer->writeDump(); |
| 329 |
– |
std::cout << "new initial configuration file: " << outInitFileName |
| 330 |
– |
<< " is generated." << std::endl; |
| 331 |
– |
|
| 305 |
|
|
| 306 |
|
// deleting the writer will put the closing at the end of the dump file |
| 307 |
+ |
|
| 308 |
|
delete writer; |
| 309 |
|
|
| 310 |
|
// cleanup a by calling sim error..... |