48#include "parallel/ForceDecomposition.hpp"
59 ForceDecomposition::ForceDecomposition(
SimInfo* info,
62 interactionMan_(iMan), needVelocities_(false) {
63 sman_ = info_->getSnapshotManager();
64 atomStorageLayout_ = sman_->getAtomStorageLayout();
65 rigidBodyStorageLayout_ = sman_->getRigidBodyStorageLayout();
66 cutoffGroupStorageLayout_ = sman_->getCutoffGroupStorageLayout();
67 ff_ = info_->getForceField();
69 usePeriodicBoundaryConditions_ =
70 info->getSimParams()->getUsePeriodicBoundaryConditions();
72 Globals* simParams_ = info_->getSimParams();
73 if (simParams_->havePrintHeatFlux()) {
74 if (simParams_->getPrintHeatFlux()) { needVelocities_ = true; }
77 if (simParams_->haveSkinThickness()) {
78 skinThickness_ = simParams_->getSkinThickness();
81 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
82 "ForceDecomposition: No value was set for the skinThickness.\n"
83 "\tOpenMD will use a default value of %f Angstroms\n"
84 "\tfor this simulation\n",
86 painCave.severity = OPENMD_INFO;
94 cellOffsets_.push_back(Vector3i(0, 0, 0));
95 cellOffsets_.push_back(Vector3i(1, 0, 0));
96 cellOffsets_.push_back(Vector3i(1, 1, 0));
97 cellOffsets_.push_back(Vector3i(0, 1, 0));
98 cellOffsets_.push_back(Vector3i(-1, 1, 0));
99 cellOffsets_.push_back(Vector3i(0, 0, 1));
100 cellOffsets_.push_back(Vector3i(1, 0, 1));
101 cellOffsets_.push_back(Vector3i(1, 1, 1));
102 cellOffsets_.push_back(Vector3i(0, 1, 1));
103 cellOffsets_.push_back(Vector3i(-1, 1, 1));
104 cellOffsets_.push_back(Vector3i(-1, 0, 1));
105 cellOffsets_.push_back(Vector3i(-1, -1, 1));
106 cellOffsets_.push_back(Vector3i(0, -1, 1));
107 cellOffsets_.push_back(Vector3i(1, -1, 1));
110 void ForceDecomposition::setCutoffRadius(RealType rcut) {
112 rList_ = rCut_ + skinThickness_;
113 rListSq_ = rList_ * rList_;
116 void ForceDecomposition::fillPreForceData(SelfData& sdat,
int atom) {
117 sdat.atid = idents[atom];
118 sdat.selfPot = selfPot;
119 sdat.selePot = selectedSelfPot;
121 if (atomStorageLayout_ & DataStorage::dslDensity) {
122 sdat.rho = snap_->atomData.density[atom];
125 if (atomStorageLayout_ & DataStorage::dslParticlePot) {
126 sdat.particlePot = snap_->atomData.particlePot[atom];
130 void ForceDecomposition::fillSelfData(SelfData& sdat,
int atom) {
131 sdat.atid = idents[atom];
132 sdat.selfPot = selfPot;
133 sdat.selePot = selectedSelfPot;
135 if (atomStorageLayout_ & DataStorage::dslSkippedCharge) {
136 sdat.skippedCharge = snap_->atomData.skippedCharge[atom];
139 if (atomStorageLayout_ & DataStorage::dslParticlePot) {
140 sdat.particlePot = snap_->atomData.particlePot[atom];
143 if (atomStorageLayout_ & DataStorage::dslFlucQPosition) {
144 sdat.flucQ = snap_->atomData.flucQPos[atom];
147 if (atomStorageLayout_ & DataStorage::dslFlucQForce) {
148 sdat.flucQfrc = snap_->atomData.flucQFrc[atom];
152 void ForceDecomposition::unpackPreForceData(SelfData& sdat,
int atom) {
153 selfPot = sdat.selfPot;
154 selectedSelfPot = sdat.selePot;
156 if (atomStorageLayout_ & DataStorage::dslFunctional) {
157 snap_->atomData.functional[atom] += sdat.frho;
160 if (atomStorageLayout_ & DataStorage::dslFunctionalDerivative) {
161 snap_->atomData.functionalDerivative[atom] += sdat.dfrhodrho;
164 if (sdat.doParticlePot &&
165 (atomStorageLayout_ & DataStorage::dslParticlePot)) {
166 snap_->atomData.particlePot[atom] = sdat.particlePot;
170 void ForceDecomposition::unpackSelfData(SelfData& sdat,
int atom) {
171 selfPot = sdat.selfPot;
172 selectedSelfPot = sdat.selePot;
174 if (atomStorageLayout_ & DataStorage::dslFlucQForce) {
175 snap_->atomData.flucQFrc[atom] = sdat.flucQfrc;
179 bool ForceDecomposition::checkNeighborList(vector<Vector3d> savedPositions) {
180 RealType st2 = pow(skinThickness_ / 2.0, 2);
181 std::size_t nGroups = snap_->cgData.position.size();
183 snap_->cgData.setStorageLayout(DataStorage::dslPosition |
184 DataStorage::dslVelocity);
189 if (savedPositions.size() != nGroups)
return true;
191 RealType dispmax = 0.0;
194 for (std::size_t i = 0; i < nGroups; i++) {
195 disp = snap_->cgData.position[i] - savedPositions[i];
196 dispmax = max(dispmax, disp.lengthSquare());
200 MPI_Allreduce(MPI_IN_PLACE, &dispmax, 1, MPI_REALTYPE, MPI_MAX,
204 return (dispmax > st2) ? true :
false;
207 void ForceDecomposition::addToHeatFlux(Vector3d hf) {
208 Vector3d chf = snap_->getConductiveHeatFlux();
210 snap_->setConductiveHeatFlux(chf);
212 void ForceDecomposition::setHeatFlux(Vector3d hf) {
213 snap_->setConductiveHeatFlux(hf);
InteractionManager is responsible for keeping track of the non-bonded interactions (C++).
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.