ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new-templateless/OOPSE/libmdtools/SimInfo.cpp
(Generate patch)

Comparing:
trunk/OOPSE/libmdtools/SimInfo.cpp (file contents), Revision 586 by mmeineke, Wed Jul 9 22:14:06 2003 UTC vs.
branches/new-templateless/OOPSE/libmdtools/SimInfo.cpp (file contents), Revision 852 by mmeineke, Thu Nov 6 18:20:47 2003 UTC

# Line 1 | Line 1
1 < #include <cstdlib>
2 < #include <cstring>
3 < #include <cmath>
1 > #include <stdlib.h>
2 > #include <string.h>
3 > #include <math.h>
4  
5   #include <iostream>
6   using namespace std;
# Line 26 | Line 26 | SimInfo::SimInfo(){
26   SimInfo::SimInfo(){
27    excludes = NULL;
28    n_constraints = 0;
29 +  nZconstraints = 0;
30    n_oriented = 0;
31    n_dipoles = 0;
32    ndf = 0;
33    ndfRaw = 0;
34 +  nZconstraints = 0;
35    the_integrator = NULL;
36    setTemp = 0;
37    thermalTime = 0.0;
38 +  currentTime = 0.0;
39    rCut = 0.0;
40 +  origRcut = -1.0;
41 +  ecr = 0.0;
42 +  origEcr = -1.0;
43 +  est = 0.0;
44 +  oldEcr = 0.0;
45 +  oldRcut = 0.0;
46  
47 +  haveOrigRcut = 0;
48 +  haveOrigEcr = 0;
49 +  boxIsInit = 0;
50 +  
51 +  resetTime = 1e99;
52 +  
53 +
54    usePBC = 0;
55    useLJ = 0;
56    useSticky = 0;
# Line 43 | Line 59 | SimInfo::SimInfo(){
59    useGB = 0;
60    useEAM = 0;
61  
62 +  myConfiguration = new SimState();
63 +
64 +  properties = new GenericData();
65 +
66    wrapMeSimInfo( this );
67   }
68  
69 +
70 + SimInfo::~SimInfo(){
71 +
72 +  delete myConfiguration;
73 +  delete properties;    
74 + }
75 +
76   void SimInfo::setBox(double newBox[3]) {
77    
78 <  int i;
79 <  double tempMat[9];
78 >  int i, j;
79 >  double tempMat[3][3];
80  
81 <  for(i=0; i<9; i++) tempMat[i] = 0.0;;
81 >  for(i=0; i<3; i++)
82 >    for (j=0; j<3; j++) tempMat[i][j] = 0.0;;
83  
84 <  tempMat[0] = newBox[0];
85 <  tempMat[4] = newBox[1];
86 <  tempMat[8] = newBox[2];
84 >  tempMat[0][0] = newBox[0];
85 >  tempMat[1][1] = newBox[1];
86 >  tempMat[2][2] = newBox[2];
87  
88    setBoxM( tempMat );
89  
90   }
91  
92 < void SimInfo::setBoxM( double theBox[9] ){
92 > void SimInfo::setBoxM( double theBox[3][3] ){
93    
94 <  int i, status;
95 <  double smallestBoxL, maxCutoff;
94 >  int i, j;
95 >  double FortranHmat[9]; // to preserve compatibility with Fortran the
96 >                         // ordering in the array is as follows:
97 >                         // [ 0 3 6 ]
98 >                         // [ 1 4 7 ]
99 >                         // [ 2 5 8 ]
100 >  double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
101  
102 <  for(i=0; i<9; i++) Hmat[i] = theBox[i];
102 >  
103 >  if( !boxIsInit ) boxIsInit = 1;
104  
105 <  cerr
106 <    << "setting Hmat ->\n"
107 <    << "[ " << 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();
105 >  for(i=0; i < 3; i++)
106 >    for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j];
107 >  
108    calcBoxL();
109 +  calcHmatInv();
110  
111 <
112 <
113 <  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
114 <
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();
111 >  for(i=0; i < 3; i++) {
112 >    for (j=0; j < 3; j++) {
113 >      FortranHmat[3*j + i] = Hmat[i][j];
114 >      FortranHmatInv[3*j + i] = HmatInv[i][j];
115      }
116    }
117 +
118 +  setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic);
119 +
120   }
121  
122  
123 < void SimInfo::getBoxM (double theBox[9]) {
123 > void SimInfo::getBoxM (double theBox[3][3]) {
124  
125 <  int i;
126 <  for(i=0; i<9; i++) theBox[i] = Hmat[i];
125 >  int i, j;
126 >  for(i=0; i<3; i++)
127 >    for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j];
128   }
129  
130  
131   void SimInfo::scaleBox(double scale) {
132 <  double theBox[9];
133 <  int i;
132 >  double theBox[3][3];
133 >  int i, j;
134  
135 <  cerr << "Scaling box by " << scale << "\n";
135 >  // cerr << "Scaling box by " << scale << "\n";
136  
137 <  for(i=0; i<9; i++) theBox[i] = Hmat[i]*scale;
137 >  for(i=0; i<3; i++)
138 >    for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale;
139  
140    setBoxM(theBox);
141  
142   }
143  
144 < void SimInfo::calcHmatI( void ) {
144 > void SimInfo::calcHmatInv( void ) {
145  
146 <  double C[3][3];
147 <  double detHmat;
153 <  int i, j, k;
146 >  int oldOrtho;
147 >  int i,j;
148    double smallDiag;
149    double tol;
150    double sanity[3][3];
151  
152 <  // calculate the adjunct of Hmat;
152 >  invertMat3( Hmat, HmatInv );
153  
154 <  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]);
163 <
164 <  C[0][1] = -( Hmat[3]*Hmat[8]) + (Hmat[6]*Hmat[5]);
165 <  C[1][1] =  ( Hmat[0]*Hmat[8]) - (Hmat[6]*Hmat[2]);
166 <  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
173 <  
174 <  detHmat = 0.0;
175 <  for(i=0; i<3; i++) detHmat += Hmat[i] * C[i][0];
154 >  // Check the inverse to make sure it is sane:
155  
156 +  // matMul3( Hmat, HmatInv, sanity );
157 +    
158 +  // check to see if Hmat is orthorhombic
159 +
160    
161 <  // H^-1 = C^T / det(H)
179 <  
180 <  i=0;
181 <  for(j=0; j<3; j++){
182 <    for(k=0; k<3; k++){
161 >  oldOrtho = orthoRhombic;
162  
163 <      HmatI[i] = C[j][k] / detHmat;
164 <      i++;
163 >  smallDiag = fabs(Hmat[0][0]);
164 >  if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]);
165 >  if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]);
166 >  tol = smallDiag * 1E-6;
167 >
168 >  orthoRhombic = 1;
169 >  
170 >  for (i = 0; i < 3; i++ ) {
171 >    for (j = 0 ; j < 3; j++) {
172 >      if (i != j) {
173 >        if (orthoRhombic) {
174 >          if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0;
175 >        }        
176 >      }
177      }
178    }
179 +  
180 +  if( oldOrtho != orthoRhombic ){
181 +    
182 +    if( orthoRhombic ){
183 +      sprintf( painCave.errMsg,
184 +               "Hmat is switching from Non-Orthorhombic to OrthoRhombic\n"
185 +               "       If this is a bad thing change the ortho tolerance in SimInfo.\n" );
186 +      simError();
187 +    }
188 +    else {
189 +      sprintf( painCave.errMsg,
190 +               "Hmat is switching from Orthorhombic to Non-OrthoRhombic\n"
191 +               "       If this is a bad thing change the ortho tolerance in SimInfo.\n" );
192 +      simError();
193 +    }
194 +  }
195 + }
196  
197 <  // sanity check
197 > double SimInfo::matDet3(double a[3][3]) {
198 >  int i, j, k;
199 >  double determinant;
200  
201 <  for(i=0; i<3; i++){
202 <    for(j=0; j<3; j++){
203 <      
204 <      sanity[i][j] = 0.0;
205 <      for(k=0; k<3; k++){
206 <        sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k];
207 <      }
198 <    }
201 >  determinant = 0.0;
202 >
203 >  for(i = 0; i < 3; i++) {
204 >    j = (i+1)%3;
205 >    k = (i+2)%3;
206 >
207 >    determinant += a[0][i] * (a[1][j]*a[2][k] - a[1][k]*a[2][j]);
208    }
209  
210 <  cerr << "sanity => \n"
211 <       << 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 <    
210 >  return determinant;
211 > }
212  
213 <  // check to see if Hmat is orthorhombic
213 > void SimInfo::invertMat3(double a[3][3], double b[3][3]) {
214    
215 <  smallDiag = Hmat[0];
216 <  if(smallDiag > Hmat[4]) smallDiag = Hmat[4];
212 <  if(smallDiag > Hmat[8]) smallDiag = Hmat[8];
213 <  tol = smallDiag * 1E-6;
215 >  int  i, j, k, l, m, n;
216 >  double determinant;
217  
218 <  orthoRhombic = 1;
219 <  for(i=0; (i<9) && orthoRhombic; i++){
220 <    
221 <    if( (i%4) ){ // ignore the diagonals (0, 4, and 8)
222 <      orthoRhombic = (Hmat[i] <= tol);
218 >  determinant = matDet3( a );
219 >
220 >  if (determinant == 0.0) {
221 >    sprintf( painCave.errMsg,
222 >             "Can't invert a matrix with a zero determinant!\n");
223 >    painCave.isFatal = 1;
224 >    simError();
225 >  }
226 >
227 >  for (i=0; i < 3; i++) {
228 >    j = (i+1)%3;
229 >    k = (i+2)%3;
230 >    for(l = 0; l < 3; l++) {
231 >      m = (l+1)%3;
232 >      n = (l+2)%3;
233 >      
234 >      b[l][i] = (a[j][m]*a[k][n] - a[j][n]*a[k][m]) / determinant;
235      }
236    }
222    
237   }
238  
239 < void SimInfo::calcBoxL( void ){
239 > void SimInfo::matMul3(double a[3][3], double b[3][3], double c[3][3]) {
240 >  double r00, r01, r02, r10, r11, r12, r20, r21, r22;
241  
242 <  double dx, dy, dz, dsq;
243 <  int i;
242 >  r00 = a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0];
243 >  r01 = a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1];
244 >  r02 = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2];
245 >  
246 >  r10 = a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0];
247 >  r11 = a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1];
248 >  r12 = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2];
249 >  
250 >  r20 = a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0];
251 >  r21 = a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1];
252 >  r22 = a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2];
253 >  
254 >  c[0][0] = r00; c[0][1] = r01; c[0][2] = r02;
255 >  c[1][0] = r10; c[1][1] = r11; c[1][2] = r12;
256 >  c[2][0] = r20; c[2][1] = r21; c[2][2] = r22;
257 > }
258  
259 <  // boxVol = h1 (dot) h2 (cross) h3
259 > void SimInfo::matVecMul3(double m[3][3], double inVec[3], double outVec[3]) {
260 >  double a0, a1, a2;
261  
262 <  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]) );
262 >  a0 = inVec[0];  a1 = inVec[1];  a2 = inVec[2];
263  
264 +  outVec[0] = m[0][0]*a0 + m[0][1]*a1 + m[0][2]*a2;
265 +  outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2;
266 +  outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2;
267 + }
268  
269 <  // boxLx
270 <  
271 <  dx = Hmat[0]; dy = Hmat[1]; dz = Hmat[2];
269 > void SimInfo::transposeMat3(double in[3][3], double out[3][3]) {
270 >  double temp[3][3];
271 >  int i, j;
272 >
273 >  for (i = 0; i < 3; i++) {
274 >    for (j = 0; j < 3; j++) {
275 >      temp[j][i] = in[i][j];
276 >    }
277 >  }
278 >  for (i = 0; i < 3; i++) {
279 >    for (j = 0; j < 3; j++) {
280 >      out[i][j] = temp[i][j];
281 >    }
282 >  }
283 > }
284 >  
285 > void SimInfo::printMat3(double A[3][3] ){
286 >
287 >  std::cerr
288 >            << "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n"
289 >            << "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n"
290 >            << "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n";
291 > }
292 >
293 > void SimInfo::printMat9(double A[9] ){
294 >
295 >  std::cerr
296 >            << "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n"
297 >            << "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n"
298 >            << "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n";
299 > }
300 >
301 >
302 > void SimInfo::crossProduct3(double a[3],double b[3], double out[3]){
303 >
304 >      out[0] = a[1] * b[2] - a[2] * b[1];
305 >      out[1] = a[2] * b[0] - a[0] * b[2] ;
306 >      out[2] = a[0] * b[1] - a[1] * b[0];
307 >      
308 > }
309 >
310 > double SimInfo::dotProduct3(double a[3], double b[3]){
311 >  return a[0]*b[0] + a[1]*b[1]+ a[2]*b[2];
312 > }
313 >
314 > double SimInfo::length3(double a[3]){
315 >  return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
316 > }
317 >
318 > void SimInfo::calcBoxL( void ){
319 >
320 >  double dx, dy, dz, dsq;
321 >
322 >  // boxVol = Determinant of Hmat
323 >
324 >  boxVol = matDet3( Hmat );
325 >
326 >  // boxLx
327 >  
328 >  dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
329    dsq = dx*dx + dy*dy + dz*dz;
330 <  boxLx = sqrt( dsq );
330 >  boxL[0] = sqrt( dsq );
331 >  //maxCutoff = 0.5 * boxL[0];
332  
333    // boxLy
334    
335 <  dx = Hmat[3]; dy = Hmat[4]; dz = Hmat[5];
335 >  dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
336    dsq = dx*dx + dy*dy + dz*dz;
337 <  boxLy = sqrt( dsq );
337 >  boxL[1] = sqrt( dsq );
338 >  //if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
339  
340 +
341    // boxLz
342    
343 <  dx = Hmat[6]; dy = Hmat[7]; dz = Hmat[8];
343 >  dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
344    dsq = dx*dx + dy*dy + dz*dz;
345 <  boxLz = sqrt( dsq );
345 >  boxL[2] = sqrt( dsq );
346 >  //if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
347 >
348 >  //calculate the max cutoff
349 >  maxCutoff =  calcMaxCutOff();
350    
351 +  checkCutOffs();
352 +
353   }
354  
355  
356 + double SimInfo::calcMaxCutOff(){
357 +
358 +  double ri[3], rj[3], rk[3];
359 +  double rij[3], rjk[3], rki[3];
360 +  double minDist;
361 +
362 +  ri[0] = Hmat[0][0];
363 +  ri[1] = Hmat[1][0];
364 +  ri[2] = Hmat[2][0];
365 +
366 +  rj[0] = Hmat[0][1];
367 +  rj[1] = Hmat[1][1];
368 +  rj[2] = Hmat[2][1];
369 +
370 +  rk[0] = Hmat[0][2];
371 +  rk[1] = Hmat[1][2];
372 +  rk[2] = Hmat[2][2];
373 +  
374 +  crossProduct3(ri,rj, rij);
375 +  distXY = dotProduct3(rk,rij) / length3(rij);
376 +
377 +  crossProduct3(rj,rk, rjk);
378 +  distYZ = dotProduct3(ri,rjk) / length3(rjk);
379 +
380 +  crossProduct3(rk,ri, rki);
381 +  distZX = dotProduct3(rj,rki) / length3(rki);
382 +
383 +  minDist = min(min(distXY, distYZ), distZX);
384 +  return minDist/2;
385 +  
386 + }
387 +
388   void SimInfo::wrapVector( double thePos[3] ){
389  
390 <  int i, j, k;
390 >  int i;
391    double scaled[3];
392  
393    if( !orthoRhombic ){
394      // calc the scaled coordinates.
395 +  
396 +
397 +    matVecMul3(HmatInv, thePos, scaled);
398      
399      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++)
400        scaled[i] -= roundMe(scaled[i]);
401      
402      // calc the wrapped real coordinates from the wrapped scaled coordinates
403      
404 <    for(i=0; i<3; i++)
405 <      thePos[i] =
279 <        scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6];
404 >    matVecMul3(Hmat, scaled, thePos);
405 >
406    }
407    else{
408      // calc the scaled coordinates.
409      
410      for(i=0; i<3; i++)
411 <      scaled[i] = thePos[i]*HmatI[i*4];
411 >      scaled[i] = thePos[i]*HmatInv[i][i];
412      
413      // wrap the scaled coordinates
414      
# Line 292 | Line 418 | void SimInfo::wrapVector( double thePos[3] ){
418      // calc the wrapped real coordinates from the wrapped scaled coordinates
419      
420      for(i=0; i<3; i++)
421 <      thePos[i] = scaled[i]*Hmat[i*4];
421 >      thePos[i] = scaled[i]*Hmat[i][i];
422    }
423      
298    
424   }
425  
426  
427   int SimInfo::getNDF(){
428 <  int ndf_local, ndf;
428 >  int ndf_local;
429    
430    ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints;
431  
# Line 310 | Line 435 | int SimInfo::getNDF(){
435    ndf = ndf_local;
436   #endif
437  
438 <  ndf = ndf - 3;
438 >  ndf = ndf - 3 - nZconstraints;
439  
440    return ndf;
441   }
442  
443   int SimInfo::getNDFraw() {
444 <  int ndfRaw_local, ndfRaw;
444 >  int ndfRaw_local;
445  
446    // Raw degrees of freedom that we have to set
447    ndfRaw_local = 3 * n_atoms + 3 * n_oriented;
# Line 329 | Line 454 | int SimInfo::getNDFraw() {
454  
455    return ndfRaw;
456   }
457 <
457 >
458 > int SimInfo::getNDFtranslational() {
459 >  int ndfTrans_local;
460 >
461 >  ndfTrans_local = 3 * n_atoms - n_constraints;
462 >
463 > #ifdef IS_MPI
464 >  MPI_Allreduce(&ndfTrans_local,&ndfTrans,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
465 > #else
466 >  ndfTrans = ndfTrans_local;
467 > #endif
468 >
469 >  ndfTrans = ndfTrans - 3 - nZconstraints;
470 >
471 >  return ndfTrans;
472 > }
473 >
474   void SimInfo::refreshSim(){
475  
476    simtype fInfo;
477    int isError;
478    int n_global;
479    int* excl;
480 <  
340 <  fInfo.rrf = 0.0;
341 <  fInfo.rt = 0.0;
480 >
481    fInfo.dielect = 0.0;
482  
344  fInfo.rlist = rList;
345  fInfo.rcut = rCut;
346
483    if( useDipole ){
348    fInfo.rrf = ecr;
349    fInfo.rt = ecr - est;
484      if( useReactionField )fInfo.dielect = dielectric;
485    }
486  
# Line 392 | Line 526 | void SimInfo::refreshSim(){
526  
527    this->ndf = this->getNDF();
528    this->ndfRaw = this->getNDFraw();
529 +  this->ndfTrans = this->getNDFtranslational();
530 + }
531  
532 +
533 + void SimInfo::setRcut( double theRcut ){
534 +
535 +  rCut = theRcut;
536 +  checkCutOffs();
537   }
538  
539 + void SimInfo::setDefaultRcut( double theRcut ){
540 +
541 +  haveOrigRcut = 1;
542 +  origRcut = theRcut;
543 +  rCut = theRcut;
544 +
545 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
546 +
547 +  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
548 + }
549 +
550 + void SimInfo::setEcr( double theEcr ){
551 +
552 +  ecr = theEcr;
553 +  checkCutOffs();
554 + }
555 +
556 + void SimInfo::setDefaultEcr( double theEcr ){
557 +
558 +  haveOrigEcr = 1;
559 +  origEcr = theEcr;
560 +  
561 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
562 +
563 +  ecr = theEcr;
564 +
565 +  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
566 + }
567 +
568 + void SimInfo::setEcr( double theEcr, double theEst ){
569 +
570 +  est = theEst;
571 +  setEcr( theEcr );
572 + }
573 +
574 + void SimInfo::setDefaultEcr( double theEcr, double theEst ){
575 +
576 +  est = theEst;
577 +  setDefaultEcr( theEcr );
578 + }
579 +
580 +
581 + void SimInfo::checkCutOffs( void ){
582 +
583 +  int cutChanged = 0;
584 +  
585 +  if( boxIsInit ){
586 +    
587 +    //we need to check cutOffs against the box
588 +
589 +    //detect the change of rCut
590 +    if(( maxCutoff > rCut )&&(usePBC)){
591 +      if( rCut < origRcut ){
592 +        rCut = origRcut;
593 +        
594 +        if (rCut > maxCutoff)
595 +          rCut = maxCutoff;
596 +  
597 +          sprintf( painCave.errMsg,
598 +                    "New Box size is setting the long range cutoff radius "
599 +                    "to %lf at time %lf\n",
600 +                    rCut, currentTime );
601 +          painCave.isFatal = 0;
602 +          simError();
603 +      }
604 +    }
605 +    else if ((rCut > maxCutoff)&&(usePBC)) {
606 +      sprintf( painCave.errMsg,
607 +               "New Box size is setting the long range cutoff radius "
608 +               "to %lf at time %lf\n",
609 +               maxCutoff, currentTime );
610 +      painCave.isFatal = 0;
611 +      simError();
612 +      rCut = maxCutoff;
613 +    }
614 +
615 +
616 +    //detect the change of ecr
617 +    if( maxCutoff > ecr ){
618 +      if( ecr < origEcr ){
619 +        ecr = origEcr;
620 +        if (ecr > maxCutoff) ecr = maxCutoff;
621 +  
622 +          sprintf( painCave.errMsg,
623 +                    "New Box size is setting the electrostaticCutoffRadius "
624 +                    "to %lf at time %lf\n",
625 +                    ecr, currentTime );
626 +            painCave.isFatal = 0;
627 +            simError();
628 +      }
629 +    }
630 +    else if( ecr > maxCutoff){
631 +      sprintf( painCave.errMsg,
632 +               "New Box size is setting the electrostaticCutoffRadius "
633 +               "to %lf at time %lf\n",
634 +               maxCutoff, currentTime  );
635 +      painCave.isFatal = 0;
636 +      simError();      
637 +      ecr = maxCutoff;
638 +    }
639 +
640 +    if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1;
641 +    
642 +    // rlist is the 1.0 plus max( rcut, ecr )
643 +    
644 +    ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
645 +    
646 +    if( cutChanged ){
647 +      notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
648 +    }
649 +    
650 +    oldEcr = ecr;
651 +    oldRcut = rCut;
652 +    
653 +  } else {
654 +    // initialize this stuff before using it, OK?
655 +    sprintf( painCave.errMsg,
656 +             "Trying to check cutoffs without a box. Be smarter.\n" );
657 +    painCave.isFatal = 1;
658 +    simError();      
659 +  }
660 +  
661 + }
662 +
663 + GenericData* SimInfo::getProperty(char* propName){
664 +
665 +  return properties->find( propName );
666 + }
667 +
668 + double SimInfo::matTrace3(double m[3][3]){
669 +  double trace;
670 +  trace = m[0][0] + m[1][1] + m[2][2];
671 +
672 +  return trace;
673 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines