| 35 |  | * | 
| 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). | 
| 38 | > | * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). | 
| 39 | > | * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 | > | * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 |  | */ | 
| 42 |  | #include "parallel/ForceDecomposition.hpp" | 
| 43 |  | #include "math/Vector3.hpp" | 
| 48 |  | using namespace std; | 
| 49 |  | namespace OpenMD { | 
| 50 |  |  | 
| 51 | < | ForceDecomposition::ForceDecomposition(SimInfo* info, InteractionManager* iMan) : info_(info), interactionMan_(iMan) { | 
| 51 | > | ForceDecomposition::ForceDecomposition(SimInfo* info, InteractionManager* iMan) : info_(info), interactionMan_(iMan), needVelocities_(false) { | 
| 52 | > |  | 
| 53 |  | sman_ = info_->getSnapshotManager(); | 
| 54 |  | storageLayout_ = sman_->getStorageLayout(); | 
| 55 |  | ff_ = info_->getForceField(); | 
| 56 |  | userChoseCutoff_ = false; | 
| 57 |  |  | 
| 58 | + | usePeriodicBoundaryConditions_ = info->getSimParams()->getUsePeriodicBoundaryConditions(); | 
| 59 | + |  | 
| 60 |  | Globals* simParams_ = info_->getSimParams(); | 
| 61 | < |  | 
| 61 | > | if (simParams_->havePrintHeatFlux()) { | 
| 62 | > | if (simParams_->getPrintHeatFlux()) { | 
| 63 | > | needVelocities_ = true; | 
| 64 | > | } | 
| 65 | > | } | 
| 66 | > |  | 
| 67 |  | if (simParams_->haveSkinThickness()) { | 
| 68 |  | skinThickness_ = simParams_->getSkinThickness(); | 
| 69 |  | } else { | 
| 97 |  | } | 
| 98 |  |  | 
| 99 |  | void ForceDecomposition::fillSelfData(SelfData &sdat, int atom1) { | 
| 100 | < |  | 
| 101 | < | // Still Missing atype, skippedCharge, potVec pot, | 
| 102 | < | if (storageLayout_ & DataStorage::dslElectroFrame) { | 
| 103 | < | sdat.eFrame = &(snap_->atomData.electroFrame[atom1]); | 
| 100 | > |  | 
| 101 | > | sdat.atype = atypesLocal[atom1]; | 
| 102 | > | sdat.atid = idents[atom1]; | 
| 103 | > |  | 
| 104 | > | sdat.pot = &embeddingPot; | 
| 105 | > | sdat.excludedPot = &excludedSelfPot; | 
| 106 | > |  | 
| 107 | > | if (storageLayout_ & DataStorage::dslDipole) { | 
| 108 | > | sdat.dipole = &(snap_->atomData.dipole[atom1]); | 
| 109 |  | } | 
| 110 | < |  | 
| 110 | > |  | 
| 111 | > | if (storageLayout_ & DataStorage::dslQuadrupole) { | 
| 112 | > | sdat.quadrupole = &(snap_->atomData.quadrupole[atom1]); | 
| 113 | > | } | 
| 114 | > |  | 
| 115 |  | if (storageLayout_ & DataStorage::dslTorque) { | 
| 116 |  | sdat.t = &(snap_->atomData.torque[atom1]); | 
| 117 |  | } | 
| 128 |  | sdat.dfrhodrho = &(snap_->atomData.functionalDerivative[atom1]); | 
| 129 |  | } | 
| 130 |  |  | 
| 131 | + | if (storageLayout_ & DataStorage::dslSkippedCharge) { | 
| 132 | + | sdat.skippedCharge = &(snap_->atomData.skippedCharge[atom1]); | 
| 133 | + | } | 
| 134 | + |  | 
| 135 |  | if (storageLayout_ & DataStorage::dslParticlePot) { | 
| 136 |  | sdat.particlePot = &(snap_->atomData.particlePot[atom1]); | 
| 137 |  | } | 
| 138 | + |  | 
| 139 | + | if (storageLayout_ & DataStorage::dslFlucQPosition) { | 
| 140 | + | sdat.flucQ = &(snap_->atomData.flucQPos[atom1]); | 
| 141 | + | } | 
| 142 | + |  | 
| 143 | + | if (storageLayout_ & DataStorage::dslFlucQForce) { | 
| 144 | + | sdat.dVdFQ = &(snap_->atomData.flucQFrc[atom1]); | 
| 145 | + | } | 
| 146 |  | } | 
| 147 |  |  | 
| 148 |  | bool ForceDecomposition::checkNeighborList() { | 
| 149 |  |  | 
| 150 |  | int nGroups = snap_->cgData.position.size(); | 
| 151 | < |  | 
| 151 | > | if (needVelocities_) | 
| 152 | > | snap_->cgData.setStorageLayout(DataStorage::dslPosition | DataStorage::dslVelocity); | 
| 153 | > |  | 
| 154 |  | // if we have changed the group identities or haven't set up the | 
| 155 |  | // saved positions we automatically will need a neighbor list update: | 
| 156 |  |  | 
| 157 | < | if ( saved_CG_positions_.size() != nGroups ) { | 
| 126 | < | cerr << "build because size\n"; | 
| 127 | < | return true; | 
| 128 | < | } | 
| 157 | > | if ( saved_CG_positions_.size() != nGroups ) return true; | 
| 158 |  |  | 
| 159 |  | RealType dispmax = 0.0; | 
| 160 |  | Vector3d disp; | 
| 173 |  | dispmax = 2.0 * sqrt (3.0 * dispmax * dispmax); | 
| 174 |  |  | 
| 175 |  |  | 
| 176 | < | if (dispmax > skinThickness_) { | 
| 148 | < | cerr << "build because movement\n"; | 
| 176 | > | if (dispmax > skinThickness_) | 
| 177 |  | return (dispmax > skinThickness_); | 
| 178 | < | } | 
| 178 | > |  | 
| 179 |  | return false; | 
| 180 |  | } | 
| 181 | + |  | 
| 182 | + | void ForceDecomposition::addToHeatFlux(Vector3d hf) { | 
| 183 | + | Vector3d chf = snap_->getConductiveHeatFlux(); | 
| 184 | + | chf += hf; | 
| 185 | + | snap_->setConductiveHeatFlux(chf); | 
| 186 | + | } | 
| 187 | + | void ForceDecomposition::setHeatFlux(Vector3d hf) { | 
| 188 | + | snap_->setConductiveHeatFlux(hf); | 
| 189 | + | } | 
| 190 | + |  | 
| 191 |  | } |