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 1545 by gezelter, Fri Apr 8 21:25:19 2011 UTC vs.
Revision 1587 by gezelter, Fri Jul 8 20:25:32 2011 UTC

# Line 47 | Line 47
47   * @version 1.0
48   */
49  
50 +
51   #include "brains/ForceManager.hpp"
52   #include "primitives/Molecule.hpp"
52 #include "UseTheForce/doForces_interface.h"
53   #define __OPENMD_C
54 #include "UseTheForce/DarkSide/fInteractionMap.h"
54   #include "utils/simError.h"
55   #include "primitives/Bond.hpp"
56   #include "primitives/Bend.hpp"
57   #include "primitives/Torsion.hpp"
58   #include "primitives/Inversion.hpp"
59 < #include "parallel/ForceDecomposition.hpp"
60 < //#include "parallel/SerialDecomposition.hpp"
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 <    decomp_ = new ForceDecomposition(info_);
70 < #else
71 <    // decomp_ = new SerialDecomposition(info);
72 < #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 <    if (!info_->isFortranInitialized()) {
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 <      nbiMan_->setSimInfo(info_);
299 <      nbiMan_->initialize();
300 <      swfun_ = nbiMan_->getSwitchingFunction();
301 <      decomp_->distributeInitialData();
302 <      info_->setupFortran();
298 >      interactionMan_->setSimInfo(info_);
299 >      interactionMan_->initialize();
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 <    preCalculation();  
313 <    calcShortRangeInteraction();
314 <    calcLongRangeInteraction();
315 <    postCalculation();
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();    
350    }
351    
352    void ForceManager::preCalculation() {
# Line 128 | Line 387 | namespace OpenMD {
387      
388    }
389    
390 <  void ForceManager::calcShortRangeInteraction() {
390 >  void ForceManager::shortRangeInteractions() {
391      Molecule* mol;
392      RigidBody* rb;
393      Bond* bond;
# Line 245 | Line 504 | namespace OpenMD {
504      curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential;    
505    }
506    
507 <  void ForceManager::calcLongRangeInteraction() {
507 >  void ForceManager::longRangeInteractions() {
508  
250    // some of this initial stuff will go away:
509      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
510      DataStorage* config = &(curSnapshot->atomData);
511      DataStorage* cgConfig = &(curSnapshot->cgData);
254    RealType* frc = config->getArrayPointer(DataStorage::dslForce);
255    RealType* pos = config->getArrayPointer(DataStorage::dslPosition);
256    RealType* trq = config->getArrayPointer(DataStorage::dslTorque);
257    RealType* A = config->getArrayPointer(DataStorage::dslAmat);
258    RealType* electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame);
259    RealType* particlePot = config->getArrayPointer(DataStorage::dslParticlePot);
260    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      }
269    
270    //initialize data before passing to fortran
271    RealType longRangePotential[LR_POT_TYPES];
272    RealType lrPot = 0.0;
273    int isError = 0;
533  
534 <    for (int i=0; i<LR_POT_TYPES;i++){
535 <      longRangePotential[i]=0.0; //Initialize array
536 <    }
537 <
538 <    // new stuff starts here:
539 <
540 <    decomp_->distributeData();
282 <
283 <    int cg1, cg2;
284 <    Vector3d d_grp;
285 <    RealType rgrpsq, rgrp;
534 >    fDecomp_->zeroWorkArrays();
535 >    fDecomp_->distributeData();
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;
547 <    vector<int> atomListI;
293 <    vector<int> atomListJ;
547 >    vector<int> atomListColumn, atomListRow, atomListLocal;
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_) {
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 = decomp_->checkNeighborList();
578 >        bool update_nlist = fDecomp_->checkNeighborList();
579          if (update_nlist)
580 <          neighborList = decomp_->buildNeighborList();
581 <      }
582 <
580 >          neighborList = fDecomp_->buildNeighborList();
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  
591 <        gtypes = decomp_->getGroupTypes(cg1, cg2);
320 <        d_grp  = decomp_->getIntergroupVector(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;
601              fij = V3Zero;
602            }
603            
604 <          in_switching_region = swfun_->getSwitch(rgrpsq, idat.sw, idat.dswdr, rgrp);    
605 <          
606 <          atomListI = decomp_->getAtomsInGroupI(cg1);
607 <          atomListJ = decomp_->getAtomsInGroupJ(cg2);
604 >          in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr,
605 >                                                     rgrp);
606 >              
607 >          atomListRow = fDecomp_->getAtomsInGroupRow(cg1);
608 >          atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2);
609  
610 <          for (vector<int>::iterator ia = atomListI.begin();
611 <               ia != atomListI.end(); ++ia) {            
610 >          for (vector<int>::iterator ia = atomListRow.begin();
611 >               ia != atomListRow.end(); ++ia) {            
612              atom1 = (*ia);
613              
614 <            for (vector<int>::iterator jb = atomListJ.begin();
615 <                 jb != atomListJ.end(); ++jb) {              
614 >            for (vector<int>::iterator jb = atomListColumn.begin();
615 >                 jb != atomListColumn.end(); ++jb) {              
616                atom2 = (*jb);
617 <              
618 <              if (!decomp_->skipAtomPair(atom1, atom2)) {
619 <                
620 <                if (atomListI.size() == 1 && atomListJ.size() == 1) {
621 <                  idat.d = d_grp;
622 <                  idat.r2 = rgrpsq;
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 >                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;
632                  } else {
633 <                  idat.d = decomp_->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.r = sqrt(idat.r2);
641 <                decomp_->fillInteractionData(atom1, atom2, idat);
642 <                
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.f);
647 >                  fDecomp_->unpackInteractionData(idat, atom1, atom2);
648 >                  vij += vpair;
649 >                  fij += f1;
650 >                  tau -= outProduct( *(idat.d), f1);
651                  }
652                }
653              }
# Line 372 | Line 657 | namespace OpenMD {
657              if (in_switching_region) {
658                swderiv = vij * dswdr / rgrp;
659                fg = swderiv * d_grp;
375
660                fij += fg;
661  
662 <              if (atomListI.size() == 1 && atomListJ.size() == 1) {
663 <                tau -= outProduct(idat.d, fg);
662 >              if (atomListRow.size() == 1 && atomListColumn.size() == 1) {
663 >                tau -= outProduct( *(idat.d), fg);
664                }
665            
666 <              for (vector<int>::iterator ia = atomListI.begin();
667 <                   ia != atomListI.end(); ++ia) {            
666 >              for (vector<int>::iterator ia = atomListRow.begin();
667 >                   ia != atomListRow.end(); ++ia) {            
668                  atom1 = (*ia);                
669 <                mf = decomp_->getMfactI(atom1);
669 >                mf = fDecomp_->getMassFactorRow(atom1);
670                  // fg is the force on atom ia due to cutoff group's
671                  // presence in switching region
672                  fg = swderiv * d_grp * mf;
673 <                decomp_->addForceToAtomI(atom1, fg);
673 >                fDecomp_->addForceToAtomRow(atom1, fg);
674  
675 <                if (atomListI.size() > 1) {
676 <                  if (info_->usesAtomicVirial_) {
675 >                if (atomListRow.size() > 1) {
676 >                  if (info_->usesAtomicVirial()) {
677                      // find the distance between the atom
678                      // and the center of the cutoff group:
679 <                    dag = decomp_->getAtomToGroupVectorI(atom1, cg1);
679 >                    dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1);
680                      tau -= outProduct(dag, fg);
681                    }
682                  }
683                }
684 <              for (vector<int>::iterator jb = atomListJ.begin();
685 <                   jb != atomListJ.end(); ++jb) {              
684 >              for (vector<int>::iterator jb = atomListColumn.begin();
685 >                   jb != atomListColumn.end(); ++jb) {              
686                  atom2 = (*jb);
687 <                mf = decomp_->getMfactJ(atom2);
687 >                mf = fDecomp_->getMassFactorColumn(atom2);
688                  // fg is the force on atom jb due to cutoff group's
689                  // presence in switching region
690                  fg = -swderiv * d_grp * mf;
691 <                decomp_->addForceToAtomJ(atom2, fg);
691 >                fDecomp_->addForceToAtomColumn(atom2, fg);
692  
693 <                if (atomListJ.size() > 1) {
694 <                  if (info_->usesAtomicVirial_) {
693 >                if (atomListColumn.size() > 1) {
694 >                  if (info_->usesAtomicVirial()) {
695                      // find the distance between the atom
696                      // and the center of the cutoff group:
697 <                    dag = decomp_->getAtomToGroupVectorJ(atom2, cg2);
697 >                    dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2);
698                      tau -= outProduct(dag, fg);
699                    }
700                  }
# Line 424 | Line 708 | namespace OpenMD {
708        }
709  
710        if (iLoop == PREPAIR_LOOP) {
711 <        if (info_->requiresPrepair_) {            
712 <          decomp_->collectIntermediateData();
713 <          atomList = decomp_->getAtomList();
714 <          for (vector<int>::iterator ia = atomList.begin();
715 <               ia != atomList.end(); ++ia) {              
432 <            atom1 = (*ia);            
433 <            decomp_->populateSelfData(atom1, SelfData sdat);
711 >        if (info_->requiresPrepair()) {            
712 >          fDecomp_->collectIntermediateData();
713 >
714 >          for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) {
715 >            fDecomp_->fillSelfData(sdat, atom1);
716              interactionMan_->doPreForce(sdat);
717            }
718 <          decomp_->distributeIntermediateData();        
718 >          
719 >          
720 >          fDecomp_->distributeIntermediateData();        
721          }
722        }
723  
724      }
725      
726 <    decomp_->collectData();
727 <    
728 <    if (info_->requiresSkipCorrection_ || info_->requiresSelfCorrection_) {
445 <      atomList = decomp_->getAtomList();
446 <      for (vector<int>::iterator ia = atomList.begin();
447 <           ia != atomList.end(); ++ia) {              
448 <        atom1 = (*ia);    
726 >    fDecomp_->collectData();
727 >        
728 >    if (info_->requiresSelfCorrection()) {
729  
730 <        if (info_->requiresSkipCorrection_) {
731 <          vector<int> skipList = decomp_->getSkipsForAtom(atom1);
732 <          for (vector<int>::iterator jb = skipList.begin();
453 <               jb != skipList.end(); ++jb) {              
454 <            atom2 = (*jb);
455 <            decomp_->populateSkipData(atom1, atom2, InteractionData idat);
456 <            interactionMan_->doSkipCorrection(idat);
457 <          }
458 <        }
459 <          
460 <        if (info_->requiresSelfCorrection_) {
461 <          decomp_->populateSelfData(atom1, SelfData sdat);
462 <          interactionMan_->doSelfCorrection(sdat);
730 >      for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) {          
731 >        fDecomp_->fillSelfData(sdat, atom1);
732 >        interactionMan_->doSelfCorrection(sdat);
733        }
464      
465      
466    }
734  
468    for (int i=0; i<LR_POT_TYPES;i++){
469      lrPot += longRangePotential[i]; //Quick hack
735      }
736 <        
736 >
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[VDW_POT];
745 <    curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_POT];
744 >    curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY];
745 >    curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY];
746    }
747  
748    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines