--- trunk/SHAPES/GridBuilder.cpp 2004/06/21 15:10:29 1282 +++ trunk/SHAPES/GridBuilder.cpp 2004/06/22 18:04:58 1285 @@ -3,66 +3,88 @@ GridBuilder::GridBuilder(RigidBody* rb, int bandWidth) #define PI 3.14159265359 -GridBuilder::GridBuilder(RigidBody* rb, int bandWidth) { +GridBuilder::GridBuilder(RigidBody* rb, int gridWidth) { rbMol = rb; - bandwidth = bandWidth; - thetaStep = PI / bandwidth; + gridwidth = gridWidth; + thetaStep = PI / gridwidth; 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; - } - } } GridBuilder::~GridBuilder() { } -void GridBuilder::launchProbe(int forceField, vector sigmaGrid, vector sGrid, - vector epsGrid){ +void GridBuilder::launchProbe(int forceField, vector sigmaGrid, + vector sGrid, vector epsGrid){ ofstream sigmaOut("sigma.grid"); ofstream sOut("s.grid"); ofstream epsOut("eps.grid"); double startDist; double phiVal; double thetaVal; + double sigTemp, sTemp, epsTemp, sigProbe; double minDist = 10.0; //minimum start distance sList = sGrid; sigList = sigmaGrid; epsList = epsGrid; forcefield = forceField; + + //load the probe atom parameters + switch(forcefield){ + case 1:{ + rparHe = 1.4800; + epsHe = -0.021270; + }; break; + case 2:{ + rparHe = 1.14; + epsHe = 0.0203; + }; break; + case 3:{ + rparHe = 2.28; + epsHe = 0.020269601874; + }; break; + case 4:{ + rparHe = 2.5560; + epsHe = 0.0200; + }; break; + case 5:{ + rparHe = 1.14; + epsHe = 0.0203; + }; break; + } - //first determine the start distance - we always start at least minDist away + if (rparHe < 2.2) + sigProbe = 2*rparHe/1.12246204831; + else + sigProbe = rparHe; + + //determine the start distance - we always start at least minDist away startDist = rbMol->findMaxExtent() + minDist; if (startDist < minDist) startDist = minDist; //set the initial orientation of the body and loop over theta values - phiVal = 0.0; - thetaVal = thetaMin; - rotBody(phiVal, thetaVal); - for (k=0; ksetEuler(0.0, thetaVal, phiVal); + releaseProbe(startDist); - sigList.push_back(sigDist); - sList.push_back(sDist); - epsList.push_back(epsVal); + //translate the values to sigma, s, and epsilon of the rigid body + sigTemp = 2*sigDist - sigProbe; + sTemp = (2*(sDist - sigDist))/(0.122462048309) - sigProbe; + epsTemp = pow(epsVal, 2)/fabs(epsHe); - phiVal += phiStep; - rotBody(phiVal, thetaVal); + sigList.push_back(sigTemp); + sList.push_back(sTemp); + epsList.push_back(epsTemp); } - phiVal = 0.0; - thetaVal += thetaStep; - rotBody(phiVal, thetaVal); - printf("step theta %i\n",k); } } @@ -78,8 +100,7 @@ void GridBuilder::releaseProbe(double farPos){ tooClose = 0; epsVal = 0; rhoStep = 0.1; //the distance the probe atom moves between steps - - + while (!tooClose){ calcEnergy(); potProgress.push_back(potEnergy); @@ -120,36 +141,11 @@ void GridBuilder::calcEnergy(){ double rXij, rYij, rZij; double rijSquared; double rValSquared, rValPowerSix; - double rparHe, epsHe; double atomRpar, atomEps; double rbAtomPos[3]; - - //first get the probe atom parameters - switch(forcefield){ - case 1:{ - rparHe = 1.4800; - epsHe = -0.021270; - }; break; - case 2:{ - rparHe = 1.14; - epsHe = 0.0203; - }; break; - case 3:{ - rparHe = 2.28; - epsHe = 0.020269601874; - }; break; - case 4:{ - rparHe = 2.5560; - epsHe = 0.0200; - }; break; - case 5:{ - rparHe = 1.14; - epsHe = 0.0203; - }; break; - } - + potEnergy = 0.0; - + for(i=0; igetNumAtoms(); i++){ rbMol->getAtomPos(rbAtomPos, i); @@ -159,8 +155,8 @@ void GridBuilder::calcEnergy(){ 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 + //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 @@ -216,28 +212,6 @@ void GridBuilder::rotBody(double pValue, double tValue } } -void GridBuilder::rotBody(double pValue, double tValue){ - //zero out the euler angles - for (l=0; l<3; l++) - angles[i] = 0.0; - - //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); - - //start from the reference position - identityMat3(rbMatrix); - rbMol->setA(rbMatrix); - - //rotate the rigid body - matMul3(rotX, rbMatrix, rotatedMat); - rbMol->setA(rotatedMat); -} - void GridBuilder::printGridFiles(){ ofstream sigmaOut("sigma.grid"); ofstream sOut("s.grid"); @@ -248,4 +222,4 @@ void GridBuilder::printGridFiles(){ sOut << sList[k] << "\n0\n"; epsOut << epsList[k] << "\n0\n"; } -} \ No newline at end of file +}