ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/Snapshot.cpp
(Generate patch)

Comparing branches/development/src/brains/Snapshot.cpp (file contents):
Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC vs.
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 36 | Line 36
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38   * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42    
43   /**
# Line 59 | Line 60 | namespace OpenMD {
60      hmat_ = m;
61      invHmat_ = hmat_.inverse();
62      
62
63      //prepare fortran Hmat
64      RealType fortranHmat[9];
65      RealType fortranInvHmat[9];
# Line 115 | Line 115 | namespace OpenMD {
115      }    
116  
117      //notify fortran simulation box has changed
118 <    setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_);
118 >    // setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_);
119    }
120  
121  
122    void Snapshot::wrapVector(Vector3d& pos) {
123 +    
124 +    Vector3d scaled = scaleVector(pos);
125 +    
126 +    for (int i = 0; i < 3; i++)
127 +      scaled[i] -= roundMe(scaled[i]);
128  
129 <    int i;
130 <    Vector3d scaled;
129 >    if( !orthoRhombic_ )
130 >      pos = hmat_ * scaled;    
131 >    else {
132  
127    if( !orthoRhombic_ ){
128
129      // calc the scaled coordinates.
130      scaled = invHmat_* pos;
131
132      // wrap the scaled coordinates
133      for (i = 0; i < 3; ++i) {
134        scaled[i] -= roundMe(scaled[i]);
135      }
136
133        // calc the wrapped real coordinates from the wrapped scaled coordinates
134 <      pos = hmat_ * scaled;    
134 >      for (int i=0; i<3; i++) {
135 >        pos[i] = scaled[i] * hmat_(i, i);
136 >      }  
137 >    }
138 >  }
139  
140 <    } else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element
140 >  inline Vector3d Snapshot::scaleVector(Vector3d& pos) {  
141      
142 <      // calc the scaled coordinates.
143 <      for (i=0; i<3; i++) {
144 <        scaled[i] = pos[i] * invHmat_(i, i);
145 <      }
146 <        
147 <      // wrap the scaled coordinates
148 <      for (i = 0; i < 3; ++i) {
149 <        scaled[i] -= roundMe(scaled[i]);
150 <      }
142 >    Vector3d scaled;
143  
144 <      // calc the wrapped real coordinates from the wrapped scaled coordinates
145 <      for (i=0; i<3; i++) {
146 <        pos[i] = scaled[i] * hmat_(i, i);
147 <      }
148 <        
144 >    if( !orthoRhombic_ )
145 >      scaled = invHmat_* pos;
146 >    else {
147 >      // calc the scaled coordinates.
148 >      for (int i=0; i<3; i++)
149 >        scaled[i] = pos[i] * invHmat_(i, i);
150      }
151  
152 +    return scaled;
153    }
154 <
154 >  
155    Vector3d Snapshot::getCOM() {
156      if( !hasCOM_ ) {
157        sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");
# Line 184 | Line 178 | namespace OpenMD {
178      }
179      return COMw_;
180    }
187
181   }
182    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines