1 |
|
#include "GridBuilder.hpp" |
2 |
– |
#include "MatVec3.h" |
2 |
|
#define PI 3.14159265359 |
3 |
|
|
4 |
|
|
5 |
< |
GridBuilder::GridBuilder(RigidBody* rb, int bandWidth) { |
5 |
> |
GridBuilder::GridBuilder(RigidBody* rb, int gridWidth) { |
6 |
|
rbMol = rb; |
7 |
< |
bandwidth = bandWidth; |
8 |
< |
thetaStep = PI / bandwidth; |
7 |
> |
gridwidth = gridWidth; |
8 |
> |
thetaStep = PI / gridwidth; |
9 |
|
thetaMin = thetaStep / 2.0; |
10 |
|
phiStep = thetaStep * 2.0; |
12 |
– |
|
13 |
– |
//zero out the rot mats |
14 |
– |
for (i=0; i<3; i++) { |
15 |
– |
for (j=0; j<3; j++) { |
16 |
– |
rotX[i][j] = 0.0; |
17 |
– |
rotZ[i][j] = 0.0; |
18 |
– |
rbMatrix[i][j] = 0.0; |
19 |
– |
} |
20 |
– |
} |
11 |
|
} |
12 |
|
|
13 |
|
GridBuilder::~GridBuilder() { |
14 |
|
} |
15 |
|
|
16 |
< |
void GridBuilder::launchProbe(int forceField, vector<double> sigmaGrid, vector<double> sGrid, |
17 |
< |
vector<double> epsGrid){ |
16 |
> |
void GridBuilder::launchProbe(int forceField, vector<double> sigmaGrid, |
17 |
> |
vector<double> sGrid, vector<double> epsGrid){ |
18 |
|
ofstream sigmaOut("sigma.grid"); |
19 |
|
ofstream sOut("s.grid"); |
20 |
|
ofstream epsOut("eps.grid"); |
21 |
|
double startDist; |
22 |
+ |
double phiVal; |
23 |
+ |
double thetaVal; |
24 |
+ |
double sigTemp, sTemp, epsTemp, sigProbe; |
25 |
|
double minDist = 10.0; //minimum start distance |
26 |
|
|
34 |
– |
sList = sGrid; |
27 |
|
sigList = sigmaGrid; |
28 |
+ |
sList = sGrid; |
29 |
|
epsList = epsGrid; |
30 |
|
forcefield = forceField; |
31 |
+ |
|
32 |
+ |
//load the probe atom parameters |
33 |
+ |
switch(forcefield){ |
34 |
+ |
case 1:{ |
35 |
+ |
rparHe = 1.4800; |
36 |
+ |
epsHe = -0.021270; |
37 |
+ |
}; break; |
38 |
+ |
case 2:{ |
39 |
+ |
rparHe = 1.14; |
40 |
+ |
epsHe = 0.0203; |
41 |
+ |
}; break; |
42 |
+ |
case 3:{ |
43 |
+ |
rparHe = 2.28; |
44 |
+ |
epsHe = 0.020269601874; |
45 |
+ |
}; break; |
46 |
+ |
case 4:{ |
47 |
+ |
rparHe = 2.5560; |
48 |
+ |
epsHe = 0.0200; |
49 |
+ |
}; break; |
50 |
+ |
case 5:{ |
51 |
+ |
rparHe = 1.14; |
52 |
+ |
epsHe = 0.0203; |
53 |
+ |
}; break; |
54 |
+ |
} |
55 |
|
|
56 |
< |
//first determine the start distance - we always start at least minDist away |
56 |
> |
if (rparHe < 2.2) |
57 |
> |
sigProbe = 2*rparHe/1.12246204831; |
58 |
> |
else |
59 |
> |
sigProbe = rparHe; |
60 |
> |
|
61 |
> |
//determine the start distance - we always start at least minDist away |
62 |
|
startDist = rbMol->findMaxExtent() + minDist; |
63 |
|
if (startDist < minDist) |
64 |
|
startDist = minDist; |
65 |
|
|
66 |
< |
initBody(); |
67 |
< |
for (k=0; k<bandwidth; k++){ |
68 |
< |
printf("step theta...\n"); |
69 |
< |
for (j=0; j<bandwidth; j++){ |
66 |
> |
//set the initial orientation of the body and loop over theta values |
67 |
> |
|
68 |
> |
for (k =0; k < gridwidth; k++) { |
69 |
> |
thetaVal = thetaMin + k*thetaStep; |
70 |
> |
for (j=0; j < gridwidth; j++) { |
71 |
> |
phiVal = j*phiStep + 0.5*PI; |
72 |
> |
|
73 |
> |
rbMol->setEuler(0.0, thetaVal, phiVal); |
74 |
> |
|
75 |
|
releaseProbe(startDist); |
76 |
|
|
77 |
< |
sigList.push_back(sigDist); |
78 |
< |
sList.push_back(sDist); |
79 |
< |
epsList.push_back(epsVal); |
80 |
< |
|
81 |
< |
stepPhi(phiStep); |
77 |
> |
//translate the values to sigma, s, and epsilon of the rigid body |
78 |
> |
sigTemp = 2*sigDist - sigProbe; |
79 |
> |
sTemp = (2*(sDist - sigDist))/(0.122462048309) - sigProbe; |
80 |
> |
epsTemp = pow(epsVal, 2)/fabs(epsHe); |
81 |
> |
|
82 |
> |
sigList.push_back(sigTemp); |
83 |
> |
sList.push_back(sTemp); |
84 |
> |
epsList.push_back(epsTemp); |
85 |
|
} |
56 |
– |
stepTheta(thetaStep); |
86 |
|
} |
58 |
– |
/* |
59 |
– |
//write out the grid files |
60 |
– |
printf("the grid size is %d\n",sigmaGrid.size()); |
61 |
– |
for (k=0; k<sigmaGrid.size(); k++){ |
62 |
– |
sigmaOut << sigmaGrid[k] << "\n0\n"; |
63 |
– |
sOut << sGrid[k] << "\n0\n"; |
64 |
– |
epsOut << epsGrid[k] << "\n0\n"; |
65 |
– |
} |
66 |
– |
*/ |
87 |
|
} |
88 |
|
|
69 |
– |
void GridBuilder::initBody(){ |
70 |
– |
//set up the rigid body in the starting configuration |
71 |
– |
stepTheta(thetaMin); |
72 |
– |
} |
73 |
– |
|
89 |
|
void GridBuilder::releaseProbe(double farPos){ |
90 |
|
int tooClose; |
91 |
|
double tempPotEnergy; |
98 |
|
tooClose = 0; |
99 |
|
epsVal = 0; |
100 |
|
rhoStep = 0.1; //the distance the probe atom moves between steps |
101 |
< |
|
87 |
< |
|
101 |
> |
|
102 |
|
while (!tooClose){ |
103 |
|
calcEnergy(); |
104 |
|
potProgress.push_back(potEnergy); |
139 |
|
double rXij, rYij, rZij; |
140 |
|
double rijSquared; |
141 |
|
double rValSquared, rValPowerSix; |
128 |
– |
double rparHe, epsHe; |
142 |
|
double atomRpar, atomEps; |
143 |
|
double rbAtomPos[3]; |
144 |
< |
|
132 |
< |
//first get the probe atom parameters |
133 |
< |
switch(forcefield){ |
134 |
< |
case 1:{ |
135 |
< |
rparHe = 1.4800; |
136 |
< |
epsHe = -0.021270; |
137 |
< |
}; break; |
138 |
< |
case 2:{ |
139 |
< |
rparHe = 1.14; |
140 |
< |
epsHe = 0.0203; |
141 |
< |
}; break; |
142 |
< |
case 3:{ |
143 |
< |
rparHe = 2.28; |
144 |
< |
epsHe = 0.020269601874; |
145 |
< |
}; break; |
146 |
< |
case 4:{ |
147 |
< |
rparHe = 2.5560; |
148 |
< |
epsHe = 0.0200; |
149 |
< |
}; break; |
150 |
< |
case 5:{ |
151 |
< |
rparHe = 1.14; |
152 |
< |
epsHe = 0.0203; |
153 |
< |
}; break; |
154 |
< |
} |
155 |
< |
|
144 |
> |
|
145 |
|
potEnergy = 0.0; |
146 |
< |
|
146 |
> |
|
147 |
|
for(i=0; i<rbMol->getNumAtoms(); i++){ |
148 |
|
rbMol->getAtomPos(rbAtomPos, i); |
149 |
|
|
153 |
|
|
154 |
|
rijSquared = rXij * rXij + rYij * rYij + rZij * rZij; |
155 |
|
|
156 |
< |
//in the interest of keeping the code more compact, we are being less efficient by placing |
157 |
< |
//a switch statement in the calculation loop |
156 |
> |
//in the interest of keeping the code more compact, we are being less |
157 |
> |
//efficient by placing a switch statement in the calculation loop |
158 |
|
switch(forcefield){ |
159 |
|
case 1:{ |
160 |
|
//we are using the CHARMm force field |
186 |
|
potEnergy += 4*sqrt(epsHe*atomEps)*(rValPowerSix * (rValPowerSix - 1.0)); |
187 |
|
|
188 |
|
}; break; |
200 |
– |
|
189 |
|
|
190 |
|
case 4:{ |
191 |
|
//we are using the OPLS force field |
210 |
|
} |
211 |
|
} |
212 |
|
|
225 |
– |
void GridBuilder::stepTheta(double increment){ |
226 |
– |
//zero out the euler angles |
227 |
– |
for (l=0; l<3; l++) |
228 |
– |
angles[i] = 0.0; |
229 |
– |
|
230 |
– |
//the second euler angle is for rotation about the x-axis (we use the zxz convention) |
231 |
– |
angles[1] = increment; |
232 |
– |
|
233 |
– |
//obtain the rotation matrix through the rigid body class |
234 |
– |
rbMol->doEulerToRotMat(angles, rotX); |
235 |
– |
|
236 |
– |
//rotate the rigid body |
237 |
– |
rbMol->getA(rbMatrix); |
238 |
– |
matMul3(rotX, rbMatrix, rotatedMat); |
239 |
– |
rbMol->setA(rotatedMat); |
240 |
– |
} |
241 |
– |
|
242 |
– |
void GridBuilder::stepPhi(double increment){ |
243 |
– |
//zero out the euler angles |
244 |
– |
for (l=0; l<3; l++) |
245 |
– |
angles[i] = 0.0; |
246 |
– |
|
247 |
– |
//the phi euler angle is for rotation about the z-axis (we use the zxz convention) |
248 |
– |
angles[0] = increment; |
249 |
– |
|
250 |
– |
//obtain the rotation matrix through the rigid body class |
251 |
– |
rbMol->doEulerToRotMat(angles, rotZ); |
252 |
– |
|
253 |
– |
//rotate the rigid body |
254 |
– |
rbMol->getA(rbMatrix); |
255 |
– |
matMul3(rotZ, rbMatrix, rotatedMat); |
256 |
– |
rbMol->setA(rotatedMat); |
257 |
– |
} |
258 |
– |
|
213 |
|
void GridBuilder::printGridFiles(){ |
214 |
|
ofstream sigmaOut("sigma.grid"); |
215 |
|
ofstream sOut("s.grid"); |
220 |
|
sOut << sList[k] << "\n0\n"; |
221 |
|
epsOut << epsList[k] << "\n0\n"; |
222 |
|
} |
223 |
< |
} |
223 |
> |
} |
224 |
> |
|