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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines