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 572 by mmeineke, Wed Jul 2 21:26:55 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 54 | Line 61 | void SimInfo::setBox(double newBox[3]) {
61    calcHmatI();
62    calcBoxL();
63  
64 <  setFortranBoxSize(Hmat);
64 >  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
65  
66    smallestBoxL = boxLx;
67    if (boxLy < smallestBoxL) smallestBoxL = boxLy;
# Line 110 | Line 117 | void SimInfo::setBoxM( double theBox[9] ){
117    calcHmatI();
118    calcBoxL();
119  
120 <  setFortranBoxSize(Hmat);
120 >  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
121  
122    smallestBoxL = boxLx;
123    if (boxLy < smallestBoxL) smallestBoxL = boxLy;
# Line 158 | Line 165 | void SimInfo::getBox(double theBox[9]) {
165   }
166  
167  
168 < void SimInfo::getBox(double theBox[9]) {
168 > void SimInfo::getBoxM (double theBox[9]) {
169  
170    int i;
171    for(i=0; i<9; i++) theBox[i] = Hmat[i];
# Line 170 | Line 177 | void SimInfo::calcHmatI( void ) {
177    double C[3][3];
178    double detHmat;
179    int i, j, k;
180 +  double smallDiag;
181 +  double tol;
182 +  double sanity[3][3];
183  
184    // calculate the adjunct of Hmat;
185  
# Line 201 | Line 211 | void SimInfo::calcHmatI( void ) {
211        i++;
212      }
213    }
214 +
215 +  // sanity check
216 +
217 +  for(i=0; i<3; i++){
218 +    for(j=0; j<3; j++){
219 +      
220 +      sanity[i][j] = 0.0;
221 +      for(k=0; k<3; k++){
222 +        sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k];
223 +      }
224 +    }
225 +  }
226 +
227 +  cerr << "sanity => \n"
228 +       << sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n"
229 +       << sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n"
230 +       << sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2]
231 +       << "\n";
232 +    
233 +
234 +  // check to see if Hmat is orthorhombic
235 +  
236 +  smallDiag = Hmat[0];
237 +  if(smallDiag > Hmat[4]) smallDiag = Hmat[4];
238 +  if(smallDiag > Hmat[8]) smallDiag = Hmat[8];
239 +  tol = smallDiag * 1E-6;
240 +
241 +  orthoRhombic = 1;
242 +  for(i=0; (i<9) && orthoRhombic; i++){
243 +    
244 +    if( (i%4) ){ // ignore the diagonals (0, 4, and 8)
245 +      orthoRhombic = (Hmat[i] <= tol);
246 +    }
247 +  }
248 +    
249   }
250  
251   void SimInfo::calcBoxL( void ){
# Line 241 | Line 286 | void SimInfo::wrapVector( double thePos[3] ){
286    int i, j, k;
287    double scaled[3];
288  
289 <  // calc the scaled coordinates.
290 <  
291 <  for(i=0; i<3; i++)
292 <    scaled[i] = thePos[0]*Hmat[i] + thePos[1]*Hat[i+3] + thePos[3]*Hmat[i+6];
293 <
294 <  // wrap the scaled coordinates
295 <
296 <  for(i=0; i<3; i++)
297 <    scaled[i] -= (copysign(1,scaled[i]) * (int)(fabs(scaled[i]) + 0.5));
298 <  
299 <
289 >  if( !orthoRhombic ){
290 >    // calc the scaled coordinates.
291 >    
292 >    for(i=0; i<3; i++)
293 >      scaled[i] =
294 >        thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6];
295 >    
296 >    // wrap the scaled coordinates
297 >    
298 >    for(i=0; i<3; i++)
299 >      scaled[i] -= roundMe(scaled[i]);
300 >    
301 >    // calc the wrapped real coordinates from the wrapped scaled coordinates
302 >    
303 >    for(i=0; i<3; i++)
304 >      thePos[i] =
305 >        scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6];
306 >  }
307 >  else{
308 >    // calc the scaled coordinates.
309 >    
310 >    for(i=0; i<3; i++)
311 >      scaled[i] = thePos[i]*HmatI[i*4];
312 >    
313 >    // wrap the scaled coordinates
314 >    
315 >    for(i=0; i<3; i++)
316 >      scaled[i] -= roundMe(scaled[i]);
317 >    
318 >    // calc the wrapped real coordinates from the wrapped scaled coordinates
319 >    
320 >    for(i=0; i<3; i++)
321 >      thePos[i] = scaled[i]*Hmat[i*4];
322 >  }
323 >    
324 >    
325   }
326  
327  
# Line 297 | Line 367 | void SimInfo::refreshSim(){
367    fInfo.rt = 0.0;
368    fInfo.dielect = 0.0;
369  
300  fInfo.box[0] = box_x;
301  fInfo.box[1] = box_y;
302  fInfo.box[2] = box_z;
303
370    fInfo.rlist = rList;
371    fInfo.rcut = rCut;
372  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines