| 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; | 
| 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; | 
| 59 | 
  | 
  useGB = 0; | 
| 60 | 
  | 
  useEAM = 0; | 
| 61 | 
  | 
 | 
| 62 | 
+ | 
  myConfiguration = new SimState(); | 
| 63 | 
+ | 
 | 
| 64 | 
  | 
  wrapMeSimInfo( this ); | 
| 65 | 
  | 
} | 
| 66 | 
  | 
 | 
| 67 | 
+ | 
 | 
| 68 | 
+ | 
SimInfo::~SimInfo(){ | 
| 69 | 
+ | 
 | 
| 70 | 
+ | 
  delete myConfiguration; | 
| 71 | 
+ | 
 | 
| 72 | 
+ | 
  map<string, GenericData*>::iterator i; | 
| 73 | 
+ | 
   | 
| 74 | 
+ | 
  for(i = properties.begin(); i != properties.end(); i++) | 
| 75 | 
+ | 
    delete (*i).second; | 
| 76 | 
+ | 
     | 
| 77 | 
+ | 
} | 
| 78 | 
+ | 
 | 
| 79 | 
  | 
void SimInfo::setBox(double newBox[3]) { | 
| 80 | 
  | 
   | 
| 81 | 
  | 
  int i, j; | 
| 94 | 
  | 
 | 
| 95 | 
  | 
void SimInfo::setBoxM( double theBox[3][3] ){ | 
| 96 | 
  | 
   | 
| 97 | 
< | 
  int i, j, status; | 
| 70 | 
< | 
  double smallestBoxL, maxCutoff; | 
| 97 | 
> | 
  int i, j; | 
| 98 | 
  | 
  double FortranHmat[9]; // to preserve compatibility with Fortran the | 
| 99 | 
  | 
                         // ordering in the array is as follows: | 
| 100 | 
  | 
                         // [ 0 3 6 ] | 
| 102 | 
  | 
                         // [ 2 5 8 ] | 
| 103 | 
  | 
  double FortranHmatInv[9]; // the inverted Hmat (for Fortran); | 
| 104 | 
  | 
 | 
| 105 | 
+ | 
   | 
| 106 | 
+ | 
  if( !boxIsInit ) boxIsInit = 1; | 
| 107 | 
  | 
 | 
| 108 | 
  | 
  for(i=0; i < 3; i++)  | 
| 109 | 
  | 
    for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; | 
| 110 | 
  | 
   | 
| 82 | 
– | 
  //  cerr  | 
| 83 | 
– | 
  // << "setting Hmat ->\n" | 
| 84 | 
– | 
  // << "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n" | 
| 85 | 
– | 
  // << "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n" | 
| 86 | 
– | 
  // << "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n"; | 
| 87 | 
– | 
 | 
| 111 | 
  | 
  calcBoxL(); | 
| 112 | 
  | 
  calcHmatInv(); | 
| 113 | 
  | 
 | 
| 120 | 
  | 
 | 
| 121 | 
  | 
  setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); | 
| 122 | 
  | 
  | 
| 100 | 
– | 
  smallestBoxL = boxLx; | 
| 101 | 
– | 
  if (boxLy < smallestBoxL) smallestBoxL = boxLy; | 
| 102 | 
– | 
  if (boxLz < smallestBoxL) smallestBoxL = boxLz; | 
| 103 | 
– | 
 | 
| 104 | 
– | 
  maxCutoff = smallestBoxL / 2.0; | 
| 105 | 
– | 
 | 
| 106 | 
– | 
  if (rList > maxCutoff) { | 
| 107 | 
– | 
    sprintf( painCave.errMsg, | 
| 108 | 
– | 
             "New Box size is forcing neighborlist radius down to %lf\n", | 
| 109 | 
– | 
             maxCutoff ); | 
| 110 | 
– | 
    painCave.isFatal = 0; | 
| 111 | 
– | 
    simError(); | 
| 112 | 
– | 
 | 
| 113 | 
– | 
    rList = maxCutoff; | 
| 114 | 
– | 
 | 
| 115 | 
– | 
    sprintf( painCave.errMsg, | 
| 116 | 
– | 
             "New Box size is forcing cutoff radius down to %lf\n", | 
| 117 | 
– | 
             maxCutoff - 1.0 ); | 
| 118 | 
– | 
    painCave.isFatal = 0; | 
| 119 | 
– | 
    simError(); | 
| 120 | 
– | 
 | 
| 121 | 
– | 
    rCut = rList - 1.0; | 
| 122 | 
– | 
 | 
| 123 | 
– | 
    // list radius changed so we have to refresh the simulation structure. | 
| 124 | 
– | 
    refreshSim(); | 
| 125 | 
– | 
  } | 
| 126 | 
– | 
 | 
| 127 | 
– | 
  if( ecr > maxCutoff ){ | 
| 128 | 
– | 
 | 
| 129 | 
– | 
    sprintf( painCave.errMsg, | 
| 130 | 
– | 
             "New Box size is forcing electrostatic cutoff radius " | 
| 131 | 
– | 
             "down to %lf\n", | 
| 132 | 
– | 
             maxCutoff ); | 
| 133 | 
– | 
    painCave.isFatal = 0; | 
| 134 | 
– | 
    simError(); | 
| 135 | 
– | 
 | 
| 136 | 
– | 
    ecr = maxCutoff; | 
| 137 | 
– | 
    est = 0.05 * ecr; | 
| 138 | 
– | 
 | 
| 139 | 
– | 
    refreshSim(); | 
| 140 | 
– | 
  } | 
| 141 | 
– | 
     | 
| 123 | 
  | 
} | 
| 124 | 
  | 
  | 
| 125 | 
  | 
 | 
| 146 | 
  | 
 | 
| 147 | 
  | 
void SimInfo::calcHmatInv( void ) { | 
| 148 | 
  | 
   | 
| 149 | 
+ | 
  int oldOrtho; | 
| 150 | 
  | 
  int i,j; | 
| 151 | 
  | 
  double smallDiag; | 
| 152 | 
  | 
  double tol; | 
| 154 | 
  | 
 | 
| 155 | 
  | 
  invertMat3( Hmat, HmatInv ); | 
| 156 | 
  | 
 | 
| 175 | 
– | 
  // Check the inverse to make sure it is sane: | 
| 176 | 
– | 
 | 
| 177 | 
– | 
  matMul3( Hmat, HmatInv, sanity ); | 
| 178 | 
– | 
     | 
| 157 | 
  | 
  // check to see if Hmat is orthorhombic | 
| 158 | 
  | 
   | 
| 159 | 
< | 
  smallDiag = Hmat[0][0]; | 
| 160 | 
< | 
  if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; | 
| 161 | 
< | 
  if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; | 
| 159 | 
> | 
  oldOrtho = orthoRhombic; | 
| 160 | 
> | 
 | 
| 161 | 
> | 
  smallDiag = fabs(Hmat[0][0]); | 
| 162 | 
> | 
  if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]); | 
| 163 | 
> | 
  if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]); | 
| 164 | 
  | 
  tol = smallDiag * 1E-6; | 
| 165 | 
  | 
 | 
| 166 | 
  | 
  orthoRhombic = 1; | 
| 169 | 
  | 
    for (j = 0 ; j < 3; j++) { | 
| 170 | 
  | 
      if (i != j) { | 
| 171 | 
  | 
        if (orthoRhombic) { | 
| 172 | 
< | 
          if (Hmat[i][j] >= tol) orthoRhombic = 0; | 
| 172 | 
> | 
          if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0; | 
| 173 | 
  | 
        }         | 
| 174 | 
  | 
      } | 
| 175 | 
  | 
    } | 
| 176 | 
  | 
  } | 
| 177 | 
+ | 
 | 
| 178 | 
+ | 
  if( oldOrtho != orthoRhombic ){ | 
| 179 | 
+ | 
     | 
| 180 | 
+ | 
    if( orthoRhombic ){ | 
| 181 | 
+ | 
      sprintf( painCave.errMsg, | 
| 182 | 
+ | 
               "Hmat is switching from Non-Orthorhombic to OrthoRhombic\n" | 
| 183 | 
+ | 
               "       If this is a bad thing change the ortho tolerance in SimInfo.\n" ); | 
| 184 | 
+ | 
      simError(); | 
| 185 | 
+ | 
    } | 
| 186 | 
+ | 
    else { | 
| 187 | 
+ | 
      sprintf( painCave.errMsg, | 
| 188 | 
+ | 
               "Hmat is switching from Orthorhombic to Non-OrthoRhombic\n" | 
| 189 | 
+ | 
               "       If this is a bad thing change the ortho tolerance in SimInfo.\n" ); | 
| 190 | 
+ | 
      simError(); | 
| 191 | 
+ | 
    } | 
| 192 | 
+ | 
  } | 
| 193 | 
  | 
} | 
| 194 | 
  | 
 | 
| 195 | 
  | 
double SimInfo::matDet3(double a[3][3]) { | 
| 296 | 
  | 
            << "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; | 
| 297 | 
  | 
} | 
| 298 | 
  | 
 | 
| 299 | 
+ | 
 | 
| 300 | 
+ | 
void SimInfo::crossProduct3(double a[3],double b[3], double out[3]){ | 
| 301 | 
+ | 
 | 
| 302 | 
+ | 
      out[0] = a[1] * b[2] - a[2] * b[1]; | 
| 303 | 
+ | 
      out[1] = a[2] * b[0] - a[0] * b[2] ; | 
| 304 | 
+ | 
      out[2] = a[0] * b[1] - a[1] * b[0]; | 
| 305 | 
+ | 
       | 
| 306 | 
+ | 
} | 
| 307 | 
+ | 
 | 
| 308 | 
+ | 
double SimInfo::dotProduct3(double a[3], double b[3]){ | 
| 309 | 
+ | 
  return a[0]*b[0] + a[1]*b[1]+ a[2]*b[2]; | 
| 310 | 
+ | 
} | 
| 311 | 
+ | 
 | 
| 312 | 
+ | 
double SimInfo::length3(double a[3]){ | 
| 313 | 
+ | 
  return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]); | 
| 314 | 
+ | 
} | 
| 315 | 
+ | 
 | 
| 316 | 
  | 
void SimInfo::calcBoxL( void ){ | 
| 317 | 
  | 
 | 
| 318 | 
  | 
  double dx, dy, dz, dsq; | 
| 306 | 
– | 
  int i; | 
| 319 | 
  | 
 | 
| 320 | 
  | 
  // boxVol = Determinant of Hmat | 
| 321 | 
  | 
 | 
| 325 | 
  | 
   | 
| 326 | 
  | 
  dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; | 
| 327 | 
  | 
  dsq = dx*dx + dy*dy + dz*dz; | 
| 328 | 
< | 
  boxLx = sqrt( dsq ); | 
| 328 | 
> | 
  boxL[0] = sqrt( dsq ); | 
| 329 | 
> | 
  //maxCutoff = 0.5 * boxL[0]; | 
| 330 | 
  | 
 | 
| 331 | 
  | 
  // boxLy | 
| 332 | 
  | 
   | 
| 333 | 
  | 
  dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; | 
| 334 | 
  | 
  dsq = dx*dx + dy*dy + dz*dz; | 
| 335 | 
< | 
  boxLy = sqrt( dsq ); | 
| 335 | 
> | 
  boxL[1] = sqrt( dsq ); | 
| 336 | 
> | 
  //if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; | 
| 337 | 
  | 
 | 
| 338 | 
+ | 
 | 
| 339 | 
  | 
  // boxLz | 
| 340 | 
  | 
   | 
| 341 | 
  | 
  dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; | 
| 342 | 
  | 
  dsq = dx*dx + dy*dy + dz*dz; | 
| 343 | 
< | 
  boxLz = sqrt( dsq ); | 
| 343 | 
> | 
  boxL[2] = sqrt( dsq ); | 
| 344 | 
> | 
  //if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; | 
| 345 | 
> | 
 | 
| 346 | 
> | 
  //calculate the max cutoff | 
| 347 | 
> | 
  maxCutoff =  calcMaxCutOff();  | 
| 348 | 
  | 
   | 
| 349 | 
+ | 
  checkCutOffs(); | 
| 350 | 
+ | 
 | 
| 351 | 
  | 
} | 
| 352 | 
  | 
 | 
| 353 | 
  | 
 | 
| 354 | 
+ | 
double SimInfo::calcMaxCutOff(){ | 
| 355 | 
+ | 
 | 
| 356 | 
+ | 
  double ri[3], rj[3], rk[3]; | 
| 357 | 
+ | 
  double rij[3], rjk[3], rki[3]; | 
| 358 | 
+ | 
  double minDist; | 
| 359 | 
+ | 
 | 
| 360 | 
+ | 
  ri[0] = Hmat[0][0]; | 
| 361 | 
+ | 
  ri[1] = Hmat[1][0]; | 
| 362 | 
+ | 
  ri[2] = Hmat[2][0]; | 
| 363 | 
+ | 
 | 
| 364 | 
+ | 
  rj[0] = Hmat[0][1]; | 
| 365 | 
+ | 
  rj[1] = Hmat[1][1]; | 
| 366 | 
+ | 
  rj[2] = Hmat[2][1]; | 
| 367 | 
+ | 
 | 
| 368 | 
+ | 
  rk[0] = Hmat[0][2]; | 
| 369 | 
+ | 
  rk[1] = Hmat[1][2]; | 
| 370 | 
+ | 
  rk[2] = Hmat[2][2]; | 
| 371 | 
+ | 
   | 
| 372 | 
+ | 
  crossProduct3(ri,rj, rij); | 
| 373 | 
+ | 
  distXY = dotProduct3(rk,rij) / length3(rij); | 
| 374 | 
+ | 
 | 
| 375 | 
+ | 
  crossProduct3(rj,rk, rjk); | 
| 376 | 
+ | 
  distYZ = dotProduct3(ri,rjk) / length3(rjk); | 
| 377 | 
+ | 
 | 
| 378 | 
+ | 
  crossProduct3(rk,ri, rki); | 
| 379 | 
+ | 
  distZX = dotProduct3(rj,rki) / length3(rki); | 
| 380 | 
+ | 
 | 
| 381 | 
+ | 
  minDist = min(min(distXY, distYZ), distZX); | 
| 382 | 
+ | 
  return minDist/2; | 
| 383 | 
+ | 
   | 
| 384 | 
+ | 
} | 
| 385 | 
+ | 
 | 
| 386 | 
  | 
void SimInfo::wrapVector( double thePos[3] ){ | 
| 387 | 
  | 
 | 
| 388 | 
< | 
  int i, j, k; | 
| 388 | 
> | 
  int i; | 
| 389 | 
  | 
  double scaled[3]; | 
| 390 | 
  | 
 | 
| 391 | 
  | 
  if( !orthoRhombic ){ | 
| 423 | 
  | 
 | 
| 424 | 
  | 
 | 
| 425 | 
  | 
int SimInfo::getNDF(){ | 
| 426 | 
< | 
  int ndf_local, ndf; | 
| 426 | 
> | 
  int ndf_local; | 
| 427 | 
  | 
   | 
| 428 | 
  | 
  ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints; | 
| 429 | 
  | 
 | 
| 433 | 
  | 
  ndf = ndf_local; | 
| 434 | 
  | 
#endif | 
| 435 | 
  | 
 | 
| 436 | 
< | 
  ndf = ndf - 3; | 
| 436 | 
> | 
  ndf = ndf - 3 - nZconstraints; | 
| 437 | 
  | 
 | 
| 438 | 
  | 
  return ndf; | 
| 439 | 
  | 
} | 
| 440 | 
  | 
 | 
| 441 | 
  | 
int SimInfo::getNDFraw() { | 
| 442 | 
< | 
  int ndfRaw_local, ndfRaw; | 
| 442 | 
> | 
  int ndfRaw_local; | 
| 443 | 
  | 
 | 
| 444 | 
  | 
  // Raw degrees of freedom that we have to set | 
| 445 | 
  | 
  ndfRaw_local = 3 * n_atoms + 3 * n_oriented; | 
| 452 | 
  | 
 | 
| 453 | 
  | 
  return ndfRaw; | 
| 454 | 
  | 
} | 
| 455 | 
< | 
  | 
| 455 | 
> | 
 | 
| 456 | 
> | 
int SimInfo::getNDFtranslational() { | 
| 457 | 
> | 
  int ndfTrans_local; | 
| 458 | 
> | 
 | 
| 459 | 
> | 
  ndfTrans_local = 3 * n_atoms - n_constraints; | 
| 460 | 
> | 
 | 
| 461 | 
> | 
#ifdef IS_MPI | 
| 462 | 
> | 
  MPI_Allreduce(&ndfTrans_local,&ndfTrans,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); | 
| 463 | 
> | 
#else | 
| 464 | 
> | 
  ndfTrans = ndfTrans_local; | 
| 465 | 
> | 
#endif | 
| 466 | 
> | 
 | 
| 467 | 
> | 
  ndfTrans = ndfTrans - 3 - nZconstraints; | 
| 468 | 
> | 
 | 
| 469 | 
> | 
  return ndfTrans; | 
| 470 | 
> | 
} | 
| 471 | 
> | 
 | 
| 472 | 
  | 
void SimInfo::refreshSim(){ | 
| 473 | 
  | 
 | 
| 474 | 
  | 
  simtype fInfo; | 
| 475 | 
  | 
  int isError; | 
| 476 | 
  | 
  int n_global; | 
| 477 | 
  | 
  int* excl; | 
| 478 | 
< | 
   | 
| 410 | 
< | 
  fInfo.rrf = 0.0; | 
| 411 | 
< | 
  fInfo.rt = 0.0; | 
| 478 | 
> | 
 | 
| 479 | 
  | 
  fInfo.dielect = 0.0; | 
| 480 | 
  | 
 | 
| 414 | 
– | 
  fInfo.rlist = rList; | 
| 415 | 
– | 
  fInfo.rcut = rCut; | 
| 416 | 
– | 
 | 
| 481 | 
  | 
  if( useDipole ){ | 
| 418 | 
– | 
    fInfo.rrf = ecr; | 
| 419 | 
– | 
    fInfo.rt = ecr - est; | 
| 482 | 
  | 
    if( useReactionField )fInfo.dielect = dielectric; | 
| 483 | 
  | 
  } | 
| 484 | 
  | 
 | 
| 524 | 
  | 
 | 
| 525 | 
  | 
  this->ndf = this->getNDF(); | 
| 526 | 
  | 
  this->ndfRaw = this->getNDFraw(); | 
| 527 | 
+ | 
  this->ndfTrans = this->getNDFtranslational(); | 
| 528 | 
+ | 
} | 
| 529 | 
  | 
 | 
| 530 | 
+ | 
 | 
| 531 | 
+ | 
void SimInfo::setRcut( double theRcut ){ | 
| 532 | 
+ | 
 | 
| 533 | 
+ | 
  rCut = theRcut; | 
| 534 | 
+ | 
  checkCutOffs(); | 
| 535 | 
  | 
} | 
| 536 | 
  | 
 | 
| 537 | 
+ | 
void SimInfo::setDefaultRcut( double theRcut ){ | 
| 538 | 
+ | 
 | 
| 539 | 
+ | 
  haveOrigRcut = 1; | 
| 540 | 
+ | 
  origRcut = theRcut; | 
| 541 | 
+ | 
  rCut = theRcut; | 
| 542 | 
+ | 
 | 
| 543 | 
+ | 
  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | 
| 544 | 
+ | 
 | 
| 545 | 
+ | 
  notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | 
| 546 | 
+ | 
} | 
| 547 | 
+ | 
 | 
| 548 | 
+ | 
void SimInfo::setEcr( double theEcr ){ | 
| 549 | 
+ | 
 | 
| 550 | 
+ | 
  ecr = theEcr; | 
| 551 | 
+ | 
  checkCutOffs(); | 
| 552 | 
+ | 
} | 
| 553 | 
+ | 
 | 
| 554 | 
+ | 
void SimInfo::setDefaultEcr( double theEcr ){ | 
| 555 | 
+ | 
 | 
| 556 | 
+ | 
  haveOrigEcr = 1; | 
| 557 | 
+ | 
  origEcr = theEcr; | 
| 558 | 
+ | 
   | 
| 559 | 
+ | 
  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | 
| 560 | 
+ | 
 | 
| 561 | 
+ | 
  ecr = theEcr; | 
| 562 | 
+ | 
 | 
| 563 | 
+ | 
  notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | 
| 564 | 
+ | 
} | 
| 565 | 
+ | 
 | 
| 566 | 
+ | 
void SimInfo::setEcr( double theEcr, double theEst ){ | 
| 567 | 
+ | 
 | 
| 568 | 
+ | 
  est = theEst; | 
| 569 | 
+ | 
  setEcr( theEcr ); | 
| 570 | 
+ | 
} | 
| 571 | 
+ | 
 | 
| 572 | 
+ | 
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ | 
| 573 | 
+ | 
 | 
| 574 | 
+ | 
  est = theEst; | 
| 575 | 
+ | 
  setDefaultEcr( theEcr ); | 
| 576 | 
+ | 
} | 
| 577 | 
+ | 
 | 
| 578 | 
+ | 
 | 
| 579 | 
+ | 
void SimInfo::checkCutOffs( void ){ | 
| 580 | 
+ | 
 | 
| 581 | 
+ | 
  int cutChanged = 0; | 
| 582 | 
+ | 
   | 
| 583 | 
+ | 
  if( boxIsInit ){ | 
| 584 | 
+ | 
     | 
| 585 | 
+ | 
    //we need to check cutOffs against the box | 
| 586 | 
+ | 
 | 
| 587 | 
+ | 
    //detect the change of rCut | 
| 588 | 
+ | 
    if(( maxCutoff > rCut )&&(usePBC)){ | 
| 589 | 
+ | 
      if( rCut < origRcut ){ | 
| 590 | 
+ | 
        rCut = origRcut; | 
| 591 | 
+ | 
         | 
| 592 | 
+ | 
        if (rCut > maxCutoff) | 
| 593 | 
+ | 
          rCut = maxCutoff; | 
| 594 | 
+ | 
   | 
| 595 | 
+ | 
          sprintf( painCave.errMsg, | 
| 596 | 
+ | 
                    "New Box size is setting the long range cutoff radius " | 
| 597 | 
+ | 
                    "to %lf at time %lf\n", | 
| 598 | 
+ | 
                    rCut, currentTime ); | 
| 599 | 
+ | 
          painCave.isFatal = 0; | 
| 600 | 
+ | 
          simError(); | 
| 601 | 
+ | 
      } | 
| 602 | 
+ | 
    } | 
| 603 | 
+ | 
    else if ((rCut > maxCutoff)&&(usePBC)) { | 
| 604 | 
+ | 
      sprintf( painCave.errMsg, | 
| 605 | 
+ | 
               "New Box size is setting the long range cutoff radius " | 
| 606 | 
+ | 
               "to %lf at time %lf\n", | 
| 607 | 
+ | 
               maxCutoff, currentTime ); | 
| 608 | 
+ | 
      painCave.isFatal = 0; | 
| 609 | 
+ | 
      simError(); | 
| 610 | 
+ | 
      rCut = maxCutoff; | 
| 611 | 
+ | 
    } | 
| 612 | 
+ | 
 | 
| 613 | 
+ | 
 | 
| 614 | 
+ | 
    //detect the change of ecr | 
| 615 | 
+ | 
    if( maxCutoff > ecr ){ | 
| 616 | 
+ | 
      if( ecr < origEcr ){ | 
| 617 | 
+ | 
        ecr = origEcr; | 
| 618 | 
+ | 
        if (ecr > maxCutoff) ecr = maxCutoff; | 
| 619 | 
+ | 
   | 
| 620 | 
+ | 
          sprintf( painCave.errMsg, | 
| 621 | 
+ | 
                    "New Box size is setting the electrostaticCutoffRadius " | 
| 622 | 
+ | 
                    "to %lf at time %lf\n", | 
| 623 | 
+ | 
                    ecr, currentTime ); | 
| 624 | 
+ | 
            painCave.isFatal = 0; | 
| 625 | 
+ | 
            simError(); | 
| 626 | 
+ | 
      } | 
| 627 | 
+ | 
    } | 
| 628 | 
+ | 
    else if( ecr > maxCutoff){ | 
| 629 | 
+ | 
      sprintf( painCave.errMsg, | 
| 630 | 
+ | 
               "New Box size is setting the electrostaticCutoffRadius " | 
| 631 | 
+ | 
               "to %lf at time %lf\n", | 
| 632 | 
+ | 
               maxCutoff, currentTime  ); | 
| 633 | 
+ | 
      painCave.isFatal = 0; | 
| 634 | 
+ | 
      simError();       | 
| 635 | 
+ | 
      ecr = maxCutoff; | 
| 636 | 
+ | 
    } | 
| 637 | 
+ | 
 | 
| 638 | 
+ | 
    if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; | 
| 639 | 
+ | 
     | 
| 640 | 
+ | 
    // rlist is the 1.0 plus max( rcut, ecr ) | 
| 641 | 
+ | 
     | 
| 642 | 
+ | 
    ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | 
| 643 | 
+ | 
     | 
| 644 | 
+ | 
    if( cutChanged ){ | 
| 645 | 
+ | 
      notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | 
| 646 | 
+ | 
    } | 
| 647 | 
+ | 
     | 
| 648 | 
+ | 
    oldEcr = ecr; | 
| 649 | 
+ | 
    oldRcut = rCut; | 
| 650 | 
+ | 
     | 
| 651 | 
+ | 
  } else { | 
| 652 | 
+ | 
    // initialize this stuff before using it, OK? | 
| 653 | 
+ | 
    sprintf( painCave.errMsg, | 
| 654 | 
+ | 
             "Trying to check cutoffs without a box. Be smarter.\n" ); | 
| 655 | 
+ | 
    painCave.isFatal = 1; | 
| 656 | 
+ | 
    simError();       | 
| 657 | 
+ | 
  } | 
| 658 | 
+ | 
   | 
| 659 | 
+ | 
} | 
| 660 | 
+ | 
 | 
| 661 | 
+ | 
void SimInfo::addProperty(GenericData* prop){ | 
| 662 | 
+ | 
 | 
| 663 | 
+ | 
  map<string, GenericData*>::iterator result; | 
| 664 | 
+ | 
  result = properties.find(prop->getID()); | 
| 665 | 
+ | 
   | 
| 666 | 
+ | 
  //we can't simply use  properties[prop->getID()] = prop, | 
| 667 | 
+ | 
  //it will cause memory leak if we already contain a propery which has the same name of prop | 
| 668 | 
+ | 
   | 
| 669 | 
+ | 
  if(result != properties.end()){ | 
| 670 | 
+ | 
     | 
| 671 | 
+ | 
    delete (*result).second; | 
| 672 | 
+ | 
    (*result).second = prop; | 
| 673 | 
+ | 
       | 
| 674 | 
+ | 
  } | 
| 675 | 
+ | 
  else{ | 
| 676 | 
+ | 
 | 
| 677 | 
+ | 
    properties[prop->getID()] = prop; | 
| 678 | 
+ | 
 | 
| 679 | 
+ | 
  } | 
| 680 | 
+ | 
     | 
| 681 | 
+ | 
} | 
| 682 | 
+ | 
 | 
| 683 | 
+ | 
GenericData* SimInfo::getProperty(const string& propName){ | 
| 684 | 
+ | 
  | 
| 685 | 
+ | 
  map<string, GenericData*>::iterator result; | 
| 686 | 
+ | 
   | 
| 687 | 
+ | 
  //string lowerCaseName = (); | 
| 688 | 
+ | 
   | 
| 689 | 
+ | 
  result = properties.find(propName); | 
| 690 | 
+ | 
   | 
| 691 | 
+ | 
  if(result != properties.end())  | 
| 692 | 
+ | 
    return (*result).second;   | 
| 693 | 
+ | 
  else    | 
| 694 | 
+ | 
    return NULL;   | 
| 695 | 
+ | 
} | 
| 696 | 
+ | 
 | 
| 697 | 
+ | 
vector<GenericData*> SimInfo::getProperties(){ | 
| 698 | 
+ | 
 | 
| 699 | 
+ | 
  vector<GenericData*> result; | 
| 700 | 
+ | 
  map<string, GenericData*>::iterator i; | 
| 701 | 
+ | 
   | 
| 702 | 
+ | 
  for(i = properties.begin(); i != properties.end(); i++) | 
| 703 | 
+ | 
    result.push_back((*i).second); | 
| 704 | 
+ | 
     | 
| 705 | 
+ | 
  return result; | 
| 706 | 
+ | 
} | 
| 707 | 
+ | 
 | 
| 708 | 
+ | 
double SimInfo::matTrace3(double m[3][3]){ | 
| 709 | 
+ | 
  double trace; | 
| 710 | 
+ | 
  trace = m[0][0] + m[1][1] + m[2][2]; | 
| 711 | 
+ | 
 | 
| 712 | 
+ | 
  return trace; | 
| 713 | 
+ | 
} |