# | Line 33 | Line 33 | SimInfo::SimInfo(){ | |
---|---|---|
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; | |
# | Line 43 | Line 54 | SimInfo::SimInfo(){ | |
54 | useGB = 0; | |
55 | useEAM = 0; | |
56 | ||
57 | + | myConfiguration = new SimState(); |
58 | + | |
59 | wrapMeSimInfo( this ); | |
60 | } | |
61 | ||
62 | + | |
63 | + | SimInfo::~SimInfo(){ |
64 | + | |
65 | + | delete myConfiguration; |
66 | + | |
67 | + | map<string, GenericData*>::iterator i; |
68 | + | |
69 | + | for(i = properties.begin(); i != properties.end(); i++) |
70 | + | delete (*i).second; |
71 | + | |
72 | + | } |
73 | + | |
74 | void SimInfo::setBox(double newBox[3]) { | |
75 | ||
76 | < | int i; |
77 | < | double tempMat[9]; |
76 | > | int i, j; |
77 | > | double tempMat[3][3]; |
78 | ||
79 | < | for(i=0; i<9; i++) tempMat[i] = 0.0;; |
79 | > | for(i=0; i<3; i++) |
80 | > | for (j=0; j<3; j++) tempMat[i][j] = 0.0;; |
81 | ||
82 | < | tempMat[0] = newBox[0]; |
83 | < | tempMat[4] = newBox[1]; |
84 | < | tempMat[8] = newBox[2]; |
82 | > | tempMat[0][0] = newBox[0]; |
83 | > | tempMat[1][1] = newBox[1]; |
84 | > | tempMat[2][2] = newBox[2]; |
85 | ||
86 | setBoxM( tempMat ); | |
87 | ||
88 | } | |
89 | ||
90 | < | void SimInfo::setBoxM( double theBox[9] ){ |
90 | > | void SimInfo::setBoxM( double theBox[3][3] ){ |
91 | ||
92 | < | int i, status; |
92 | > | int i, j, status; |
93 | double smallestBoxL, maxCutoff; | |
94 | + | double FortranHmat[9]; // to preserve compatibility with Fortran the |
95 | + | // ordering in the array is as follows: |
96 | + | // [ 0 3 6 ] |
97 | + | // [ 1 4 7 ] |
98 | + | // [ 2 5 8 ] |
99 | + | double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
100 | ||
101 | < | for(i=0; i<9; i++) Hmat[i] = theBox[i]; |
101 | > | |
102 | > | if( !boxIsInit ) boxIsInit = 1; |
103 | ||
104 | < | cerr |
105 | < | << "setting Hmat ->\n" |
106 | < | << "[ " << Hmat[0] << ", " << Hmat[3] << ", " << Hmat[6] << " ]\n" |
74 | < | << "[ " << Hmat[1] << ", " << Hmat[4] << ", " << Hmat[7] << " ]\n" |
75 | < | << "[ " << Hmat[2] << ", " << Hmat[5] << ", " << Hmat[8] << " ]\n"; |
76 | < | |
77 | < | calcHmatI(); |
104 | > | for(i=0; i < 3; i++) |
105 | > | for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
106 | > | |
107 | calcBoxL(); | |
108 | + | calcHmatInv(); |
109 | ||
110 | < | |
111 | < | |
112 | < | setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
113 | < | |
84 | < | smallestBoxL = boxLx; |
85 | < | if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
86 | < | if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
87 | < | |
88 | < | maxCutoff = smallestBoxL / 2.0; |
89 | < | |
90 | < | if (rList > maxCutoff) { |
91 | < | sprintf( painCave.errMsg, |
92 | < | "New Box size is forcing neighborlist radius down to %lf\n", |
93 | < | maxCutoff ); |
94 | < | painCave.isFatal = 0; |
95 | < | simError(); |
96 | < | |
97 | < | rList = maxCutoff; |
98 | < | |
99 | < | sprintf( painCave.errMsg, |
100 | < | "New Box size is forcing cutoff radius down to %lf\n", |
101 | < | maxCutoff - 1.0 ); |
102 | < | painCave.isFatal = 0; |
103 | < | simError(); |
104 | < | |
105 | < | rCut = rList - 1.0; |
106 | < | |
107 | < | // list radius changed so we have to refresh the simulation structure. |
108 | < | refreshSim(); |
109 | < | } |
110 | < | |
111 | < | if (rCut > maxCutoff) { |
112 | < | sprintf( painCave.errMsg, |
113 | < | "New Box size is forcing cutoff radius down to %lf\n", |
114 | < | maxCutoff ); |
115 | < | painCave.isFatal = 0; |
116 | < | simError(); |
117 | < | |
118 | < | status = 0; |
119 | < | LJ_new_rcut(&rCut, &status); |
120 | < | if (status != 0) { |
121 | < | sprintf( painCave.errMsg, |
122 | < | "Error in recomputing LJ shifts based on new rcut\n"); |
123 | < | painCave.isFatal = 1; |
124 | < | simError(); |
110 | > | for(i=0; i < 3; i++) { |
111 | > | for (j=0; j < 3; j++) { |
112 | > | FortranHmat[3*j + i] = Hmat[i][j]; |
113 | > | FortranHmatInv[3*j + i] = HmatInv[i][j]; |
114 | } | |
115 | } | |
116 | + | |
117 | + | setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
118 | + | |
119 | } | |
120 | ||
121 | ||
122 | < | void SimInfo::getBoxM (double theBox[9]) { |
122 | > | void SimInfo::getBoxM (double theBox[3][3]) { |
123 | ||
124 | < | int i; |
125 | < | for(i=0; i<9; i++) theBox[i] = Hmat[i]; |
124 | > | int i, j; |
125 | > | for(i=0; i<3; i++) |
126 | > | for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]; |
127 | } | |
128 | ||
129 | ||
130 | void SimInfo::scaleBox(double scale) { | |
131 | < | double theBox[9]; |
132 | < | int i; |
131 | > | double theBox[3][3]; |
132 | > | int i, j; |
133 | ||
134 | < | cerr << "Scaling box by " << scale << "\n"; |
134 | > | // cerr << "Scaling box by " << scale << "\n"; |
135 | ||
136 | < | for(i=0; i<9; i++) theBox[i] = Hmat[i]*scale; |
136 | > | for(i=0; i<3; i++) |
137 | > | for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
138 | ||
139 | setBoxM(theBox); | |
140 | ||
141 | } | |
142 | ||
143 | < | void SimInfo::calcHmatI( void ) { |
144 | < | |
145 | < | double C[3][3]; |
152 | < | double detHmat; |
153 | < | int i, j, k; |
143 | > | void SimInfo::calcHmatInv( void ) { |
144 | > | |
145 | > | int i,j; |
146 | double smallDiag; | |
147 | double tol; | |
148 | double sanity[3][3]; | |
149 | ||
150 | < | // calculate the adjunct of Hmat; |
150 | > | invertMat3( Hmat, HmatInv ); |
151 | ||
152 | < | C[0][0] = ( Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]); |
161 | < | C[1][0] = -( Hmat[1]*Hmat[8]) + (Hmat[7]*Hmat[2]); |
162 | < | C[2][0] = ( Hmat[1]*Hmat[5]) - (Hmat[4]*Hmat[2]); |
152 | > | // Check the inverse to make sure it is sane: |
153 | ||
154 | < | C[0][1] = -( Hmat[3]*Hmat[8]) + (Hmat[6]*Hmat[5]); |
155 | < | C[1][1] = ( Hmat[0]*Hmat[8]) - (Hmat[6]*Hmat[2]); |
156 | < | C[2][1] = -( Hmat[0]*Hmat[5]) + (Hmat[3]*Hmat[2]); |
167 | < | |
168 | < | C[0][2] = ( Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]); |
169 | < | C[1][2] = -( Hmat[0]*Hmat[7]) + (Hmat[6]*Hmat[1]); |
170 | < | C[2][2] = ( Hmat[0]*Hmat[4]) - (Hmat[3]*Hmat[1]); |
171 | < | |
172 | < | // calcutlate the determinant of Hmat |
154 | > | matMul3( Hmat, HmatInv, sanity ); |
155 | > | |
156 | > | // check to see if Hmat is orthorhombic |
157 | ||
158 | < | detHmat = 0.0; |
159 | < | for(i=0; i<3; i++) detHmat += Hmat[i] * C[i][0]; |
158 | > | smallDiag = Hmat[0][0]; |
159 | > | if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; |
160 | > | if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; |
161 | > | tol = smallDiag * 1E-6; |
162 | ||
163 | + | orthoRhombic = 1; |
164 | ||
165 | < | // H^-1 = C^T / det(H) |
166 | < | |
167 | < | i=0; |
168 | < | for(j=0; j<3; j++){ |
169 | < | for(k=0; k<3; k++){ |
170 | < | |
171 | < | HmatI[i] = C[j][k] / detHmat; |
185 | < | i++; |
165 | > | for (i = 0; i < 3; i++ ) { |
166 | > | for (j = 0 ; j < 3; j++) { |
167 | > | if (i != j) { |
168 | > | if (orthoRhombic) { |
169 | > | if (Hmat[i][j] >= tol) orthoRhombic = 0; |
170 | > | } |
171 | > | } |
172 | } | |
173 | } | |
174 | + | } |
175 | ||
176 | < | // sanity check |
176 | > | double SimInfo::matDet3(double a[3][3]) { |
177 | > | int i, j, k; |
178 | > | double determinant; |
179 | ||
180 | < | for(i=0; i<3; i++){ |
181 | < | for(j=0; j<3; j++){ |
180 | > | determinant = 0.0; |
181 | > | |
182 | > | for(i = 0; i < 3; i++) { |
183 | > | j = (i+1)%3; |
184 | > | k = (i+2)%3; |
185 | > | |
186 | > | determinant += a[0][i] * (a[1][j]*a[2][k] - a[1][k]*a[2][j]); |
187 | > | } |
188 | > | |
189 | > | return determinant; |
190 | > | } |
191 | > | |
192 | > | void SimInfo::invertMat3(double a[3][3], double b[3][3]) { |
193 | > | |
194 | > | int i, j, k, l, m, n; |
195 | > | double determinant; |
196 | > | |
197 | > | determinant = matDet3( a ); |
198 | > | |
199 | > | if (determinant == 0.0) { |
200 | > | sprintf( painCave.errMsg, |
201 | > | "Can't invert a matrix with a zero determinant!\n"); |
202 | > | painCave.isFatal = 1; |
203 | > | simError(); |
204 | > | } |
205 | > | |
206 | > | for (i=0; i < 3; i++) { |
207 | > | j = (i+1)%3; |
208 | > | k = (i+2)%3; |
209 | > | for(l = 0; l < 3; l++) { |
210 | > | m = (l+1)%3; |
211 | > | n = (l+2)%3; |
212 | ||
213 | < | sanity[i][j] = 0.0; |
195 | < | for(k=0; k<3; k++){ |
196 | < | sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k]; |
197 | < | } |
213 | > | b[l][i] = (a[j][m]*a[k][n] - a[j][n]*a[k][m]) / determinant; |
214 | } | |
215 | } | |
216 | + | } |
217 | ||
218 | < | cerr << "sanity => \n" |
219 | < | << sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n" |
203 | < | << sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n" |
204 | < | << sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2] |
205 | < | << "\n"; |
206 | < | |
218 | > | void SimInfo::matMul3(double a[3][3], double b[3][3], double c[3][3]) { |
219 | > | double r00, r01, r02, r10, r11, r12, r20, r21, r22; |
220 | ||
221 | < | // check to see if Hmat is orthorhombic |
221 | > | r00 = a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0]; |
222 | > | r01 = a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1]; |
223 | > | r02 = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2]; |
224 | ||
225 | < | smallDiag = Hmat[0]; |
226 | < | if(smallDiag > Hmat[4]) smallDiag = Hmat[4]; |
227 | < | if(smallDiag > Hmat[8]) smallDiag = Hmat[8]; |
228 | < | tol = smallDiag * 1E-6; |
225 | > | r10 = a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0]; |
226 | > | r11 = a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1]; |
227 | > | r12 = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2]; |
228 | > | |
229 | > | r20 = a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0]; |
230 | > | r21 = a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1]; |
231 | > | r22 = a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2]; |
232 | > | |
233 | > | c[0][0] = r00; c[0][1] = r01; c[0][2] = r02; |
234 | > | c[1][0] = r10; c[1][1] = r11; c[1][2] = r12; |
235 | > | c[2][0] = r20; c[2][1] = r21; c[2][2] = r22; |
236 | > | } |
237 | ||
238 | < | orthoRhombic = 1; |
239 | < | for(i=0; (i<9) && orthoRhombic; i++){ |
240 | < | |
241 | < | if( (i%4) ){ // ignore the diagonals (0, 4, and 8) |
242 | < | orthoRhombic = (Hmat[i] <= tol); |
238 | > | void SimInfo::matVecMul3(double m[3][3], double inVec[3], double outVec[3]) { |
239 | > | double a0, a1, a2; |
240 | > | |
241 | > | a0 = inVec[0]; a1 = inVec[1]; a2 = inVec[2]; |
242 | > | |
243 | > | outVec[0] = m[0][0]*a0 + m[0][1]*a1 + m[0][2]*a2; |
244 | > | outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
245 | > | outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
246 | > | } |
247 | > | |
248 | > | void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
249 | > | double temp[3][3]; |
250 | > | int i, j; |
251 | > | |
252 | > | for (i = 0; i < 3; i++) { |
253 | > | for (j = 0; j < 3; j++) { |
254 | > | temp[j][i] = in[i][j]; |
255 | } | |
256 | } | |
257 | < | |
257 | > | for (i = 0; i < 3; i++) { |
258 | > | for (j = 0; j < 3; j++) { |
259 | > | out[i][j] = temp[i][j]; |
260 | > | } |
261 | > | } |
262 | } | |
263 | + | |
264 | + | void SimInfo::printMat3(double A[3][3] ){ |
265 | ||
266 | + | std::cerr |
267 | + | << "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
268 | + | << "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
269 | + | << "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
270 | + | } |
271 | + | |
272 | + | void SimInfo::printMat9(double A[9] ){ |
273 | + | |
274 | + | std::cerr |
275 | + | << "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
276 | + | << "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
277 | + | << "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
278 | + | } |
279 | + | |
280 | void SimInfo::calcBoxL( void ){ | |
281 | ||
282 | double dx, dy, dz, dsq; | |
283 | int i; | |
284 | ||
285 | < | // boxVol = h1 (dot) h2 (cross) h3 |
285 | > | // boxVol = Determinant of Hmat |
286 | ||
287 | < | boxVol = Hmat[0] * ( (Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]) ) |
233 | < | + Hmat[1] * ( (Hmat[5]*Hmat[6]) - (Hmat[8]*Hmat[3]) ) |
234 | < | + Hmat[2] * ( (Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]) ); |
287 | > | boxVol = matDet3( Hmat ); |
288 | ||
236 | – | |
289 | // boxLx | |
290 | ||
291 | < | dx = Hmat[0]; dy = Hmat[1]; dz = Hmat[2]; |
291 | > | dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
292 | dsq = dx*dx + dy*dy + dz*dz; | |
293 | < | boxLx = sqrt( dsq ); |
293 | > | boxL[0] = sqrt( dsq ); |
294 | > | maxCutoff = 0.5 * boxL[0]; |
295 | ||
296 | // boxLy | |
297 | ||
298 | < | dx = Hmat[3]; dy = Hmat[4]; dz = Hmat[5]; |
298 | > | dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
299 | dsq = dx*dx + dy*dy + dz*dz; | |
300 | < | boxLy = sqrt( dsq ); |
300 | > | boxL[1] = sqrt( dsq ); |
301 | > | if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
302 | ||
303 | // boxLz | |
304 | ||
305 | < | dx = Hmat[6]; dy = Hmat[7]; dz = Hmat[8]; |
305 | > | dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
306 | dsq = dx*dx + dy*dy + dz*dz; | |
307 | < | boxLz = sqrt( dsq ); |
307 | > | boxL[2] = sqrt( dsq ); |
308 | > | if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
309 | ||
310 | + | checkCutOffs(); |
311 | + | |
312 | } | |
313 | ||
314 | ||
# | Line 262 | Line 319 | void SimInfo::wrapVector( double thePos[3] ){ | |
319 | ||
320 | if( !orthoRhombic ){ | |
321 | // calc the scaled coordinates. | |
322 | + | |
323 | + | |
324 | + | matVecMul3(HmatInv, thePos, scaled); |
325 | ||
326 | for(i=0; i<3; i++) | |
267 | – | scaled[i] = |
268 | – | thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6]; |
269 | – | |
270 | – | // wrap the scaled coordinates |
271 | – | |
272 | – | for(i=0; i<3; i++) |
327 | scaled[i] -= roundMe(scaled[i]); | |
328 | ||
329 | // calc the wrapped real coordinates from the wrapped scaled coordinates | |
330 | ||
331 | < | for(i=0; i<3; i++) |
332 | < | thePos[i] = |
279 | < | scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6]; |
331 | > | matVecMul3(Hmat, scaled, thePos); |
332 | > | |
333 | } | |
334 | else{ | |
335 | // calc the scaled coordinates. | |
336 | ||
337 | for(i=0; i<3; i++) | |
338 | < | scaled[i] = thePos[i]*HmatI[i*4]; |
338 | > | scaled[i] = thePos[i]*HmatInv[i][i]; |
339 | ||
340 | // wrap the scaled coordinates | |
341 | ||
# | Line 292 | Line 345 | void SimInfo::wrapVector( double thePos[3] ){ | |
345 | // calc the wrapped real coordinates from the wrapped scaled coordinates | |
346 | ||
347 | for(i=0; i<3; i++) | |
348 | < | thePos[i] = scaled[i]*Hmat[i*4]; |
348 | > | thePos[i] = scaled[i]*Hmat[i][i]; |
349 | } | |
350 | ||
298 | – | |
351 | } | |
352 | ||
353 | ||
# | Line 336 | Line 388 | void SimInfo::refreshSim(){ | |
388 | int isError; | |
389 | int n_global; | |
390 | int* excl; | |
391 | < | |
340 | < | fInfo.rrf = 0.0; |
341 | < | fInfo.rt = 0.0; |
391 | > | |
392 | fInfo.dielect = 0.0; | |
393 | ||
344 | – | fInfo.rlist = rList; |
345 | – | fInfo.rcut = rCut; |
346 | – | |
394 | if( useDipole ){ | |
348 | – | fInfo.rrf = ecr; |
349 | – | fInfo.rt = ecr - est; |
395 | if( useReactionField )fInfo.dielect = dielectric; | |
396 | } | |
397 | ||
# | Line 392 | Line 437 | void SimInfo::refreshSim(){ | |
437 | ||
438 | this->ndf = this->getNDF(); | |
439 | this->ndfRaw = this->getNDFraw(); | |
440 | + | |
441 | + | } |
442 | + | |
443 | + | |
444 | + | void SimInfo::setRcut( double theRcut ){ |
445 | + | |
446 | + | if( !haveOrigRcut ){ |
447 | + | haveOrigRcut = 1; |
448 | + | origRcut = theRcut; |
449 | + | } |
450 | + | |
451 | + | rCut = theRcut; |
452 | + | checkCutOffs(); |
453 | + | } |
454 | + | |
455 | + | void SimInfo::setEcr( double theEcr ){ |
456 | + | |
457 | + | if( !haveOrigEcr ){ |
458 | + | haveOrigEcr = 1; |
459 | + | origEcr = theEcr; |
460 | + | } |
461 | + | |
462 | + | ecr = theEcr; |
463 | + | checkCutOffs(); |
464 | + | } |
465 | + | |
466 | + | void SimInfo::setEcr( double theEcr, double theEst ){ |
467 | + | |
468 | + | est = theEst; |
469 | + | setEcr( theEcr ); |
470 | + | } |
471 | + | |
472 | + | |
473 | + | void SimInfo::checkCutOffs( void ){ |
474 | + | |
475 | + | int cutChanged = 0; |
476 | ||
477 | + | |
478 | + | |
479 | + | if( boxIsInit ){ |
480 | + | |
481 | + | //we need to check cutOffs against the box |
482 | + | |
483 | + | if(( maxCutoff > rCut )&&(usePBC)){ |
484 | + | if( rCut < origRcut ){ |
485 | + | rCut = origRcut; |
486 | + | if (rCut > maxCutoff) rCut = maxCutoff; |
487 | + | |
488 | + | sprintf( painCave.errMsg, |
489 | + | "New Box size is setting the long range cutoff radius " |
490 | + | "to %lf\n", |
491 | + | rCut ); |
492 | + | painCave.isFatal = 0; |
493 | + | simError(); |
494 | + | } |
495 | + | } |
496 | + | |
497 | + | if( maxCutoff > ecr ){ |
498 | + | if( ecr < origEcr ){ |
499 | + | rCut = origEcr; |
500 | + | if (ecr > maxCutoff) ecr = maxCutoff; |
501 | + | |
502 | + | sprintf( painCave.errMsg, |
503 | + | "New Box size is setting the electrostaticCutoffRadius " |
504 | + | "to %lf\n", |
505 | + | ecr ); |
506 | + | painCave.isFatal = 0; |
507 | + | simError(); |
508 | + | } |
509 | + | } |
510 | + | |
511 | + | |
512 | + | if ((rCut > maxCutoff)&&(usePBC)) { |
513 | + | sprintf( painCave.errMsg, |
514 | + | "New Box size is setting the long range cutoff radius " |
515 | + | "to %lf\n", |
516 | + | maxCutoff ); |
517 | + | painCave.isFatal = 0; |
518 | + | simError(); |
519 | + | rCut = maxCutoff; |
520 | + | } |
521 | + | |
522 | + | if( ecr > maxCutoff){ |
523 | + | sprintf( painCave.errMsg, |
524 | + | "New Box size is setting the electrostaticCutoffRadius " |
525 | + | "to %lf\n", |
526 | + | maxCutoff ); |
527 | + | painCave.isFatal = 0; |
528 | + | simError(); |
529 | + | ecr = maxCutoff; |
530 | + | } |
531 | + | |
532 | + | |
533 | + | } |
534 | + | |
535 | + | |
536 | + | if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
537 | + | |
538 | + | // rlist is the 1.0 plus max( rcut, ecr ) |
539 | + | |
540 | + | ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
541 | + | |
542 | + | if( cutChanged ){ |
543 | + | |
544 | + | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
545 | + | } |
546 | + | |
547 | + | oldEcr = ecr; |
548 | + | oldRcut = rCut; |
549 | } | |
550 | ||
551 | + | void SimInfo::addProperty(GenericData* prop){ |
552 | + | |
553 | + | map<string, GenericData*>::iterator result; |
554 | + | result = properties.find(prop->getID()); |
555 | + | |
556 | + | //we can't simply use properties[prop->getID()] = prop, |
557 | + | //it will cause memory leak if we already contain a propery which has the same name of prop |
558 | + | |
559 | + | if(result != properties.end()){ |
560 | + | |
561 | + | delete (*result).second; |
562 | + | (*result).second = prop; |
563 | + | |
564 | + | } |
565 | + | else{ |
566 | + | |
567 | + | properties[prop->getID()] = prop; |
568 | + | |
569 | + | } |
570 | + | |
571 | + | } |
572 | + | |
573 | + | GenericData* SimInfo::getProperty(const string& propName){ |
574 | + | |
575 | + | map<string, GenericData*>::iterator result; |
576 | + | |
577 | + | //string lowerCaseName = (); |
578 | + | |
579 | + | result = properties.find(propName); |
580 | + | |
581 | + | if(result != properties.end()) |
582 | + | return (*result).second; |
583 | + | else |
584 | + | return NULL; |
585 | + | } |
586 | + | |
587 | + | vector<GenericData*> SimInfo::getProperties(){ |
588 | + | |
589 | + | vector<GenericData*> result; |
590 | + | map<string, GenericData*>::iterator i; |
591 | + | |
592 | + | for(i = properties.begin(); i != properties.end(); i++) |
593 | + | result.push_back((*i).second); |
594 | + | |
595 | + | return result; |
596 | + | } |
597 | + | |
598 | + |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |