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