| 4 |
|
#include "simError.h" |
| 5 |
|
|
| 6 |
|
|
| 7 |
< |
Lattice::Lattice(int latticeType, double latticeSpacing){ |
| 7 |
> |
Lattice::Lattice(int latticeType, double latticeParameter){ |
| 8 |
|
int hasError; |
| 9 |
|
|
| 10 |
|
latticePosX = NULL; |
| 11 |
|
latticePosY = NULL; |
| 12 |
|
latticePosZ = NULL; |
| 13 |
|
|
| 14 |
+ |
startX = 0.0; |
| 15 |
+ |
startY = 0.0; |
| 16 |
+ |
startZ = 0.0; |
| 17 |
|
|
| 18 |
|
switch(latticeType){ |
| 19 |
|
|
| 20 |
|
case FCC_LATTICE_TYPE: |
| 21 |
< |
hasError = createFccLattice(latticeSpacing); |
| 21 |
> |
hasError = createFccLattice(latticeParameter); |
| 22 |
|
break; |
| 23 |
|
|
| 24 |
|
case BCC_LATTICE_TYPE: |
| 25 |
< |
hasError = createBccLattice(latticeSpacing); |
| 25 |
> |
hasError = createBccLattice(latticeParameter); |
| 26 |
|
break; |
| 27 |
|
|
| 28 |
|
case HCP_LATTICE_TYPE: |
| 29 |
< |
hasError = createHcpLattice(latticeSpacing); |
| 29 |
> |
hasError = createHcpLattice(latticeParameter); |
| 30 |
|
break; |
| 31 |
|
|
| 32 |
|
case HCPWATER_LATTICE_TYPE: |
| 33 |
< |
hasError = createHcpWaterLattice(latticeSpacing); |
| 33 |
> |
hasError = createHcpWaterLattice(latticeParameter); |
| 34 |
|
break; |
| 35 |
|
|
| 36 |
+ |
case ORTHORHOMBIC_LATTICE_TYPE: |
| 37 |
+ |
hasError = createFccLattice(latticeParameter); |
| 38 |
+ |
break; |
| 39 |
+ |
|
| 40 |
+ |
|
| 41 |
|
default: |
| 42 |
< |
//simerror here..... |
| 42 |
> |
//simerror here..... |
| 43 |
> |
; |
| 44 |
> |
} |
| 45 |
> |
|
| 46 |
> |
latticePosX = new double[nCellSites]; |
| 47 |
> |
latticePosY = new double[nCellSites]; |
| 48 |
> |
latticePosZ = new double[nCellSites]; |
| 49 |
> |
|
| 50 |
> |
return; |
| 51 |
> |
} |
| 52 |
|
|
| 53 |
< |
latticePosX = new double[nCellSites]; |
| 54 |
< |
latticePosY = new double[nCellSites]; |
| 55 |
< |
latticePosZ = new double[nCellSites]; |
| 53 |
> |
Lattice::Lattice(int latticeType, double latticeParameters[3]){ |
| 54 |
> |
int hasError; |
| 55 |
> |
|
| 56 |
> |
latticePosX = NULL; |
| 57 |
> |
latticePosY = NULL; |
| 58 |
> |
latticePosZ = NULL; |
| 59 |
> |
|
| 60 |
> |
startX = 0.0; |
| 61 |
> |
startY = 0.0; |
| 62 |
> |
startZ = 0.0; |
| 63 |
> |
|
| 64 |
> |
switch(latticeType){ |
| 65 |
> |
|
| 66 |
> |
case ORTHORHOMBIC_LATTICE_TYPE: |
| 67 |
> |
hasError = createOrthorhombicLattice(latticeParameters); |
| 68 |
> |
break; |
| 69 |
> |
|
| 70 |
> |
|
| 71 |
> |
default: |
| 72 |
> |
//simerror here..... |
| 73 |
> |
; |
| 74 |
|
} |
| 75 |
+ |
|
| 76 |
+ |
latticePosX = new double[nCellSites]; |
| 77 |
+ |
latticePosY = new double[nCellSites]; |
| 78 |
+ |
latticePosZ = new double[nCellSites]; |
| 79 |
+ |
|
| 80 |
|
return; |
| 81 |
|
} |
| 82 |
|
|
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
< |
int Lattice::createFccLattice(double latticeSpacing){ |
| 91 |
> |
int Lattice::createFccLattice(double latticeParameter){ |
| 92 |
|
double cell2; |
| 93 |
|
double rroot3; |
| 94 |
|
|
| 95 |
< |
cell2 = 0.5 * latticeSpacing; |
| 95 |
> |
cellLengthX = latticeParameter; |
| 96 |
> |
cellLengthY = latticeParameter; |
| 97 |
> |
cellLengthZ = latticeParameter; |
| 98 |
> |
|
| 99 |
> |
cell2 = 0.5 * latticeParameter; |
| 100 |
|
rroot3 = 1.0 / sqrt(3.0); |
| 101 |
|
|
| 102 |
|
nCellSites = 4; |
| 137 |
|
thisUnitCell.sx[3] = cell2; |
| 138 |
|
thisUnitCell.sy[3] = 0.0; |
| 139 |
|
thisUnitCell.sz[3] = cell2; |
| 140 |
+ |
thisUnitCell.s_ex[3] = -rroot3; |
| 141 |
+ |
thisUnitCell.s_ey[3] = -rroot3; |
| 142 |
+ |
thisUnitCell.s_ez[3] = rroot3; |
| 143 |
+ |
|
| 144 |
+ |
return 0; |
| 145 |
+ |
} |
| 146 |
+ |
|
| 147 |
+ |
|
| 148 |
+ |
int Lattice::createOrthorhombicLattice(double latticeParameters[3]){ |
| 149 |
+ |
double cellx2, celly2, cellz2; |
| 150 |
+ |
double rroot3; |
| 151 |
+ |
|
| 152 |
+ |
cellLengthX = latticeParameters[0]; |
| 153 |
+ |
cellLengthY = latticeParameters[1]; |
| 154 |
+ |
cellLengthZ = latticeParameters[2]; |
| 155 |
+ |
|
| 156 |
+ |
cellx2 = 0.5 * latticeParameters[0]; |
| 157 |
+ |
celly2 = 0.5 * latticeParameters[1]; |
| 158 |
+ |
cellz2 = 0.5 * latticeParameters[2]; |
| 159 |
+ |
rroot3 = 1.0 / sqrt(3.0); |
| 160 |
+ |
|
| 161 |
+ |
nCellSites = 4; |
| 162 |
+ |
// create new unit cells |
| 163 |
+ |
thisUnitCell.sx = new double[nCellSites]; |
| 164 |
+ |
thisUnitCell.sy = new double[nCellSites]; |
| 165 |
+ |
thisUnitCell.sz = new double[nCellSites]; |
| 166 |
+ |
thisUnitCell.s_ex = new double[nCellSites]; |
| 167 |
+ |
thisUnitCell.s_ey = new double[nCellSites]; |
| 168 |
+ |
thisUnitCell.s_ez = new double[nCellSites]; |
| 169 |
+ |
|
| 170 |
+ |
// add members to each unit cell |
| 171 |
+ |
// Molecule 1 |
| 172 |
+ |
thisUnitCell.sx[0] = 0.0; |
| 173 |
+ |
thisUnitCell.sy[0] = 0.0; |
| 174 |
+ |
thisUnitCell.sz[0] = 0.0; |
| 175 |
+ |
thisUnitCell.s_ex[0] = rroot3; |
| 176 |
+ |
thisUnitCell.s_ey[0] = rroot3; |
| 177 |
+ |
thisUnitCell.s_ez[0] = rroot3; |
| 178 |
+ |
|
| 179 |
+ |
// Molecule 2 |
| 180 |
+ |
thisUnitCell.sx[1] = 0.0; |
| 181 |
+ |
thisUnitCell.sy[1] = celly2; |
| 182 |
+ |
thisUnitCell.sz[1] = cellz2; |
| 183 |
+ |
thisUnitCell.s_ex[1] = -rroot3; |
| 184 |
+ |
thisUnitCell.s_ey[1] = rroot3; |
| 185 |
+ |
thisUnitCell.s_ez[1] = -rroot3; |
| 186 |
+ |
|
| 187 |
+ |
// Molecule 3 |
| 188 |
+ |
thisUnitCell.sx[2] = cellx2; |
| 189 |
+ |
thisUnitCell.sy[2] = celly2; |
| 190 |
+ |
thisUnitCell.sz[2] = 0.0; |
| 191 |
+ |
thisUnitCell.s_ex[2] = rroot3; |
| 192 |
+ |
thisUnitCell.s_ey[2] = -rroot3; |
| 193 |
+ |
thisUnitCell.s_ez[2] = -rroot3; |
| 194 |
+ |
|
| 195 |
+ |
// Molecule 4 |
| 196 |
+ |
thisUnitCell.sx[3] = cellx2; |
| 197 |
+ |
thisUnitCell.sy[3] = 0.0; |
| 198 |
+ |
thisUnitCell.sz[3] = cellz2; |
| 199 |
|
thisUnitCell.s_ex[3] = -rroot3; |
| 200 |
|
thisUnitCell.s_ey[3] = -rroot3; |
| 201 |
|
thisUnitCell.s_ez[3] = rroot3; |
| 205 |
|
|
| 206 |
|
|
| 207 |
|
// Body centered cubic lattice |
| 208 |
< |
int Lattice::createBccLattice(double latticeSpacing){ |
| 208 |
> |
int Lattice::createBccLattice(double latticeParameter){ |
| 209 |
|
return 0; |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
// Standard HCP lattice |
| 214 |
< |
int Lattice::createHcpLattice(double latticeSpacing){ |
| 214 |
> |
int Lattice::createHcpLattice(double latticeParameter){ |
| 215 |
|
return 0; |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
// HCP contains tetrahedral sites for waters |
| 219 |
< |
int Lattice::createHcpWaterLattice(double latticeSpacing){ |
| 219 |
> |
int Lattice::createHcpWaterLattice(double latticeParameter){ |
| 220 |
> |
|
| 221 |
> |
return 0; |
| 222 |
> |
|
| 223 |
|
double rroot3; |
| 224 |
|
double cell; |
| 225 |
|
double cell2; |
| 241 |
|
thisUnitCell.s_ez = new double[nCellSites]; |
| 242 |
|
|
| 243 |
|
rroot3 = 1.0 / sqrt(3.0); |
| 244 |
< |
cell = latticeSpacing; |
| 244 |
> |
cell = latticeParameter; |
| 245 |
|
cell2 = 0.5 * cell; |
| 246 |
|
cell4 = 0.25 * cell; |
| 247 |
|
cell16 = cell / 6.0; |
| 355 |
|
|
| 356 |
|
//Returns lattice points when called repeatedly |
| 357 |
|
int Lattice::getLatticePoints(double** thePosX, double** thePosY, |
| 358 |
< |
double** thePosZ, |
| 359 |
< |
int ix, int iy, int iz){ |
| 358 |
> |
double** thePosZ, |
| 359 |
> |
int ix, int iy, int iz){ |
| 360 |
|
|
| 361 |
|
int iref; |
| 362 |
|
|
| 363 |
|
for( iref=0;iref < nCellSites;iref++){ |
| 364 |
|
|
| 365 |
< |
latticePosX[iref] = thisUnitCell.sx[iref] + |
| 366 |
< |
cellLength * (double( ix ) - 0.5); |
| 367 |
< |
latticePosY[iref] = thisUnitCell.sy[iref] + |
| 368 |
< |
cellLength * (double( iy ) - 0.5); |
| 369 |
< |
latticePosZ[iref] = thisUnitCell.sz[iref] + |
| 370 |
< |
cellLength * (double( iz ) - 0.5); |
| 365 |
> |
latticePosX[iref] = startX + thisUnitCell.sx[iref] + |
| 366 |
> |
cellLengthX * (double( ix ) - 0.5); |
| 367 |
> |
latticePosY[iref] = startY + thisUnitCell.sy[iref] + |
| 368 |
> |
cellLengthY * (double( iy ) - 0.5); |
| 369 |
> |
latticePosZ[iref] = startZ + thisUnitCell.sz[iref] + |
| 370 |
> |
cellLengthZ * (double( iz ) - 0.5); |
| 371 |
|
|
| 372 |
|
} |
| 373 |
|
|