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

Comparing branches/development/src/nonbonded/SC.cpp (file contents):
Revision 1502 by gezelter, Sat Oct 2 19:53:32 2010 UTC vs.
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 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   #include <stdio.h>
# Line 302 | Line 303 | namespace OpenMD {
303      return;
304    }
305  
306 <  void SC::calcDensity(DensityData ddat) {
306 >  void SC::calcDensity(InteractionData &idat) {
307      
308      if (!initialized_) initialize();
309      
310 <    SCInteractionData mixer = MixingMap[make_pair(ddat.atype1, ddat.atype2)];
310 >    SCInteractionData mixer = MixingMap[ idat.atypes ];
311  
312      RealType rcij = mixer.rCut;
313  
314 <    if (ddat.rij < rcij) {
315 <      ddat.rho_i_at_j = mixer.phi->getValueAt(ddat.rij);
316 <      ddat.rho_j_at_i = ddat.rho_i_at_j;
317 <    } else {
318 <      ddat.rho_i_at_j = 0.0;
319 <      ddat.rho_j_at_i = 0.0;
319 <    }
320 <
314 >    if ( *(idat.rij)  < rcij) {
315 >      RealType rho = mixer.phi->getValueAt( *(idat.rij) );
316 >      *(idat.rho1) += rho;
317 >      *(idat.rho2) += rho;
318 >    }
319 >    
320      return;
321    }
322  
323 <  void SC::calcFunctional(FunctionalData fdat) {
323 >  void SC::calcFunctional(SelfData &sdat) {
324  
325      if (!initialized_) initialize();
326  
327 <    SCAtomData data1 = SCMap[fdat.atype];
328 <    
329 <    fdat.frho = - data1.c * data1.epsilon * sqrt(fdat.rho);
330 <    fdat.dfrhodrho = 0.5 * fdat.frho / fdat.rho;
327 >    SCAtomData data1 = SCMap[sdat.atype];
328 >  
329 >    RealType u = - data1.c * data1.epsilon * sqrt( *(sdat.rho) );
330 >    *(sdat.frho) = u;
331 >    *(sdat.dfrhodrho) = 0.5 * *(sdat.frho) / *(sdat.rho);
332 >
333 >    (*(sdat.pot))[METALLIC_FAMILY] += u;
334 >    *(sdat.particlePot) += u;
335      
336      return;
337    }
338    
339  
340 <  void SC::calcForce(InteractionData idat) {
340 >  void SC::calcForce(InteractionData &idat) {
341      
342      if (!initialized_) initialize();
343      
344 <    SCAtomData data1 = SCMap[idat.atype1];
345 <    SCAtomData data2 = SCMap[idat.atype2];
344 >    SCAtomData data1 = SCMap[idat.atypes.first];
345 >    SCAtomData data2 = SCMap[idat.atypes.second];
346  
347 <    SCInteractionData mixer = MixingMap[make_pair(idat.atype1, idat.atype2)];
347 >    SCInteractionData mixer = MixingMap[idat.atypes];
348  
349      RealType rcij = mixer.rCut;
350  
351 <    if (idat.rij < rcij) {
351 >    if ( *(idat.rij)  < rcij) {
352        RealType vcij = mixer.vCut;
353        
354        pair<RealType, RealType> res;
355        
356 <      res = mixer.phi->getValueAndDerivativeAt(idat.rij);
356 >      res = mixer.phi->getValueAndDerivativeAt( *(idat.rij) );
357        RealType rhtmp = res.first;
358        RealType drhodr = res.second;
359        
360 <      res = mixer.V->getValueAndDerivativeAt(idat.rij);
360 >      res = mixer.V->getValueAndDerivativeAt( *(idat.rij) );
361        RealType vptmp = res.first;
362        RealType dvpdr = res.second;
363        
364        RealType pot_temp = vptmp - vcij;
365 <      idat.vpair += pot_temp;
363 <      
364 <      RealType dudr = drhodr * (idat.dfrho1 + idat.dfrho2) + dvpdr;
365 >      *(idat.vpair) += pot_temp;
366        
367 <      idat.f1 += idat.d * dudr / idat.rij;
367 >      RealType dudr = drhodr * ( *(idat.dfrho1) + *(idat.dfrho2) ) + dvpdr;
368 >      
369 >      *(idat.f1) += *(idat.d) * dudr / *(idat.rij) ;
370          
371 <      // particle_pot is the difference between the full potential
372 <      // and the full potential without the presence of a particular
371 >      // particlePot is the difference between the full potential and
372 >      // the full potential without the presence of a particular
373        // particle (atom1).
374        //
375 <      // This reduces the density at other particle locations, so
376 <      // we need to recompute the density at atom2 assuming atom1
377 <      // didn't contribute.  This then requires recomputing the
378 <      // density functional for atom2 as well.
379 <      //
380 <      // Most of the particle_pot heavy lifting comes from the
381 <      // pair interaction, and will be handled by vpair.
375 >      // This reduces the density at other particle locations, so we
376 >      // need to recompute the density at atom2 assuming atom1 didn't
377 >      // contribute.  This then requires recomputing the density
378 >      // functional for atom2 as well.
379 >          
380 >      *(idat.particlePot1) -= data2.c * data2.epsilon *
381 >        sqrt( *(idat.rho2) - rhtmp) + *(idat.frho2);
382 >
383 >      *(idat.particlePot2) -= data1.c * data1.epsilon *
384 >        sqrt( *(idat.rho1) - rhtmp) + *(idat.frho1);
385        
386 <      idat.fshift1 = - data1.c * data1.epsilon * sqrt(idat.rho1 - rhtmp);
381 <      idat.fshift2 = - data2.c * data2.epsilon * sqrt(idat.rho2 - rhtmp);
382 <      
383 <      idat.pot += pot_temp;
386 >      (*(idat.pot))[METALLIC_FAMILY] += pot_temp;
387      }
388        
389      return;    
390    }
391 +
392 +  RealType SC::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {
393 +    if (!initialized_) initialize();  
394 +
395 +    map<pair<AtomType*, AtomType*>, SCInteractionData>::iterator it;
396 +    it = MixingMap.find(atypes);
397 +    if (it == MixingMap.end())
398 +      return 0.0;
399 +    else  {
400 +      SCInteractionData mixer = (*it).second;
401 +      return mixer.rCut;
402 +    }
403 +  }
404   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines