| 1 | #include "Lattice.hpp" | 
| 2 | #include "LatticeFactory.hpp" | 
| 3 | #include "LatticeCreator.hpp" | 
| 4 |  | 
| 5 | static LatticeCreator<FCCLattice> *FCCLatticeCreator = new LatticeCreator<FCCLattice>(FCCLatticeType); | 
| 6 | //static LatticeCreator<FCCLattice> *BCCLatticeCreator = new LatticeCreator<FCCLattice>(BCCLatticeType); | 
| 7 | //static LatticeCreator<FCCLattice> *HCPLatticeCreator = new LatticeCreator<FCCLattice>(HCPCLatticeType); | 
| 8 | //static LatticeCreator<FCCLattice> *OrthorhombicLattice = new LatticeCreator<FCCLattice>(OrthorhombicLatticeType); | 
| 9 |  | 
| 10 | CubicLattice::CubicLattice(){ | 
| 11 | latticeParam = 1.0; | 
| 12 |  | 
| 13 | cellLen.x = latticeParam; | 
| 14 | cellLen.y = latticeParam; | 
| 15 | cellLen.z = latticeParam; | 
| 16 |  | 
| 17 | } | 
| 18 |  | 
| 19 | vector<double> CubicLattice::getLatticeConstant(){ | 
| 20 | vector<double> lc; | 
| 21 |  | 
| 22 | lc.push_back(cellLen.x); | 
| 23 | return lc; | 
| 24 | } | 
| 25 |  | 
| 26 | void CubicLattice::setLatticeConstant(const vector<double>& lc){ | 
| 27 |  | 
| 28 | if(lc.size() < 1){ | 
| 29 | cerr << "CubicLattice::setLatticeConstant Error: the size of lattice constant vector  is 0" << endl; | 
| 30 | exit(1); | 
| 31 | } | 
| 32 | else if (lc.size() > 1){ | 
| 33 | cerr << "CubicLattice::setLatticeConstant Warning: the size of lattice constant vector  is " << lc.size() << endl; | 
| 34 | } | 
| 35 |  | 
| 36 | latticeParam = lc[0]; | 
| 37 |  | 
| 38 | cellLen.x = latticeParam; | 
| 39 | cellLen.y = latticeParam; | 
| 40 | cellLen.z = latticeParam; | 
| 41 |  | 
| 42 | update(); | 
| 43 | } | 
| 44 |  | 
| 45 | FCCLattice::FCCLattice() : CubicLattice(){ | 
| 46 | nCellSites = 4; | 
| 47 | cellSitesPos.resize(nCellSites); | 
| 48 | cellSitesOrt.resize(nCellSites); | 
| 49 | update(); | 
| 50 |  | 
| 51 | } | 
| 52 |  | 
| 53 | void FCCLattice::update(){ | 
| 54 |  | 
| 55 | double cellLenOver2; | 
| 56 | double oneOverRoot3; | 
| 57 |  | 
| 58 | cellLenOver2  = 0.5 * latticeParam; | 
| 59 | oneOverRoot3 = 1.0 / sqrt(3.0); | 
| 60 |  | 
| 61 | // Molecule 1 | 
| 62 | cellSitesPos[0].x = 0.0; | 
| 63 | cellSitesPos[0].y = 0.0; | 
| 64 | cellSitesPos[0].z = 0.0; | 
| 65 |  | 
| 66 | cellSitesOrt[0].x = oneOverRoot3; | 
| 67 | cellSitesOrt[0].y = oneOverRoot3; | 
| 68 | cellSitesOrt[0].z = oneOverRoot3; | 
| 69 |  | 
| 70 | // Molecule 2 | 
| 71 | cellSitesPos[1].x   = 0.0; | 
| 72 | cellSitesPos[1].y   = cellLenOver2; | 
| 73 | cellSitesPos[1].z   = cellLenOver2; | 
| 74 |  | 
| 75 | cellSitesOrt[1].x = -oneOverRoot3; | 
| 76 | cellSitesOrt[1].y = oneOverRoot3; | 
| 77 | cellSitesOrt[1].z = -oneOverRoot3; | 
| 78 |  | 
| 79 | // Molecule 3 | 
| 80 | cellSitesPos[2].x   = cellLenOver2; | 
| 81 | cellSitesPos[2].y   = cellLenOver2; | 
| 82 | cellSitesPos[2].z   = 0.0; | 
| 83 |  | 
| 84 | cellSitesOrt[2].x = oneOverRoot3; | 
| 85 | cellSitesOrt[2].y = -oneOverRoot3; | 
| 86 | cellSitesOrt[2].z = -oneOverRoot3; | 
| 87 |  | 
| 88 | // Molecule 4 | 
| 89 |  | 
| 90 | cellSitesPos[3].x   = cellLenOver2; | 
| 91 | cellSitesPos[3].y   = 0.0; | 
| 92 | cellSitesPos[3].z   = cellLenOver2; | 
| 93 |  | 
| 94 | cellSitesOrt[3].x = -oneOverRoot3; | 
| 95 | cellSitesOrt[3].y = oneOverRoot3; | 
| 96 | cellSitesOrt[3].z = oneOverRoot3; | 
| 97 | } | 
| 98 |  |