| 58 | 
  | 
#include "primitives/Inversion.hpp" | 
| 59 | 
  | 
#include "nonbonded/NonBondedInteraction.hpp" | 
| 60 | 
  | 
#include "perturbations/UniformField.hpp" | 
| 61 | 
+ | 
#include "perturbations/UniformGradient.hpp" | 
| 62 | 
  | 
#include "parallel/ForceMatrixDecomposition.hpp" | 
| 63 | 
  | 
 | 
| 64 | 
  | 
#include <cstdio> | 
| 68 | 
  | 
using namespace std; | 
| 69 | 
  | 
namespace OpenMD { | 
| 70 | 
  | 
   | 
| 71 | 
< | 
  ForceManager::ForceManager(SimInfo * info) : info_(info), switcher_(NULL), | 
| 72 | 
< | 
                                               initialized_(false) { | 
| 71 | 
> | 
  ForceManager::ForceManager(SimInfo * info) : info_(info),  | 
| 72 | 
> | 
                                               initialized_(false), | 
| 73 | 
> | 
                                               switcher_(NULL) { | 
| 74 | 
  | 
    forceField_ = info_->getForceField(); | 
| 75 | 
  | 
    interactionMan_ = new InteractionManager(); | 
| 76 | 
  | 
    fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_); | 
| 89 | 
  | 
  /** | 
| 90 | 
  | 
   * setupCutoffs | 
| 91 | 
  | 
   * | 
| 92 | 
< | 
   * Sets the values of cutoffRadius, switchingRadius, cutoffMethod, | 
| 91 | 
< | 
   * and cutoffPolicy | 
| 92 | 
> | 
   * Sets the values of cutoffRadius, switchingRadius, and cutoffMethod | 
| 93 | 
  | 
   * | 
| 94 | 
  | 
   * cutoffRadius : realType | 
| 95 | 
  | 
   *  If the cutoffRadius was explicitly set, use that value. | 
| 104 | 
  | 
   *      If cutoffMethod was explicitly set, use that choice. | 
| 105 | 
  | 
   *      If cutoffMethod was not explicitly set, use SHIFTED_FORCE | 
| 106 | 
  | 
   * | 
| 106 | 
– | 
   * cutoffPolicy : (one of MIX, MAX, TRADITIONAL) | 
| 107 | 
– | 
   *      If cutoffPolicy was explicitly set, use that choice. | 
| 108 | 
– | 
   *      If cutoffPolicy was not explicitly set, use TRADITIONAL | 
| 109 | 
– | 
   * | 
| 107 | 
  | 
   * switchingRadius : realType | 
| 108 | 
  | 
   *  If the cutoffMethod was set to SWITCHED: | 
| 109 | 
  | 
   *      If the switchingRadius was explicitly set, use that value | 
| 160 | 
  | 
      } | 
| 161 | 
  | 
    } | 
| 162 | 
  | 
 | 
| 163 | 
< | 
    fDecomp_->setUserCutoff(rCut_); | 
| 163 | 
> | 
    fDecomp_->setCutoffRadius(rCut_); | 
| 164 | 
  | 
    interactionMan_->setCutoffRadius(rCut_); | 
| 165 | 
+ | 
    rCutSq_ = rCut_ * rCut_; | 
| 166 | 
  | 
 | 
| 167 | 
  | 
    map<string, CutoffMethod> stringToCutoffMethod; | 
| 168 | 
  | 
    stringToCutoffMethod["HARD"] = HARD; | 
| 271 | 
  | 
          } | 
| 272 | 
  | 
        } | 
| 273 | 
  | 
      } | 
| 276 | 
– | 
    } | 
| 277 | 
– | 
 | 
| 278 | 
– | 
    map<string, CutoffPolicy> stringToCutoffPolicy; | 
| 279 | 
– | 
    stringToCutoffPolicy["MIX"] = MIX; | 
| 280 | 
– | 
    stringToCutoffPolicy["MAX"] = MAX; | 
| 281 | 
– | 
    stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL;     | 
| 282 | 
– | 
 | 
| 283 | 
– | 
    string cutPolicy; | 
| 284 | 
– | 
    if (forceFieldOptions_.haveCutoffPolicy()){ | 
| 285 | 
– | 
      cutPolicy = forceFieldOptions_.getCutoffPolicy(); | 
| 286 | 
– | 
    }else if (simParams_->haveCutoffPolicy()) { | 
| 287 | 
– | 
      cutPolicy = simParams_->getCutoffPolicy(); | 
| 274 | 
  | 
    } | 
| 289 | 
– | 
 | 
| 290 | 
– | 
    if (!cutPolicy.empty()){ | 
| 291 | 
– | 
      toUpper(cutPolicy); | 
| 292 | 
– | 
      map<string, CutoffPolicy>::iterator i; | 
| 293 | 
– | 
      i = stringToCutoffPolicy.find(cutPolicy); | 
| 294 | 
– | 
 | 
| 295 | 
– | 
      if (i == stringToCutoffPolicy.end()) { | 
| 296 | 
– | 
        sprintf(painCave.errMsg, | 
| 297 | 
– | 
                "ForceManager::setupCutoffs: Could not find chosen cutoffPolicy %s\n" | 
| 298 | 
– | 
                "\tShould be one of: " | 
| 299 | 
– | 
                "MIX, MAX, or TRADITIONAL\n", | 
| 300 | 
– | 
                cutPolicy.c_str()); | 
| 301 | 
– | 
        painCave.isFatal = 1; | 
| 302 | 
– | 
        painCave.severity = OPENMD_ERROR; | 
| 303 | 
– | 
        simError(); | 
| 304 | 
– | 
      } else { | 
| 305 | 
– | 
        cutoffPolicy_ = i->second; | 
| 306 | 
– | 
      } | 
| 307 | 
– | 
    } else { | 
| 308 | 
– | 
      sprintf(painCave.errMsg, | 
| 309 | 
– | 
              "ForceManager::setupCutoffs: No value was set for the cutoffPolicy.\n" | 
| 310 | 
– | 
              "\tOpenMD will use TRADITIONAL.\n"); | 
| 311 | 
– | 
      painCave.isFatal = 0; | 
| 312 | 
– | 
      painCave.severity = OPENMD_INFO; | 
| 313 | 
– | 
      simError(); | 
| 314 | 
– | 
      cutoffPolicy_ = TRADITIONAL;         | 
| 315 | 
– | 
    } | 
| 316 | 
– | 
 | 
| 317 | 
– | 
    fDecomp_->setCutoffPolicy(cutoffPolicy_); | 
| 275 | 
  | 
         | 
| 276 | 
  | 
    // create the switching function object: | 
| 277 | 
  | 
 | 
| 406 | 
  | 
      UniformField* eField = new UniformField(info_); | 
| 407 | 
  | 
      perturbations_.push_back(eField); | 
| 408 | 
  | 
    } | 
| 409 | 
< | 
 | 
| 409 | 
> | 
    if (info_->getSimParams()->haveUniformGradientStrength() || | 
| 410 | 
> | 
        info_->getSimParams()->haveUniformGradientDirection1() || | 
| 411 | 
> | 
        info_->getSimParams()->haveUniformGradientDirection2() ) { | 
| 412 | 
> | 
      UniformGradient* eGrad = new UniformGradient(info_); | 
| 413 | 
> | 
      perturbations_.push_back(eGrad); | 
| 414 | 
> | 
    } | 
| 415 | 
> | 
     | 
| 416 | 
  | 
    usePeriodicBoundaryConditions_ = info_->getSimParams()->getUsePeriodicBoundaryConditions(); | 
| 417 | 
  | 
     | 
| 418 | 
  | 
    fDecomp_->distributeInitialData(); | 
| 628 | 
  | 
    DataStorage* config = &(curSnapshot->atomData); | 
| 629 | 
  | 
    DataStorage* cgConfig = &(curSnapshot->cgData); | 
| 630 | 
  | 
 | 
| 668 | 
– | 
 | 
| 631 | 
  | 
    //calculate the center of mass of cutoff group | 
| 632 | 
  | 
 | 
| 633 | 
  | 
    SimInfo::MoleculeIterator mi; | 
| 634 | 
  | 
    Molecule* mol; | 
| 635 | 
  | 
    Molecule::CutoffGroupIterator ci; | 
| 636 | 
  | 
    CutoffGroup* cg; | 
| 637 | 
< | 
 | 
| 638 | 
< | 
    if(info_->getNCutoffGroups() > 0){       | 
| 637 | 
> | 
     | 
| 638 | 
> | 
    if(info_->getNCutoffGroups() != info_->getNAtoms()){ | 
| 639 | 
  | 
      for (mol = info_->beginMolecule(mi); mol != NULL;  | 
| 640 | 
  | 
           mol = info_->nextMolecule(mi)) { | 
| 641 | 
  | 
        for(cg = mol->beginCutoffGroup(ci); cg != NULL;  | 
| 659 | 
  | 
    RealType electroMult, vdwMult; | 
| 660 | 
  | 
    RealType vij; | 
| 661 | 
  | 
    Vector3d fij, fg, f1; | 
| 700 | 
– | 
    tuple3<RealType, RealType, RealType> cuts; | 
| 701 | 
– | 
    RealType rCut, rCutSq, rListSq; | 
| 662 | 
  | 
    bool in_switching_region; | 
| 663 | 
  | 
    RealType sw, dswdr, swderiv; | 
| 664 | 
  | 
    vector<int> atomListColumn, atomListRow; | 
| 676 | 
  | 
    Vector3d eField2(0.0); | 
| 677 | 
  | 
    RealType sPot1(0.0); | 
| 678 | 
  | 
    RealType sPot2(0.0); | 
| 679 | 
+ | 
    bool newAtom1; | 
| 680 | 
  | 
                    | 
| 681 | 
  | 
    vector<int>::iterator ia, jb; | 
| 682 | 
  | 
 | 
| 683 | 
  | 
    int loopStart, loopEnd; | 
| 684 | 
  | 
     | 
| 685 | 
< | 
    idat.rcut = &rCut; | 
| 685 | 
> | 
    idat.rcut = &rCut_; | 
| 686 | 
  | 
    idat.vdwMult = &vdwMult; | 
| 687 | 
  | 
    idat.electroMult = &electroMult; | 
| 688 | 
  | 
    idat.pot = &workPot; | 
| 719 | 
  | 
        if (update_nlist) { | 
| 720 | 
  | 
          if (!usePeriodicBoundaryConditions_) | 
| 721 | 
  | 
            Mat3x3d bbox = thermo->getBoundingBox(); | 
| 722 | 
< | 
          fDecomp_->buildNeighborList(neighborList_); | 
| 722 | 
> | 
          fDecomp_->buildNeighborList(neighborList_, point_); | 
| 723 | 
  | 
        } | 
| 724 | 
  | 
      } | 
| 725 | 
  | 
 | 
| 726 | 
< | 
      for (vector<pair<int, int> >::iterator it = neighborList_.begin();  | 
| 766 | 
< | 
           it != neighborList_.end(); ++it) { | 
| 767 | 
< | 
                 | 
| 768 | 
< | 
        cg1 = (*it).first; | 
| 769 | 
< | 
        cg2 = (*it).second; | 
| 726 | 
> | 
      for (cg1 = 0; cg1 < point_.size() - 1; cg1++) { | 
| 727 | 
  | 
         | 
| 728 | 
< | 
        fDecomp_->getGroupCutoffs(cg1, cg2, rCut, rCutSq, rListSq); | 
| 729 | 
< | 
 | 
| 730 | 
< | 
        d_grp  = fDecomp_->getIntergroupVector(cg1, cg2); | 
| 731 | 
< | 
 | 
| 775 | 
< | 
        // already wrapped in the getIntergroupVector call: | 
| 776 | 
< | 
        // curSnapshot->wrapVector(d_grp);         | 
| 777 | 
< | 
        rgrpsq = d_grp.lengthSquare(); | 
| 728 | 
> | 
        atomListRow = fDecomp_->getAtomsInGroupRow(cg1);         | 
| 729 | 
> | 
        newAtom1 = true; | 
| 730 | 
> | 
         | 
| 731 | 
> | 
        for (int m2 = point_[cg1]; m2 < point_[cg1+1]; m2++) { | 
| 732 | 
  | 
 | 
| 733 | 
< | 
        if (rgrpsq < rCutSq) { | 
| 780 | 
< | 
          if (iLoop == PAIR_LOOP) { | 
| 781 | 
< | 
            vij = 0.0; | 
| 782 | 
< | 
            fij.zero(); | 
| 783 | 
< | 
            eField1.zero(); | 
| 784 | 
< | 
            eField2.zero(); | 
| 785 | 
< | 
            sPot1 = 0.0; | 
| 786 | 
< | 
            sPot2 = 0.0; | 
| 787 | 
< | 
          } | 
| 733 | 
> | 
          cg2 = neighborList_[m2]; | 
| 734 | 
  | 
           | 
| 735 | 
< | 
          in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr,  | 
| 736 | 
< | 
                                                     rgrp);  | 
| 737 | 
< | 
 | 
| 738 | 
< | 
          atomListRow = fDecomp_->getAtomsInGroupRow(cg1); | 
| 739 | 
< | 
          atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); | 
| 740 | 
< | 
 | 
| 741 | 
< | 
          if (doHeatFlux_) | 
| 742 | 
< | 
            gvel2 = fDecomp_->getGroupVelocityColumn(cg2); | 
| 743 | 
< | 
 | 
| 744 | 
< | 
          for (ia = atomListRow.begin();  | 
| 745 | 
< | 
               ia != atomListRow.end(); ++ia) {             | 
| 746 | 
< | 
            atom1 = (*ia); | 
| 747 | 
< | 
 | 
| 748 | 
< | 
            for (jb = atomListColumn.begin();  | 
| 749 | 
< | 
                 jb != atomListColumn.end(); ++jb) {               | 
| 750 | 
< | 
              atom2 = (*jb); | 
| 751 | 
< | 
 | 
| 752 | 
< | 
              if (!fDecomp_->skipAtomPair(atom1, atom2, cg1, cg2)) { | 
| 753 | 
< | 
 | 
| 754 | 
< | 
                vpair = 0.0; | 
| 755 | 
< | 
                workPot = 0.0; | 
| 756 | 
< | 
                exPot = 0.0; | 
| 757 | 
< | 
                f1.zero(); | 
| 758 | 
< | 
                dVdFQ1 = 0.0; | 
| 759 | 
< | 
                dVdFQ2 = 0.0; | 
| 760 | 
< | 
 | 
| 761 | 
< | 
                fDecomp_->fillInteractionData(idat, atom1, atom2); | 
| 762 | 
< | 
 | 
| 763 | 
< | 
                topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); | 
| 764 | 
< | 
                vdwMult = vdwScale_[topoDist]; | 
| 765 | 
< | 
                electroMult = electrostaticScale_[topoDist]; | 
| 766 | 
< | 
 | 
| 767 | 
< | 
                if (atomListRow.size() == 1 && atomListColumn.size() == 1) { | 
| 768 | 
< | 
                  idat.d = &d_grp; | 
| 769 | 
< | 
                  idat.r2 = &rgrpsq; | 
| 770 | 
< | 
                  if (doHeatFlux_) | 
| 771 | 
< | 
                    vel2 = gvel2; | 
| 772 | 
< | 
                } else { | 
| 773 | 
< | 
                  d = fDecomp_->getInteratomicVector(atom1, atom2); | 
| 774 | 
< | 
                  curSnapshot->wrapVector( d ); | 
| 775 | 
< | 
                  r2 = d.lengthSquare(); | 
| 776 | 
< | 
                  idat.d = &d; | 
| 777 | 
< | 
                  idat.r2 = &r2; | 
| 778 | 
< | 
                  if (doHeatFlux_) | 
| 779 | 
< | 
                    vel2 = fDecomp_->getAtomVelocityColumn(atom2); | 
| 780 | 
< | 
                } | 
| 781 | 
< | 
                | 
| 782 | 
< | 
                r = sqrt( *(idat.r2) ); | 
| 783 | 
< | 
                idat.rij = &r; | 
| 784 | 
< | 
 | 
| 785 | 
< | 
                if (iLoop == PREPAIR_LOOP) { | 
| 786 | 
< | 
                  interactionMan_->doPrePair(idat); | 
| 787 | 
< | 
                } else { | 
| 788 | 
< | 
                  interactionMan_->doPair(idat); | 
| 789 | 
< | 
                  fDecomp_->unpackInteractionData(idat, atom1, atom2); | 
| 790 | 
< | 
                  vij += vpair; | 
| 791 | 
< | 
                  fij += f1; | 
| 792 | 
< | 
                  stressTensor -= outProduct( *(idat.d), f1); | 
| 793 | 
< | 
                  if (doHeatFlux_)  | 
| 794 | 
< | 
                    fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); | 
| 735 | 
> | 
          d_grp  = fDecomp_->getIntergroupVector(cg1, cg2); | 
| 736 | 
> | 
         | 
| 737 | 
> | 
          // already wrapped in the getIntergroupVector call: | 
| 738 | 
> | 
          // curSnapshot->wrapVector(d_grp);         | 
| 739 | 
> | 
          rgrpsq = d_grp.lengthSquare(); | 
| 740 | 
> | 
           | 
| 741 | 
> | 
          if (rgrpsq < rCutSq_) { | 
| 742 | 
> | 
            if (iLoop == PAIR_LOOP) { | 
| 743 | 
> | 
              vij = 0.0; | 
| 744 | 
> | 
              fij.zero(); | 
| 745 | 
> | 
              eField1.zero(); | 
| 746 | 
> | 
              eField2.zero(); | 
| 747 | 
> | 
              sPot1 = 0.0; | 
| 748 | 
> | 
              sPot2 = 0.0; | 
| 749 | 
> | 
            } | 
| 750 | 
> | 
             | 
| 751 | 
> | 
            in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr,  | 
| 752 | 
> | 
                                                       rgrp);  | 
| 753 | 
> | 
             | 
| 754 | 
> | 
            atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); | 
| 755 | 
> | 
             | 
| 756 | 
> | 
            if (doHeatFlux_) | 
| 757 | 
> | 
              gvel2 = fDecomp_->getGroupVelocityColumn(cg2); | 
| 758 | 
> | 
             | 
| 759 | 
> | 
            for (ia = atomListRow.begin();  | 
| 760 | 
> | 
                 ia != atomListRow.end(); ++ia) {             | 
| 761 | 
> | 
              atom1 = (*ia); | 
| 762 | 
> | 
               | 
| 763 | 
> | 
              for (jb = atomListColumn.begin();  | 
| 764 | 
> | 
                   jb != atomListColumn.end(); ++jb) {               | 
| 765 | 
> | 
                atom2 = (*jb); | 
| 766 | 
> | 
                 | 
| 767 | 
> | 
                if (!fDecomp_->skipAtomPair(atom1, atom2, cg1, cg2)) { | 
| 768 | 
> | 
                   | 
| 769 | 
> | 
                  vpair = 0.0; | 
| 770 | 
> | 
                  workPot = 0.0; | 
| 771 | 
> | 
                  exPot = 0.0; | 
| 772 | 
> | 
                  f1.zero(); | 
| 773 | 
> | 
                  dVdFQ1 = 0.0; | 
| 774 | 
> | 
                  dVdFQ2 = 0.0; | 
| 775 | 
> | 
                   | 
| 776 | 
> | 
                  fDecomp_->fillInteractionData(idat, atom1, atom2, newAtom1); | 
| 777 | 
> | 
                   | 
| 778 | 
> | 
                  topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); | 
| 779 | 
> | 
                  vdwMult = vdwScale_[topoDist]; | 
| 780 | 
> | 
                  electroMult = electrostaticScale_[topoDist]; | 
| 781 | 
> | 
                   | 
| 782 | 
> | 
                  if (atomListRow.size() == 1 && atomListColumn.size() == 1) { | 
| 783 | 
> | 
                    idat.d = &d_grp; | 
| 784 | 
> | 
                    idat.r2 = &rgrpsq; | 
| 785 | 
> | 
                    if (doHeatFlux_) | 
| 786 | 
> | 
                      vel2 = gvel2; | 
| 787 | 
> | 
                  } else { | 
| 788 | 
> | 
                    d = fDecomp_->getInteratomicVector(atom1, atom2); | 
| 789 | 
> | 
                    curSnapshot->wrapVector( d ); | 
| 790 | 
> | 
                    r2 = d.lengthSquare(); | 
| 791 | 
> | 
                    idat.d = &d; | 
| 792 | 
> | 
                    idat.r2 = &r2; | 
| 793 | 
> | 
                    if (doHeatFlux_) | 
| 794 | 
> | 
                      vel2 = fDecomp_->getAtomVelocityColumn(atom2); | 
| 795 | 
> | 
                  } | 
| 796 | 
> | 
                   | 
| 797 | 
> | 
                  r = sqrt( *(idat.r2) ); | 
| 798 | 
> | 
                  idat.rij = &r; | 
| 799 | 
> | 
                   | 
| 800 | 
> | 
                  if (iLoop == PREPAIR_LOOP) { | 
| 801 | 
> | 
                    interactionMan_->doPrePair(idat); | 
| 802 | 
> | 
                  } else { | 
| 803 | 
> | 
                    interactionMan_->doPair(idat); | 
| 804 | 
> | 
                    fDecomp_->unpackInteractionData(idat, atom1, atom2); | 
| 805 | 
> | 
                    vij += vpair; | 
| 806 | 
> | 
                    fij += f1; | 
| 807 | 
> | 
                    stressTensor -= outProduct( *(idat.d), f1); | 
| 808 | 
> | 
                    if (doHeatFlux_)  | 
| 809 | 
> | 
                      fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); | 
| 810 | 
> | 
                  } | 
| 811 | 
  | 
                } | 
| 812 | 
  | 
              } | 
| 813 | 
  | 
            } | 
| 814 | 
< | 
          } | 
| 815 | 
< | 
 | 
| 816 | 
< | 
          if (iLoop == PAIR_LOOP) { | 
| 817 | 
< | 
            if (in_switching_region) { | 
| 818 | 
< | 
              swderiv = vij * dswdr / rgrp; | 
| 819 | 
< | 
              fg = swderiv * d_grp; | 
| 820 | 
< | 
              fij += fg; | 
| 821 | 
< | 
 | 
| 822 | 
< | 
              if (atomListRow.size() == 1 && atomListColumn.size() == 1) { | 
| 823 | 
< | 
                if (!fDecomp_->skipAtomPair(atomListRow[0],  | 
| 824 | 
< | 
                                            atomListColumn[0],  | 
| 863 | 
< | 
                                            cg1, cg2)) { | 
| 814 | 
> | 
             | 
| 815 | 
> | 
            if (iLoop == PAIR_LOOP) { | 
| 816 | 
> | 
              if (in_switching_region) { | 
| 817 | 
> | 
                swderiv = vij * dswdr / rgrp; | 
| 818 | 
> | 
                fg = swderiv * d_grp; | 
| 819 | 
> | 
                fij += fg; | 
| 820 | 
> | 
                 | 
| 821 | 
> | 
                if (atomListRow.size() == 1 && atomListColumn.size() == 1) { | 
| 822 | 
> | 
                  if (!fDecomp_->skipAtomPair(atomListRow[0],  | 
| 823 | 
> | 
                                              atomListColumn[0],  | 
| 824 | 
> | 
                                              cg1, cg2)) { | 
| 825 | 
  | 
                  stressTensor -= outProduct( *(idat.d), fg); | 
| 826 | 
  | 
                  if (doHeatFlux_) | 
| 827 | 
  | 
                    fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); | 
| 828 | 
< | 
                }                 | 
| 829 | 
< | 
              } | 
| 830 | 
< | 
           | 
| 831 | 
< | 
              for (ia = atomListRow.begin();  | 
| 832 | 
< | 
                   ia != atomListRow.end(); ++ia) {             | 
| 833 | 
< | 
                atom1 = (*ia);                 | 
| 834 | 
< | 
                mf = fDecomp_->getMassFactorRow(atom1); | 
| 835 | 
< | 
                // fg is the force on atom ia due to cutoff group's | 
| 836 | 
< | 
                // presence in switching region | 
| 837 | 
< | 
                fg = swderiv * d_grp * mf; | 
| 838 | 
< | 
                fDecomp_->addForceToAtomRow(atom1, fg); | 
| 839 | 
< | 
                if (atomListRow.size() > 1) { | 
| 840 | 
< | 
                  if (info_->usesAtomicVirial()) { | 
| 841 | 
< | 
                    // find the distance between the atom | 
| 842 | 
< | 
                    // and the center of the cutoff group: | 
| 843 | 
< | 
                    dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); | 
| 844 | 
< | 
                    stressTensor -= outProduct(dag, fg); | 
| 845 | 
< | 
                    if (doHeatFlux_) | 
| 846 | 
< | 
                      fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); | 
| 828 | 
> | 
                  }                 | 
| 829 | 
> | 
                } | 
| 830 | 
> | 
                 | 
| 831 | 
> | 
                for (ia = atomListRow.begin();  | 
| 832 | 
> | 
                     ia != atomListRow.end(); ++ia) {             | 
| 833 | 
> | 
                  atom1 = (*ia);                 | 
| 834 | 
> | 
                  mf = fDecomp_->getMassFactorRow(atom1); | 
| 835 | 
> | 
                  // fg is the force on atom ia due to cutoff group's | 
| 836 | 
> | 
                  // presence in switching region | 
| 837 | 
> | 
                  fg = swderiv * d_grp * mf; | 
| 838 | 
> | 
                  fDecomp_->addForceToAtomRow(atom1, fg); | 
| 839 | 
> | 
                  if (atomListRow.size() > 1) { | 
| 840 | 
> | 
                    if (info_->usesAtomicVirial()) { | 
| 841 | 
> | 
                      // find the distance between the atom | 
| 842 | 
> | 
                      // and the center of the cutoff group: | 
| 843 | 
> | 
                      dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); | 
| 844 | 
> | 
                      stressTensor -= outProduct(dag, fg); | 
| 845 | 
> | 
                      if (doHeatFlux_) | 
| 846 | 
> | 
                        fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); | 
| 847 | 
> | 
                    } | 
| 848 | 
  | 
                  } | 
| 849 | 
  | 
                } | 
| 850 | 
< | 
              } | 
| 851 | 
< | 
              for (jb = atomListColumn.begin();  | 
| 852 | 
< | 
                   jb != atomListColumn.end(); ++jb) {               | 
| 853 | 
< | 
                atom2 = (*jb); | 
| 854 | 
< | 
                mf = fDecomp_->getMassFactorColumn(atom2); | 
| 855 | 
< | 
                // fg is the force on atom jb due to cutoff group's | 
| 856 | 
< | 
                // presence in switching region | 
| 857 | 
< | 
                fg = -swderiv * d_grp * mf; | 
| 858 | 
< | 
                fDecomp_->addForceToAtomColumn(atom2, fg); | 
| 859 | 
< | 
 | 
| 860 | 
< | 
                if (atomListColumn.size() > 1) { | 
| 861 | 
< | 
                  if (info_->usesAtomicVirial()) { | 
| 862 | 
< | 
                    // find the distance between the atom | 
| 863 | 
< | 
                    // and the center of the cutoff group: | 
| 864 | 
< | 
                    dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); | 
| 865 | 
< | 
                    stressTensor -= outProduct(dag, fg); | 
| 866 | 
< | 
                    if (doHeatFlux_) | 
| 867 | 
< | 
                      fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); | 
| 850 | 
> | 
                for (jb = atomListColumn.begin();  | 
| 851 | 
> | 
                     jb != atomListColumn.end(); ++jb) {               | 
| 852 | 
> | 
                  atom2 = (*jb); | 
| 853 | 
> | 
                  mf = fDecomp_->getMassFactorColumn(atom2); | 
| 854 | 
> | 
                  // fg is the force on atom jb due to cutoff group's | 
| 855 | 
> | 
                  // presence in switching region | 
| 856 | 
> | 
                  fg = -swderiv * d_grp * mf; | 
| 857 | 
> | 
                  fDecomp_->addForceToAtomColumn(atom2, fg); | 
| 858 | 
> | 
                   | 
| 859 | 
> | 
                  if (atomListColumn.size() > 1) { | 
| 860 | 
> | 
                    if (info_->usesAtomicVirial()) { | 
| 861 | 
> | 
                      // find the distance between the atom | 
| 862 | 
> | 
                      // and the center of the cutoff group: | 
| 863 | 
> | 
                      dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); | 
| 864 | 
> | 
                      stressTensor -= outProduct(dag, fg); | 
| 865 | 
> | 
                      if (doHeatFlux_) | 
| 866 | 
> | 
                        fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); | 
| 867 | 
> | 
                    } | 
| 868 | 
  | 
                  } | 
| 869 | 
  | 
                } | 
| 870 | 
  | 
              } | 
| 871 | 
+ | 
              //if (!info_->usesAtomicVirial()) { | 
| 872 | 
+ | 
              //  stressTensor -= outProduct(d_grp, fij); | 
| 873 | 
+ | 
              //  if (doHeatFlux_) | 
| 874 | 
+ | 
              //     fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); | 
| 875 | 
+ | 
              //} | 
| 876 | 
  | 
            } | 
| 910 | 
– | 
            //if (!info_->usesAtomicVirial()) { | 
| 911 | 
– | 
            //  stressTensor -= outProduct(d_grp, fij); | 
| 912 | 
– | 
            //  if (doHeatFlux_) | 
| 913 | 
– | 
            //     fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); | 
| 914 | 
– | 
            //} | 
| 877 | 
  | 
          } | 
| 878 | 
  | 
        } | 
| 879 | 
+ | 
        newAtom1 = false; | 
| 880 | 
  | 
      } | 
| 881 | 
< | 
 | 
| 881 | 
> | 
         | 
| 882 | 
  | 
      if (iLoop == PREPAIR_LOOP) { | 
| 883 | 
  | 
        if (info_->requiresPrepair()) { | 
| 884 | 
< | 
 | 
| 884 | 
> | 
           | 
| 885 | 
  | 
          fDecomp_->collectIntermediateData(); | 
| 886 | 
< | 
 | 
| 886 | 
> | 
           | 
| 887 | 
  | 
          for (unsigned int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { | 
| 888 | 
  | 
            fDecomp_->fillSelfData(sdat, atom1); | 
| 889 | 
  | 
            interactionMan_->doPreForce(sdat); | 
| 890 | 
  | 
          } | 
| 891 | 
< | 
 | 
| 891 | 
> | 
           | 
| 892 | 
  | 
          fDecomp_->distributeIntermediateData(); | 
| 893 | 
< | 
 | 
| 893 | 
> | 
           | 
| 894 | 
  | 
        } | 
| 895 | 
  | 
      } | 
| 896 | 
  | 
    } |