ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/ForceManager.cpp
(Generate patch)

Comparing branches/development/src/brains/ForceManager.cpp (file contents):
Revision 1576 by gezelter, Wed Jun 8 16:05:07 2011 UTC vs.
Revision 1711 by gezelter, Sat May 19 02:58:35 2012 UTC

# Line 36 | Line 36
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).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   /**
# Line 59 | Line 60
60   #include "nonbonded/NonBondedInteraction.hpp"
61   #include "parallel/ForceMatrixDecomposition.hpp"
62  
63 + #include <cstdio>
64 + #include <iostream>
65 + #include <iomanip>
66 +
67   using namespace std;
68   namespace OpenMD {
69    
70    ForceManager::ForceManager(SimInfo * info) : info_(info) {
71      forceField_ = info_->getForceField();
72 <    fDecomp_ = new ForceMatrixDecomposition(info_);
72 >    interactionMan_ = new InteractionManager();
73 >    fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_);
74    }
75  
76    /**
77     * setupCutoffs
78     *
79 <   * Sets the values of cutoffRadius, cutoffMethod, and cutoffPolicy
79 >   * Sets the values of cutoffRadius, switchingRadius, cutoffMethod,
80 >   * and cutoffPolicy
81     *
82     * cutoffRadius : realType
83     *  If the cutoffRadius was explicitly set, use that value.
# Line 80 | Line 87 | namespace OpenMD {
87     *      simulation for suggested cutoff values (e.g. 2.5 * sigma).
88     *      Use the maximum suggested value that was found.
89     *
90 <   * cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL)
90 >   * cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE,
91 >   *                        or SHIFTED_POTENTIAL)
92     *      If cutoffMethod was explicitly set, use that choice.
93     *      If cutoffMethod was not explicitly set, use SHIFTED_FORCE
94     *
95     * cutoffPolicy : (one of MIX, MAX, TRADITIONAL)
96     *      If cutoffPolicy was explicitly set, use that choice.
97     *      If cutoffPolicy was not explicitly set, use TRADITIONAL
98 +   *
99 +   * switchingRadius : realType
100 +   *  If the cutoffMethod was set to SWITCHED:
101 +   *      If the switchingRadius was explicitly set, use that value
102 +   *          (but do a sanity check first).
103 +   *      If the switchingRadius was not explicitly set: use 0.85 *
104 +   *      cutoffRadius_
105 +   *  If the cutoffMethod was not set to SWITCHED:
106 +   *      Set switchingRadius equal to cutoffRadius for safety.
107     */
108    void ForceManager::setupCutoffs() {
109      
110      Globals* simParams_ = info_->getSimParams();
111      ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions();
112 +    int mdFileVersion;
113      
114 +    if (simParams_->haveMDfileVersion())
115 +      mdFileVersion = simParams_->getMDfileVersion();
116 +    else
117 +      mdFileVersion = 0;
118 +  
119      if (simParams_->haveCutoffRadius()) {
120        rCut_ = simParams_->getCutoffRadius();
121      } else {      
# Line 121 | Line 144 | namespace OpenMD {
144          painCave.isFatal = 0;
145          painCave.severity = OPENMD_INFO;
146          simError();
147 <      }            
147 >      }
148      }
149  
150 +    fDecomp_->setUserCutoff(rCut_);
151 +    interactionMan_->setCutoffRadius(rCut_);
152 +
153      map<string, CutoffMethod> stringToCutoffMethod;
154      stringToCutoffMethod["HARD"] = HARD;
155      stringToCutoffMethod["SWITCHED"] = SWITCHED;
# Line 147 | Line 173 | namespace OpenMD {
173          cutoffMethod_ = i->second;
174        }
175      } else {
176 <      sprintf(painCave.errMsg,
177 <              "ForceManager::setupCutoffs: No value was set for the cutoffMethod.\n"
178 <              "\tOpenMD will use SHIFTED_FORCE.\n");
179 <      painCave.isFatal = 0;
180 <      painCave.severity = OPENMD_INFO;
181 <      simError();
182 <      cutoffMethod_ = SHIFTED_FORCE;        
176 >      if (mdFileVersion > 1) {
177 >        sprintf(painCave.errMsg,
178 >                "ForceManager::setupCutoffs: No value was set for the cutoffMethod.\n"
179 >                "\tOpenMD will use SHIFTED_FORCE.\n");
180 >        painCave.isFatal = 0;
181 >        painCave.severity = OPENMD_INFO;
182 >        simError();
183 >        cutoffMethod_ = SHIFTED_FORCE;        
184 >      } else {
185 >        // handle the case where the old file version was in play
186 >        // (there should be no cutoffMethod, so we have to deduce it
187 >        // from other data).        
188 >
189 >        sprintf(painCave.errMsg,
190 >                "ForceManager::setupCutoffs : DEPRECATED FILE FORMAT!\n"
191 >                "\tOpenMD found a file which does not set a cutoffMethod.\n"
192 >                "\tOpenMD will attempt to deduce a cutoffMethod using the\n"
193 >                "\tbehavior of the older (version 1) code.  To remove this\n"
194 >                "\twarning, add an explicit cutoffMethod and change the top\n"
195 >                "\tof the file so that it begins with <OpenMD version=2>\n");
196 >        painCave.isFatal = 0;
197 >        painCave.severity = OPENMD_WARNING;
198 >        simError();            
199 >                
200 >        // The old file version tethered the shifting behavior to the
201 >        // electrostaticSummationMethod keyword.
202 >        
203 >        if (simParams_->haveElectrostaticSummationMethod()) {
204 >          string myMethod = simParams_->getElectrostaticSummationMethod();
205 >          toUpper(myMethod);
206 >        
207 >          if (myMethod == "SHIFTED_POTENTIAL") {
208 >            cutoffMethod_ = SHIFTED_POTENTIAL;
209 >          } else if (myMethod == "SHIFTED_FORCE") {
210 >            cutoffMethod_ = SHIFTED_FORCE;
211 >          }
212 >        
213 >          if (simParams_->haveSwitchingRadius())
214 >            rSwitch_ = simParams_->getSwitchingRadius();
215 >
216 >          if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") {
217 >            if (simParams_->haveSwitchingRadius()){
218 >              sprintf(painCave.errMsg,
219 >                      "ForceManager::setupCutoffs : DEPRECATED ERROR MESSAGE\n"
220 >                      "\tA value was set for the switchingRadius\n"
221 >                      "\teven though the electrostaticSummationMethod was\n"
222 >                      "\tset to %s\n", myMethod.c_str());
223 >              painCave.severity = OPENMD_WARNING;
224 >              painCave.isFatal = 1;
225 >              simError();            
226 >            }
227 >          }
228 >          if (abs(rCut_ - rSwitch_) < 0.0001) {
229 >            if (cutoffMethod_ == SHIFTED_FORCE) {              
230 >              sprintf(painCave.errMsg,
231 >                      "ForceManager::setupCutoffs : DEPRECATED BEHAVIOR\n"
232 >                      "\tcutoffRadius and switchingRadius are set to the\n"
233 >                      "\tsame value.  OpenMD will use shifted force\n"
234 >                      "\tpotentials instead of switching functions.\n");
235 >              painCave.isFatal = 0;
236 >              painCave.severity = OPENMD_WARNING;
237 >              simError();            
238 >            } else {
239 >              cutoffMethod_ = SHIFTED_POTENTIAL;
240 >              sprintf(painCave.errMsg,
241 >                      "ForceManager::setupCutoffs : DEPRECATED BEHAVIOR\n"
242 >                      "\tcutoffRadius and switchingRadius are set to the\n"
243 >                      "\tsame value.  OpenMD will use shifted potentials\n"
244 >                      "\tinstead of switching functions.\n");
245 >              painCave.isFatal = 0;
246 >              painCave.severity = OPENMD_WARNING;
247 >              simError();            
248 >            }
249 >          }
250 >        }
251 >      }
252      }
253  
254      map<string, CutoffPolicy> stringToCutoffPolicy;
# Line 161 | Line 256 | namespace OpenMD {
256      stringToCutoffPolicy["MAX"] = MAX;
257      stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL;    
258  
259 <    std::string cutPolicy;
259 >    string cutPolicy;
260      if (forceFieldOptions_.haveCutoffPolicy()){
261        cutPolicy = forceFieldOptions_.getCutoffPolicy();
262      }else if (simParams_->haveCutoffPolicy()) {
# Line 194 | Line 289 | namespace OpenMD {
289        simError();
290        cutoffPolicy_ = TRADITIONAL;        
291      }
197  }
292  
293 <  /**
294 <   * setupSwitching
295 <   *
296 <   * Sets the values of switchingRadius and
297 <   *  If the switchingRadius was explicitly set, use that value (but check it)
298 <   *  If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_
299 <   */
300 <  void ForceManager::setupSwitching() {
301 <    Globals* simParams_ = info_->getSimParams();
302 <    
303 <    if (simParams_->haveSwitchingRadius()) {
304 <      rSwitch_ = simParams_->getSwitchingRadius();
305 <      if (rSwitch_ > rCut_) {        
293 >    fDecomp_->setCutoffPolicy(cutoffPolicy_);
294 >        
295 >    // create the switching function object:
296 >
297 >    switcher_ = new SwitchingFunction();
298 >  
299 >    if (cutoffMethod_ == SWITCHED) {
300 >      if (simParams_->haveSwitchingRadius()) {
301 >        rSwitch_ = simParams_->getSwitchingRadius();
302 >        if (rSwitch_ > rCut_) {        
303 >          sprintf(painCave.errMsg,
304 >                  "ForceManager::setupCutoffs: switchingRadius (%f) is larger "
305 >                  "than the cutoffRadius(%f)\n", rSwitch_, rCut_);
306 >          painCave.isFatal = 1;
307 >          painCave.severity = OPENMD_ERROR;
308 >          simError();
309 >        }
310 >      } else {      
311 >        rSwitch_ = 0.85 * rCut_;
312          sprintf(painCave.errMsg,
313 <                "ForceManager::setupSwitching: switchingRadius (%f) is larger than cutoffRadius(%f)\n",
314 <                rSwitch_, rCut_);
315 <        painCave.isFatal = 1;
316 <        painCave.severity = OPENMD_ERROR;
313 >                "ForceManager::setupCutoffs: No value was set for the switchingRadius.\n"
314 >                "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n"
315 >                "\tswitchingRadius = %f. for this simulation\n", rSwitch_);
316 >        painCave.isFatal = 0;
317 >        painCave.severity = OPENMD_WARNING;
318          simError();
319        }
320 <    } else {      
321 <      rSwitch_ = 0.85 * rCut_;
322 <      sprintf(painCave.errMsg,
323 <              "ForceManager::setupSwitching: No value was set for the switchingRadius.\n"
324 <              "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n"
325 <              "\tswitchingRadius = %f. for this simulation\n", rSwitch_);
326 <      painCave.isFatal = 0;
327 <      painCave.severity = OPENMD_WARNING;
328 <      simError();
329 <    }          
320 >    } else {
321 >      if (mdFileVersion > 1) {
322 >        // throw an error if we define a switching radius and don't need one.
323 >        // older file versions should not do this.
324 >        if (simParams_->haveSwitchingRadius()) {
325 >          map<string, CutoffMethod>::const_iterator it;
326 >          string theMeth;
327 >          for (it = stringToCutoffMethod.begin();
328 >               it != stringToCutoffMethod.end(); ++it) {
329 >            if (it->second == cutoffMethod_) {
330 >              theMeth = it->first;
331 >              break;
332 >            }
333 >          }
334 >          sprintf(painCave.errMsg,
335 >                  "ForceManager::setupCutoffs: the cutoffMethod (%s)\n"
336 >                  "\tis not set to SWITCHED, so switchingRadius value\n"
337 >                  "\twill be ignored for this simulation\n", theMeth.c_str());
338 >          painCave.isFatal = 0;
339 >          painCave.severity = OPENMD_WARNING;
340 >          simError();
341 >        }
342 >      }
343 >      rSwitch_ = rCut_;
344 >    }
345      
346 +    // Default to cubic switching function.
347 +    sft_ = cubic;
348      if (simParams_->haveSwitchingFunctionType()) {
349        string funcType = simParams_->getSwitchingFunctionType();
350        toUpper(funcType);
# Line 250 | Line 368 | namespace OpenMD {
368      }
369      switcher_->setSwitchType(sft_);
370      switcher_->setSwitch(rSwitch_, rCut_);
371 +    interactionMan_->setSwitchingRadius(rSwitch_);
372    }
373 +
374 +
375 +
376    
377    void ForceManager::initialize() {
378  
379      if (!info_->isTopologyDone()) {
380 +
381        info_->update();
382        interactionMan_->setSimInfo(info_);
383        interactionMan_->initialize();
# Line 262 | Line 385 | namespace OpenMD {
385        // We want to delay the cutoffs until after the interaction
386        // manager has set up the atom-atom interactions so that we can
387        // query them for suggested cutoff values
265
388        setupCutoffs();
267      setupSwitching();
389  
390        info_->prepareTopology();      
391 +
392 +      doParticlePot_ = info_->getSimParams()->getOutputParticlePotential();
393 +      cerr << "dPP = " << doParticlePot_ << "\n";
394 +  
395      }
396  
397      ForceFieldOptions& fopts = forceField_->getForceFieldOptions();
398      
399 <    // Force fields can set options on how to scale van der Waals and electrostatic
400 <    // interactions for atoms connected via bonds, bends and torsions
401 <    // in this case the topological distance between atoms is:
399 >    // Force fields can set options on how to scale van der Waals and
400 >    // electrostatic interactions for atoms connected via bonds, bends
401 >    // and torsions in this case the topological distance between
402 >    // atoms is:
403      // 0 = topologically unconnected
404      // 1 = bonded together
405      // 2 = connected via a bend
# Line 325 | Line 451 | namespace OpenMD {
451      
452      for (mol = info_->beginMolecule(mi); mol != NULL;
453           mol = info_->nextMolecule(mi)) {
454 <      for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
454 >      for(atom = mol->beginAtom(ai); atom != NULL;
455 >          atom = mol->nextAtom(ai)) {
456          atom->zeroForcesAndTorques();
457        }
458 <          
458 >      
459        //change the positions of atoms which belong to the rigidbodies
460        for (rb = mol->beginRigidBody(rbIter); rb != NULL;
461             rb = mol->nextRigidBody(rbIter)) {
462          rb->zeroForcesAndTorques();
463        }        
464 <
464 >      
465        if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){
466          for(cg = mol->beginCutoffGroup(ci); cg != NULL;
467              cg = mol->nextCutoffGroup(ci)) {
# Line 343 | Line 470 | namespace OpenMD {
470          }
471        }      
472      }
473 <  
473 >    
474      // Zero out the stress tensor
475      tau *= 0.0;
476      
# Line 397 | Line 524 | namespace OpenMD {
524            dataSet.prev.angle = dataSet.curr.angle = angle;
525            dataSet.prev.potential = dataSet.curr.potential = currBendPot;
526            dataSet.deltaV = 0.0;
527 <          bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend, dataSet));
527 >          bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend,
528 >                                                                  dataSet));
529          }else {
530            i->second.prev.angle = i->second.curr.angle;
531            i->second.prev.potential = i->second.curr.potential;
# Line 468 | Line 596 | namespace OpenMD {
596    
597    void ForceManager::longRangeInteractions() {
598  
471    // some of this initial stuff will go away:
599      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
600      DataStorage* config = &(curSnapshot->atomData);
601      DataStorage* cgConfig = &(curSnapshot->cgData);
475    RealType* frc = config->getArrayPointer(DataStorage::dslForce);
476    RealType* pos = config->getArrayPointer(DataStorage::dslPosition);
477    RealType* trq = config->getArrayPointer(DataStorage::dslTorque);
478    RealType* A = config->getArrayPointer(DataStorage::dslAmat);
479    RealType* electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame);
480    RealType* particlePot = config->getArrayPointer(DataStorage::dslParticlePot);
481    RealType* rc;    
602  
603 <    if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){
604 <      rc = cgConfig->getArrayPointer(DataStorage::dslPosition);
603 >    //calculate the center of mass of cutoff group
604 >
605 >    SimInfo::MoleculeIterator mi;
606 >    Molecule* mol;
607 >    Molecule::CutoffGroupIterator ci;
608 >    CutoffGroup* cg;
609 >
610 >    if(info_->getNCutoffGroups() > 0){      
611 >      for (mol = info_->beginMolecule(mi); mol != NULL;
612 >           mol = info_->nextMolecule(mi)) {
613 >        for(cg = mol->beginCutoffGroup(ci); cg != NULL;
614 >            cg = mol->nextCutoffGroup(ci)) {
615 >          cg->updateCOM();
616 >        }
617 >      }      
618      } else {
619        // center of mass of the group is the same as position of the atom  
620        // if cutoff group does not exist
621 <      rc = pos;
621 >      cgConfig->position = config->position;
622      }
623 <    
491 <    // new stuff starts here:
623 >
624      fDecomp_->zeroWorkArrays();
625      fDecomp_->distributeData();
626 <
627 <    int cg1, cg2, atom1, atom2;
628 <    Vector3d d_grp, dag;
629 <    RealType rgrpsq, rgrp;
626 >    
627 >    int cg1, cg2, atom1, atom2, topoDist;
628 >    Vector3d d_grp, dag, d;
629 >    RealType rgrpsq, rgrp, r2, r;
630 >    RealType electroMult, vdwMult;
631      RealType vij;
632 <    Vector3d fij, fg;
632 >    Vector3d fij, fg, f1;
633      tuple3<RealType, RealType, RealType> cuts;
634      RealType rCutSq;
635      bool in_switching_region;
# Line 505 | Line 638 | namespace OpenMD {
638      InteractionData idat;
639      SelfData sdat;
640      RealType mf;
508    potVec pot(0.0);
509    potVec longRangePotential(0.0);
641      RealType lrPot;
642 +    RealType vpair;
643 +    potVec longRangePotential(0.0);
644 +    potVec workPot(0.0);
645  
646      int loopStart, loopEnd;
647  
648 +    idat.vdwMult = &vdwMult;
649 +    idat.electroMult = &electroMult;
650 +    idat.pot = &workPot;
651 +    sdat.pot = fDecomp_->getEmbeddingPotential();
652 +    idat.vpair = &vpair;
653 +    idat.f1 = &f1;
654 +    idat.sw = &sw;
655 +    idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false;
656 +    idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false;
657 +    idat.doParticlePot = doParticlePot_;
658 +    sdat.doParticlePot = doParticlePot_;
659 +    
660      loopEnd = PAIR_LOOP;
661      if (info_->requiresPrepair() ) {
662        loopStart = PREPAIR_LOOP;
663      } else {
664        loopStart = PAIR_LOOP;
665      }
666 <
667 <    for (int iLoop = loopStart; iLoop < loopEnd; iLoop++) {
668 <      
666 >  
667 >    for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) {
668 >    
669        if (iLoop == loopStart) {
670          bool update_nlist = fDecomp_->checkNeighborList();
671          if (update_nlist)
672            neighborList = fDecomp_->buildNeighborList();
673 <      }
673 >      }            
674  
675        for (vector<pair<int, int> >::iterator it = neighborList.begin();
676               it != neighborList.end(); ++it) {
677 <        
677 >                
678          cg1 = (*it).first;
679          cg2 = (*it).second;
680          
681          cuts = fDecomp_->getGroupCutoffs(cg1, cg2);
682  
683          d_grp  = fDecomp_->getIntergroupVector(cg1, cg2);
684 +
685          curSnapshot->wrapVector(d_grp);        
686          rgrpsq = d_grp.lengthSquare();
540
687          rCutSq = cuts.second;
688  
689          if (rgrpsq < rCutSq) {
690 <          *(idat.rcut) = cuts.first;
690 >          idat.rcut = &cuts.first;
691            if (iLoop == PAIR_LOOP) {
692 <            vij *= 0.0;
692 >            vij = 0.0;
693              fij = V3Zero;
694            }
695            
696 <          in_switching_region = switcher_->getSwitch(rgrpsq, *(idat.sw), dswdr,
696 >          in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr,
697                                                       rgrp);
698 <              
698 >          
699            atomListRow = fDecomp_->getAtomsInGroupRow(cg1);
700            atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2);
701  
# Line 560 | Line 706 | namespace OpenMD {
706              for (vector<int>::iterator jb = atomListColumn.begin();
707                   jb != atomListColumn.end(); ++jb) {              
708                atom2 = (*jb);
709 <              
709 >
710                if (!fDecomp_->skipAtomPair(atom1, atom2)) {
711 +                vpair = 0.0;
712 +                workPot = 0.0;
713 +                f1 = V3Zero;
714 +
715 +                fDecomp_->fillInteractionData(idat, atom1, atom2);
716                  
717 <                pot *= 0.0;
717 >                topoDist = fDecomp_->getTopologicalDistance(atom1, atom2);
718 >                vdwMult = vdwScale_[topoDist];
719 >                electroMult = electrostaticScale_[topoDist];
720  
568                idat = fDecomp_->fillInteractionData(atom1, atom2);
569                *(idat.pot) = pot;
570
721                  if (atomListRow.size() == 1 && atomListColumn.size() == 1) {
722 <                  *(idat.d) = d_grp;
723 <                  *(idat.r2) = rgrpsq;
722 >                  idat.d = &d_grp;
723 >                  idat.r2 = &rgrpsq;
724                  } else {
725 <                  *(idat.d) = fDecomp_->getInteratomicVector(atom1, atom2);
726 <                  curSnapshot->wrapVector( *(idat.d) );
727 <                  *(idat.r2) = idat.d->lengthSquare();
725 >                  d = fDecomp_->getInteratomicVector(atom1, atom2);
726 >                  curSnapshot->wrapVector( d );
727 >                  r2 = d.lengthSquare();
728 >                  idat.d = &d;
729 >                  idat.r2 = &r2;
730                  }
579                
580                *(idat.rij) = sqrt( *(idat.r2) );
731                
732 +                r = sqrt( *(idat.r2) );
733 +                idat.rij = &r;
734 +              
735                  if (iLoop == PREPAIR_LOOP) {
736                    interactionMan_->doPrePair(idat);
737                  } else {
738                    interactionMan_->doPair(idat);
739                    fDecomp_->unpackInteractionData(idat, atom1, atom2);
740 <                  vij += *(idat.vpair);
741 <                  fij += *(idat.f1);
742 <                  tau -= outProduct( *(idat.d), *(idat.f1));
740 >                  vij += vpair;
741 >                  fij += f1;
742 >                  tau -= outProduct( *(idat.d), f1);
743                  }
744                }
745              }
# Line 596 | Line 749 | namespace OpenMD {
749              if (in_switching_region) {
750                swderiv = vij * dswdr / rgrp;
751                fg = swderiv * d_grp;
599
752                fij += fg;
753  
754                if (atomListRow.size() == 1 && atomListColumn.size() == 1) {
# Line 611 | Line 763 | namespace OpenMD {
763                  // presence in switching region
764                  fg = swderiv * d_grp * mf;
765                  fDecomp_->addForceToAtomRow(atom1, fg);
614
766                  if (atomListRow.size() > 1) {
767                    if (info_->usesAtomicVirial()) {
768                      // find the distance between the atom
# Line 640 | Line 791 | namespace OpenMD {
791                  }
792                }
793              }
794 <            //if (!SIM_uses_AtomicVirial) {
794 >            //if (!info_->usesAtomicVirial()) {
795              //  tau -= outProduct(d_grp, fij);
796              //}
797            }
# Line 648 | Line 799 | namespace OpenMD {
799        }
800  
801        if (iLoop == PREPAIR_LOOP) {
802 <        if (info_->requiresPrepair()) {            
802 >        if (info_->requiresPrepair()) {
803 >
804            fDecomp_->collectIntermediateData();
805  
806            for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) {
807 <            sdat = fDecomp_->fillSelfData(atom1);
807 >            fDecomp_->fillSelfData(sdat, atom1);
808              interactionMan_->doPreForce(sdat);
809            }
810  
811 <          fDecomp_->distributeIntermediateData();        
811 >          fDecomp_->distributeIntermediateData();
812 >
813          }
814        }
662
815      }
816      
817      fDecomp_->collectData();
666    
667    if ( info_->requiresSkipCorrection() ) {
668      
669      for (int atom1 = 0; atom1 < fDecomp_->getNAtomsInRow(); atom1++) {
670
671        vector<int> skipList = fDecomp_->getSkipsForRowAtom( atom1 );
818          
673        for (vector<int>::iterator jb = skipList.begin();
674             jb != skipList.end(); ++jb) {        
675    
676          atom2 = (*jb);
677          idat = fDecomp_->fillSkipData(atom1, atom2);
678          interactionMan_->doSkipCorrection(idat);
679
680        }
681      }
682    }
683    
819      if (info_->requiresSelfCorrection()) {
820  
821        for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) {          
822 <        sdat = fDecomp_->fillSelfData(atom1);
822 >        fDecomp_->fillSelfData(sdat, atom1);
823          interactionMan_->doSelfCorrection(sdat);
824        }
825  
826      }
827  
828 <    longRangePotential = fDecomp_->getLongRangePotential();
828 >    longRangePotential = *(fDecomp_->getEmbeddingPotential()) +
829 >      *(fDecomp_->getPairwisePotential());
830 >
831      lrPot = longRangePotential.sum();
832  
833      //store the tau and long range potential    
# Line 723 | Line 860 | namespace OpenMD {
860      MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
861                    9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
862   #endif
863 <    curSnapshot->statData.setTau(tau);
863 >    curSnapshot->setTau(tau);
864    }
865  
866   } //end namespace OpenMD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines