28 |
|
ifstream springs(springName); |
29 |
|
|
30 |
|
if (!springs) { |
31 |
< |
cout << "Unable to open HarmSpringConsts.txt for reading.\n"; |
31 |
> |
sprintf(painCave.errMsg, |
32 |
> |
"Restraints Warning: Unable to open HarmSpringConsts.txt for reading.\n" |
33 |
> |
"\tDefault spring constants will be loaded. If you want to specify\n" |
34 |
> |
"\tspring constants, include a three line HarmSpringConsts.txt file\n" |
35 |
> |
"\tin the current directory.\n"); |
36 |
> |
painCave.isFatal = 0; |
37 |
> |
simError(); |
38 |
|
|
39 |
< |
// load place holder spring constants |
39 |
> |
// load default spring constants |
40 |
|
kDist = 6; // spring constant in units of kcal/(mol*ang^2) |
41 |
|
kTheta = 7.5; // in units of kcal/mol |
42 |
|
kOmega = 13.5; // in units of kcal/mol |
61 |
|
kOmega = (atof(inValue)); |
62 |
|
springs.close(); |
63 |
|
|
64 |
< |
cout << "Spring Constants: " << kDist << "\t" << kTheta << "\t" << kOmega << "\n"; |
64 |
> |
cout << "The Spring Constants are:\n\tkDist = " << kDist << "\n\tkTheta = " << kTheta << "\n\tkOmega = " << kOmega << "\n"; |
65 |
|
} |
66 |
|
|
67 |
|
Restraints::~Restraints(){ |
75 |
|
return; |
76 |
|
} |
77 |
|
|
72 |
– |
void Restraints::Calc_thetaVal(double matrix[3][3], int currentMol){ |
73 |
– |
uTx = matrix[2][0]; |
74 |
– |
uTy = matrix[2][1]; |
75 |
– |
uTz = matrix[2][2]; |
76 |
– |
|
77 |
– |
normalize = sqrt(uTx*uTx + uTy*uTy + uTz*uTz); |
78 |
– |
uTx = uTx/normalize; |
79 |
– |
uTy = uTy/normalize; |
80 |
– |
uTz = uTz/normalize; |
81 |
– |
|
82 |
– |
// Theta is the dot product of the reference and new z-axes |
83 |
– |
theta = acos(uTx*uX0[currentMol]+uTy*uY0[currentMol]+uTz*uZ0[currentMol]); |
84 |
– |
|
85 |
– |
return; |
86 |
– |
} |
87 |
– |
|
78 |
|
void Restraints::Calc_body_thetaVal(double matrix[3][3], int currentMol){ |
79 |
|
ub0x = matrix[0][0]*uX0[currentMol] + matrix[0][1]*uY0[currentMol] |
80 |
|
+ matrix[0][2]*uZ0[currentMol]; |
94 |
|
return; |
95 |
|
} |
96 |
|
|
97 |
< |
void Restraints::Calc_omegaVal(double matrix[3][3], int currentMol){ |
108 |
< |
double dot; |
109 |
< |
|
110 |
< |
uTx = matrix[2][0]; |
111 |
< |
uTy = matrix[2][1]; |
112 |
< |
uTz = matrix[2][2]; |
113 |
< |
vTx = matrix[1][0]; |
114 |
< |
vTy = matrix[1][1]; |
115 |
< |
vTz = matrix[1][2]; |
116 |
< |
|
117 |
< |
normalize = sqrt(uTx*uTx + uTy*uTy + uTz*uTz); |
118 |
< |
uTx = uTx/normalize; |
119 |
< |
uTy = uTy/normalize; |
120 |
< |
uTz = uTz/normalize; |
121 |
< |
|
122 |
< |
normalize = sqrt(vTx*vTx + vTy*vTy + vTz*vTz); |
123 |
< |
vTx = vTx/normalize; |
124 |
< |
vTy = vTy/normalize; |
125 |
< |
vTz = vTz/normalize; |
126 |
< |
|
127 |
< |
dot = uTx * vX0[currentMol] + uTy * vY0[currentMol] + uTz * vZ0[currentMol]; |
128 |
< |
|
129 |
< |
// Find the original y-axis vector projection on the current |
130 |
< |
// space-fixed xy-plane |
131 |
< |
vProj0[0] = vX0[currentMol] - dot * uTx; |
132 |
< |
vProj0[1] = vY0[currentMol] - dot * uTy; |
133 |
< |
vProj0[2] = vZ0[currentMol] - dot * uTz; |
134 |
< |
|
135 |
< |
// Convert the projection to a unit vector |
136 |
< |
vProjDist = sqrt(vProj0[0]*vProj0[0] + vProj0[1]*vProj0[1] |
137 |
< |
+ vProj0[2]*vProj0[2]); |
138 |
< |
vProj0[0] = vProj0[0]/vProjDist; |
139 |
< |
vProj0[1] = vProj0[1]/vProjDist; |
140 |
< |
vProj0[2] = vProj0[2]/vProjDist; |
141 |
< |
|
142 |
< |
// Omega is the dot product of the new y-axis and the projection |
143 |
< |
// of the reference y-axis on the current xy-plane |
144 |
< |
omega = acos(vTx*vProj0[0] + vTy*vProj0[1] + vTz*vProj0[2]); |
145 |
< |
|
146 |
< |
return; |
147 |
< |
} |
148 |
< |
|
149 |
< |
void Restraints::Calc_body_omegaVal(double matrix[3][3], int currentMol){ |
97 |
> |
void Restraints::Calc_body_omegaVal(double matrix[3][3], double zAngle){ |
98 |
|
double zRotator[3][3]; |
99 |
|
double tempOmega; |
100 |
|
double wholeTwoPis; |
101 |
|
// Use the omega accumulated from the rotation propagation |
102 |
< |
omega = zAngle[currentMol]; |
102 |
> |
omega = zAngle; |
103 |
|
|
104 |
|
// translate the omega into a range between -PI and PI |
105 |
|
if (omega < -PI){ |
140 |
|
double tempPotent; |
141 |
|
double factor; |
142 |
|
double spaceTrq[3]; |
143 |
< |
|
196 |
< |
// atoms = atomPoint; |
143 |
> |
double omega; |
144 |
|
|
198 |
– |
// kDist = 6; // spring constant in units of kcal/(mol*ang^2) |
199 |
– |
// kTheta = 7.5; // in units of kcal/mol |
200 |
– |
// kOmega = 13.5; // in units of kcal/mol |
201 |
– |
|
145 |
|
tolerance = 5.72957795131e-7; |
146 |
|
|
147 |
|
harmPotent = 0.0; // zero out the global harmonic potential variable |
148 |
|
|
149 |
|
factor = 1 - pow(lambdaValue, lambdaK); |
150 |
|
|
151 |
< |
for (i=0; i<vecParticles.size(); i++){ |
151 |
> |
for (i=0; i<nMol; i++){ |
152 |
|
if (vecParticles[i]->isDirectional()){ |
153 |
|
vecParticles[i]->getPos(pos); |
154 |
|
vecParticles[i]->getA(A); |
155 |
|
Calc_rVal( pos, i ); |
156 |
|
Calc_body_thetaVal( A, i ); |
157 |
< |
Calc_body_omegaVal( A, i ); |
157 |
> |
vecParticles[i]->getZangle(omega); |
158 |
> |
Calc_body_omegaVal( A, omega ); |
159 |
|
|
160 |
|
if (omega > PI || omega < -PI) |
161 |
|
cout << "oops... " << omega << "\n"; |
242 |
|
return tempPotent; |
243 |
|
} |
244 |
|
|
245 |
< |
void Restraints::Store_Init_Info(){ |
245 |
> |
void Restraints::Store_Init_Info(vector<StuntDouble*> vecParticles){ |
246 |
|
double pos[3]; |
247 |
|
double A[3][3]; |
248 |
|
double RfromQ[3][3]; |
263 |
|
ifstream angleIn(angleName); |
264 |
|
|
265 |
|
if (!crystalIn) { |
266 |
< |
cout << "Unable to open idealCrystal.in for reading.\n"; |
266 |
> |
sprintf(painCave.errMsg, |
267 |
> |
"Restraints Error: Unable to open idealCrystal.in for reading.\n" |
268 |
> |
"\tMake sure a reference crystal file is in the current directory.\n"); |
269 |
> |
painCave.isFatal = 1; |
270 |
> |
simError(); |
271 |
> |
|
272 |
|
return; |
273 |
|
} |
274 |
|
|
275 |
|
if (!angleIn) { |
276 |
< |
cout << "Unable to open zAngle.ang for reading.\n"; |
277 |
< |
cout << "The omega values are all assumed to be zero.\n"; |
276 |
> |
sprintf(painCave.errMsg, |
277 |
> |
"Restraints Warning: The lack of a zAngle.ang file is mildly\n" |
278 |
> |
"\tunsettling... This means you arestarting from the idealCrystal.in\n" |
279 |
> |
"\treference configuration, so the omega values will all be set to\n" |
280 |
> |
"\tzero. If this isn't the case, you should question your results.\n"); |
281 |
> |
painCave.isFatal = 0; |
282 |
> |
simError(); |
283 |
|
} |
284 |
|
|
285 |
|
// A rather specific reader for OOPSE .eor files... |
346 |
|
angleIn.getline(inLine,999,'\n'); |
347 |
|
token = strtok(inLine,delimit); |
348 |
|
strcpy(inValue,token); |
349 |
< |
zAngle[i] = (atof(inValue)); |
349 |
> |
vecParticles[i]->setZangle(atof(inValue)); |
350 |
|
} |
351 |
|
} |
352 |
|
|
353 |
|
return; |
354 |
|
} |
355 |
|
|
356 |
< |
void Restraints::Determine_Lambda(){ |
403 |
< |
// double tempEps; |
356 |
> |
void Restraints::Write_zAngle_File(vector<StuntDouble*> vecParticles){ |
357 |
|
|
405 |
– |
// atoms = entry_plug->atoms; |
406 |
– |
|
407 |
– |
// if (!strcmp(atoms[0]->getType(),"SSD") || |
408 |
– |
// !strcmp(atoms[0]->getType(),"SSD_E") || |
409 |
– |
// !strcmp(atoms[0]->getType(),"SSD_RF") || |
410 |
– |
// !strcmp(atoms[0]->getType(),"SSD1")){ |
411 |
– |
|
412 |
– |
// tempEps = atoms[0]->getEpsilon(); |
413 |
– |
// scaleLam = 1.0 - (tempEps/0.152); |
414 |
– |
// } |
415 |
– |
// else if (!strcmp(atoms[0]->getType(),"O_TIP3P")){ |
416 |
– |
// tempEps = atoms[0]->getEpsilon(); |
417 |
– |
// scaleLam = 1.0 - (tempEps/0.1521); |
418 |
– |
// } |
419 |
– |
// else if (!strcmp(atoms[0]->getType(),"O_TIP4P")){ |
420 |
– |
// tempEps = atoms[0]->getEpsilon(); |
421 |
– |
// scaleLam = 1.0 - (tempEps/0.1550); |
422 |
– |
// } |
423 |
– |
// else if (!strcmp(atoms[0]->getType(),"O_TIP5P")){ |
424 |
– |
// tempEps = atoms[0]->getEpsilon(); |
425 |
– |
// scaleLam = 1.0 - (tempEps/0.16); |
426 |
– |
// } |
427 |
– |
// else if (!strcmp(atoms[0]->getType(),"O_SPCE")){ |
428 |
– |
// tempEps = atoms[0]->getEpsilon(); |
429 |
– |
// scaleLam = 1.0 - (tempEps/0.15532); |
430 |
– |
// } |
431 |
– |
// else |
432 |
– |
// sprintf( painCave.errMsg, |
433 |
– |
// "Error in setting the lambda scale: Restraints\n" ); |
434 |
– |
|
435 |
– |
// if (fabs(scaleLam < 1e-9)) |
436 |
– |
// scaleLam = 0.0; |
437 |
– |
// cout << "The scaleLam is " << scaleLam << "\n"; |
438 |
– |
} |
439 |
– |
|
440 |
– |
void Restraints::Write_zAngle_File(){ |
441 |
– |
|
358 |
|
char zOutName[200]; |
359 |
|
|
360 |
|
strcpy(zOutName,"zAngle.ang"); |
361 |
|
|
362 |
|
ofstream angleOut(zOutName); |
363 |
|
angleOut << "This file contains the omega values for the .eor file\n"; |
364 |
< |
for (i=0; i<nMol; i++) |
365 |
< |
angleOut << zAngle[i] << "\n"; |
366 |
< |
|
364 |
> |
for (i=0; i<nMol; i++) { |
365 |
> |
angleOut << vecParticles[i]->getZangle() << "\n"; |
366 |
> |
} |
367 |
|
return; |
368 |
|
} |
369 |
|
|