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 2071 by gezelter, Sat Mar 7 21:41:51 2015 UTC

# Line 51 | Line 51 | namespace OpenMD {
51  
52   namespace OpenMD {
53  
54 <  EAM::EAM() : name_("EAM"), initialized_(false), forceField_(NULL),
55 <               mixMeth_(eamJohnson), eamRcut_(0.0), haveCutoffRadius_(false) {}
54 >  EAM::EAM() : initialized_(false), haveCutoffRadius_(false),
55 >               forceField_(NULL), eamRcut_(0.0), mixMeth_(eamJohnson),
56 >               name_("EAM") {}
57    
58    CubicSpline* EAM::getPhi(AtomType* atomType1, AtomType* atomType2) {  
59      EAMAdapter ea1 = EAMAdapter(atomType1);
# Line 60 | Line 61 | namespace OpenMD {
61      CubicSpline* z1 = ea1.getZ();
62      CubicSpline* z2 = ea2.getZ();
63  
64 +    // Thise prefactors convert the charge-charge interactions into
65 +    // kcal / mol all were computed assuming distances are measured in
66 +    // angstroms Charge-Charge, assuming charges are measured in
67 +    // electrons.  Matches value in Electrostatics.cpp
68 +    pre11_ = 332.0637778;
69 +
70      // make the r grid:
71  
65
72      // we need phi out to the largest value we'll encounter in the radial space;
73      
74      RealType rmax = 0.0;
# Line 101 | Line 107 | namespace OpenMD {
107        zi = r <= ea1.getRcut() ? z1->getValueAt(r) : 0.0;
108        zj = r <= ea2.getRcut() ? z2->getValueAt(r) : 0.0;
109  
110 <      phi = 331.999296 * (zi * zj) / r;
111 <
110 >      phi = pre11_ * (zi * zj) / r;
111 >      
112        phivals.push_back(phi);
113      }
108      
114      CubicSpline* cs = new CubicSpline();
115      cs->addPoints(rvals, phivals);
116      return cs;
# Line 207 | Line 212 | namespace OpenMD {
212      eamAtomData.F = ea.getF();
213      eamAtomData.Z = ea.getZ();
214      eamAtomData.rcut = ea.getRcut();
215 <
215 >      
216      // add it to the map:
217      int atid = atomType->getIdent();
218      int eamtid = EAMtypes.size();
# Line 223 | Line 228 | namespace OpenMD {
228        simError();        
229      }
230  
231 +
232      EAMtids[atid] = eamtid;
233      EAMdata[eamtid] = eamAtomData;
234      MixingMap[eamtid].resize(nEAM_);
# Line 237 | Line 243 | namespace OpenMD {
243  
244        EAMInteractionData mixer;
245        mixer.phi = getPhi(atomType, atype2);
246 +      mixer.rcut = mixer.phi->getLimits().second;
247        mixer.explicitlySet = false;
248  
249        MixingMap[eamtid2].resize( nEAM_ );
# Line 265 | Line 272 | namespace OpenMD {
272  
273      cs->addPoints(rVals, phiVals);
274      mixer.phi = cs;
275 +    mixer.rcut = mixer.phi->getLimits().second;
276      mixer.explicitlySet = true;
277  
278      int eamtid1 = EAMtids[ atype1->getIdent() ];
# Line 287 | Line 295 | namespace OpenMD {
295      if (haveCutoffRadius_)
296        if ( *(idat.rij) > eamRcut_) return;
297      
298 <    if ( *(idat.rij) < data1.rcut)
299 <      *(idat.rho1) += data1.rho->getValueAt( *(idat.rij));
300 <    
298 >    if ( *(idat.rij) < data1.rcut) {
299 >      *(idat.rho2) += data1.rho->getValueAt( *(idat.rij));
300 >    }
301        
302 <    if ( *(idat.rij) < data2.rcut)
303 <      *(idat.rho2) += data2.rho->getValueAt( *(idat.rij));
302 >    if ( *(idat.rij) < data2.rcut) {
303 >      *(idat.rho1) += data2.rho->getValueAt( *(idat.rij));
304 >    }
305      
306      return;  
307    }
# Line 300 | Line 309 | namespace OpenMD {
309    void EAM::calcFunctional(SelfData &sdat) {
310      
311      if (!initialized_) initialize();
303
312      EAMAtomData &data1 = EAMdata[ EAMtids[sdat.atid] ];
313 <        
314 <    data1.F->getValueAndDerivativeAt( *(sdat.rho), *(sdat.frho), *(sdat.dfrhodrho) );
313 >            
314 >    data1.F->getValueAndDerivativeAt( *(sdat.rho), *(sdat.frho),
315 >                                      *(sdat.dfrhodrho) );
316  
317      (*(sdat.pot))[METALLIC_FAMILY] += *(sdat.frho);
318      if (sdat.doParticlePot) {
# Line 324 | Line 333 | namespace OpenMD {
333  
334      int eamtid1 = EAMtids[idat.atid1];
335      int eamtid2 = EAMtids[idat.atid2];
327    
336      EAMAtomData &data1 = EAMdata[eamtid1];
337      EAMAtomData &data2 = EAMdata[eamtid2];
338      
# Line 332 | Line 340 | namespace OpenMD {
340      
341      RealType rci = data1.rcut;
342      RealType rcj = data2.rcut;
343 +
344      
345      RealType rha(0.0), drha(0.0), rhb(0.0), drhb(0.0);
346      RealType pha(0.0), dpha(0.0), phb(0.0), dphb(0.0);
# Line 349 | Line 358 | namespace OpenMD {
358        CubicSpline* phi = MixingMap[eamtid2][eamtid2].phi;
359        phi->getValueAndDerivativeAt( *(idat.rij), phb, dphb);
360      }
352
361      switch(mixMeth_) {
362      case eamJohnson:
355      
363        if ( *(idat.rij) < rci) {
364          phab = phab + 0.5 * (rhb / rha) * pha;
365          dvpdr = dvpdr + 0.5*((rhb/rha)*dpha +
366                               pha*((drhb/rha) - (rhb*drha/rha/rha)));
367        }
368 <      
362 <      
363 <      
368 >                
369        if ( *(idat.rij) < rcj) {
370          phab = phab + 0.5 * (rha / rhb) * phb;
371          dvpdr = dvpdr + 0.5 * ((rha/rhb)*dphb +
372                                 phb*((drha/rhb) - (rha*drhb/rhb/rhb)));
373        }
369      
374        break;
371      
375      case eamDaw:
376 <      MixingMap[eamtid1][eamtid2].phi->getValueAndDerivativeAt( *(idat.rij), phab, dvpdr);
377 <      
376 >      if ( *(idat.rij) <  MixingMap[eamtid1][eamtid2].rcut) {
377 >        MixingMap[eamtid1][eamtid2].phi->getValueAndDerivativeAt( *(idat.rij),
378 >                                                                  phab, dvpdr);
379 >      }
380        break;
381      case eamUnknown:
382      default:
# Line 391 | Line 396 | namespace OpenMD {
396      dudr = drhojdr* *(idat.dfrho1) + drhoidr* *(idat.dfrho2) + dvpdr;
397      
398      *(idat.f1) += *(idat.d) * dudr / *(idat.rij);
399 <        
399 >
400      if (idat.doParticlePot) {
401        // particlePot is the difference between the full potential and
402        // the full potential without the presence of a particular
# Line 409 | Line 414 | namespace OpenMD {
414          - *(idat.frho1);
415      }
416      
417 <    (*(idat.pot))[METALLIC_FAMILY] += phab;
418 <    
419 <    *(idat.vpair) += phab;
415 <  
416 <    return;
417 <    
417 >    (*(idat.pot))[METALLIC_FAMILY] += phab;    
418 >    *(idat.vpair) += phab;  
419 >    return;    
420    }
421  
422    RealType EAM::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines