33 |
|
the_integrator = NULL; |
34 |
|
setTemp = 0; |
35 |
|
thermalTime = 0.0; |
36 |
+ |
currentTime = 0.0; |
37 |
|
rCut = 0.0; |
38 |
+ |
ecr = 0.0; |
39 |
+ |
est = 0.0; |
40 |
+ |
oldEcr = 0.0; |
41 |
+ |
oldRcut = 0.0; |
42 |
|
|
43 |
+ |
haveOrigRcut = 0; |
44 |
+ |
haveOrigEcr = 0; |
45 |
+ |
boxIsInit = 0; |
46 |
+ |
|
47 |
+ |
|
48 |
+ |
|
49 |
|
usePBC = 0; |
50 |
|
useLJ = 0; |
51 |
|
useSticky = 0; |
58 |
|
} |
59 |
|
|
60 |
|
void SimInfo::setBox(double newBox[3]) { |
61 |
+ |
|
62 |
+ |
int i, j; |
63 |
+ |
double tempMat[3][3]; |
64 |
|
|
65 |
< |
double smallestBoxL, maxCutoff; |
66 |
< |
int status; |
53 |
< |
int i; |
65 |
> |
for(i=0; i<3; i++) |
66 |
> |
for (j=0; j<3; j++) tempMat[i][j] = 0.0;; |
67 |
|
|
68 |
< |
for(i=0; i<9; i++) Hmat[i] = 0.0;; |
68 |
> |
tempMat[0][0] = newBox[0]; |
69 |
> |
tempMat[1][1] = newBox[1]; |
70 |
> |
tempMat[2][2] = newBox[2]; |
71 |
|
|
72 |
< |
Hmat[0] = newBox[0]; |
58 |
< |
Hmat[4] = newBox[1]; |
59 |
< |
Hmat[8] = newBox[2]; |
72 |
> |
setBoxM( tempMat ); |
73 |
|
|
74 |
< |
calcHmatI(); |
74 |
> |
} |
75 |
> |
|
76 |
> |
void SimInfo::setBoxM( double theBox[3][3] ){ |
77 |
> |
|
78 |
> |
int i, j, status; |
79 |
> |
double smallestBoxL, maxCutoff; |
80 |
> |
double FortranHmat[9]; // to preserve compatibility with Fortran the |
81 |
> |
// ordering in the array is as follows: |
82 |
> |
// [ 0 3 6 ] |
83 |
> |
// [ 1 4 7 ] |
84 |
> |
// [ 2 5 8 ] |
85 |
> |
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
86 |
> |
|
87 |
> |
|
88 |
> |
if( !boxIsInit ) boxIsInit = 1; |
89 |
> |
|
90 |
> |
for(i=0; i < 3; i++) |
91 |
> |
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
92 |
> |
|
93 |
|
calcBoxL(); |
94 |
+ |
calcHmatInv(); |
95 |
|
|
96 |
< |
setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
96 |
> |
for(i=0; i < 3; i++) { |
97 |
> |
for (j=0; j < 3; j++) { |
98 |
> |
FortranHmat[3*j + i] = Hmat[i][j]; |
99 |
> |
FortranHmatInv[3*j + i] = HmatInv[i][j]; |
100 |
> |
} |
101 |
> |
} |
102 |
|
|
103 |
< |
smallestBoxL = boxLx; |
104 |
< |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
105 |
< |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
103 |
> |
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
104 |
> |
|
105 |
> |
} |
106 |
> |
|
107 |
|
|
108 |
< |
maxCutoff = smallestBoxL / 2.0; |
108 |
> |
void SimInfo::getBoxM (double theBox[3][3]) { |
109 |
|
|
110 |
< |
if (rList > maxCutoff) { |
111 |
< |
sprintf( painCave.errMsg, |
112 |
< |
"New Box size is forcing neighborlist radius down to %lf\n", |
113 |
< |
maxCutoff ); |
76 |
< |
painCave.isFatal = 0; |
77 |
< |
simError(); |
110 |
> |
int i, j; |
111 |
> |
for(i=0; i<3; i++) |
112 |
> |
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]; |
113 |
> |
} |
114 |
|
|
79 |
– |
rList = maxCutoff; |
115 |
|
|
116 |
< |
sprintf( painCave.errMsg, |
117 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
118 |
< |
maxCutoff - 1.0 ); |
84 |
< |
painCave.isFatal = 0; |
85 |
< |
simError(); |
116 |
> |
void SimInfo::scaleBox(double scale) { |
117 |
> |
double theBox[3][3]; |
118 |
> |
int i, j; |
119 |
|
|
120 |
< |
rCut = rList - 1.0; |
120 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
121 |
|
|
122 |
< |
// list radius changed so we have to refresh the simulation structure. |
123 |
< |
refreshSim(); |
91 |
< |
} |
122 |
> |
for(i=0; i<3; i++) |
123 |
> |
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
124 |
|
|
125 |
< |
if (rCut > maxCutoff) { |
94 |
< |
sprintf( painCave.errMsg, |
95 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
96 |
< |
maxCutoff ); |
97 |
< |
painCave.isFatal = 0; |
98 |
< |
simError(); |
125 |
> |
setBoxM(theBox); |
126 |
|
|
100 |
– |
status = 0; |
101 |
– |
LJ_new_rcut(&rCut, &status); |
102 |
– |
if (status != 0) { |
103 |
– |
sprintf( painCave.errMsg, |
104 |
– |
"Error in recomputing LJ shifts based on new rcut\n"); |
105 |
– |
painCave.isFatal = 1; |
106 |
– |
simError(); |
107 |
– |
} |
108 |
– |
} |
127 |
|
} |
128 |
|
|
129 |
< |
void SimInfo::setBoxM( double theBox[9] ){ |
129 |
> |
void SimInfo::calcHmatInv( void ) { |
130 |
|
|
131 |
< |
int i, status; |
132 |
< |
double smallestBoxL, maxCutoff; |
131 |
> |
int i,j; |
132 |
> |
double smallDiag; |
133 |
> |
double tol; |
134 |
> |
double sanity[3][3]; |
135 |
|
|
136 |
< |
for(i=0; i<9; i++) Hmat[i] = theBox[i]; |
117 |
< |
calcHmatI(); |
118 |
< |
calcBoxL(); |
136 |
> |
invertMat3( Hmat, HmatInv ); |
137 |
|
|
138 |
< |
setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
121 |
< |
|
122 |
< |
smallestBoxL = boxLx; |
123 |
< |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
124 |
< |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
138 |
> |
// Check the inverse to make sure it is sane: |
139 |
|
|
140 |
< |
maxCutoff = smallestBoxL / 2.0; |
140 |
> |
matMul3( Hmat, HmatInv, sanity ); |
141 |
> |
|
142 |
> |
// check to see if Hmat is orthorhombic |
143 |
> |
|
144 |
> |
smallDiag = Hmat[0][0]; |
145 |
> |
if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; |
146 |
> |
if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; |
147 |
> |
tol = smallDiag * 1E-6; |
148 |
|
|
149 |
< |
if (rList > maxCutoff) { |
150 |
< |
sprintf( painCave.errMsg, |
151 |
< |
"New Box size is forcing neighborlist radius down to %lf\n", |
152 |
< |
maxCutoff ); |
153 |
< |
painCave.isFatal = 0; |
154 |
< |
simError(); |
149 |
> |
orthoRhombic = 1; |
150 |
> |
|
151 |
> |
for (i = 0; i < 3; i++ ) { |
152 |
> |
for (j = 0 ; j < 3; j++) { |
153 |
> |
if (i != j) { |
154 |
> |
if (orthoRhombic) { |
155 |
> |
if (Hmat[i][j] >= tol) orthoRhombic = 0; |
156 |
> |
} |
157 |
> |
} |
158 |
> |
} |
159 |
> |
} |
160 |
> |
} |
161 |
|
|
162 |
< |
rList = maxCutoff; |
162 |
> |
double SimInfo::matDet3(double a[3][3]) { |
163 |
> |
int i, j, k; |
164 |
> |
double determinant; |
165 |
|
|
166 |
< |
sprintf( painCave.errMsg, |
138 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
139 |
< |
maxCutoff - 1.0 ); |
140 |
< |
painCave.isFatal = 0; |
141 |
< |
simError(); |
166 |
> |
determinant = 0.0; |
167 |
|
|
168 |
< |
rCut = rList - 1.0; |
168 |
> |
for(i = 0; i < 3; i++) { |
169 |
> |
j = (i+1)%3; |
170 |
> |
k = (i+2)%3; |
171 |
|
|
172 |
< |
// list radius changed so we have to refresh the simulation structure. |
146 |
< |
refreshSim(); |
172 |
> |
determinant += a[0][i] * (a[1][j]*a[2][k] - a[1][k]*a[2][j]); |
173 |
|
} |
174 |
|
|
175 |
< |
if (rCut > maxCutoff) { |
175 |
> |
return determinant; |
176 |
> |
} |
177 |
> |
|
178 |
> |
void SimInfo::invertMat3(double a[3][3], double b[3][3]) { |
179 |
> |
|
180 |
> |
int i, j, k, l, m, n; |
181 |
> |
double determinant; |
182 |
> |
|
183 |
> |
determinant = matDet3( a ); |
184 |
> |
|
185 |
> |
if (determinant == 0.0) { |
186 |
|
sprintf( painCave.errMsg, |
187 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
188 |
< |
maxCutoff ); |
153 |
< |
painCave.isFatal = 0; |
187 |
> |
"Can't invert a matrix with a zero determinant!\n"); |
188 |
> |
painCave.isFatal = 1; |
189 |
|
simError(); |
190 |
+ |
} |
191 |
|
|
192 |
< |
status = 0; |
193 |
< |
LJ_new_rcut(&rCut, &status); |
194 |
< |
if (status != 0) { |
195 |
< |
sprintf( painCave.errMsg, |
196 |
< |
"Error in recomputing LJ shifts based on new rcut\n"); |
197 |
< |
painCave.isFatal = 1; |
198 |
< |
simError(); |
192 |
> |
for (i=0; i < 3; i++) { |
193 |
> |
j = (i+1)%3; |
194 |
> |
k = (i+2)%3; |
195 |
> |
for(l = 0; l < 3; l++) { |
196 |
> |
m = (l+1)%3; |
197 |
> |
n = (l+2)%3; |
198 |
> |
|
199 |
> |
b[l][i] = (a[j][m]*a[k][n] - a[j][n]*a[k][m]) / determinant; |
200 |
|
} |
201 |
|
} |
202 |
|
} |
166 |
– |
|
203 |
|
|
204 |
< |
void SimInfo::getBoxM (double theBox[9]) { |
204 |
> |
void SimInfo::matMul3(double a[3][3], double b[3][3], double c[3][3]) { |
205 |
> |
double r00, r01, r02, r10, r11, r12, r20, r21, r22; |
206 |
|
|
207 |
< |
int i; |
208 |
< |
for(i=0; i<9; i++) theBox[i] = Hmat[i]; |
207 |
> |
r00 = a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0]; |
208 |
> |
r01 = a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1]; |
209 |
> |
r02 = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2]; |
210 |
> |
|
211 |
> |
r10 = a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0]; |
212 |
> |
r11 = a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1]; |
213 |
> |
r12 = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2]; |
214 |
> |
|
215 |
> |
r20 = a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0]; |
216 |
> |
r21 = a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1]; |
217 |
> |
r22 = a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2]; |
218 |
> |
|
219 |
> |
c[0][0] = r00; c[0][1] = r01; c[0][2] = r02; |
220 |
> |
c[1][0] = r10; c[1][1] = r11; c[1][2] = r12; |
221 |
> |
c[2][0] = r20; c[2][1] = r21; c[2][2] = r22; |
222 |
|
} |
173 |
– |
|
223 |
|
|
224 |
< |
void SimInfo::calcHmatI( void ) { |
224 |
> |
void SimInfo::matVecMul3(double m[3][3], double inVec[3], double outVec[3]) { |
225 |
> |
double a0, a1, a2; |
226 |
|
|
227 |
< |
double C[3][3]; |
178 |
< |
double detHmat; |
179 |
< |
int i, j, k; |
180 |
< |
double smallDiag; |
181 |
< |
double tol; |
182 |
< |
double sanity[3][3]; |
227 |
> |
a0 = inVec[0]; a1 = inVec[1]; a2 = inVec[2]; |
228 |
|
|
229 |
< |
// calculate the adjunct of Hmat; |
229 |
> |
outVec[0] = m[0][0]*a0 + m[0][1]*a1 + m[0][2]*a2; |
230 |
> |
outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
231 |
> |
outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
232 |
> |
} |
233 |
|
|
234 |
< |
C[0][0] = ( Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]); |
235 |
< |
C[1][0] = -( Hmat[1]*Hmat[8]) + (Hmat[7]*Hmat[2]); |
236 |
< |
C[2][0] = ( Hmat[1]*Hmat[5]) - (Hmat[4]*Hmat[2]); |
234 |
> |
void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
235 |
> |
double temp[3][3]; |
236 |
> |
int i, j; |
237 |
|
|
238 |
< |
C[0][1] = -( Hmat[3]*Hmat[8]) + (Hmat[6]*Hmat[5]); |
239 |
< |
C[1][1] = ( Hmat[0]*Hmat[8]) - (Hmat[6]*Hmat[2]); |
240 |
< |
C[2][1] = -( Hmat[0]*Hmat[5]) + (Hmat[3]*Hmat[2]); |
193 |
< |
|
194 |
< |
C[0][2] = ( Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]); |
195 |
< |
C[1][2] = -( Hmat[0]*Hmat[7]) + (Hmat[6]*Hmat[1]); |
196 |
< |
C[2][2] = ( Hmat[0]*Hmat[4]) - (Hmat[3]*Hmat[1]); |
197 |
< |
|
198 |
< |
// calcutlate the determinant of Hmat |
199 |
< |
|
200 |
< |
detHmat = 0.0; |
201 |
< |
for(i=0; i<3; i++) detHmat += Hmat[i] * C[i][0]; |
202 |
< |
|
203 |
< |
|
204 |
< |
// H^-1 = C^T / det(H) |
205 |
< |
|
206 |
< |
i=0; |
207 |
< |
for(j=0; j<3; j++){ |
208 |
< |
for(k=0; k<3; k++){ |
209 |
< |
|
210 |
< |
HmatI[i] = C[j][k] / detHmat; |
211 |
< |
i++; |
238 |
> |
for (i = 0; i < 3; i++) { |
239 |
> |
for (j = 0; j < 3; j++) { |
240 |
> |
temp[j][i] = in[i][j]; |
241 |
|
} |
242 |
|
} |
243 |
< |
|
244 |
< |
// sanity check |
245 |
< |
|
217 |
< |
for(i=0; i<3; i++){ |
218 |
< |
for(j=0; j<3; j++){ |
219 |
< |
|
220 |
< |
sanity[i][j] = 0.0; |
221 |
< |
for(k=0; k<3; k++){ |
222 |
< |
sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k]; |
223 |
< |
} |
243 |
> |
for (i = 0; i < 3; i++) { |
244 |
> |
for (j = 0; j < 3; j++) { |
245 |
> |
out[i][j] = temp[i][j]; |
246 |
|
} |
247 |
|
} |
248 |
+ |
} |
249 |
+ |
|
250 |
+ |
void SimInfo::printMat3(double A[3][3] ){ |
251 |
|
|
252 |
< |
cerr << "sanity => \n" |
253 |
< |
<< sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n" |
254 |
< |
<< sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n" |
255 |
< |
<< sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2] |
256 |
< |
<< "\n"; |
232 |
< |
|
252 |
> |
std::cerr |
253 |
> |
<< "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
254 |
> |
<< "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
255 |
> |
<< "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
256 |
> |
} |
257 |
|
|
258 |
< |
// check to see if Hmat is orthorhombic |
235 |
< |
|
236 |
< |
smallDiag = Hmat[0]; |
237 |
< |
if(smallDiag > Hmat[4]) smallDiag = Hmat[4]; |
238 |
< |
if(smallDiag > Hmat[8]) smallDiag = Hmat[8]; |
239 |
< |
tol = smallDiag * 1E-6; |
258 |
> |
void SimInfo::printMat9(double A[9] ){ |
259 |
|
|
260 |
< |
orthoRhombic = 1; |
261 |
< |
for(i=0; (i<9) && orthoRhombic; i++){ |
262 |
< |
|
263 |
< |
if( (i%4) ){ // ignore the diagonals (0, 4, and 8) |
245 |
< |
orthoRhombic = (Hmat[i] <= tol); |
246 |
< |
} |
247 |
< |
} |
248 |
< |
|
260 |
> |
std::cerr |
261 |
> |
<< "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
262 |
> |
<< "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
263 |
> |
<< "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
264 |
|
} |
265 |
|
|
266 |
|
void SimInfo::calcBoxL( void ){ |
268 |
|
double dx, dy, dz, dsq; |
269 |
|
int i; |
270 |
|
|
271 |
< |
// boxVol = h1 (dot) h2 (cross) h3 |
271 |
> |
// boxVol = Determinant of Hmat |
272 |
|
|
273 |
< |
boxVol = Hmat[0] * ( (Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]) ) |
259 |
< |
+ Hmat[1] * ( (Hmat[5]*Hmat[6]) - (Hmat[8]*Hmat[3]) ) |
260 |
< |
+ Hmat[2] * ( (Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]) ); |
273 |
> |
boxVol = matDet3( Hmat ); |
274 |
|
|
262 |
– |
|
275 |
|
// boxLx |
276 |
|
|
277 |
< |
dx = Hmat[0]; dy = Hmat[1]; dz = Hmat[2]; |
277 |
> |
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
278 |
|
dsq = dx*dx + dy*dy + dz*dz; |
279 |
< |
boxLx = sqrt( dsq ); |
279 |
> |
boxL[0] = sqrt( dsq ); |
280 |
> |
maxCutoff = 0.5 * boxL[0]; |
281 |
|
|
282 |
|
// boxLy |
283 |
|
|
284 |
< |
dx = Hmat[3]; dy = Hmat[4]; dz = Hmat[5]; |
284 |
> |
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
285 |
|
dsq = dx*dx + dy*dy + dz*dz; |
286 |
< |
boxLy = sqrt( dsq ); |
286 |
> |
boxL[1] = sqrt( dsq ); |
287 |
> |
if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
288 |
|
|
289 |
|
// boxLz |
290 |
|
|
291 |
< |
dx = Hmat[6]; dy = Hmat[7]; dz = Hmat[8]; |
291 |
> |
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
292 |
|
dsq = dx*dx + dy*dy + dz*dz; |
293 |
< |
boxLz = sqrt( dsq ); |
294 |
< |
|
293 |
> |
boxL[2] = sqrt( dsq ); |
294 |
> |
if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
295 |
> |
|
296 |
|
} |
297 |
|
|
298 |
|
|
303 |
|
|
304 |
|
if( !orthoRhombic ){ |
305 |
|
// calc the scaled coordinates. |
306 |
+ |
|
307 |
+ |
|
308 |
+ |
matVecMul3(HmatInv, thePos, scaled); |
309 |
|
|
310 |
|
for(i=0; i<3; i++) |
293 |
– |
scaled[i] = |
294 |
– |
thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6]; |
295 |
– |
|
296 |
– |
// wrap the scaled coordinates |
297 |
– |
|
298 |
– |
for(i=0; i<3; i++) |
311 |
|
scaled[i] -= roundMe(scaled[i]); |
312 |
|
|
313 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
314 |
|
|
315 |
< |
for(i=0; i<3; i++) |
316 |
< |
thePos[i] = |
305 |
< |
scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6]; |
315 |
> |
matVecMul3(Hmat, scaled, thePos); |
316 |
> |
|
317 |
|
} |
318 |
|
else{ |
319 |
|
// calc the scaled coordinates. |
320 |
|
|
321 |
|
for(i=0; i<3; i++) |
322 |
< |
scaled[i] = thePos[i]*HmatI[i*4]; |
322 |
> |
scaled[i] = thePos[i]*HmatInv[i][i]; |
323 |
|
|
324 |
|
// wrap the scaled coordinates |
325 |
|
|
329 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
330 |
|
|
331 |
|
for(i=0; i<3; i++) |
332 |
< |
thePos[i] = scaled[i]*Hmat[i*4]; |
332 |
> |
thePos[i] = scaled[i]*Hmat[i][i]; |
333 |
|
} |
323 |
– |
|
334 |
|
|
335 |
|
} |
336 |
|
|
372 |
|
int isError; |
373 |
|
int n_global; |
374 |
|
int* excl; |
375 |
< |
|
366 |
< |
fInfo.rrf = 0.0; |
367 |
< |
fInfo.rt = 0.0; |
375 |
> |
|
376 |
|
fInfo.dielect = 0.0; |
377 |
|
|
370 |
– |
fInfo.rlist = rList; |
371 |
– |
fInfo.rcut = rCut; |
372 |
– |
|
378 |
|
if( useDipole ){ |
374 |
– |
fInfo.rrf = ecr; |
375 |
– |
fInfo.rt = ecr - est; |
379 |
|
if( useReactionField )fInfo.dielect = dielectric; |
380 |
|
} |
381 |
|
|
424 |
|
|
425 |
|
} |
426 |
|
|
427 |
+ |
|
428 |
+ |
void SimInfo::setRcut( double theRcut ){ |
429 |
+ |
|
430 |
+ |
if( !haveOrigRcut ){ |
431 |
+ |
haveOrigRcut = 1; |
432 |
+ |
origRcut = theRcut; |
433 |
+ |
} |
434 |
+ |
|
435 |
+ |
rCut = theRcut; |
436 |
+ |
checkCutOffs(); |
437 |
+ |
} |
438 |
+ |
|
439 |
+ |
void SimInfo::setEcr( double theEcr ){ |
440 |
+ |
|
441 |
+ |
if( !haveOrigEcr ){ |
442 |
+ |
haveOrigEcr = 1; |
443 |
+ |
origEcr = theEcr; |
444 |
+ |
} |
445 |
+ |
|
446 |
+ |
ecr = theEcr; |
447 |
+ |
checkCutOffs(); |
448 |
+ |
} |
449 |
+ |
|
450 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
451 |
+ |
|
452 |
+ |
est = theEst; |
453 |
+ |
setEcr( theEcr ); |
454 |
+ |
} |
455 |
+ |
|
456 |
+ |
|
457 |
+ |
void SimInfo::checkCutOffs( void ){ |
458 |
+ |
|
459 |
+ |
int cutChanged = 0; |
460 |
+ |
|
461 |
+ |
if( boxIsInit ){ |
462 |
+ |
|
463 |
+ |
//we need to check cutOffs against the box |
464 |
+ |
|
465 |
+ |
if( maxCutoff > rCut ){ |
466 |
+ |
if( rCut < origRcut ){ |
467 |
+ |
rCut = origRcut; |
468 |
+ |
if (rCut > maxCutoff) rCut = maxCutoff; |
469 |
+ |
|
470 |
+ |
sprintf( painCave.errMsg, |
471 |
+ |
"New Box size is setting the long range cutoff radius " |
472 |
+ |
"to %lf\n", |
473 |
+ |
rCut ); |
474 |
+ |
painCave.isFatal = 0; |
475 |
+ |
simError(); |
476 |
+ |
} |
477 |
+ |
} |
478 |
+ |
|
479 |
+ |
if( maxCutoff > ecr ){ |
480 |
+ |
if( ecr < origEcr ){ |
481 |
+ |
rCut = origEcr; |
482 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
483 |
+ |
|
484 |
+ |
sprintf( painCave.errMsg, |
485 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
486 |
+ |
"to %lf\n", |
487 |
+ |
ecr ); |
488 |
+ |
painCave.isFatal = 0; |
489 |
+ |
simError(); |
490 |
+ |
} |
491 |
+ |
} |
492 |
+ |
|
493 |
+ |
|
494 |
+ |
if (rCut > maxCutoff) { |
495 |
+ |
sprintf( painCave.errMsg, |
496 |
+ |
"New Box size is setting the long range cutoff radius " |
497 |
+ |
"to %lf\n", |
498 |
+ |
maxCutoff ); |
499 |
+ |
painCave.isFatal = 0; |
500 |
+ |
simError(); |
501 |
+ |
rCut = maxCutoff; |
502 |
+ |
} |
503 |
+ |
|
504 |
+ |
if( ecr > maxCutoff){ |
505 |
+ |
sprintf( painCave.errMsg, |
506 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
507 |
+ |
"to %lf\n", |
508 |
+ |
maxCutoff ); |
509 |
+ |
painCave.isFatal = 0; |
510 |
+ |
simError(); |
511 |
+ |
ecr = maxCutoff; |
512 |
+ |
} |
513 |
+ |
|
514 |
+ |
|
515 |
+ |
} |
516 |
+ |
|
517 |
+ |
|
518 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
519 |
+ |
|
520 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
521 |
+ |
|
522 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
523 |
+ |
|
524 |
+ |
if( cutChanged ){ |
525 |
+ |
|
526 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
527 |
+ |
} |
528 |
+ |
|
529 |
+ |
oldEcr = ecr; |
530 |
+ |
oldRcut = rCut; |
531 |
+ |
} |