--- trunk/src/brains/Snapshot.cpp 2012/08/22 02:28:28 1782 +++ trunk/src/brains/Snapshot.cpp 2014/09/26 22:22:28 2022 @@ -35,7 +35,7 @@ * * [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). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ @@ -44,7 +44,6 @@ * @file Snapshot.cpp * @author tlin * @date 11/11/2004 - * @time 10:56am * @version 1.0 */ @@ -71,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; @@ -95,13 +95,16 @@ namespace OpenMD { frameData.id = -1; frameData.currentTime = 0; frameData.hmat = Mat3x3d(0.0); - frameData.invHmat = Mat3x3d(0.0); + frameData.invHmat = Mat3x3d(0.0); + frameData.bBox = Mat3x3d(0.0); + frameData.invBbox = Mat3x3d(0.0); frameData.orthoRhombic = false; frameData.bondPotential = 0.0; frameData.bendPotential = 0.0; 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; @@ -127,12 +130,13 @@ namespace OpenMD { frameData.pressure = 0.0; frameData.temperature = 0.0; frameData.pressureTensor = Mat3x3d(0.0); - frameData.systemDipole = Vector3d(0.0); + frameData.systemDipole = Vector3d(0.0); + frameData.systemQuadrupole = Mat3x3d(0.0); frameData.convectiveHeatFlux = Vector3d(0.0, 0.0, 0.0); frameData.electronicTemperature = 0.0; frameData.COM = V3Zero; frameData.COMvel = V3Zero; - frameData.COMw = V3Zero; + frameData.COMw = V3Zero; hasTotalEnergy = false; hasTranslationalKineticEnergy = false; @@ -151,11 +155,13 @@ namespace OpenMD { hasCOMw = false; hasPressureTensor = false; hasSystemDipole = false; + hasSystemQuadrupole = false; hasConvectiveHeatFlux = false; hasInertiaTensor = false; hasGyrationalVolume = false; hasHullVolume = false; hasConservedQuantity = false; + hasBoundingBox = false; } /** Returns the id of this Snapshot */ @@ -186,6 +192,11 @@ namespace OpenMD { int Snapshot::getNumberOfCutoffGroups() { return cgData.getSize(); } + + /** Returns the number of bytes in a FrameData structure */ + int Snapshot::getFrameDataSize() { + return sizeof(FrameData); + } /** Returns the H-Matrix */ Mat3x3d Snapshot::getHmat() { @@ -221,29 +232,32 @@ namespace OpenMD { if( oldOrthoRhombic != frameData.orthoRhombic){ - if( frameData.orthoRhombic ) { - sprintf( painCave.errMsg, - "OpenMD is switching from the default Non-Orthorhombic\n" - "\tto the faster Orthorhombic periodic boundary computations.\n" - "\tThis is usually a good thing, but if you want the\n" - "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" - "\tvariable ( currently set to %G ) smaller.\n", - orthoTolerance_); - painCave.severity = OPENMD_INFO; - simError(); - } - else { - sprintf( painCave.errMsg, - "OpenMD is switching from the faster Orthorhombic to the more\n" - "\tflexible Non-Orthorhombic periodic boundary computations.\n" - "\tThis is usually because the box has deformed under\n" - "\tNPTf integration. If you want to live on the edge with\n" - "\tthe Orthorhombic computations, make the orthoBoxTolerance\n" - "\tvariable ( currently set to %G ) larger.\n", - orthoTolerance_); - painCave.severity = OPENMD_WARNING; - simError(); - } + // It is finally time to suppress these warnings once and for + // all. They were annoying and not very informative. + + // if( frameData.orthoRhombic ) { + // sprintf( painCave.errMsg, + // "OpenMD is switching from the default Non-Orthorhombic\n" + // "\tto the faster Orthorhombic periodic boundary computations.\n" + // "\tThis is usually a good thing, but if you want the\n" + // "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" + // "\tvariable ( currently set to %G ) smaller.\n", + // orthoTolerance_); + // painCave.severity = OPENMD_INFO; + // simError(); + // } + // else { + // sprintf( painCave.errMsg, + // "OpenMD is switching from the faster Orthorhombic to the more\n" + // "\tflexible Non-Orthorhombic periodic boundary computations.\n" + // "\tThis is usually because the box has deformed under\n" + // "\tNPTf integration. If you want to live on the edge with\n" + // "\tthe Orthorhombic computations, make the orthoBoxTolerance\n" + // "\tvariable ( currently set to %G ) larger.\n", + // orthoTolerance_); + // painCave.severity = OPENMD_WARNING; + // simError(); + // } } } @@ -252,6 +266,23 @@ namespace OpenMD { return frameData.invHmat; } + /** Returns the Bounding Box */ + Mat3x3d Snapshot::getBoundingBox() { + return frameData.bBox; + } + + /** Sets the Bounding Box */ + void Snapshot::setBoundingBox(const Mat3x3d& m) { + frameData.bBox = m; + frameData.invBbox = frameData.bBox.inverse(); + hasBoundingBox = true; + } + + /** Returns the inverse Bounding Box */ + Mat3x3d Snapshot::getInvBoundingBox() { + return frameData.invBbox; + } + RealType Snapshot::getXYarea() { if (!hasXYarea) { Vector3d x = frameData.hmat.getColumn(0); @@ -275,22 +306,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); + } } } @@ -390,6 +423,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; } @@ -399,6 +440,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; @@ -562,6 +604,15 @@ namespace OpenMD { frameData.systemDipole = bd; } + Mat3x3d Snapshot::getSystemQuadrupole() { + return frameData.systemQuadrupole; + } + + void Snapshot::setSystemQuadrupole(const Mat3x3d& bq) { + hasSystemQuadrupole = true; + frameData.systemQuadrupole = bq; + } + void Snapshot::setThermostat(const pair& thermostat) { frameData.thermostat = thermostat; }