--- branches/development/src/brains/Snapshot.cpp 2011/01/17 21:34:36 1540 +++ branches/development/src/brains/Snapshot.cpp 2011/11/22 20:38:56 1665 @@ -36,7 +36,8 @@ * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ /** @@ -114,50 +115,43 @@ namespace OpenMD { } //notify fortran simulation box has changed - setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); + // setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); } void Snapshot::wrapVector(Vector3d& pos) { + + Vector3d scaled = scaleVector(pos); + + for (int i = 0; i < 3; i++) + scaled[i] -= roundMe(scaled[i]); - int i; - Vector3d scaled; - - if( !orthoRhombic_ ){ - - // calc the scaled coordinates. - scaled = invHmat_* pos; - - // wrap the scaled coordinates - for (i = 0; i < 3; ++i) { - scaled[i] -= roundMe(scaled[i]); - } - - // calc the wrapped real coordinates from the wrapped scaled coordinates + if( !orthoRhombic_ ) pos = hmat_ * scaled; + else { - } else { - - // if it is orthoRhombic, we could improve efficiency by only - // caculating the diagonal element - - // calc the scaled coordinates. - for (i=0; i<3; i++) { - scaled[i] = pos[i] * invHmat_(i, i); - } - - // wrap the scaled coordinates - for (i = 0; i < 3; ++i) { - scaled[i] -= roundMe(scaled[i]); - } - // calc the wrapped real coordinates from the wrapped scaled coordinates - for (i=0; i<3; i++) { + for (int i=0; i<3; i++) { pos[i] = scaled[i] * hmat_(i, i); } } } + inline Vector3d Snapshot::scaleVector(Vector3d& pos) { + + Vector3d scaled; + + if( !orthoRhombic_ ) + scaled = invHmat_* pos; + else { + // calc the scaled coordinates. + for (int i=0; i<3; i++) + scaled[i] = pos[i] * invHmat_(i, i); + } + + return scaled; + } + Vector3d Snapshot::getCOM() { if( !hasCOM_ ) { sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");