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

Comparing:
branches/development/src/nonbonded/SC.cpp (file contents), Revision 1505 by gezelter, Sun Oct 3 22:18:59 2010 UTC vs.
branches/devel_omp/src/nonbonded/SC.cpp (file contents), Revision 1614 by mciznick, Tue Aug 23 20:55:51 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines