54 |
|
#ifdef HAVE_CGAL |
55 |
|
#include "GeometryBuilder.hpp" |
56 |
|
#endif |
57 |
+ |
#include "GeometryFactory.hpp" |
58 |
+ |
#include "Geometry.hpp" |
59 |
|
#include "lattice/LatticeFactory.hpp" |
60 |
|
#include "utils/MoLocator.hpp" |
61 |
|
#include "lattice/Lattice.hpp" |
105 |
|
std::vector<Vector3d> latticePos; |
106 |
|
std::vector<Vector3d> latticeOrt; |
107 |
|
int numMolPerCell; |
106 |
– |
int curMolIndex; |
108 |
|
DumpWriter *writer; |
109 |
|
|
110 |
|
// parse command line arguments |
124 |
|
|
125 |
|
//get lattice type |
126 |
|
latticeType = UpperCase(args_info.latticetype_arg); |
127 |
< |
|
127 |
< |
|
128 |
< |
simpleLat = LatticeFactory::getInstance()->createLattice(latticeType); |
129 |
< |
if (simpleLat == NULL) { |
130 |
< |
sprintf(painCave.errMsg, "Lattice Factory can not create %s lattice\n", |
131 |
< |
latticeType.c_str()); |
132 |
< |
painCave.isFatal = 1; |
133 |
< |
simError(); |
134 |
< |
} |
135 |
< |
|
127 |
> |
|
128 |
|
//get input file name |
129 |
|
if (args_info.inputs_num) |
130 |
|
inputFileName = args_info.inputs[0]; |
177 |
|
else |
178 |
|
outInitFileName = getPrefix(inputFileName.c_str()) + ".in"; |
179 |
|
|
180 |
+ |
|
181 |
+ |
|
182 |
+ |
|
183 |
+ |
|
184 |
+ |
|
185 |
|
//creat Molocator |
186 |
|
locator = new MoLocator(oldInfo->getMoleculeStamp(0), oldInfo->getForceField()); |
187 |
|
|
201 |
|
|
202 |
|
// Create geometry for nanocrystal |
203 |
|
#ifdef HAVE_CGAL |
204 |
< |
GeometryBuilder myGeometry(rodLength,rodDiameter); |
204 |
> |
GeometryBuilder *myGeometry; |
205 |
> |
// GeometryBuilder myGeometry(rodLength,rodDiameter); |
206 |
> |
if (args_info.twinnedCrystal_flag){ |
207 |
> |
myGeometry = new GeometryBuilder(rodLength,rodDiameter); |
208 |
> |
} |
209 |
> |
else{ |
210 |
> |
myGeometry = new GeometryBuilder(rodLength,rodDiameter); |
211 |
> |
} |
212 |
> |
|
213 |
> |
if (args_info.genGeomview_given){ |
214 |
> |
if (args_info.genGeomview_flag){ |
215 |
> |
outGeomFileName = getPrefix(inputFileName.c_str()) + ".off"; |
216 |
> |
myGeometry->dumpGeometry(outGeomFileName); |
217 |
> |
} |
218 |
> |
} |
219 |
> |
|
220 |
|
#endif |
221 |
|
|
222 |
|
/* |
227 |
|
|
228 |
|
//place the molecules |
229 |
|
|
230 |
< |
curMolIndex = 0; |
230 |
> |
|
231 |
|
|
232 |
|
//get the orientation of the cell sites |
233 |
|
//for the same type of molecule in same lattice, it will not change |
234 |
|
latticeOrt = simpleLat->getLatticePointsOrt(); |
235 |
|
|
236 |
|
|
225 |
– |
/* |
226 |
– |
void BaseLattice::getLatticePointsPos(std::vector<Vector3d>& |
227 |
– |
latticePos, int nx, int ny, int nz){ |
228 |
– |
|
229 |
– |
latticePos.resize(nCellSites); |
230 |
– |
|
231 |
– |
for( int i=0;i < nCellSites;i++){ |
232 |
– |
|
233 |
– |
latticePos[i][0] = origin[0] + cellSitesPos[i][0] + cellLen[0] * (double(nx) - 0.5); |
234 |
– |
latticePos[i][1] = origin[1] + cellSitesPos[i][1] + cellLen[1] * (double(ny) - 0.5); |
235 |
– |
latticePos[i][2] = origin[2] + cellSitesPos[i][2] + cellLen[2] * (double(nz) - 0.5); |
236 |
– |
} |
237 |
– |
|
238 |
– |
*/ |
237 |
|
|
240 |
– |
|
241 |
– |
|
242 |
– |
|
238 |
|
numMol = 0; |
239 |
< |
for(int i = 0; i < nx; i++) { |
240 |
< |
for(int j = 0; j < ny; j++) { |
241 |
< |
for(int k = 0; k < nz; k++) { |
239 |
> |
for(int i = -nx; i < nx; i++) { |
240 |
> |
for(int j = -ny; j < ny; j++) { |
241 |
> |
for(int k = -nz; k < nz; k++) { |
242 |
|
//if (oldInfo->getNGlobalMolecules() != numMol) { |
243 |
|
|
244 |
|
|
249 |
|
for(int l = 0; l < numMolPerCell; l++) { |
250 |
|
|
251 |
|
#ifdef HAVE_CGAL |
252 |
< |
if (myGeometry.isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){ |
252 |
> |
if (myGeometry->isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){ |
253 |
|
numMol++; |
254 |
|
} |
255 |
+ |
#else |
256 |
+ |
numMol++; |
257 |
|
#endif |
258 |
|
} |
259 |
|
} |
260 |
|
} |
261 |
|
} |
262 |
+ |
|
263 |
|
|
266 |
– |
|
264 |
|
// needed for writing out new md file. |
265 |
|
|
266 |
|
outPrefix = getPrefix(inputFileName.c_str()) + "_" + latticeType; |
284 |
|
Molecule* mol; |
285 |
|
SimInfo::MoleculeIterator mi; |
286 |
|
mol = NewInfo->beginMolecule(mi); |
290 |
– |
|
291 |
– |
for(int i = 0; i < nx; i++) { |
292 |
– |
for(int j = 0; j < ny; j++) { |
293 |
– |
for(int k = 0; k < nz; k++) { |
294 |
– |
|
295 |
– |
//get the position of the cell sites |
296 |
– |
simpleLat->getLatticePointsPos(latticePos, i, j, k); |
297 |
– |
|
298 |
– |
for(int l = 0; l < numMolPerCell; l++) { |
299 |
– |
if (mol != NULL) { |
287 |
|
|
288 |
< |
#ifdef HAVE_GCAL |
289 |
< |
if (myGeometry.isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){ |
290 |
< |
locator->placeMol(latticePos[l], latticeOrt[l], mol); |
291 |
< |
} |
292 |
< |
#else |
293 |
< |
|
294 |
< |
locator->placeMol(latticePos[l], latticeOrt[l], mol); |
295 |
< |
#endif |
296 |
< |
} else { |
297 |
< |
std::cerr << std::endl; |
298 |
< |
} |
299 |
< |
mol = NewInfo->nextMolecule(mi); |
288 |
> |
|
289 |
> |
for(int i = -nx; i < nx; i++) { |
290 |
> |
for(int j = -ny; j < ny; j++) { |
291 |
> |
for(int k = -nz; k < nz; k++) { |
292 |
> |
|
293 |
> |
//get the position of the cell sites |
294 |
> |
simpleLat->getLatticePointsPos(latticePos, i, j, k); |
295 |
> |
|
296 |
> |
for(int l = 0; l < numMolPerCell; l++) { |
297 |
> |
#ifdef HAVE_CGAL |
298 |
> |
if (myGeometry->isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){ |
299 |
> |
#endif |
300 |
> |
if (mol != NULL) { |
301 |
> |
locator->placeMol(latticePos[l], latticeOrt[l], mol); |
302 |
> |
} else { |
303 |
> |
std::cerr<<"Error in placing molecule " << std::endl; |
304 |
> |
} |
305 |
> |
mol = NewInfo->nextMolecule(mi); |
306 |
> |
#ifdef HAVE_CGAL |
307 |
> |
} |
308 |
> |
#endif |
309 |
> |
} |
310 |
|
} |
311 |
< |
} |
315 |
< |
} |
311 |
> |
} |
312 |
|
} |
313 |
|
|
314 |
+ |
|
315 |
|
|
319 |
– |
|
316 |
|
//fill Hmat |
317 |
|
hmat(0, 0)= nx * latticeConstant; |
318 |
|
hmat(0, 1) = 0.0; |