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 569 by mmeineke, Tue Jul 1 21:33:45 2003 UTC

# Line 54 | Line 54 | void SimInfo::setBox(double newBox[3]) {
54    calcHmatI();
55    calcBoxL();
56  
57 <  setFortranBoxSize(Hmat);
57 >  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
58  
59    smallestBoxL = boxLx;
60    if (boxLy < smallestBoxL) smallestBoxL = boxLy;
# Line 110 | Line 110 | void SimInfo::setBoxM( double theBox[9] ){
110    calcHmatI();
111    calcBoxL();
112  
113 <  setFortranBoxSize(Hmat);
113 >  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
114  
115    smallestBoxL = boxLx;
116    if (boxLy < smallestBoxL) smallestBoxL = boxLy;
# Line 170 | Line 170 | void SimInfo::calcHmatI( void ) {
170    double C[3][3];
171    double detHmat;
172    int i, j, k;
173 +  double smallDiag;
174 +  double tol;
175 +  double sanity[3][3];
176  
177    // calculate the adjunct of Hmat;
178  
# Line 199 | Line 202 | void SimInfo::calcHmatI( void ) {
202  
203        HmatI[i] = C[j][k] / detHmat;
204        i++;
205 +    }
206 +  }
207 +
208 +  // sanity check
209 +
210 +  for(i=0; i<3; i++){
211 +    for(j=0; j<3; j++){
212 +      
213 +      sanity[i][j] = 0.0;
214 +      for(k=0; k<3; k++){
215 +        sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k];
216 +      }
217 +    }
218 +  }
219 +
220 +  cerr << "sanity => \n"
221 +       << sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n"
222 +       << sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n"
223 +       << sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2]
224 +       << "\n";
225 +    
226 +
227 +  // check to see if Hmat is orthorhombic
228 +  
229 +  smallDiag = Hmat[0];
230 +  if(smallDiag > Hmat[4]) smallDiag = Hmat[4];
231 +  if(smallDiag > Hmat[8]) smallDiag = Hmat[8];
232 +  tol = smallDiag * 1E-6;
233 +
234 +  orthoRhombic = 1;
235 +  for(i=0; (i<9) && orthoRhombic; i++){
236 +    
237 +    if( (i%4) ){ // ignore the diagonals (0, 4, and 8)
238 +      orthoRhombic = (Hmat[i] <= tol);
239      }
240    }
241 +    
242   }
243  
244   void SimInfo::calcBoxL( void ){
# Line 241 | Line 279 | void SimInfo::wrapVector( double thePos[3] ){
279    int i, j, k;
280    double scaled[3];
281  
282 <  // calc the scaled coordinates.
283 <  
284 <  for(i=0; i<3; i++)
285 <    scaled[i] = thePos[0]*Hmat[i] + thePos[1]*Hat[i+3] + thePos[3]*Hmat[i+6];
286 <
287 <  // wrap the scaled coordinates
288 <
289 <  for(i=0; i<3; i++)
290 <    scaled[i] -= (copysign(1,scaled[i]) * (int)(fabs(scaled[i]) + 0.5));
291 <  
292 <
282 >  if( !orthoRhombic ){
283 >    // calc the scaled coordinates.
284 >    
285 >    for(i=0; i<3; i++)
286 >      scaled[i] =
287 >        thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6];
288 >    
289 >    // wrap the scaled coordinates
290 >    
291 >    for(i=0; i<3; i++)
292 >      scaled[i] -= round(scaled[i]);
293 >    
294 >    // calc the wrapped real coordinates from the wrapped scaled coordinates
295 >    
296 >    for(i=0; i<3; i++)
297 >      thePos[i] =
298 >        scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[3]*Hmat[i+6];
299 >  }
300 >  else{
301 >    // calc the scaled coordinates.
302 >    
303 >    for(i=0; i<3; i++)
304 >      scaled[i] = thePos[i]*HmatI[i*4];
305 >    
306 >    // wrap the scaled coordinates
307 >    
308 >    for(i=0; i<3; i++)
309 >      scaled[i] -= round(scaled[i]);
310 >    
311 >    // calc the wrapped real coordinates from the wrapped scaled coordinates
312 >    
313 >    for(i=0; i<3; i++)
314 >      thePos[i] = scaled[i]*Hmat[i*4];
315 >  }
316 >    
317 >    
318   }
319  
320  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines