--- branches/development/src/brains/Snapshot.cpp 2010/07/09 23:08:25 1465 +++ 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). */ /** @@ -59,7 +60,6 @@ namespace OpenMD { hmat_ = m; invHmat_ = hmat_.inverse(); - //prepare fortran Hmat RealType fortranHmat[9]; RealType fortranInvHmat[9]; @@ -115,49 +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_ ) + pos = hmat_ * scaled; + else { - 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 - pos = hmat_ * scaled; + for (int i=0; i<3; i++) { + pos[i] = scaled[i] * hmat_(i, i); + } + } + } - } else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element + inline Vector3d Snapshot::scaleVector(Vector3d& pos) { - // 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]); - } + Vector3d scaled; - // calc the wrapped real coordinates from the wrapped scaled coordinates - for (i=0; i<3; i++) { - pos[i] = scaled[i] * hmat_(i, i); - } - + 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"); @@ -184,6 +178,5 @@ namespace OpenMD { } return COMw_; } - }