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 569 by mmeineke, Tue Jul 1 21:33:45 2003 UTC vs.
Revision 586 by mmeineke, Wed Jul 9 22:14:06 2003 UTC

# 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 | 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 +
24   SimInfo* currentInfo;
25  
26   SimInfo::SimInfo(){
# Line 40 | Line 47 | void SimInfo::setBox(double newBox[3]) {
47   }
48  
49   void SimInfo::setBox(double newBox[3]) {
50 <
44 <  double smallestBoxL, maxCutoff;
45 <  int status;
50 >  
51    int i;
52 +  double tempMat[9];
53  
54 <  for(i=0; i<9; i++) Hmat[i] = 0.0;;
54 >  for(i=0; i<9; i++) tempMat[i] = 0.0;;
55  
56 <  Hmat[0] = newBox[0];
57 <  Hmat[4] = newBox[1];
58 <  Hmat[8] = newBox[2];
56 >  tempMat[0] = newBox[0];
57 >  tempMat[4] = newBox[1];
58 >  tempMat[8] = newBox[2];
59  
60 <  calcHmatI();
55 <  calcBoxL();
56 <
57 <  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
58 <
59 <  smallestBoxL = boxLx;
60 <  if (boxLy < smallestBoxL) smallestBoxL = boxLy;
61 <  if (boxLz < smallestBoxL) smallestBoxL = boxLz;
62 <
63 <  maxCutoff = smallestBoxL / 2.0;
64 <
65 <  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();
71 <
72 <    rList = maxCutoff;
73 <
74 <    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();
79 <
80 <    rCut = rList - 1.0;
81 <
82 <    // list radius changed so we have to refresh the simulation structure.
83 <    refreshSim();
84 <  }
85 <
86 <  if (rCut > maxCutoff) {
87 <    sprintf( painCave.errMsg,
88 <             "New Box size is forcing cutoff radius down to %lf\n",
89 <             maxCutoff );
90 <    painCave.isFatal = 0;
91 <    simError();
60 >  setBoxM( tempMat );
61  
93    status = 0;
94    LJ_new_rcut(&rCut, &status);
95    if (status != 0) {
96      sprintf( painCave.errMsg,
97               "Error in recomputing LJ shifts based on new rcut\n");
98      painCave.isFatal = 1;
99      simError();
100    }
101  }
62   }
63  
64   void SimInfo::setBoxM( double theBox[9] ){
# Line 107 | Line 67 | void SimInfo::setBoxM( double theBox[9] ){
67    double smallestBoxL, maxCutoff;
68  
69    for(i=0; i<9; i++) Hmat[i] = theBox[i];
70 +
71 +  cerr
72 +    << "setting Hmat ->\n"
73 +    << "[ " << 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();
78    calcBoxL();
79  
80 +
81 +
82    setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
83  
84    smallestBoxL = boxLx;
# Line 158 | Line 127 | void SimInfo::getBox(double theBox[9]) {
127   }
128  
129  
130 < void SimInfo::getBox(double theBox[9]) {
130 > void SimInfo::getBoxM (double theBox[9]) {
131  
132    int i;
133    for(i=0; i<9; i++) theBox[i] = Hmat[i];
134   }
135 <
135 >
136 >
137 > void SimInfo::scaleBox(double scale) {
138 >  double theBox[9];
139 >  int i;
140 >
141 >  cerr << "Scaling box by " << scale << "\n";
142 >
143 >  for(i=0; i<9; i++) theBox[i] = Hmat[i]*scale;
144 >
145 >  setBoxM(theBox);
146 >
147 > }
148  
149   void SimInfo::calcHmatI( void ) {
150  
# Line 289 | Line 270 | void SimInfo::wrapVector( double thePos[3] ){
270      // wrap the scaled coordinates
271      
272      for(i=0; i<3; i++)
273 <      scaled[i] -= round(scaled[i]);
273 >      scaled[i] -= roundMe(scaled[i]);
274      
275      // calc the wrapped real coordinates from the wrapped scaled coordinates
276      
277      for(i=0; i<3; i++)
278        thePos[i] =
279 <        scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[3]*Hmat[i+6];
279 >        scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6];
280    }
281    else{
282      // calc the scaled coordinates.
# Line 306 | Line 287 | void SimInfo::wrapVector( double thePos[3] ){
287      // wrap the scaled coordinates
288      
289      for(i=0; i<3; i++)
290 <      scaled[i] -= round(scaled[i]);
290 >      scaled[i] -= roundMe(scaled[i]);
291      
292      // calc the wrapped real coordinates from the wrapped scaled coordinates
293      
# Line 360 | Line 341 | void SimInfo::refreshSim(){
341    fInfo.rt = 0.0;
342    fInfo.dielect = 0.0;
343  
363  fInfo.box[0] = box_x;
364  fInfo.box[1] = box_y;
365  fInfo.box[2] = box_z;
366
344    fInfo.rlist = rList;
345    fInfo.rcut = rCut;
346  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines