ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/nonbonded/EAM.cpp
(Generate patch)

Comparing:
branches/development/src/nonbonded/EAM.cpp (file contents), Revision 1505 by gezelter, Sun Oct 3 22:18:59 2010 UTC vs.
trunk/src/nonbonded/EAM.cpp (file contents), Revision 1927 by gezelter, Wed Aug 14 20:19:19 2013 UTC

# Line 35 | Line 35
35   *                                                                      
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).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
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   #include <stdio.h>
# Line 51 | Line 52 | namespace OpenMD {
52   namespace OpenMD {
53  
54    EAM::EAM() : name_("EAM"), initialized_(false), forceField_(NULL),
55 <               mixMeth_(eamJohnson), eamRcut_(0.0) {}
55 >               mixMeth_(eamJohnson), eamRcut_(0.0), haveCutoffRadius_(false) {}
56    
57 <  EAMParam EAM::getEAMParam(AtomType* atomType) {
58 <    
59 <    // Do sanity checking on the AtomType we were passed before
60 <    // building any data structures:
61 <    if (!atomType->isEAM()) {
61 <      sprintf( painCave.errMsg,
62 <               "EAM::getEAMParam was passed an atomType (%s) that does not\n"
63 <               "\tappear to be an embedded atom method (EAM) atom.\n",
64 <               atomType->getName().c_str());
65 <      painCave.severity = OPENMD_ERROR;
66 <      painCave.isFatal = 1;
67 <      simError();
68 <    }
69 <    
70 <    GenericData* data = atomType->getPropertyByName("EAM");
71 <    if (data == NULL) {
72 <      sprintf( painCave.errMsg, "EAM::getEAMParam could not find EAM\n"
73 <               "\tparameters for atomType %s.\n",
74 <               atomType->getName().c_str());
75 <      painCave.severity = OPENMD_ERROR;
76 <      painCave.isFatal = 1;
77 <      simError();
78 <    }
79 <    
80 <    EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
81 <    if (eamData == NULL) {
82 <      sprintf( painCave.errMsg,
83 <               "EAM::getEAMParam could not convert GenericData to EAMParam for\n"
84 <               "\tatom type %s\n", atomType->getName().c_str());
85 <      painCave.severity = OPENMD_ERROR;
86 <      painCave.isFatal = 1;
87 <      simError();          
88 <    }
89 <    
90 <    return eamData->getData();
91 <  }
57 >  CubicSpline* EAM::getPhi(AtomType* atomType1, AtomType* atomType2) {  
58 >    EAMAdapter ea1 = EAMAdapter(atomType1);
59 >    EAMAdapter ea2 = EAMAdapter(atomType2);
60 >    CubicSpline* z1 = ea1.getZ();
61 >    CubicSpline* z2 = ea2.getZ();
62  
63 <  CubicSpline* EAM::getZ(AtomType* atomType) {    
64 <    EAMParam eamParam = getEAMParam(atomType);
65 <    int nr = eamParam.nr;
66 <    RealType dr = eamParam.dr;
67 <    vector<RealType> rvals;
98 <    
99 <    for (int i = 0; i < nr; i++) rvals.push_back(RealType(i) * dr);
100 <      
101 <    CubicSpline* cs = new CubicSpline();
102 <    cs->addPoints(rvals, eamParam.Z);
103 <    return cs;
104 <  }
63 >    // Thise prefactors convert the charge-charge interactions into
64 >    // kcal / mol all were computed assuming distances are measured in
65 >    // angstroms Charge-Charge, assuming charges are measured in
66 >    // electrons.  Matches value in Electrostatics.cpp
67 >    pre11_ = 332.0637778;
68  
106  RealType EAM::getRcut(AtomType* atomType) {    
107    EAMParam eamParam = getEAMParam(atomType);
108    return eamParam.rcut;
109  }
110
111  CubicSpline* EAM::getRho(AtomType* atomType) {    
112    EAMParam eamParam = getEAMParam(atomType);
113    int nr = eamParam.nr;
114    RealType dr = eamParam.dr;
115    vector<RealType> rvals;
116    
117    for (int i = 0; i < nr; i++) rvals.push_back(RealType(i) * dr);
118      
119    CubicSpline* cs = new CubicSpline();
120    cs->addPoints(rvals, eamParam.rho);
121    return cs;
122  }
123
124  CubicSpline* EAM::getF(AtomType* atomType) {    
125    EAMParam eamParam = getEAMParam(atomType);
126    int nrho = eamParam.nrho;
127    RealType drho = eamParam.drho;
128    vector<RealType> rhovals;
129    vector<RealType> scaledF;
130    
131    for (int i = 0; i < nrho; i++) {
132      rhovals.push_back(RealType(i) * drho);
133      scaledF.push_back( eamParam.F[i] * 23.06054 );
134    }
135      
136    CubicSpline* cs = new CubicSpline();
137    cs->addPoints(rhovals, scaledF);
138    return cs;
139  }
140  
141  CubicSpline* EAM::getPhi(AtomType* atomType1, AtomType* atomType2) {    
142    EAMParam eamParam1 = getEAMParam(atomType1);
143    EAMParam eamParam2 = getEAMParam(atomType2);
144    CubicSpline* z1 = getZ(atomType1);
145    CubicSpline* z2 = getZ(atomType2);
146
69      // make the r grid:
70  
149
71      // we need phi out to the largest value we'll encounter in the radial space;
72      
73      RealType rmax = 0.0;
74 <    rmax = max(rmax, eamParam1.rcut);
75 <    rmax = max(rmax, eamParam1.nr * eamParam1.dr);
74 >    rmax = max(rmax, ea1.getRcut());
75 >    rmax = max(rmax, ea1.getNr() * ea1.getDr());
76  
77 <    rmax = max(rmax, eamParam2.rcut);
78 <    rmax = max(rmax, eamParam2.nr * eamParam2.dr);
77 >    rmax = max(rmax, ea2.getRcut());
78 >    rmax = max(rmax, ea2.getNr() * ea2.getDr());
79  
80      // use the smallest dr (finest grid) to build our grid:
81  
82 <    RealType dr = min(eamParam1.dr, eamParam2.dr);
82 >    RealType dr = min(ea1.getDr(), ea2.getDr());
83  
84      int nr = int(rmax/dr + 0.5);
85  
# Line 174 | Line 95 | namespace OpenMD {
95  
96      phivals.push_back(0.0);
97  
98 <    for (int i = 1; i < rvals.size(); i++ ) {
98 >    for (unsigned int i = 1; i < rvals.size(); i++ ) {
99        r = rvals[i];
100  
101        // only use z(r) if we're inside this atom's cutoff radius,
# Line 182 | Line 103 | namespace OpenMD {
103        // means that our phi grid goes out beyond the cutoff of the
104        // pair potential
105  
106 <      zi = r <= eamParam1.rcut ? z1->getValueAt(r) : 0.0;
107 <      zj = r <= eamParam2.rcut ? z2->getValueAt(r) : 0.0;
106 >      zi = r <= ea1.getRcut() ? z1->getValueAt(r) : 0.0;
107 >      zj = r <= ea2.getRcut() ? z2->getValueAt(r) : 0.0;
108  
109 <      phi = 331.999296 * (zi * zj) / r;
109 >      phi = pre11_ * (zi * zj) / r;
110  
111        phivals.push_back(phi);
112      }
# Line 195 | Line 116 | namespace OpenMD {
116      return cs;
117    }
118  
119 <  void EAM::initialize() {
119 >  void EAM::setCutoffRadius( RealType rCut ) {
120 >    eamRcut_ = rCut;
121 >    haveCutoffRadius_ = true;
122 >  }
123  
124 +  void EAM::initialize() {
125      // set up the mixing method:
126      ForceFieldOptions& fopts = forceField_->getForceFieldOptions();
127      string EAMMixMeth = fopts.getEAMMixingMethod();
# Line 210 | Line 135 | namespace OpenMD {
135        mixMeth_ = eamUnknown;
136        
137      // find all of the EAM atom Types:
138 <    ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes();
139 <    ForceField::AtomTypeContainer::MapTypeIterator i;
140 <    AtomType* at;
138 >    EAMtypes.clear();
139 >    EAMtids.clear();
140 >    EAMdata.clear();
141 >    MixingMap.clear();
142 >    nEAM_ = 0;
143 >    
144 >    EAMtids.resize( forceField_->getNAtomType(), -1);
145  
146 <    for (at = atomTypes->beginType(i); at != NULL;
147 <         at = atomTypes->nextType(i)) {
148 <      
220 <      if (at->isEAM())
221 <        addType(at);
146 >    set<AtomType*>::iterator at;
147 >    for (at = simTypes_.begin(); at != simTypes_.end(); ++at) {
148 >      if ((*at)->isEAM()) nEAM_++;
149      }
150 +    EAMdata.resize(nEAM_);
151 +    MixingMap.resize(nEAM_);
152 +
153 +    for (at = simTypes_.begin(); at != simTypes_.end(); ++at) {
154 +      if ((*at)->isEAM()) addType(*at);
155 +    }
156      
157      // find all of the explicit EAM interactions (setfl):
158      ForceField::NonBondedInteractionTypeContainer* nbiTypes = forceField_->getNonBondedInteractionTypes();
# Line 272 | Line 205 | namespace OpenMD {
205  
206    void EAM::addType(AtomType* atomType){
207  
208 +    EAMAdapter ea = EAMAdapter(atomType);
209      EAMAtomData eamAtomData;
276    
277    eamAtomData.rho = getRho(atomType);
278    eamAtomData.F = getF(atomType);
279    eamAtomData.Z = getZ(atomType);
280    eamAtomData.rcut = getRcut(atomType);
210  
211 +    eamAtomData.rho = ea.getRho();
212 +    eamAtomData.F = ea.getF();
213 +    eamAtomData.Z = ea.getZ();
214 +    eamAtomData.rcut = ea.getRcut();
215 +    eamAtomData.isFluctuating = atomType->isFluctuatingCharge();
216 +      
217      // add it to the map:
218 <    AtomTypeProperties atp = atomType->getATP();    
218 >    int atid = atomType->getIdent();
219 >    int eamtid = EAMtypes.size();
220  
221 <    pair<map<int,AtomType*>::iterator,bool> ret;    
222 <    ret = EAMlist.insert( pair<int, AtomType*>(atp.ident, atomType) );
221 >    pair<set<int>::iterator,bool> ret;    
222 >    ret = EAMtypes.insert( atid );
223      if (ret.second == false) {
224        sprintf( painCave.errMsg,
225                 "EAM already had a previous entry with ident %d\n",
226 <               atp.ident);
226 >               atid);
227        painCave.severity = OPENMD_INFO;
228        painCave.isFatal = 0;
229        simError();        
230      }
231  
232 <    EAMMap[atomType] = eamAtomData;
232 >    if (eamAtomData.isFluctuating) {
233 >      // compute charge to rho scaling:
234 >      RealType z0 = eamAtomData.Z->getValueAt(0.0);
235 >      RealType dr = ea.getDr();
236 >      RealType rmax = max(eamAtomData.rcut, ea.getNr() * dr);
237 >      int nr = int(rmax/dr + 0.5);
238 >      RealType r;
239 >      RealType sum(0.0);
240 >
241 >      for (int i = 0; i < nr; i++) {
242 >        r = RealType(i*dr);
243 >        sum += r * r * eamAtomData.rho->getValueAt(r) * dr;      
244 >      }
245 >      sum *= 4.0 * M_PI;
246 >      eamAtomData.qToRhoScaling = sum / z0;
247 >    }
248 >
249 >
250 >    EAMtids[atid] = eamtid;
251 >    EAMdata[eamtid] = eamAtomData;
252 >    MixingMap[eamtid].resize(nEAM_);
253      
254      // Now, iterate over all known types and add to the mixing map:
255      
256 <    map<AtomType*, EAMAtomData>::iterator it;
257 <    for( it = EAMMap.begin(); it != EAMMap.end(); ++it) {
256 >    std::set<int>::iterator it;
257 >    for( it = EAMtypes.begin(); it != EAMtypes.end(); ++it) {
258        
259 <      AtomType* atype2 = (*it).first;
259 >      int eamtid2 = EAMtids[ (*it) ];
260 >      AtomType* atype2 = forceField_->getAtomType( (*it) );
261  
262        EAMInteractionData mixer;
263        mixer.phi = getPhi(atomType, atype2);
264        mixer.explicitlySet = false;
265  
266 <      pair<AtomType*, AtomType*> key1, key2;
310 <      key1 = make_pair(atomType, atype2);
311 <      key2 = make_pair(atype2, atomType);
266 >      MixingMap[eamtid2].resize( nEAM_ );
267        
268 <      MixingMap[key1] = mixer;
269 <      if (key2 != key1) {
270 <        MixingMap[key2] = mixer;
268 >      MixingMap[eamtid][eamtid2] = mixer;
269 >      if (eamtid2 != eamtid) {
270 >        MixingMap[eamtid2][eamtid] = mixer;
271        }
272      }      
273      return;
# Line 336 | Line 291 | namespace OpenMD {
291      mixer.phi = cs;
292      mixer.explicitlySet = true;
293  
294 <    pair<AtomType*, AtomType*> key1, key2;
295 <    key1 = make_pair(atype1, atype2);
341 <    key2 = make_pair(atype2, atype1);
294 >    int eamtid1 = EAMtids[ atype1->getIdent() ];
295 >    int eamtid2 = EAMtids[ atype2->getIdent() ];
296      
297 <    MixingMap[key1] = mixer;
298 <    if (key2 != key1) {
299 <      MixingMap[key2] = mixer;
297 >    MixingMap[eamtid1][eamtid2] = mixer;
298 >    if (eamtid2 != eamtid1) {
299 >      MixingMap[eamtid2][eamtid1] = mixer;
300      }    
301      return;
302    }
303  
304 <  void EAM::calcDensity(DensityData ddat) {
304 >  void EAM::calcDensity(InteractionData &idat) {
305      
306      if (!initialized_) initialize();
307      
308 <    EAMAtomData data1 = EAMMap[ddat.atype1];
309 <    EAMAtomData data2 = EAMMap[ddat.atype2];
308 >    EAMAtomData &data1 = EAMdata[EAMtids[idat.atid1]];
309 >    EAMAtomData &data2 = EAMdata[EAMtids[idat.atid2]];
310  
311 <    if (ddat.rij < data1.rcut)
312 <      ddat.rho_i_at_j = data1.rho->getValueAt(ddat.rij);
313 <
314 <    if (ddat.rij < data2.rcut)
315 <      ddat.rho_j_at_i = data2.rho->getValueAt(ddat.rij);
316 <
317 <    return;
318 <  }
319 <
320 <  void EAM::calcFunctional(FunctionalData fdat) {
321 <
311 >    if (haveCutoffRadius_)
312 >      if ( *(idat.rij) > eamRcut_) return;
313 >    
314 >    if ( *(idat.rij) < data1.rcut) {
315 >      if (data1.isFluctuating) {
316 >        *(idat.rho2) += (1.0 -  *(idat.flucQ1) * data1.qToRhoScaling ) *
317 >          data1.rho->getValueAt( *(idat.rij) );
318 >      } else {
319 >        *(idat.rho2) += data1.rho->getValueAt( *(idat.rij));
320 >      }
321 >    }
322 >      
323 >    if ( *(idat.rij) < data2.rcut) {
324 >      if (data2.isFluctuating) {
325 >        *(idat.rho1) += (1.0 -  *(idat.flucQ2) * data2.qToRhoScaling ) *
326 >          data2.rho->getValueAt( *(idat.rij) );
327 >      } else {
328 >        *(idat.rho1) += data2.rho->getValueAt( *(idat.rij));
329 >      }
330 >    }
331 >    
332 >    return;  
333 >  }
334 >  
335 >  void EAM::calcFunctional(SelfData &sdat) {
336 >    
337      if (!initialized_) initialize();
338  
339 <    EAMAtomData data1 = EAMMap[fdat.atype];
340 <        
341 <    pair<RealType, RealType> result = data1.F->getValueAndDerivativeAt(fdat.rho);
339 >    EAMAtomData &data1 = EAMdata[ EAMtids[sdat.atid] ];
340 >            
341 >    data1.F->getValueAndDerivativeAt( *(sdat.rho), *(sdat.frho), *(sdat.dfrhodrho) );
342  
343 <    fdat.frho = result.first;
344 <    fdat.dfrhodrho = result.second;
343 >    (*(sdat.pot))[METALLIC_FAMILY] += *(sdat.frho);
344 >    if (sdat.doParticlePot) {
345 >      *(sdat.particlePot) += *(sdat.frho);
346 >    }
347 >
348      return;
349    }
350  
351  
352 <  void EAM::calcForce(InteractionData idat) {
352 >  void EAM::calcForce(InteractionData &idat) {
353  
354      if (!initialized_) initialize();
355  
356 <    pair<RealType, RealType> res;
357 <    
358 <    if (idat.rij < eamRcut_) {
356 >    if (haveCutoffRadius_)
357 >      if ( *(idat.rij) > eamRcut_) return;
358 >  
359  
360 <      EAMAtomData data1 = EAMMap[idat.atype1];
361 <      EAMAtomData data2 = EAMMap[idat.atype2];
362 <
363 <      // get type-specific cutoff radii
364 <
365 <      RealType rci = data1.rcut;
366 <      RealType rcj = data2.rcut;
367 <      
368 <      RealType rha, drha, rhb, drhb;
369 <      RealType pha, dpha, phb, dphb;
370 <      RealType phab, dvpdr;
371 <      RealType drhoidr, drhojdr, dudr;
372 <      
373 <      if (idat.rij < rci) {
374 <        res = data1.rho->getValueAndDerivativeAt(idat.rij);
375 <        rha = res.first;
376 <        drha = res.second;
377 <
378 <        res = MixingMap[make_pair(idat.atype1, idat.atype1)].phi->getValueAndDerivativeAt(idat.rij);
379 <        pha = res.first;
380 <        dpha = res.second;
360 >    int eamtid1 = EAMtids[idat.atid1];
361 >    int eamtid2 = EAMtids[idat.atid2];
362 >    
363 >    EAMAtomData &data1 = EAMdata[eamtid1];
364 >    EAMAtomData &data2 = EAMdata[eamtid2];
365 >    
366 >    // get type-specific cutoff radii
367 >    
368 >    RealType rci = data1.rcut;
369 >    RealType rcj = data2.rcut;
370 >    
371 >    RealType rha(0.0), drha(0.0), rhb(0.0), drhb(0.0);
372 >    RealType pha(0.0), dpha(0.0), phb(0.0), dphb(0.0);
373 >    RealType phab(0.0), dvpdr(0.0);
374 >    RealType drhoidr, drhojdr, dudr;
375 >    
376 >    if ( *(idat.rij) < rci) {
377 >      data1.rho->getValueAndDerivativeAt( *(idat.rij), rha, drha);
378 >      CubicSpline* phi = MixingMap[eamtid1][eamtid1].phi;
379 >      phi->getValueAndDerivativeAt( *(idat.rij), pha, dpha);
380 >      if (data1.isFluctuating) {
381 >        *(idat.dVdFQ1) -= *(idat.dfrho2) * rha * data1.qToRhoScaling;
382        }
383 <
384 <      if (idat.rij < rcj) {
385 <        res = data2.rho->getValueAndDerivativeAt(idat.rij);
386 <        rhb = res.first;
387 <        drhb = res.second;
388 <
389 <        res = MixingMap[make_pair(idat.atype2, idat.atype2)].phi->getValueAndDerivativeAt(idat.rij);
390 <        phb = res.first;
418 <        dphb = res.second;
383 >    }
384 >    
385 >    if ( *(idat.rij) < rcj) {
386 >      data2.rho->getValueAndDerivativeAt( *(idat.rij), rhb, drhb );
387 >      CubicSpline* phi = MixingMap[eamtid2][eamtid2].phi;
388 >      phi->getValueAndDerivativeAt( *(idat.rij), phb, dphb);
389 >      if (data2.isFluctuating) {
390 >        *(idat.dVdFQ2) -= *(idat.dfrho1) * rhb * data2.qToRhoScaling;
391        }
392 +    }
393  
394 <      phab = 0.0;
395 <      dvpdr = 0.0;
396 <
397 <      switch(mixMeth_) {
398 <      case eamJohnson:
399 <      
400 <        if (idat.rij < rci) {
428 <          phab = phab + 0.5 * (rhb / rha) * pha;
429 <          dvpdr = dvpdr + 0.5*((rhb/rha)*dpha +
430 <                               pha*((drhb/rha) - (rhb*drha/rha/rha)));
431 <        }
432 <
433 <        if (idat.rij < rcj) {
434 <          phab = phab + 0.5 * (rha / rhb) * phb;
435 <          dvpdr = dvpdr + 0.5 * ((rha/rhb)*dphb +
436 <                                 phb*((drha/rhb) - (rha*drhb/rhb/rhb)));
437 <        }
438 <
439 <        break;
440 <
441 <      case eamDaw:
442 <        res = MixingMap[make_pair(idat.atype1,idat.atype2)].phi->getValueAndDerivativeAt(idat.rij);
443 <        phab = res.first;
444 <        dvpdr = res.second;
445 <
446 <        break;
447 <      case eamUnknown:
448 <      default:
449 <
450 <        sprintf(painCave.errMsg,
451 <                "EAM::calcForce hit a mixing method it doesn't know about!\n"
452 <                );
453 <        painCave.severity = OPENMD_ERROR;
454 <        painCave.isFatal = 1;
455 <        simError();        
456 <          
394 >    switch(mixMeth_) {
395 >    case eamJohnson:
396 >      
397 >      if ( *(idat.rij) < rci) {
398 >        phab = phab + 0.5 * (rhb / rha) * pha;
399 >        dvpdr = dvpdr + 0.5*((rhb/rha)*dpha +
400 >                             pha*((drhb/rha) - (rhb*drha/rha/rha)));
401        }
402        
403 <      drhoidr = drha;
404 <      drhojdr = drhb;
403 >      
404 >      
405 >      if ( *(idat.rij) < rcj) {
406 >        phab = phab + 0.5 * (rha / rhb) * phb;
407 >        dvpdr = dvpdr + 0.5 * ((rha/rhb)*dphb +
408 >                               phb*((drha/rhb) - (rha*drhb/rhb/rhb)));
409 >      }
410 >      
411 >      break;
412 >      
413 >    case eamDaw:
414 >      MixingMap[eamtid1][eamtid2].phi->getValueAndDerivativeAt( *(idat.rij), phab, dvpdr);
415 >      
416 >      break;
417 >    case eamUnknown:
418 >    default:
419 >      
420 >      sprintf(painCave.errMsg,
421 >              "EAM::calcForce hit a mixing method it doesn't know about!\n"
422 >              );
423 >      painCave.severity = OPENMD_ERROR;
424 >      painCave.isFatal = 1;
425 >      simError();        
426 >      
427 >    }
428 >    
429 >    drhoidr = drha;
430 >    drhojdr = drhb;
431 >    
432 >    dudr = drhojdr* *(idat.dfrho1) + drhoidr* *(idat.dfrho2) + dvpdr;
433 >    
434 >    *(idat.f1) += *(idat.d) * dudr / *(idat.rij);
435  
462      dudr = drhojdr*idat.dfrho1 + drhoidr*idat.dfrho2 + dvpdr;
463
464      idat.f1 = idat.d * dudr / idat.rij;
436          
437 <      // particle_pot is the difference between the full potential
438 <      // and the full potential without the presence of a particular
437 >    if (idat.doParticlePot) {
438 >      // particlePot is the difference between the full potential and
439 >      // the full potential without the presence of a particular
440        // particle (atom1).
441        //
442 <      // This reduces the density at other particle locations, so
443 <      // we need to recompute the density at atom2 assuming atom1
444 <      // didn't contribute.  This then requires recomputing the
445 <      // density functional for atom2 as well.
446 <      //
447 <      // Most of the particle_pot heavy lifting comes from the
448 <      // pair interaction, and will be handled by vpair.
449 <    
450 <      idat.fshift1 = data1.F->getValueAt( idat.rho1 - rhb );
451 <      idat.fshift2 = data1.F->getValueAt( idat.rho2 - rha );
480 <
481 <      idat.pot += phab;
482 <
483 <      idat.vpair += phab;
442 >      // This reduces the density at other particle locations, so we
443 >      // need to recompute the density at atom2 assuming atom1 didn't
444 >      // contribute.  This then requires recomputing the density
445 >      // functional for atom2 as well.
446 >      
447 >      *(idat.particlePot1) += data2.F->getValueAt( *(idat.rho2) - rha )
448 >        - *(idat.frho2);
449 >      
450 >      *(idat.particlePot2) += data1.F->getValueAt( *(idat.rho1) - rhb)
451 >        - *(idat.frho1);
452      }
453 <
453 >    
454 >    (*(idat.pot))[METALLIC_FAMILY] += phab;
455 >    
456 >    *(idat.vpair) += phab;
457 >  
458      return;
459      
460    }
461  
462 <  RealType EAM::getSuggestedCutoffRadius(AtomType* at1, AtomType* at2) {
462 >  RealType EAM::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {
463      if (!initialized_) initialize();  
464  
465      RealType cut = 0.0;
466  
467 <    map<AtomType*, EAMAtomData>::iterator it;
468 <
469 <    it = EAMMap.find(at1);
470 <    if (it != EAMMap.end()) {
471 <      EAMAtomData data1 = (*it).second;
467 >    int atid1 = atypes.first->getIdent();
468 >    int atid2 = atypes.second->getIdent();
469 >    int eamtid1 = EAMtids[atid1];
470 >    int eamtid2 = EAMtids[atid2];
471 >    
472 >    if (eamtid1 != -1) {
473 >      EAMAtomData data1 = EAMdata[eamtid1];
474        cut = data1.rcut;
475      }
476  
477 <    it = EAMMap.find(at2);
478 <    if (it != EAMMap.end()) {
505 <      EAMAtomData data2 = (*it).second;
477 >    if (eamtid2 != -1) {
478 >      EAMAtomData data2 = EAMdata[eamtid2];
479        if (data2.rcut > cut)
480          cut = data2.rcut;
481      }
482 <
482 >    
483      return cut;
484    }
485   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines