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 770 by gezelter, Fri Sep 19 14:55:41 2003 UTC vs.
Revision 787 by mmeineke, Thu Sep 25 19:27:15 2003 UTC

# Line 48 | Line 48 | SimInfo::SimInfo(){
48    haveOrigEcr = 0;
49    boxIsInit = 0;
50    
51 +  resetTime = 1e99;
52    
53  
54    usePBC = 0;
# Line 93 | Line 94 | void SimInfo::setBoxM( double theBox[3][3] ){
94  
95   void SimInfo::setBoxM( double theBox[3][3] ){
96    
97 <  int i, j, status;
97 <  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 ]
# Line 279 | Line 279 | void SimInfo::printMat9(double A[9] ){
279              << "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n"
280              << "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n"
281              << "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n";
282 + }
283 +
284 +
285 + void SimInfo::crossProduct3(double a[3],double b[3], double out[3]){
286 +
287 +      out[0] = a[1] * b[2] - a[2] * b[1];
288 +      out[1] = a[2] * b[0] - a[0] * b[2] ;
289 +      out[2] = a[0] * b[1] - a[1] * b[0];
290 +      
291 + }
292 +
293 + double SimInfo::dotProduct3(double a[3], double b[3]){
294 +  return a[0]*b[0] + a[1]*b[1]+ a[2]*b[2];
295   }
296  
297 + double SimInfo::length3(double a[3]){
298 +  return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
299 + }
300 +
301   void SimInfo::calcBoxL( void ){
302  
303    double dx, dy, dz, dsq;
287  int i;
304  
305    // boxVol = Determinant of Hmat
306  
# Line 295 | Line 311 | void SimInfo::calcBoxL( void ){
311    dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
312    dsq = dx*dx + dy*dy + dz*dz;
313    boxL[0] = sqrt( dsq );
314 <  maxCutoff = 0.5 * boxL[0];
314 >  //maxCutoff = 0.5 * boxL[0];
315  
316    // boxLy
317    
318    dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
319    dsq = dx*dx + dy*dy + dz*dz;
320    boxL[1] = sqrt( dsq );
321 <  if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
321 >  //if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
322  
323 +
324    // boxLz
325    
326    dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
327    dsq = dx*dx + dy*dy + dz*dz;
328    boxL[2] = sqrt( dsq );
329 <  if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
329 >  //if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
330 >
331 >  //calculate the max cutoff
332 >  maxCutoff =  calcMaxCutOff();
333    
334    checkCutOffs();
335  
336   }
337  
338 +
339 + double SimInfo::calcMaxCutOff(){
340 +
341 +  double ri[3], rj[3], rk[3];
342 +  double rij[3], rjk[3], rki[3];
343 +  double minDist;
344 +
345 +  ri[0] = Hmat[0][0];
346 +  ri[1] = Hmat[1][0];
347 +  ri[2] = Hmat[2][0];
348 +
349 +  rj[0] = Hmat[0][1];
350 +  rj[1] = Hmat[1][1];
351 +  rj[2] = Hmat[2][1];
352 +
353 +  rk[0] = Hmat[0][2];
354 +  rk[1] = Hmat[1][2];
355 +  rk[2] = Hmat[2][2];
356 +  
357 +  crossProduct3(ri,rj, rij);
358 +  distXY = dotProduct3(rk,rij) / length3(rij);
359 +
360 +  crossProduct3(rj,rk, rjk);
361 +  distYZ = dotProduct3(ri,rjk) / length3(rjk);
362 +
363 +  crossProduct3(rk,ri, rki);
364 +  distZX = dotProduct3(rj,rki) / length3(rki);
365 +
366 +  minDist = min(min(distXY, distYZ), distZX);
367 +  return minDist/2;
368 +  
369 + }
370  
371   void SimInfo::wrapVector( double thePos[3] ){
372  
373 <  int i, j, k;
373 >  int i;
374    double scaled[3];
375  
376    if( !orthoRhombic ){
# Line 497 | Line 549 | void SimInfo::checkCutOffs( void ){
549    if( boxIsInit ){
550      
551      //we need to check cutOffs against the box
552 <    
552 >
553 >    //detect the change of rCut
554      if(( maxCutoff > rCut )&&(usePBC)){
555        if( rCut < origRcut ){
556 <        rCut = origRcut;
557 <        if (rCut > maxCutoff) rCut = maxCutoff;
558 <        
559 <        sprintf( painCave.errMsg,
560 <                 "New Box size is setting the long range cutoff radius "
561 <                 "to %lf at time %lf\n",
562 <                 rCut, currentTime );
563 <        painCave.isFatal = 0;
564 <        simError();
565 <      }
566 <    }
514 <    
515 <    if( maxCutoff > ecr ){
516 <      if( ecr < origEcr ){
517 <        ecr = origEcr;
518 <        if (ecr > maxCutoff) ecr = maxCutoff;
519 <        
520 <        sprintf( painCave.errMsg,
521 <                 "New Box size is setting the electrostaticCutoffRadius "
522 <                 "to %lf at time %lf\n",
523 <                 ecr, currentTime );
524 <        painCave.isFatal = 0;
525 <        simError();
556 >        rCut = origRcut;
557 >        
558 >        if (rCut > maxCutoff)
559 >          rCut = maxCutoff;
560 >  
561 >          sprintf( painCave.errMsg,
562 >                    "New Box size is setting the long range cutoff radius "
563 >                    "to %lf at time %lf\n",
564 >                    rCut, currentTime );
565 >          painCave.isFatal = 0;
566 >          simError();
567        }
568      }
569 <    
529 <    
530 <    if ((rCut > maxCutoff)&&(usePBC)) {
569 >    else if ((rCut > maxCutoff)&&(usePBC)) {
570        sprintf( painCave.errMsg,
571                 "New Box size is setting the long range cutoff radius "
572 <               "to %lf at time %lf\n",
572 >               "to %lf at time %lf\n",
573                 maxCutoff, currentTime );
574        painCave.isFatal = 0;
575        simError();
576        rCut = maxCutoff;
577      }
578 <    
579 <    if( ecr > maxCutoff){
578 >
579 >
580 >    //detect the change of ecr
581 >    if( maxCutoff > ecr ){
582 >      if( ecr < origEcr ){
583 >        ecr = origEcr;
584 >        if (ecr > maxCutoff) ecr = maxCutoff;
585 >  
586 >          sprintf( painCave.errMsg,
587 >                    "New Box size is setting the electrostaticCutoffRadius "
588 >                    "to %lf at time %lf\n",
589 >                    ecr, currentTime );
590 >            painCave.isFatal = 0;
591 >            simError();
592 >      }
593 >    }
594 >    else if( ecr > maxCutoff){
595        sprintf( painCave.errMsg,
596                 "New Box size is setting the electrostaticCutoffRadius "
597                 "to %lf at time %lf\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines