23 |
|
|
24 |
|
const char *jolt = " \t\n;,"; |
25 |
|
|
26 |
< |
strcpy(springName, "HarmSpringConsts.txt"); |
26 |
> |
#ifdef IS_MPI |
27 |
> |
if(worldRank == 0 ){ |
28 |
> |
#endif // is_mpi |
29 |
|
|
30 |
< |
ifstream springs(springName); |
31 |
< |
|
32 |
< |
if (!springs) { |
33 |
< |
cout << "Unable to open HarmSpringConsts.txt for reading.\n"; |
34 |
< |
|
35 |
< |
// load place holder spring constants |
36 |
< |
kDist = 6; // spring constant in units of kcal/(mol*ang^2) |
37 |
< |
kTheta = 7.5; // in units of kcal/mol |
38 |
< |
kOmega = 13.5; // in units of kcal/mol |
39 |
< |
return; |
30 |
> |
strcpy(springName, "HarmSpringConsts.txt"); |
31 |
> |
|
32 |
> |
ifstream springs(springName); |
33 |
> |
|
34 |
> |
if (!springs) { |
35 |
> |
sprintf(painCave.errMsg, |
36 |
> |
"In Restraints: Unable to open HarmSpringConsts.txt for reading.\n" |
37 |
> |
"\tDefault spring constants will be loaded. If you want to specify\n" |
38 |
> |
"\tspring constants, include a three line HarmSpringConsts.txt file\n" |
39 |
> |
"\tin the current directory.\n"); |
40 |
> |
painCave.severity = OOPSE_WARNING; |
41 |
> |
painCave.isFatal = 0; |
42 |
> |
simError(); |
43 |
> |
|
44 |
> |
// load default spring constants |
45 |
> |
kDist = 6; // spring constant in units of kcal/(mol*ang^2) |
46 |
> |
kTheta = 7.5; // in units of kcal/mol |
47 |
> |
kOmega = 13.5; // in units of kcal/mol |
48 |
> |
} else { |
49 |
> |
|
50 |
> |
springs.getline(inLine,999,'\n'); |
51 |
> |
springs.getline(inLine,999,'\n'); |
52 |
> |
token = strtok(inLine,jolt); |
53 |
> |
token = strtok(NULL,jolt); |
54 |
> |
strcpy(inValue,token); |
55 |
> |
kDist = (atof(inValue)); |
56 |
> |
springs.getline(inLine,999,'\n'); |
57 |
> |
token = strtok(inLine,jolt); |
58 |
> |
token = strtok(NULL,jolt); |
59 |
> |
strcpy(inValue,token); |
60 |
> |
kTheta = (atof(inValue)); |
61 |
> |
springs.getline(inLine,999,'\n'); |
62 |
> |
token = strtok(inLine,jolt); |
63 |
> |
token = strtok(NULL,jolt); |
64 |
> |
strcpy(inValue,token); |
65 |
> |
kOmega = (atof(inValue)); |
66 |
> |
springs.close(); |
67 |
> |
} |
68 |
> |
#ifdef IS_MPI |
69 |
|
} |
70 |
+ |
|
71 |
+ |
MPI_Bcast(&kDist, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
72 |
+ |
MPI_Bcast(&kTheta, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
73 |
+ |
MPI_Bcast(&kOmega, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
74 |
+ |
|
75 |
+ |
sprintf( checkPointMsg, |
76 |
+ |
"Sucessfully opened and read spring file.\n"); |
77 |
+ |
MPIcheckPoint(); |
78 |
|
|
79 |
< |
springs.getline(inLine,999,'\n'); |
80 |
< |
springs.getline(inLine,999,'\n'); |
81 |
< |
token = strtok(inLine,jolt); |
82 |
< |
token = strtok(NULL,jolt); |
83 |
< |
strcpy(inValue,token); |
84 |
< |
kDist = (atof(inValue)); |
85 |
< |
springs.getline(inLine,999,'\n'); |
86 |
< |
token = strtok(inLine,jolt); |
87 |
< |
token = strtok(NULL,jolt); |
88 |
< |
strcpy(inValue,token); |
50 |
< |
kTheta = (atof(inValue)); |
51 |
< |
springs.getline(inLine,999,'\n'); |
52 |
< |
token = strtok(inLine,jolt); |
53 |
< |
token = strtok(NULL,jolt); |
54 |
< |
strcpy(inValue,token); |
55 |
< |
kOmega = (atof(inValue)); |
56 |
< |
springs.close(); |
57 |
< |
|
58 |
< |
cout << "Spring Constants: " << kDist << "\t" << kTheta << "\t" << kOmega << "\n"; |
79 |
> |
#endif // is_mpi |
80 |
> |
|
81 |
> |
sprintf(painCave.errMsg, |
82 |
> |
"The spring constants for thermodynamic integration are:\n" |
83 |
> |
"\tkDist = %lf\n" |
84 |
> |
"\tkTheta = %lf\n" |
85 |
> |
"\tkOmega = %lf\n", kDist, kTheta, kOmega); |
86 |
> |
painCave.severity = OOPSE_INFO; |
87 |
> |
painCave.isFatal = 0; |
88 |
> |
simError(); |
89 |
|
} |
90 |
|
|
91 |
|
Restraints::~Restraints(){ |
99 |
|
return; |
100 |
|
} |
101 |
|
|
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 |
– |
|
102 |
|
void Restraints::Calc_body_thetaVal(double matrix[3][3], int currentMol){ |
103 |
|
ub0x = matrix[0][0]*uX0[currentMol] + matrix[0][1]*uY0[currentMol] |
104 |
|
+ matrix[0][2]*uZ0[currentMol]; |
118 |
|
return; |
119 |
|
} |
120 |
|
|
121 |
< |
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){ |
121 |
> |
void Restraints::Calc_body_omegaVal(double matrix[3][3], double zAngle){ |
122 |
|
double zRotator[3][3]; |
123 |
|
double tempOmega; |
124 |
|
double wholeTwoPis; |
125 |
|
// Use the omega accumulated from the rotation propagation |
126 |
< |
omega = zAngle[currentMol]; |
126 |
> |
omega = zAngle; |
127 |
|
|
128 |
|
// translate the omega into a range between -PI and PI |
129 |
|
if (omega < -PI){ |
164 |
|
double tempPotent; |
165 |
|
double factor; |
166 |
|
double spaceTrq[3]; |
167 |
+ |
double omegaPass; |
168 |
|
|
196 |
– |
// atoms = atomPoint; |
197 |
– |
|
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 |
– |
|
169 |
|
tolerance = 5.72957795131e-7; |
170 |
|
|
171 |
|
harmPotent = 0.0; // zero out the global harmonic potential variable |
172 |
|
|
173 |
|
factor = 1 - pow(lambdaValue, lambdaK); |
174 |
|
|
175 |
< |
for (i=0; i<vecParticles.size(); i++){ |
175 |
> |
for (i=0; i<nMol; i++){ |
176 |
|
if (vecParticles[i]->isDirectional()){ |
177 |
|
vecParticles[i]->getPos(pos); |
178 |
|
vecParticles[i]->getA(A); |
179 |
|
Calc_rVal( pos, i ); |
180 |
|
Calc_body_thetaVal( A, i ); |
181 |
< |
Calc_body_omegaVal( A, i ); |
181 |
> |
omegaPass = vecParticles[i]->getZangle(); |
182 |
> |
Calc_body_omegaVal( A, omegaPass ); |
183 |
|
|
184 |
|
if (omega > PI || omega < -PI) |
185 |
|
cout << "oops... " << omega << "\n"; |
266 |
|
return tempPotent; |
267 |
|
} |
268 |
|
|
269 |
< |
void Restraints::Store_Init_Info(){ |
269 |
> |
void Restraints::Store_Init_Info(vector<StuntDouble*> vecParticles){ |
270 |
|
double pos[3]; |
271 |
|
double A[3][3]; |
272 |
|
double RfromQ[3][3]; |
287 |
|
ifstream angleIn(angleName); |
288 |
|
|
289 |
|
if (!crystalIn) { |
290 |
< |
cout << "Unable to open idealCrystal.in for reading.\n"; |
290 |
> |
sprintf(painCave.errMsg, |
291 |
> |
"Restraints Error: Unable to open idealCrystal.in for reading.\n" |
292 |
> |
"\tMake sure a reference crystal file is in the current directory.\n"); |
293 |
> |
painCave.isFatal = 1; |
294 |
> |
simError(); |
295 |
> |
|
296 |
|
return; |
297 |
|
} |
298 |
|
|
299 |
|
if (!angleIn) { |
300 |
< |
cout << "Unable to open zAngle.ang for reading.\n"; |
301 |
< |
cout << "The omega values are all assumed to be zero.\n"; |
300 |
> |
sprintf(painCave.errMsg, |
301 |
> |
"Restraints Warning: The lack of a zAngle.ang file is mildly\n" |
302 |
> |
"\tunsettling... This means the simulation is starting from the\n" |
303 |
> |
"\tidealCrystal.in reference configuration, so the omega values\n" |
304 |
> |
"\twill all be set to zero. If this is not the case, you should\n" |
305 |
> |
"\tquestion your results.\n"); |
306 |
> |
painCave.isFatal = 0; |
307 |
> |
simError(); |
308 |
|
} |
309 |
|
|
310 |
|
// A rather specific reader for OOPSE .eor files... |
371 |
|
angleIn.getline(inLine,999,'\n'); |
372 |
|
token = strtok(inLine,delimit); |
373 |
|
strcpy(inValue,token); |
374 |
< |
zAngle[i] = (atof(inValue)); |
374 |
> |
vecParticles[i]->setZangle(atof(inValue)); |
375 |
|
} |
376 |
|
} |
377 |
|
|
378 |
|
return; |
379 |
|
} |
380 |
|
|
381 |
< |
void Restraints::Determine_Lambda(){ |
403 |
< |
// double tempEps; |
381 |
> |
void Restraints::Write_zAngle_File(vector<StuntDouble*> vecParticles){ |
382 |
|
|
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 |
– |
|
383 |
|
char zOutName[200]; |
384 |
|
|
385 |
|
strcpy(zOutName,"zAngle.ang"); |
386 |
|
|
387 |
|
ofstream angleOut(zOutName); |
388 |
|
angleOut << "This file contains the omega values for the .eor file\n"; |
389 |
< |
for (i=0; i<nMol; i++) |
390 |
< |
angleOut << zAngle[i] << "\n"; |
391 |
< |
|
389 |
> |
for (i=0; i<nMol; i++) { |
390 |
> |
angleOut << vecParticles[i]->getZangle() << "\n"; |
391 |
> |
} |
392 |
|
return; |
393 |
|
} |
394 |
|
|