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

Comparing trunk/src/nonbonded/EAM.cpp (file contents):
Revision 1895 by gezelter, Mon Jul 1 21:09:37 2013 UTC vs.
Revision 2033 by gezelter, Sat Nov 1 14:12:16 2014 UTC

# Line 60 | Line 60 | namespace OpenMD {
60      CubicSpline* z1 = ea1.getZ();
61      CubicSpline* z2 = ea2.getZ();
62  
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 +
69      // make the r grid:
70  
65
71      // we need phi out to the largest value we'll encounter in the radial space;
72      
73      RealType rmax = 0.0;
# Line 101 | Line 106 | namespace OpenMD {
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;
110 <
109 >      phi = pre11_ * (zi * zj) / r;
110 >      
111        phivals.push_back(phi);
112      }
108      
113      CubicSpline* cs = new CubicSpline();
114      cs->addPoints(rvals, phivals);
115      return cs;
# Line 207 | Line 211 | namespace OpenMD {
211      eamAtomData.F = ea.getF();
212      eamAtomData.Z = ea.getZ();
213      eamAtomData.rcut = ea.getRcut();
214 <
214 >      
215      // add it to the map:
216      int atid = atomType->getIdent();
217      int eamtid = EAMtypes.size();
# Line 223 | Line 227 | namespace OpenMD {
227        simError();        
228      }
229  
230 +
231      EAMtids[atid] = eamtid;
232      EAMdata[eamtid] = eamAtomData;
233      MixingMap[eamtid].resize(nEAM_);
# Line 237 | Line 242 | namespace OpenMD {
242  
243        EAMInteractionData mixer;
244        mixer.phi = getPhi(atomType, atype2);
245 +      mixer.rcut = mixer.phi->getLimits().second;
246        mixer.explicitlySet = false;
247  
248        MixingMap[eamtid2].resize( nEAM_ );
# Line 265 | Line 271 | namespace OpenMD {
271  
272      cs->addPoints(rVals, phiVals);
273      mixer.phi = cs;
274 +    mixer.rcut = mixer.phi->getLimits().second;
275      mixer.explicitlySet = true;
276  
277      int eamtid1 = EAMtids[ atype1->getIdent() ];
# Line 287 | Line 294 | namespace OpenMD {
294      if (haveCutoffRadius_)
295        if ( *(idat.rij) > eamRcut_) return;
296      
297 <    if ( *(idat.rij) < data1.rcut)
298 <      *(idat.rho1) += data1.rho->getValueAt( *(idat.rij));
299 <    
297 >    if ( *(idat.rij) < data1.rcut) {
298 >      *(idat.rho2) += data1.rho->getValueAt( *(idat.rij));
299 >    }
300        
301 <    if ( *(idat.rij) < data2.rcut)
302 <      *(idat.rho2) += data2.rho->getValueAt( *(idat.rij));
301 >    if ( *(idat.rij) < data2.rcut) {
302 >      *(idat.rho1) += data2.rho->getValueAt( *(idat.rij));
303 >    }
304      
305      return;  
306    }
# Line 300 | Line 308 | namespace OpenMD {
308    void EAM::calcFunctional(SelfData &sdat) {
309      
310      if (!initialized_) initialize();
303
311      EAMAtomData &data1 = EAMdata[ EAMtids[sdat.atid] ];
312 <        
313 <    data1.F->getValueAndDerivativeAt( *(sdat.rho), *(sdat.frho), *(sdat.dfrhodrho) );
312 >            
313 >    data1.F->getValueAndDerivativeAt( *(sdat.rho), *(sdat.frho),
314 >                                      *(sdat.dfrhodrho) );
315  
316      (*(sdat.pot))[METALLIC_FAMILY] += *(sdat.frho);
317      if (sdat.doParticlePot) {
# Line 324 | Line 332 | namespace OpenMD {
332  
333      int eamtid1 = EAMtids[idat.atid1];
334      int eamtid2 = EAMtids[idat.atid2];
327    
335      EAMAtomData &data1 = EAMdata[eamtid1];
336      EAMAtomData &data2 = EAMdata[eamtid2];
337      
# Line 332 | Line 339 | namespace OpenMD {
339      
340      RealType rci = data1.rcut;
341      RealType rcj = data2.rcut;
342 +
343      
344      RealType rha(0.0), drha(0.0), rhb(0.0), drhb(0.0);
345      RealType pha(0.0), dpha(0.0), phb(0.0), dphb(0.0);
# Line 349 | Line 357 | namespace OpenMD {
357        CubicSpline* phi = MixingMap[eamtid2][eamtid2].phi;
358        phi->getValueAndDerivativeAt( *(idat.rij), phb, dphb);
359      }
352
360      switch(mixMeth_) {
361      case eamJohnson:
355      
362        if ( *(idat.rij) < rci) {
363          phab = phab + 0.5 * (rhb / rha) * pha;
364          dvpdr = dvpdr + 0.5*((rhb/rha)*dpha +
365                               pha*((drhb/rha) - (rhb*drha/rha/rha)));
366        }
367 <      
362 <      
363 <      
367 >                
368        if ( *(idat.rij) < rcj) {
369          phab = phab + 0.5 * (rha / rhb) * phb;
370          dvpdr = dvpdr + 0.5 * ((rha/rhb)*dphb +
371                                 phb*((drha/rhb) - (rha*drhb/rhb/rhb)));
372        }
369      
373        break;
371      
374      case eamDaw:
375 <      MixingMap[eamtid1][eamtid2].phi->getValueAndDerivativeAt( *(idat.rij), phab, dvpdr);
376 <      
375 >      if ( *(idat.rij) <  MixingMap[eamtid1][eamtid2].rcut) {
376 >        MixingMap[eamtid1][eamtid2].phi->getValueAndDerivativeAt( *(idat.rij),
377 >                                                                  phab, dvpdr);
378 >      }
379        break;
380      case eamUnknown:
381      default:
# Line 391 | Line 395 | namespace OpenMD {
395      dudr = drhojdr* *(idat.dfrho1) + drhoidr* *(idat.dfrho2) + dvpdr;
396      
397      *(idat.f1) += *(idat.d) * dudr / *(idat.rij);
398 <        
398 >
399      if (idat.doParticlePot) {
400        // particlePot is the difference between the full potential and
401        // the full potential without the presence of a particular
# Line 409 | Line 413 | namespace OpenMD {
413          - *(idat.frho1);
414      }
415      
416 <    (*(idat.pot))[METALLIC_FAMILY] += phab;
417 <    
418 <    *(idat.vpair) += phab;
415 <  
416 <    return;
417 <    
416 >    (*(idat.pot))[METALLIC_FAMILY] += phab;    
417 >    *(idat.vpair) += phab;  
418 >    return;    
419    }
420  
421    RealType EAM::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines