# | Line 1 | Line 1 | |
---|---|---|
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 | ||
36 | – | 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 | //set the initial orientation of the body and loop over theta values | |
67 | < | phiVal = 0.0; |
68 | < | thetaVal = thetaMin; |
69 | < | rotBody(phiVal, thetaVal); |
70 | < | for (k=0; k<bandwidth; k++){ |
71 | < | //loop over phi values starting with phi = 0.0 |
72 | < | for (j=0; j<bandwidth; j++){ |
67 | > | |
68 | > | for (k =0; k < gridwidth; k++) { |
69 | > | thetaVal = thetaMin + k*thetaStep; |
70 | > | for (j=0; j < gridwidth; j++) { |
71 | > | phiVal = j*phiStep; |
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); |
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 | < | phiVal += phiStep; |
83 | < | rotBody(phiVal, thetaVal); |
82 | > | sigList.push_back(sigTemp); |
83 | > | sList.push_back(sTemp); |
84 | > | epsList.push_back(epsTemp); |
85 | } | |
62 | – | phiVal = 0.0; |
63 | – | thetaVal += thetaStep; |
64 | – | rotBody(phiVal, thetaVal); |
65 | – | printf("step theta %i\n",k); |
86 | } | |
87 | } | |
88 | ||
# | Line 78 | Line 98 | void GridBuilder::releaseProbe(double farPos){ | |
98 | tooClose = 0; | |
99 | epsVal = 0; | |
100 | rhoStep = 0.1; //the distance the probe atom moves between steps | |
101 | < | |
82 | < | |
101 | > | |
102 | while (!tooClose){ | |
103 | calcEnergy(); | |
104 | potProgress.push_back(potEnergy); | |
# | Line 120 | Line 139 | void GridBuilder::calcEnergy(){ | |
139 | double rXij, rYij, rZij; | |
140 | double rijSquared; | |
141 | double rValSquared, rValPowerSix; | |
123 | – | double rparHe, epsHe; |
142 | double atomRpar, atomEps; | |
143 | double rbAtomPos[3]; | |
144 | < | |
127 | < | //first get the probe atom parameters |
128 | < | switch(forcefield){ |
129 | < | case 1:{ |
130 | < | rparHe = 1.4800; |
131 | < | epsHe = -0.021270; |
132 | < | }; break; |
133 | < | case 2:{ |
134 | < | rparHe = 1.14; |
135 | < | epsHe = 0.0203; |
136 | < | }; break; |
137 | < | case 3:{ |
138 | < | rparHe = 2.28; |
139 | < | epsHe = 0.020269601874; |
140 | < | }; break; |
141 | < | case 4:{ |
142 | < | rparHe = 2.5560; |
143 | < | epsHe = 0.0200; |
144 | < | }; break; |
145 | < | case 5:{ |
146 | < | rparHe = 1.14; |
147 | < | epsHe = 0.0203; |
148 | < | }; break; |
149 | < | } |
150 | < | |
144 | > | |
145 | potEnergy = 0.0; | |
146 | < | |
146 | > | |
147 | for(i=0; i<rbMol->getNumAtoms(); i++){ | |
148 | rbMol->getAtomPos(rbAtomPos, i); | |
149 | ||
# | Line 159 | Line 153 | void GridBuilder::calcEnergy(){ | |
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 | |
# | Line 216 | Line 210 | void GridBuilder::calcEnergy(){ | |
210 | } | |
211 | } | |
212 | ||
219 | – | void GridBuilder::rotBody(double pValue, double tValue){ |
220 | – | //zero out the euler angles |
221 | – | for (l=0; l<3; l++) |
222 | – | angles[i] = 0.0; |
223 | – | |
224 | – | //the phi euler angle is for rotation about the z-axis (we use the zxz convention) |
225 | – | angles[0] = pValue; |
226 | – | //the second euler angle is for rotation about the x-axis (we use the zxz convention) |
227 | – | angles[1] = tValue; |
228 | – | |
229 | – | //obtain the rotation matrix through the rigid body class |
230 | – | rbMol->doEulerToRotMat(angles, rotX); |
231 | – | |
232 | – | //start from the reference position |
233 | – | identityMat3(rbMatrix); |
234 | – | rbMol->setA(rbMatrix); |
235 | – | |
236 | – | //rotate the rigid body |
237 | – | matMul3(rotX, rbMatrix, rotatedMat); |
238 | – | rbMol->setA(rotatedMat); |
239 | – | } |
240 | – | |
213 | void GridBuilder::printGridFiles(){ | |
214 | ofstream sigmaOut("sigma.grid"); | |
215 | ofstream sOut("s.grid"); | |
# | Line 248 | Line 220 | void GridBuilder::printGridFiles(){ | |
220 | sOut << sList[k] << "\n0\n"; | |
221 | epsOut << epsList[k] << "\n0\n"; | |
222 | } | |
223 | < | } |
223 | > | } |
224 | > |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |