--- trunk/OOPSE/utils/sysbuilder/latticeBuilder.cpp 2003/08/11 22:12:31 678 +++ trunk/OOPSE/utils/sysbuilder/latticeBuilder.cpp 2003/10/24 17:36:18 817 @@ -4,39 +4,79 @@ #include "simError.h" -Lattice::Lattice(int latticeType, double latticeSpacing){ +Lattice::Lattice(int latticeType, double latticeParameter){ int hasError; latticePosX = NULL; latticePosY = NULL; latticePosZ = NULL; + startX = 0.0; + startY = 0.0; + startZ = 0.0; switch(latticeType){ case FCC_LATTICE_TYPE: - hasError = createFccLattice(latticeSpacing); + hasError = createFccLattice(latticeParameter); break; case BCC_LATTICE_TYPE: - hasError = createBccLattice(latticeSpacing); + hasError = createBccLattice(latticeParameter); break; case HCP_LATTICE_TYPE: - hasError = createHcpLattice(latticeSpacing); + hasError = createHcpLattice(latticeParameter); break; case HCPWATER_LATTICE_TYPE: - hasError = createHcpWaterLattice(latticeSpacing); + hasError = createHcpWaterLattice(latticeParameter); break; + case ORTHORHOMBIC_LATTICE_TYPE: + hasError = createFccLattice(latticeParameter); + break; + + default: - //simerror here..... + //simerror here..... + ; + } + + latticePosX = new double[nCellSites]; + latticePosY = new double[nCellSites]; + latticePosZ = new double[nCellSites]; + + return; +} - latticePosX = new double[nCellSites]; - latticePosY = new double[nCellSites]; - latticePosZ = new double[nCellSites]; +Lattice::Lattice(int latticeType, double latticeParameters[3]){ + int hasError; + + latticePosX = NULL; + latticePosY = NULL; + latticePosZ = NULL; + + startX = 0.0; + startY = 0.0; + startZ = 0.0; + + switch(latticeType){ + + case ORTHORHOMBIC_LATTICE_TYPE: + hasError = createOrthorhombicLattice(latticeParameters); + break; + + + default: + //simerror here..... + ; } + + latticePosX = new double[nCellSites]; + latticePosY = new double[nCellSites]; + latticePosZ = new double[nCellSites]; + return; } @@ -48,11 +88,15 @@ Lattice::~Lattice(void){ } - int Lattice::createFccLattice(double latticeSpacing){ + int Lattice::createFccLattice(double latticeParameter){ double cell2; double rroot3; - cell2 = 0.5 * latticeSpacing; + cellLengthX = latticeParameter; + cellLengthY = latticeParameter; + cellLengthZ = latticeParameter; + + cell2 = 0.5 * latticeParameter; rroot3 = 1.0 / sqrt(3.0); nCellSites = 4; @@ -93,6 +137,65 @@ Lattice::~Lattice(void){ thisUnitCell.sx[3] = cell2; thisUnitCell.sy[3] = 0.0; thisUnitCell.sz[3] = cell2; + thisUnitCell.s_ex[3] = -rroot3; + thisUnitCell.s_ey[3] = -rroot3; + thisUnitCell.s_ez[3] = rroot3; + + return 0; + } + + + int Lattice::createOrthorhombicLattice(double latticeParameters[3]){ + double cell2; + double rroot3; + + cellLengthX = latticeParameter[0]; + cellLengthY = latticeParameter[1]; + cellLengthZ = latticeParameter[2]; + + cellx2 = 0.5 * latticeParameter[0]; + cellx2 = 0.5 * latticeParameter[1]; + cellx2 = 0.5 * latticeParameter[2]; + rroot3 = 1.0 / sqrt(3.0); + + nCellSites = 4; + // create new unit cells + thisUnitCell.sx = new double[nCellSites]; + thisUnitCell.sy = new double[nCellSites]; + thisUnitCell.sz = new double[nCellSites]; + thisUnitCell.s_ex = new double[nCellSites]; + thisUnitCell.s_ey = new double[nCellSites]; + thisUnitCell.s_ez = new double[nCellSites]; + + // add members to each unit cell + // Molecule 1 + thisUnitCell.sx[0] = 0.0; + thisUnitCell.sy[0] = 0.0; + thisUnitCell.sz[0] = 0.0; + thisUnitCell.s_ex[0] = rroot3; + thisUnitCell.s_ey[0] = rroot3; + thisUnitCell.s_ez[0] = rroot3; + + // Molecule 2 + thisUnitCell.sx[1] = 0.0; + thisUnitCell.sy[1] = celly2; + thisUnitCell.sz[1] = cellz2; + thisUnitCell.s_ex[1] = -rroot3; + thisUnitCell.s_ey[1] = rroot3; + thisUnitCell.s_ez[1] = -rroot3; + + // Molecule 3 + thisUnitCell.sx[2] = cellx2; + thisUnitCell.sy[2] = celly2; + thisUnitCell.sz[2] = 0.0; + thisUnitCell.s_ex[2] = rroot3; + thisUnitCell.s_ey[2] = -rroot3; + thisUnitCell.s_ez[2] = -rroot3; + + // Molecule 4 + thisUnitCell.sx[3] = cellx2; + thisUnitCell.sy[3] = 0.0; + thisUnitCell.sz[3] = cellz2; thisUnitCell.s_ex[3] = -rroot3; thisUnitCell.s_ey[3] = -rroot3; thisUnitCell.s_ez[3] = rroot3; @@ -102,18 +205,21 @@ Lattice::~Lattice(void){ // Body centered cubic lattice - int Lattice::createBccLattice(double latticeSpacing){ + int Lattice::createBccLattice(double latticeParameter){ return 0; } // Standard HCP lattice - int Lattice::createHcpLattice(double latticeSpacing){ + int Lattice::createHcpLattice(double latticeParameter){ return 0; } // HCP contains tetrahedral sites for waters - int Lattice::createHcpWaterLattice(double latticeSpacing){ + int Lattice::createHcpWaterLattice(double latticeParameter){ + + return 0; + double rroot3; double cell; double cell2; @@ -135,7 +241,7 @@ Lattice::~Lattice(void){ thisUnitCell.s_ez = new double[nCellSites]; rroot3 = 1.0 / sqrt(3.0); - cell = latticeSpacing; + cell = latticeParameter; cell2 = 0.5 * cell; cell4 = 0.25 * cell; cell16 = cell / 6.0; @@ -249,19 +355,19 @@ Lattice::~Lattice(void){ //Returns lattice points when called repeatedly int Lattice::getLatticePoints(double** thePosX, double** thePosY, - double** thePosZ, - int ix, int iy, int iz){ + double** thePosZ, + int ix, int iy, int iz){ int iref; for( iref=0;iref < nCellSites;iref++){ - latticePosX[iref] = thisUnitCell.sx[iref] + - cellLength * (double( ix ) - 0.5); - latticePosY[iref] = thisUnitCell.sy[iref] + - cellLength * (double( iy ) - 0.5); - latticePosZ[iref] = thisUnitCell.sz[iref] + - cellLength * (double( iz ) - 0.5); + latticePosX[iref] = startX + thisUnitCell.sx[iref] + + cellLengthX * (double( ix ) - 0.5); + latticePosY[iref] = startY + thisUnitCell.sy[iref] + + cellLengthY * (double( iy ) - 0.5); + latticePosZ[iref] = startZ + thisUnitCell.sz[iref] + + cellLengthZ * (double( iz ) - 0.5); }