--- trunk/OOPSE/utils/sysbuilder/latticeBuilder.cpp 2003/08/18 20:59:47 700 +++ trunk/OOPSE/utils/sysbuilder/latticeBuilder.cpp 2003/10/24 17:36:18 817 @@ -11,6 +11,9 @@ Lattice::Lattice(int latticeType, double latticeParame latticePosY = NULL; latticePosZ = NULL; + startX = 0.0; + startY = 0.0; + startZ = 0.0; switch(latticeType){ @@ -30,6 +33,11 @@ Lattice::Lattice(int latticeType, double latticeParame hasError = createHcpWaterLattice(latticeParameter); break; + case ORTHORHOMBIC_LATTICE_TYPE: + hasError = createFccLattice(latticeParameter); + break; + + default: //simerror here..... ; @@ -42,7 +50,37 @@ Lattice::Lattice(int latticeType, double latticeParame return; } +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; +} + + Lattice::~Lattice(void){ if (latticePosX != NULL) delete[] latticePosX; if (latticePosY != NULL) delete[] latticePosY; @@ -54,7 +92,9 @@ Lattice::~Lattice(void){ double cell2; double rroot3; - cellLength = latticeParameter; + cellLengthX = latticeParameter; + cellLengthY = latticeParameter; + cellLengthZ = latticeParameter; cell2 = 0.5 * latticeParameter; rroot3 = 1.0 / sqrt(3.0); @@ -105,6 +145,65 @@ Lattice::~Lattice(void){ } + 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; + + return 0; + } + + // Body centered cubic lattice int Lattice::createBccLattice(double latticeParameter){ return 0; @@ -263,12 +362,12 @@ Lattice::~Lattice(void){ 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); }