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