| 47 |  | * @version 1.0 | 
| 48 |  | */ | 
| 49 |  |  | 
| 50 | + |  | 
| 51 |  | #include "brains/ForceManager.hpp" | 
| 52 |  | #include "primitives/Molecule.hpp" | 
| 53 |  | #define __OPENMD_C | 
| 59 |  | #include "nonbonded/NonBondedInteraction.hpp" | 
| 60 |  | #include "parallel/ForceMatrixDecomposition.hpp" | 
| 61 |  |  | 
| 62 | + | #include <cstdio> | 
| 63 | + | #include <iostream> | 
| 64 | + | #include <iomanip> | 
| 65 | + |  | 
| 66 |  | using namespace std; | 
| 67 |  | namespace OpenMD { | 
| 68 |  |  | 
| 69 |  | ForceManager::ForceManager(SimInfo * info) : info_(info) { | 
| 70 | < |  | 
| 71 | < | #ifdef IS_MPI | 
| 72 | < | fDecomp_ = new ForceMatrixDecomposition(info_); | 
| 68 | < | #else | 
| 69 | < | // fDecomp_ = new ForceSerialDecomposition(info); | 
| 70 | < | #endif | 
| 70 | > | forceField_ = info_->getForceField(); | 
| 71 | > | interactionMan_ = new InteractionManager(); | 
| 72 | > | fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_); | 
| 73 |  | } | 
| 74 | + |  | 
| 75 | + | /** | 
| 76 | + | * setupCutoffs | 
| 77 | + | * | 
| 78 | + | * Sets the values of cutoffRadius, switchingRadius, cutoffMethod, | 
| 79 | + | * and cutoffPolicy | 
| 80 | + | * | 
| 81 | + | * cutoffRadius : realType | 
| 82 | + | *  If the cutoffRadius was explicitly set, use that value. | 
| 83 | + | *  If the cutoffRadius was not explicitly set: | 
| 84 | + | *      Are there electrostatic atoms?  Use 12.0 Angstroms. | 
| 85 | + | *      No electrostatic atoms?  Poll the atom types present in the | 
| 86 | + | *      simulation for suggested cutoff values (e.g. 2.5 * sigma). | 
| 87 | + | *      Use the maximum suggested value that was found. | 
| 88 | + | * | 
| 89 | + | * cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL) | 
| 90 | + | *      If cutoffMethod was explicitly set, use that choice. | 
| 91 | + | *      If cutoffMethod was not explicitly set, use SHIFTED_FORCE | 
| 92 | + | * | 
| 93 | + | * cutoffPolicy : (one of MIX, MAX, TRADITIONAL) | 
| 94 | + | *      If cutoffPolicy was explicitly set, use that choice. | 
| 95 | + | *      If cutoffPolicy was not explicitly set, use TRADITIONAL | 
| 96 | + | * | 
| 97 | + | * switchingRadius : realType | 
| 98 | + | *  If the cutoffMethod was set to SWITCHED: | 
| 99 | + | *      If the switchingRadius was explicitly set, use that value | 
| 100 | + | *          (but do a sanity check first). | 
| 101 | + | *      If the switchingRadius was not explicitly set: use 0.85 * | 
| 102 | + | *      cutoffRadius_ | 
| 103 | + | *  If the cutoffMethod was not set to SWITCHED: | 
| 104 | + | *      Set switchingRadius equal to cutoffRadius for safety. | 
| 105 | + | */ | 
| 106 | + | void ForceManager::setupCutoffs() { | 
| 107 | + |  | 
| 108 | + | Globals* simParams_ = info_->getSimParams(); | 
| 109 | + | ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); | 
| 110 | + |  | 
| 111 | + | if (simParams_->haveCutoffRadius()) { | 
| 112 | + | rCut_ = simParams_->getCutoffRadius(); | 
| 113 | + | } else { | 
| 114 | + | if (info_->usesElectrostaticAtoms()) { | 
| 115 | + | sprintf(painCave.errMsg, | 
| 116 | + | "ForceManager::setupCutoffs: No value was set for the cutoffRadius.\n" | 
| 117 | + | "\tOpenMD will use a default value of 12.0 angstroms" | 
| 118 | + | "\tfor the cutoffRadius.\n"); | 
| 119 | + | painCave.isFatal = 0; | 
| 120 | + | painCave.severity = OPENMD_INFO; | 
| 121 | + | simError(); | 
| 122 | + | rCut_ = 12.0; | 
| 123 | + | } else { | 
| 124 | + | RealType thisCut; | 
| 125 | + | set<AtomType*>::iterator i; | 
| 126 | + | set<AtomType*> atomTypes; | 
| 127 | + | atomTypes = info_->getSimulatedAtomTypes(); | 
| 128 | + | for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { | 
| 129 | + | thisCut = interactionMan_->getSuggestedCutoffRadius((*i)); | 
| 130 | + | rCut_ = max(thisCut, rCut_); | 
| 131 | + | } | 
| 132 | + | sprintf(painCave.errMsg, | 
| 133 | + | "ForceManager::setupCutoffs: No value was set for the cutoffRadius.\n" | 
| 134 | + | "\tOpenMD will use %lf angstroms.\n", | 
| 135 | + | rCut_); | 
| 136 | + | painCave.isFatal = 0; | 
| 137 | + | painCave.severity = OPENMD_INFO; | 
| 138 | + | simError(); | 
| 139 | + | } | 
| 140 | + | } | 
| 141 | + |  | 
| 142 | + | fDecomp_->setUserCutoff(rCut_); | 
| 143 | + | interactionMan_->setCutoffRadius(rCut_); | 
| 144 | + |  | 
| 145 | + | map<string, CutoffMethod> stringToCutoffMethod; | 
| 146 | + | stringToCutoffMethod["HARD"] = HARD; | 
| 147 | + | stringToCutoffMethod["SWITCHED"] = SWITCHED; | 
| 148 | + | stringToCutoffMethod["SHIFTED_POTENTIAL"] = SHIFTED_POTENTIAL; | 
| 149 | + | stringToCutoffMethod["SHIFTED_FORCE"] = SHIFTED_FORCE; | 
| 150 |  |  | 
| 151 | < | void ForceManager::calcForces() { | 
| 151 | > | if (simParams_->haveCutoffMethod()) { | 
| 152 | > | string cutMeth = toUpperCopy(simParams_->getCutoffMethod()); | 
| 153 | > | map<string, CutoffMethod>::iterator i; | 
| 154 | > | i = stringToCutoffMethod.find(cutMeth); | 
| 155 | > | if (i == stringToCutoffMethod.end()) { | 
| 156 | > | sprintf(painCave.errMsg, | 
| 157 | > | "ForceManager::setupCutoffs: Could not find chosen cutoffMethod %s\n" | 
| 158 | > | "\tShould be one of: " | 
| 159 | > | "HARD, SWITCHED, SHIFTED_POTENTIAL, or SHIFTED_FORCE\n", | 
| 160 | > | cutMeth.c_str()); | 
| 161 | > | painCave.isFatal = 1; | 
| 162 | > | painCave.severity = OPENMD_ERROR; | 
| 163 | > | simError(); | 
| 164 | > | } else { | 
| 165 | > | cutoffMethod_ = i->second; | 
| 166 | > | } | 
| 167 | > | } else { | 
| 168 | > | sprintf(painCave.errMsg, | 
| 169 | > | "ForceManager::setupCutoffs: No value was set for the cutoffMethod.\n" | 
| 170 | > | "\tOpenMD will use SHIFTED_FORCE.\n"); | 
| 171 | > | painCave.isFatal = 0; | 
| 172 | > | painCave.severity = OPENMD_INFO; | 
| 173 | > | simError(); | 
| 174 | > | cutoffMethod_ = SHIFTED_FORCE; | 
| 175 | > | } | 
| 176 | > |  | 
| 177 | > | map<string, CutoffPolicy> stringToCutoffPolicy; | 
| 178 | > | stringToCutoffPolicy["MIX"] = MIX; | 
| 179 | > | stringToCutoffPolicy["MAX"] = MAX; | 
| 180 | > | stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL; | 
| 181 | > |  | 
| 182 | > | std::string cutPolicy; | 
| 183 | > | if (forceFieldOptions_.haveCutoffPolicy()){ | 
| 184 | > | cutPolicy = forceFieldOptions_.getCutoffPolicy(); | 
| 185 | > | }else if (simParams_->haveCutoffPolicy()) { | 
| 186 | > | cutPolicy = simParams_->getCutoffPolicy(); | 
| 187 | > | } | 
| 188 | > |  | 
| 189 | > | if (!cutPolicy.empty()){ | 
| 190 | > | toUpper(cutPolicy); | 
| 191 | > | map<string, CutoffPolicy>::iterator i; | 
| 192 | > | i = stringToCutoffPolicy.find(cutPolicy); | 
| 193 | > |  | 
| 194 | > | if (i == stringToCutoffPolicy.end()) { | 
| 195 | > | sprintf(painCave.errMsg, | 
| 196 | > | "ForceManager::setupCutoffs: Could not find chosen cutoffPolicy %s\n" | 
| 197 | > | "\tShould be one of: " | 
| 198 | > | "MIX, MAX, or TRADITIONAL\n", | 
| 199 | > | cutPolicy.c_str()); | 
| 200 | > | painCave.isFatal = 1; | 
| 201 | > | painCave.severity = OPENMD_ERROR; | 
| 202 | > | simError(); | 
| 203 | > | } else { | 
| 204 | > | cutoffPolicy_ = i->second; | 
| 205 | > | } | 
| 206 | > | } else { | 
| 207 | > | sprintf(painCave.errMsg, | 
| 208 | > | "ForceManager::setupCutoffs: No value was set for the cutoffPolicy.\n" | 
| 209 | > | "\tOpenMD will use TRADITIONAL.\n"); | 
| 210 | > | painCave.isFatal = 0; | 
| 211 | > | painCave.severity = OPENMD_INFO; | 
| 212 | > | simError(); | 
| 213 | > | cutoffPolicy_ = TRADITIONAL; | 
| 214 | > | } | 
| 215 | > |  | 
| 216 | > | fDecomp_->setCutoffPolicy(cutoffPolicy_); | 
| 217 | > |  | 
| 218 | > | // create the switching function object: | 
| 219 | > |  | 
| 220 | > | switcher_ = new SwitchingFunction(); | 
| 221 | > |  | 
| 222 | > | if (cutoffMethod_ == SWITCHED) { | 
| 223 | > | if (simParams_->haveSwitchingRadius()) { | 
| 224 | > | rSwitch_ = simParams_->getSwitchingRadius(); | 
| 225 | > | if (rSwitch_ > rCut_) { | 
| 226 | > | sprintf(painCave.errMsg, | 
| 227 | > | "ForceManager::setupCutoffs: switchingRadius (%f) is larger " | 
| 228 | > | "than the cutoffRadius(%f)\n", rSwitch_, rCut_); | 
| 229 | > | painCave.isFatal = 1; | 
| 230 | > | painCave.severity = OPENMD_ERROR; | 
| 231 | > | simError(); | 
| 232 | > | } | 
| 233 | > | } else { | 
| 234 | > | rSwitch_ = 0.85 * rCut_; | 
| 235 | > | sprintf(painCave.errMsg, | 
| 236 | > | "ForceManager::setupCutoffs: No value was set for the switchingRadius.\n" | 
| 237 | > | "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n" | 
| 238 | > | "\tswitchingRadius = %f. for this simulation\n", rSwitch_); | 
| 239 | > | painCave.isFatal = 0; | 
| 240 | > | painCave.severity = OPENMD_WARNING; | 
| 241 | > | simError(); | 
| 242 | > | } | 
| 243 | > | } else { | 
| 244 | > | if (simParams_->haveSwitchingRadius()) { | 
| 245 | > | map<string, CutoffMethod>::const_iterator it; | 
| 246 | > | string theMeth; | 
| 247 | > | for (it = stringToCutoffMethod.begin(); | 
| 248 | > | it != stringToCutoffMethod.end(); ++it) { | 
| 249 | > | if (it->second == cutoffMethod_) { | 
| 250 | > | theMeth = it->first; | 
| 251 | > | break; | 
| 252 | > | } | 
| 253 | > | } | 
| 254 | > | sprintf(painCave.errMsg, | 
| 255 | > | "ForceManager::setupCutoffs: the cutoffMethod (%s)\n" | 
| 256 | > | "\tis not set to SWITCHED, so switchingRadius value\n" | 
| 257 | > | "\twill be ignored for this simulation\n", theMeth.c_str()); | 
| 258 | > | painCave.isFatal = 0; | 
| 259 | > | painCave.severity = OPENMD_WARNING; | 
| 260 | > | simError(); | 
| 261 | > | } | 
| 262 | > |  | 
| 263 | > | rSwitch_ = rCut_; | 
| 264 | > | } | 
| 265 |  |  | 
| 266 | + | // Default to cubic switching function. | 
| 267 | + | sft_ = cubic; | 
| 268 | + | if (simParams_->haveSwitchingFunctionType()) { | 
| 269 | + | string funcType = simParams_->getSwitchingFunctionType(); | 
| 270 | + | toUpper(funcType); | 
| 271 | + | if (funcType == "CUBIC") { | 
| 272 | + | sft_ = cubic; | 
| 273 | + | } else { | 
| 274 | + | if (funcType == "FIFTH_ORDER_POLYNOMIAL") { | 
| 275 | + | sft_ = fifth_order_poly; | 
| 276 | + | } else { | 
| 277 | + | // throw error | 
| 278 | + | sprintf( painCave.errMsg, | 
| 279 | + | "ForceManager::setupSwitching : Unknown switchingFunctionType. (Input file specified %s .)\n" | 
| 280 | + | "\tswitchingFunctionType must be one of: " | 
| 281 | + | "\"cubic\" or \"fifth_order_polynomial\".", | 
| 282 | + | funcType.c_str() ); | 
| 283 | + | painCave.isFatal = 1; | 
| 284 | + | painCave.severity = OPENMD_ERROR; | 
| 285 | + | simError(); | 
| 286 | + | } | 
| 287 | + | } | 
| 288 | + | } | 
| 289 | + | switcher_->setSwitchType(sft_); | 
| 290 | + | switcher_->setSwitch(rSwitch_, rCut_); | 
| 291 | + | interactionMan_->setSwitchingRadius(rSwitch_); | 
| 292 | + | } | 
| 293 | + |  | 
| 294 | + | void ForceManager::initialize() { | 
| 295 | + |  | 
| 296 |  | if (!info_->isTopologyDone()) { | 
| 297 |  | info_->update(); | 
| 298 |  | interactionMan_->setSimInfo(info_); | 
| 299 |  | interactionMan_->initialize(); | 
| 300 | < | swfun_ = interactionMan_->getSwitchingFunction(); | 
| 301 | < | fDecomp_->distributeInitialData(); | 
| 302 | < | info_->prepareTopology(); | 
| 300 | > |  | 
| 301 | > | // We want to delay the cutoffs until after the interaction | 
| 302 | > | // manager has set up the atom-atom interactions so that we can | 
| 303 | > | // query them for suggested cutoff values | 
| 304 | > |  | 
| 305 | > | setupCutoffs(); | 
| 306 | > |  | 
| 307 | > | info_->prepareTopology(); | 
| 308 |  | } | 
| 309 | + |  | 
| 310 | + | ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); | 
| 311 |  |  | 
| 312 | + | // Force fields can set options on how to scale van der Waals and electrostatic | 
| 313 | + | // interactions for atoms connected via bonds, bends and torsions | 
| 314 | + | // in this case the topological distance between atoms is: | 
| 315 | + | // 0 = topologically unconnected | 
| 316 | + | // 1 = bonded together | 
| 317 | + | // 2 = connected via a bend | 
| 318 | + | // 3 = connected via a torsion | 
| 319 | + |  | 
| 320 | + | vdwScale_.reserve(4); | 
| 321 | + | fill(vdwScale_.begin(), vdwScale_.end(), 0.0); | 
| 322 | + |  | 
| 323 | + | electrostaticScale_.reserve(4); | 
| 324 | + | fill(electrostaticScale_.begin(), electrostaticScale_.end(), 0.0); | 
| 325 | + |  | 
| 326 | + | vdwScale_[0] = 1.0; | 
| 327 | + | vdwScale_[1] = fopts.getvdw12scale(); | 
| 328 | + | vdwScale_[2] = fopts.getvdw13scale(); | 
| 329 | + | vdwScale_[3] = fopts.getvdw14scale(); | 
| 330 | + |  | 
| 331 | + | electrostaticScale_[0] = 1.0; | 
| 332 | + | electrostaticScale_[1] = fopts.getelectrostatic12scale(); | 
| 333 | + | electrostaticScale_[2] = fopts.getelectrostatic13scale(); | 
| 334 | + | electrostaticScale_[3] = fopts.getelectrostatic14scale(); | 
| 335 | + |  | 
| 336 | + | fDecomp_->distributeInitialData(); | 
| 337 | + |  | 
| 338 | + | initialized_ = true; | 
| 339 | + |  | 
| 340 | + | } | 
| 341 | + |  | 
| 342 | + | void ForceManager::calcForces() { | 
| 343 | + |  | 
| 344 | + | if (!initialized_) initialize(); | 
| 345 | + |  | 
| 346 |  | preCalculation(); | 
| 347 |  | shortRangeInteractions(); | 
| 348 |  | longRangeInteractions(); | 
| 349 | < | postCalculation(); | 
| 88 | < |  | 
| 349 | > | postCalculation(); | 
| 350 |  | } | 
| 351 |  |  | 
| 352 |  | void ForceManager::preCalculation() { | 
| 506 |  |  | 
| 507 |  | void ForceManager::longRangeInteractions() { | 
| 508 |  |  | 
| 248 | – | // some of this initial stuff will go away: | 
| 509 |  | Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 510 |  | DataStorage* config = &(curSnapshot->atomData); | 
| 511 |  | DataStorage* cgConfig = &(curSnapshot->cgData); | 
| 252 | – | RealType* frc = config->getArrayPointer(DataStorage::dslForce); | 
| 253 | – | RealType* pos = config->getArrayPointer(DataStorage::dslPosition); | 
| 254 | – | RealType* trq = config->getArrayPointer(DataStorage::dslTorque); | 
| 255 | – | RealType* A = config->getArrayPointer(DataStorage::dslAmat); | 
| 256 | – | RealType* electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame); | 
| 257 | – | RealType* particlePot = config->getArrayPointer(DataStorage::dslParticlePot); | 
| 258 | – | RealType* rc; | 
| 512 |  |  | 
| 513 | < | if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){ | 
| 514 | < | rc = cgConfig->getArrayPointer(DataStorage::dslPosition); | 
| 513 | > | //calculate the center of mass of cutoff group | 
| 514 | > |  | 
| 515 | > | SimInfo::MoleculeIterator mi; | 
| 516 | > | Molecule* mol; | 
| 517 | > | Molecule::CutoffGroupIterator ci; | 
| 518 | > | CutoffGroup* cg; | 
| 519 | > |  | 
| 520 | > | if(info_->getNCutoffGroups() > 0){ | 
| 521 | > | for (mol = info_->beginMolecule(mi); mol != NULL; | 
| 522 | > | mol = info_->nextMolecule(mi)) { | 
| 523 | > | for(cg = mol->beginCutoffGroup(ci); cg != NULL; | 
| 524 | > | cg = mol->nextCutoffGroup(ci)) { | 
| 525 | > | cg->updateCOM(); | 
| 526 | > | } | 
| 527 | > | } | 
| 528 |  | } else { | 
| 529 |  | // center of mass of the group is the same as position of the atom | 
| 530 |  | // if cutoff group does not exist | 
| 531 | < | rc = pos; | 
| 531 | > | cgConfig->position = config->position; | 
| 532 |  | } | 
| 267 | – |  | 
| 268 | – | //initialize data before passing to fortran | 
| 269 | – | RealType longRangePotential[N_INTERACTION_FAMILIES]; | 
| 270 | – | RealType lrPot = 0.0; | 
| 271 | – | int isError = 0; | 
| 533 |  |  | 
| 534 | < | // dangerous to iterate over enums, but we'll live on the edge: | 
| 274 | < | for (int i = NO_FAMILY; i != N_INTERACTION_FAMILIES; ++i){ | 
| 275 | < | longRangePotential[i]=0.0; //Initialize array | 
| 276 | < | } | 
| 277 | < |  | 
| 278 | < | // new stuff starts here: | 
| 279 | < |  | 
| 534 | > | fDecomp_->zeroWorkArrays(); | 
| 535 |  | fDecomp_->distributeData(); | 
| 536 | < |  | 
| 537 | < | int cg1, cg2, atom1, atom2; | 
| 538 | < | Vector3d d_grp, dag; | 
| 539 | < | RealType rgrpsq, rgrp; | 
| 536 | > |  | 
| 537 | > | int cg1, cg2, atom1, atom2, topoDist; | 
| 538 | > | Vector3d d_grp, dag, d; | 
| 539 | > | RealType rgrpsq, rgrp, r2, r; | 
| 540 | > | RealType electroMult, vdwMult; | 
| 541 |  | RealType vij; | 
| 542 | < | Vector3d fij, fg; | 
| 543 | < | pair<int, int> gtypes; | 
| 542 | > | Vector3d fij, fg, f1; | 
| 543 | > | tuple3<RealType, RealType, RealType> cuts; | 
| 544 |  | RealType rCutSq; | 
| 545 |  | bool in_switching_region; | 
| 546 |  | RealType sw, dswdr, swderiv; | 
| 548 |  | InteractionData idat; | 
| 549 |  | SelfData sdat; | 
| 550 |  | RealType mf; | 
| 551 | + | RealType lrPot; | 
| 552 | + | RealType vpair; | 
| 553 | + | potVec longRangePotential(0.0); | 
| 554 | + | potVec workPot(0.0); | 
| 555 |  |  | 
| 556 |  | int loopStart, loopEnd; | 
| 557 |  |  | 
| 558 | + | idat.vdwMult = &vdwMult; | 
| 559 | + | idat.electroMult = &electroMult; | 
| 560 | + | idat.pot = &workPot; | 
| 561 | + | sdat.pot = fDecomp_->getEmbeddingPotential(); | 
| 562 | + | idat.vpair = &vpair; | 
| 563 | + | idat.f1 = &f1; | 
| 564 | + | idat.sw = &sw; | 
| 565 | + | idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; | 
| 566 | + | idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false; | 
| 567 | + |  | 
| 568 |  | loopEnd = PAIR_LOOP; | 
| 569 |  | if (info_->requiresPrepair() ) { | 
| 570 |  | loopStart = PREPAIR_LOOP; | 
| 571 |  | } else { | 
| 572 |  | loopStart = PAIR_LOOP; | 
| 573 |  | } | 
| 574 | < |  | 
| 575 | < | for (int iLoop = loopStart; iLoop < loopEnd; iLoop++) { | 
| 576 | < |  | 
| 574 | > |  | 
| 575 | > | for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) { | 
| 576 | > |  | 
| 577 |  | if (iLoop == loopStart) { | 
| 578 |  | bool update_nlist = fDecomp_->checkNeighborList(); | 
| 579 |  | if (update_nlist) | 
| 580 |  | neighborList = fDecomp_->buildNeighborList(); | 
| 581 | < | } | 
| 582 | < |  | 
| 581 | > | } | 
| 582 | > |  | 
| 583 |  | for (vector<pair<int, int> >::iterator it = neighborList.begin(); | 
| 584 |  | it != neighborList.end(); ++it) { | 
| 585 | < |  | 
| 585 | > |  | 
| 586 |  | cg1 = (*it).first; | 
| 587 |  | cg2 = (*it).second; | 
| 588 | + |  | 
| 589 | + | cuts = fDecomp_->getGroupCutoffs(cg1, cg2); | 
| 590 |  |  | 
| 319 | – | gtypes = fDecomp_->getGroupTypes(cg1, cg2); | 
| 591 |  | d_grp  = fDecomp_->getIntergroupVector(cg1, cg2); | 
| 592 |  | curSnapshot->wrapVector(d_grp); | 
| 593 |  | rgrpsq = d_grp.lengthSquare(); | 
| 323 | – | rCutSq = groupCutoffMap[gtypes].first; | 
| 594 |  |  | 
| 595 | + | rCutSq = cuts.second; | 
| 596 | + |  | 
| 597 |  | if (rgrpsq < rCutSq) { | 
| 598 | < | *(idat.rcut) = groupCutoffMap[gtypes].second; | 
| 598 | > | idat.rcut = &cuts.first; | 
| 599 |  | if (iLoop == PAIR_LOOP) { | 
| 600 | < | vij *= 0.0; | 
| 600 | > | vij = 0.0; | 
| 601 |  | fij = V3Zero; | 
| 602 |  | } | 
| 603 |  |  | 
| 604 | < | in_switching_region = swfun_->getSwitch(rgrpsq, *(idat.sw), dswdr, | 
| 605 | < | rgrp); | 
| 604 | > | in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, | 
| 605 | > | rgrp); | 
| 606 | > |  | 
| 607 |  | atomListRow = fDecomp_->getAtomsInGroupRow(cg1); | 
| 608 |  | atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); | 
| 609 |  |  | 
| 614 |  | for (vector<int>::iterator jb = atomListColumn.begin(); | 
| 615 |  | jb != atomListColumn.end(); ++jb) { | 
| 616 |  | atom2 = (*jb); | 
| 617 | < |  | 
| 617 | > |  | 
| 618 |  | if (!fDecomp_->skipAtomPair(atom1, atom2)) { | 
| 619 | + | vpair = 0.0; | 
| 620 | + | workPot = 0.0; | 
| 621 | + | f1 = V3Zero; | 
| 622 | + |  | 
| 623 | + | fDecomp_->fillInteractionData(idat, atom1, atom2); | 
| 624 |  |  | 
| 625 | < | idat = fDecomp_->fillInteractionData(atom1, atom2); | 
| 625 | > | topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); | 
| 626 | > | vdwMult = vdwScale_[topoDist]; | 
| 627 | > | electroMult = electrostaticScale_[topoDist]; | 
| 628 |  |  | 
| 629 |  | if (atomListRow.size() == 1 && atomListColumn.size() == 1) { | 
| 630 | < | *(idat.d) = d_grp; | 
| 631 | < | *(idat.r2) = rgrpsq; | 
| 630 | > | idat.d = &d_grp; | 
| 631 | > | idat.r2 = &rgrpsq; | 
| 632 |  | } else { | 
| 633 | < | *(idat.d) = fDecomp_->getInteratomicVector(atom1, atom2); | 
| 634 | < | curSnapshot->wrapVector( *(idat.d) ); | 
| 635 | < | *(idat.r2) = idat.d->lengthSquare(); | 
| 633 | > | d = fDecomp_->getInteratomicVector(atom1, atom2); | 
| 634 | > | curSnapshot->wrapVector( d ); | 
| 635 | > | r2 = d.lengthSquare(); | 
| 636 | > | idat.d = &d; | 
| 637 | > | idat.r2 = &r2; | 
| 638 |  | } | 
| 639 |  |  | 
| 640 | < | *(idat.rij) = sqrt( *(idat.r2) ); | 
| 640 | > | r = sqrt( *(idat.r2) ); | 
| 641 | > | idat.rij = &r; | 
| 642 |  |  | 
| 643 |  | if (iLoop == PREPAIR_LOOP) { | 
| 644 |  | interactionMan_->doPrePair(idat); | 
| 645 |  | } else { | 
| 646 |  | interactionMan_->doPair(idat); | 
| 647 | < | vij += *(idat.vpair); | 
| 648 | < | fij += *(idat.f1); | 
| 649 | < | tau -= outProduct( *(idat.d), *(idat.f1)); | 
| 647 | > | fDecomp_->unpackInteractionData(idat, atom1, atom2); | 
| 648 | > | vij += vpair; | 
| 649 | > | fij += f1; | 
| 650 | > | tau -= outProduct( *(idat.d), f1); | 
| 651 |  | } | 
| 652 |  | } | 
| 653 |  | } | 
| 657 |  | if (in_switching_region) { | 
| 658 |  | swderiv = vij * dswdr / rgrp; | 
| 659 |  | fg = swderiv * d_grp; | 
| 376 | – |  | 
| 660 |  | fij += fg; | 
| 661 |  |  | 
| 662 |  | if (atomListRow.size() == 1 && atomListColumn.size() == 1) { | 
| 712 |  | fDecomp_->collectIntermediateData(); | 
| 713 |  |  | 
| 714 |  | for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { | 
| 715 | < | sdat = fDecomp_->fillSelfData(atom1); | 
| 715 | > | fDecomp_->fillSelfData(sdat, atom1); | 
| 716 |  | interactionMan_->doPreForce(sdat); | 
| 717 |  | } | 
| 718 | < |  | 
| 718 | > |  | 
| 719 | > |  | 
| 720 |  | fDecomp_->distributeIntermediateData(); | 
| 721 |  | } | 
| 722 |  | } | 
| 724 |  | } | 
| 725 |  |  | 
| 726 |  | fDecomp_->collectData(); | 
| 443 | – |  | 
| 444 | – | if ( info_->requiresSkipCorrection() ) { | 
| 445 | – |  | 
| 446 | – | for (int atom1 = 0; atom1 < fDecomp_->getNAtomsInRow(); atom1++) { | 
| 447 | – |  | 
| 448 | – | vector<int> skipList = fDecomp_->getSkipsForRowAtom( atom1 ); | 
| 727 |  |  | 
| 450 | – | for (vector<int>::iterator jb = skipList.begin(); | 
| 451 | – | jb != skipList.end(); ++jb) { | 
| 452 | – |  | 
| 453 | – | atom2 = (*jb); | 
| 454 | – | idat = fDecomp_->fillSkipData(atom1, atom2); | 
| 455 | – | interactionMan_->doSkipCorrection(idat); | 
| 456 | – |  | 
| 457 | – | } | 
| 458 | – | } | 
| 459 | – | } | 
| 460 | – |  | 
| 728 |  | if (info_->requiresSelfCorrection()) { | 
| 729 |  |  | 
| 730 |  | for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { | 
| 731 | < | sdat = fDecomp_->fillSelfData(atom1); | 
| 731 | > | fDecomp_->fillSelfData(sdat, atom1); | 
| 732 |  | interactionMan_->doSelfCorrection(sdat); | 
| 733 |  | } | 
| 734 |  |  | 
| 735 |  | } | 
| 736 |  |  | 
| 737 | < | // dangerous to iterate over enums, but we'll live on the edge: | 
| 738 | < | for (int i = NO_FAMILY; i != N_INTERACTION_FAMILIES; ++i){ | 
| 739 | < | lrPot += longRangePotential[i]; //Quick hack | 
| 740 | < | } | 
| 741 | < |  | 
| 737 | > | longRangePotential = *(fDecomp_->getEmbeddingPotential()) + | 
| 738 | > | *(fDecomp_->getPairwisePotential()); | 
| 739 | > |  | 
| 740 | > | lrPot = longRangePotential.sum(); | 
| 741 | > |  | 
| 742 |  | //store the tau and long range potential | 
| 743 |  | curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; | 
| 744 |  | curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |