--- trunk/SHAPES/GridBuilder.cpp 2004/06/18 19:01:40 1279 +++ trunk/SHAPES/GridBuilder.cpp 2004/06/21 15:10:29 1282 @@ -4,142 +4,248 @@ GridBuilder::GridBuilder(RigidBody* rb, int bandWidth) GridBuilder::GridBuilder(RigidBody* rb, int bandWidth) { - rbMol = rb; - bandwidth = bandWidth; - thetaStep = PI / bandwidth; - thetaMin = thetaStep / 2.0; - phiStep = thetaStep * 2.0; + rbMol = rb; + bandwidth = bandWidth; + thetaStep = PI / bandwidth; + thetaMin = thetaStep / 2.0; + phiStep = thetaStep * 2.0; - //zero out the rot mats - for (i=0; i<3; i++) { - for (j=0; j<3; j++) { - rotX[i][j] = 0.0; - rotZ[i][j] = 0.0; - rbMatrix[i][j] = 0.0; - } - } + //zero out the rot mats + for (i=0; i<3; i++) { + for (j=0; j<3; j++) { + rotX[i][j] = 0.0; + rotZ[i][j] = 0.0; + rbMatrix[i][j] = 0.0; + } + } } GridBuilder::~GridBuilder() { } void GridBuilder::launchProbe(int forceField, vector sigmaGrid, vector sGrid, - vector epsGrid){ - double startDist; - double minDist = 10.0; //minimum start distance + vector epsGrid){ + ofstream sigmaOut("sigma.grid"); + ofstream sOut("s.grid"); + ofstream epsOut("eps.grid"); + double startDist; + double phiVal; + double thetaVal; + double minDist = 10.0; //minimum start distance - //first determine the start distance - we always start at least minDist away - startDist = rbMol->findMaxExtent() + minDist; - if (startDist < minDist) - startDist = minDist; - - initBody(); - for (i=0; ifindMaxExtent() + minDist; + if (startDist < minDist) + startDist = minDist; - sigmaGrid.push_back(sigDist); - sGrid.push_back(sDist); - epsGrid.push_back(epsVal); - - stepPhi(phiStep); - } - stepTheta(thetaStep); - } - -} + //set the initial orientation of the body and loop over theta values + phiVal = 0.0; + thetaVal = thetaMin; + rotBody(phiVal, thetaVal); + for (k=0; kgetNumAtoms(); i++){ + rbMol->getAtomPos(rbAtomPos, i); + + rXij = rbAtomPos[0]; + rYij = rbAtomPos[1]; + rZij = rbAtomPos[2] - probeCoor; + + rijSquared = rXij * rXij + rYij * rYij + rZij * rZij; + + //in the interest of keeping the code more compact, we are being less efficient by placing + //a switch statement in the calculation loop + switch(forcefield){ + case 1:{ + //we are using the CHARMm force field + atomRpar = rbMol->getAtomRpar(i); + atomEps = rbMol->getAtomEps(i); + + rValSquared = ((rparHe+atomRpar)*(rparHe+atomRpar)) / (rijSquared); + rValPowerSix = rValSquared * rValSquared * rValSquared; + potEnergy += sqrt(epsHe*atomEps)*(rValPowerSix * (rValPowerSix - 2.0)); + }; break; + + case 2:{ + //we are using the AMBER force field + atomRpar = rbMol->getAtomRpar(i); + atomEps = rbMol->getAtomEps(i); + + rValSquared = ((rparHe+atomRpar)*(rparHe+atomRpar)) / (rijSquared); + rValPowerSix = rValSquared * rValSquared * rValSquared; + potEnergy += sqrt(epsHe*atomEps)*(rValPowerSix * (rValPowerSix - 2.0)); + }; break; + + case 3:{ + //we are using Allen-Tildesley LJ parameters + atomRpar = rbMol->getAtomRpar(i); + atomEps = rbMol->getAtomEps(i); + + rValSquared = ((rparHe+atomRpar)*(rparHe+atomRpar)) / (4*rijSquared); + rValPowerSix = rValSquared * rValSquared * rValSquared; + potEnergy += 4*sqrt(epsHe*atomEps)*(rValPowerSix * (rValPowerSix - 1.0)); + + }; break; + + case 4:{ + //we are using the OPLS force field + atomRpar = rbMol->getAtomRpar(i); + atomEps = rbMol->getAtomEps(i); + + rValSquared = (pow(sqrt(rparHe+atomRpar),2)) / (rijSquared); + rValPowerSix = rValSquared * rValSquared * rValSquared; + potEnergy += 4*sqrt(epsHe*atomEps)*(rValPowerSix * (rValPowerSix - 1.0)); + }; break; + + case 5:{ + //we are using the GAFF force field + atomRpar = rbMol->getAtomRpar(i); + atomEps = rbMol->getAtomEps(i); + + rValSquared = ((rparHe+atomRpar)*(rparHe+atomRpar)) / (rijSquared); + rValPowerSix = rValSquared * rValSquared * rValSquared; + potEnergy += sqrt(epsHe*atomEps)*(rValPowerSix * (rValPowerSix - 2.0)); + }; break; + } + } +} -void GridBuilder::stepTheta(double increment){ - //zero out the euler angles - for (i=0; i<3; i++) - angles[i] = 0.0; +void GridBuilder::rotBody(double pValue, double tValue){ + //zero out the euler angles + for (l=0; l<3; l++) + angles[i] = 0.0; - //the second euler angle is for rotation about the x-axis (we use the zxz convention) - angles[1] = increment; + //the phi euler angle is for rotation about the z-axis (we use the zxz convention) + angles[0] = pValue; + //the second euler angle is for rotation about the x-axis (we use the zxz convention) + angles[1] = tValue; - //obtain the rotation matrix through the rigid body class - rbMol->doEulerToRotMat(angles, rotX); - - //rotate the rigid body - rbMol->getA(rbMatrix); - matMul3(rotX, rbMatrix, rotatedMat); - rbMol->setA(rotatedMat); - + //obtain the rotation matrix through the rigid body class + rbMol->doEulerToRotMat(angles, rotX); + + //start from the reference position + identityMat3(rbMatrix); + rbMol->setA(rbMatrix); + + //rotate the rigid body + matMul3(rotX, rbMatrix, rotatedMat); + rbMol->setA(rotatedMat); } -void GridBuilder::stepPhi(double increment){ - //zero out the euler angles - for (i=0; i<3; i++) - angles[i] = 0.0; - - //the phi euler angle is for rotation about the z-axis (we use the zxz convention) - angles[0] = increment; - - //obtain the rotation matrix through the rigid body class - rbMol->doEulerToRotMat(angles, rotZ); - - //rotate the rigid body - rbMol->getA(rbMatrix); - matMul3(rotZ, rbMatrix, rotatedMat); - rbMol->setA(rotatedMat); - -} +void GridBuilder::printGridFiles(){ + ofstream sigmaOut("sigma.grid"); + ofstream sOut("s.grid"); + ofstream epsOut("eps.grid"); + + for (k=0; k