--- trunk/src/brains/Snapshot.cpp 2013/06/16 15:15:42 1879 +++ trunk/src/brains/Snapshot.cpp 2013/08/07 15:24:16 1925 @@ -70,6 +70,7 @@ namespace OpenMD { frameData.torsionPotential = 0.0; frameData.inversionPotential = 0.0; frameData.lrPotentials = potVec(0.0); + frameData.reciprocalPotential = 0.0; frameData.excludedPotentials = potVec(0.0); frameData.restraintPotential = 0.0; frameData.rawPotential = 0.0; @@ -103,6 +104,7 @@ namespace OpenMD { frameData.torsionPotential = 0.0; frameData.inversionPotential = 0.0; frameData.lrPotentials = potVec(0.0); + frameData.reciprocalPotential = 0.0; frameData.excludedPotentials = potVec(0.0); frameData.restraintPotential = 0.0; frameData.rawPotential = 0.0; @@ -297,22 +299,24 @@ namespace OpenMD { frameData.volume = vol; } + /** Wrap a vector according to periodic boundary conditions */ void Snapshot::wrapVector(Vector3d& pos) { - Vector3d scaled = scaleVector(pos); - - for (int i = 0; i < 3; i++) - scaled[i] -= roundMe(scaled[i]); - - if( !frameData.orthoRhombic ) - pos = frameData.hmat * scaled; - else { - + if( !frameData.orthoRhombic ) { + Vector3d scaled = frameData.invHmat * pos; + for (int i = 0; i < 3; i++) { + scaled[i] -= roundMe( scaled[i] ); + } // calc the wrapped real coordinates from the wrapped scaled coordinates - for (int i=0; i<3; i++) { - pos[i] = scaled[i] * frameData.hmat(i, i); - } + pos = frameData.hmat * scaled; + } else { + RealType scaled; + for (int i=0; i<3; i++) { + scaled = pos[i] * frameData.invHmat(i,i); + scaled -= roundMe( scaled ); + pos[i] = scaled * frameData.hmat(i,i); + } } } @@ -412,6 +416,14 @@ namespace OpenMD { return frameData.shortRangePotential; } + void Snapshot::setReciprocalPotential(RealType rp){ + frameData.reciprocalPotential = rp; + } + + RealType Snapshot::getReciprocalPotential() { + return frameData.reciprocalPotential; + } + void Snapshot::setLongRangePotential(potVec lrPot) { frameData.lrPotentials = lrPot; } @@ -421,6 +433,7 @@ namespace OpenMD { for (int i = 0; i < N_INTERACTION_FAMILIES; i++) { frameData.longRangePotential += frameData.lrPotentials[i]; } + frameData.longRangePotential += frameData.reciprocalPotential; hasLongRangePotential = true; } return frameData.longRangePotential;