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 1540 by gezelter, Mon Jan 17 21:34:36 2011 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 114 | 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;
124 <    Vector3d scaled;
125 <
126 <    if( !orthoRhombic_ ){
127 <
128 <      // calc the scaled coordinates.
129 <      scaled = invHmat_* pos;
130 <
131 <      // wrap the scaled coordinates
132 <      for (i = 0; i < 3; ++i) {
133 <        scaled[i] -= roundMe(scaled[i]);
134 <      }
135 <
136 <      // calc the wrapped real coordinates from the wrapped scaled coordinates
129 >    if( !orthoRhombic_ )
130        pos = hmat_ * scaled;    
131 +    else {
132  
139    } else {
140
141      // if it is orthoRhombic, we could improve efficiency by only
142      // caculating the diagonal element
143    
144      // calc the scaled coordinates.
145      for (i=0; i<3; i++) {
146        scaled[i] = pos[i] * invHmat_(i, i);
147      }
148        
149      // wrap the scaled coordinates
150      for (i = 0; i < 3; ++i) {
151        scaled[i] -= roundMe(scaled[i]);
152      }
153
133        // calc the wrapped real coordinates from the wrapped scaled coordinates
134 <      for (i=0; i<3; i++) {
134 >      for (int i=0; i<3; i++) {
135          pos[i] = scaled[i] * hmat_(i, i);
136        }  
137      }
138    }
139  
140 +  inline Vector3d Snapshot::scaleVector(Vector3d& pos) {  
141 +    
142 +    Vector3d scaled;
143 +
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 +  
155    Vector3d Snapshot::getCOM() {
156      if( !hasCOM_ ) {
157        sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines