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

Comparing branches/development/src/nonbonded/Electrostatic.cpp (file contents):
Revision 1616 by gezelter, Tue Aug 30 15:45:35 2011 UTC vs.
Revision 1767 by gezelter, Fri Jul 6 22:01:58 2012 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 46 | Line 47
47   #include "nonbonded/Electrostatic.hpp"
48   #include "utils/simError.h"
49   #include "types/NonBondedInteractionType.hpp"
50 < #include "types/DirectionalAtomType.hpp"
50 > #include "types/FixedChargeAdapter.hpp"
51 > #include "types/FluctuatingChargeAdapter.hpp"
52 > #include "types/MultipoleAdapter.hpp"
53   #include "io/Globals.hpp"
54 + #include "nonbonded/SlaterIntegrals.hpp"
55 + #include "utils/PhysicalConstants.hpp"
56 + #include "math/erfc.hpp"
57  
58   namespace OpenMD {
59    
# Line 187 | Line 193 | namespace OpenMD {
193          
194          // throw warning
195          sprintf( painCave.errMsg,
196 <                 "Electrostatic::initialize: dampingAlpha was not specified in the input file.\n"
197 <                 "\tA default value of %f (1/ang) will be used for the cutoff of\n\t%f (ang).\n",
196 >                 "Electrostatic::initialize: dampingAlpha was not specified in the\n"
197 >                 "\tinput file.  A default value of %f (1/ang) will be used for the\n"
198 >                 "\tcutoff of %f (ang).\n",
199                   dampingAlpha_, cutoffRadius_);
200          painCave.severity = OPENMD_INFO;
201          painCave.isFatal = 0;
# Line 211 | Line 218 | namespace OpenMD {
218          addType(at);
219      }
220      
214
221      cutoffRadius2_ = cutoffRadius_ * cutoffRadius_;
222      rcuti_ = 1.0 / cutoffRadius_;
223      rcuti2_ = rcuti_ * rcuti_;
# Line 278 | Line 284 | namespace OpenMD {
284      electrostaticAtomData.is_Dipole = false;
285      electrostaticAtomData.is_SplitDipole = false;
286      electrostaticAtomData.is_Quadrupole = false;
287 +    electrostaticAtomData.is_Fluctuating = false;
288  
289 <    if (atomType->isCharge()) {
283 <      GenericData* data = atomType->getPropertyByName("Charge");
289 >    FixedChargeAdapter fca = FixedChargeAdapter(atomType);
290  
291 <      if (data == NULL) {
286 <        sprintf( painCave.errMsg, "Electrostatic::addType could not find "
287 <                 "Charge\n"
288 <                 "\tparameters for atomType %s.\n",
289 <                 atomType->getName().c_str());
290 <        painCave.severity = OPENMD_ERROR;
291 <        painCave.isFatal = 1;
292 <        simError();                  
293 <      }
294 <      
295 <      DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data);
296 <      if (doubleData == NULL) {
297 <        sprintf( painCave.errMsg,
298 <                 "Electrostatic::addType could not convert GenericData to "
299 <                 "Charge for\n"
300 <                 "\tatom type %s\n", atomType->getName().c_str());
301 <        painCave.severity = OPENMD_ERROR;
302 <        painCave.isFatal = 1;
303 <        simError();          
304 <      }
291 >    if (fca.isFixedCharge()) {
292        electrostaticAtomData.is_Charge = true;
293 <      electrostaticAtomData.charge = doubleData->getData();          
293 >      electrostaticAtomData.fixedCharge = fca.getCharge();
294      }
295  
296 <    if (atomType->isDirectional()) {
297 <      DirectionalAtomType* daType = dynamic_cast<DirectionalAtomType*>(atomType);
298 <      
312 <      if (daType->isDipole()) {
313 <        GenericData* data = daType->getPropertyByName("Dipole");
314 <        
315 <        if (data == NULL) {
316 <          sprintf( painCave.errMsg,
317 <                   "Electrostatic::addType could not find Dipole\n"
318 <                   "\tparameters for atomType %s.\n",
319 <                   daType->getName().c_str());
320 <          painCave.severity = OPENMD_ERROR;
321 <          painCave.isFatal = 1;
322 <          simError();                  
323 <        }
324 <      
325 <        DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data);
326 <        if (doubleData == NULL) {
327 <          sprintf( painCave.errMsg,
328 <                   "Electrostatic::addType could not convert GenericData to "
329 <                   "Dipole Moment\n"
330 <                   "\tfor atom type %s\n", daType->getName().c_str());
331 <          painCave.severity = OPENMD_ERROR;
332 <          painCave.isFatal = 1;
333 <          simError();          
334 <        }
296 >    MultipoleAdapter ma = MultipoleAdapter(atomType);
297 >    if (ma.isMultipole()) {
298 >      if (ma.isDipole()) {
299          electrostaticAtomData.is_Dipole = true;
300 <        electrostaticAtomData.dipole_moment = doubleData->getData();
300 >        electrostaticAtomData.dipole_moment = ma.getDipoleMoment();
301        }
302 <
339 <      if (daType->isSplitDipole()) {
340 <        GenericData* data = daType->getPropertyByName("SplitDipoleDistance");
341 <        
342 <        if (data == NULL) {
343 <          sprintf(painCave.errMsg,
344 <                  "Electrostatic::addType could not find SplitDipoleDistance\n"
345 <                  "\tparameter for atomType %s.\n",
346 <                  daType->getName().c_str());
347 <          painCave.severity = OPENMD_ERROR;
348 <          painCave.isFatal = 1;
349 <          simError();                  
350 <        }
351 <      
352 <        DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data);
353 <        if (doubleData == NULL) {
354 <          sprintf( painCave.errMsg,
355 <                   "Electrostatic::addType could not convert GenericData to "
356 <                   "SplitDipoleDistance for\n"
357 <                   "\tatom type %s\n", daType->getName().c_str());
358 <          painCave.severity = OPENMD_ERROR;
359 <          painCave.isFatal = 1;
360 <          simError();          
361 <        }
302 >      if (ma.isSplitDipole()) {
303          electrostaticAtomData.is_SplitDipole = true;
304 <        electrostaticAtomData.split_dipole_distance = doubleData->getData();
304 >        electrostaticAtomData.split_dipole_distance = ma.getSplitDipoleDistance();
305        }
306 <
366 <      if (daType->isQuadrupole()) {
367 <        GenericData* data = daType->getPropertyByName("QuadrupoleMoments");
368 <        
369 <        if (data == NULL) {
370 <          sprintf( painCave.errMsg,
371 <                   "Electrostatic::addType could not find QuadrupoleMoments\n"
372 <                   "\tparameter for atomType %s.\n",
373 <                   daType->getName().c_str());
374 <          painCave.severity = OPENMD_ERROR;
375 <          painCave.isFatal = 1;
376 <          simError();                  
377 <        }
378 <        
306 >      if (ma.isQuadrupole()) {
307          // Quadrupoles in OpenMD are set as the diagonal elements
308          // of the diagonalized traceless quadrupole moment tensor.
309          // The column vectors of the unitary matrix that diagonalizes
310          // the quadrupole moment tensor become the eFrame (or the
311          // electrostatic version of the body-fixed frame.
384
385        Vector3dGenericData* v3dData = dynamic_cast<Vector3dGenericData*>(data);
386        if (v3dData == NULL) {
387          sprintf( painCave.errMsg,
388                   "Electrostatic::addType could not convert GenericData to "
389                   "Quadrupole Moments for\n"
390                   "\tatom type %s\n", daType->getName().c_str());
391          painCave.severity = OPENMD_ERROR;
392          painCave.isFatal = 1;
393          simError();          
394        }
312          electrostaticAtomData.is_Quadrupole = true;
313 <        electrostaticAtomData.quadrupole_moments = v3dData->getData();
313 >        electrostaticAtomData.quadrupole_moments = ma.getQuadrupoleMoments();
314        }
315      }
316      
317 <    AtomTypeProperties atp = atomType->getATP();    
317 >    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atomType);
318  
319 +    if (fqa.isFluctuatingCharge()) {
320 +      electrostaticAtomData.is_Fluctuating = true;
321 +      electrostaticAtomData.electronegativity = fqa.getElectronegativity();
322 +      electrostaticAtomData.hardness = fqa.getHardness();
323 +      electrostaticAtomData.slaterN = fqa.getSlaterN();
324 +      electrostaticAtomData.slaterZeta = fqa.getSlaterZeta();
325 +    }
326 +
327      pair<map<int,AtomType*>::iterator,bool> ret;    
328 <    ret = ElectrostaticList.insert( pair<int,AtomType*>(atp.ident, atomType) );
328 >    ret = ElectrostaticList.insert( pair<int,AtomType*>(atomType->getIdent(),
329 >                                                        atomType) );
330      if (ret.second == false) {
331        sprintf( painCave.errMsg,
332                 "Electrostatic already had a previous entry with ident %d\n",
333 <               atp.ident);
333 >               atomType->getIdent() );
334        painCave.severity = OPENMD_INFO;
335        painCave.isFatal = 0;
336        simError();        
337      }
338      
339 <    ElectrostaticMap[atomType] = electrostaticAtomData;    
339 >    ElectrostaticMap[atomType] = electrostaticAtomData;  
340 >
341 >    // Now, iterate over all known types and add to the mixing map:
342 >    
343 >    map<AtomType*, ElectrostaticAtomData>::iterator it;
344 >    for( it = ElectrostaticMap.begin(); it != ElectrostaticMap.end(); ++it) {
345 >      AtomType* atype2 = (*it).first;
346 >      ElectrostaticAtomData eaData2 = (*it).second;
347 >      if (eaData2.is_Fluctuating && electrostaticAtomData.is_Fluctuating) {
348 >        
349 >        RealType a = electrostaticAtomData.slaterZeta;
350 >        RealType b = eaData2.slaterZeta;
351 >        int m = electrostaticAtomData.slaterN;
352 >        int n = eaData2.slaterN;
353 >
354 >        // Create the spline of the coulombic integral for s-type
355 >        // Slater orbitals.  Add a 2 angstrom safety window to deal
356 >        // with cutoffGroups that have charged atoms longer than the
357 >        // cutoffRadius away from each other.
358 >
359 >        RealType rval;
360 >        RealType dr = (cutoffRadius_ + 2.0) / RealType(np_ - 1);
361 >        vector<RealType> rvals;
362 >        vector<RealType> J1vals;
363 >        vector<RealType> J2vals;
364 >        // don't start at i = 0, as rval = 0 is undefined for the slater overlap integrals.
365 >        for (int i = 1; i < np_+1; i++) {
366 >          rval = RealType(i) * dr;
367 >          rvals.push_back(rval);
368 >          J1vals.push_back(sSTOCoulInt( a, b, m, n, rval * PhysicalConstants::angstromToBohr ) * PhysicalConstants::hartreeToKcal );
369 >          // may not be necessary if Slater coulomb integral is symmetric
370 >          J2vals.push_back(sSTOCoulInt( b, a, n, m, rval * PhysicalConstants::angstromToBohr ) * PhysicalConstants::hartreeToKcal );
371 >        }
372 >
373 >        CubicSpline* J1 = new CubicSpline();
374 >        J1->addPoints(rvals, J1vals);
375 >        CubicSpline* J2 = new CubicSpline();
376 >        J2->addPoints(rvals, J2vals);
377 >        
378 >        pair<AtomType*, AtomType*> key1, key2;
379 >        key1 = make_pair(atomType, atype2);
380 >        key2 = make_pair(atype2, atomType);
381 >        
382 >        Jij[key1] = J1;
383 >        Jij[key2] = J2;
384 >      }
385 >    }
386 >
387      return;
388    }
389    
# Line 460 | Line 433 | namespace OpenMD {
433      RealType c1, c2, c3, c4;
434      RealType erfcVal(1.0), derfcVal(0.0);
435      RealType BigR;
436 +    RealType two(2.0), three(3.0);
437  
438      Vector3d Q_i, Q_j;
439      Vector3d ux_i, uy_i, uz_i;
# Line 475 | Line 449 | namespace OpenMD {
449      Vector3d indirect_dVdr(V3Zero);
450      Vector3d indirect_duduz_i(V3Zero), indirect_duduz_j(V3Zero);
451  
452 +    RealType coulInt, vFluc1(0.0), vFluc2(0.0);
453      pair<RealType, RealType> res;
454      
455 +    // splines for coulomb integrals
456 +    CubicSpline* J1;
457 +    CubicSpline* J2;
458 +    
459      if (!initialized_) initialize();
460      
461      ElectrostaticAtomData data1 = ElectrostaticMap[idat.atypes.first];
# Line 493 | Line 472 | namespace OpenMD {
472      bool i_is_Dipole = data1.is_Dipole;
473      bool i_is_SplitDipole = data1.is_SplitDipole;
474      bool i_is_Quadrupole = data1.is_Quadrupole;
475 +    bool i_is_Fluctuating = data1.is_Fluctuating;
476  
477      bool j_is_Charge = data2.is_Charge;
478      bool j_is_Dipole = data2.is_Dipole;
479      bool j_is_SplitDipole = data2.is_SplitDipole;
480      bool j_is_Quadrupole = data2.is_Quadrupole;
481 +    bool j_is_Fluctuating = data2.is_Fluctuating;
482      
483      if (i_is_Charge) {
484 <      q_i = data1.charge;
484 >      q_i = data1.fixedCharge;
485 >
486 >      if (i_is_Fluctuating) {
487 >        q_i += *(idat.flucQ1);
488 >      }
489 >      
490        if (idat.excluded) {
491          *(idat.skippedCharge2) += q_i;
492        }
# Line 538 | Line 524 | namespace OpenMD {
524      }
525  
526      if (j_is_Charge) {
527 <      q_j = data2.charge;
527 >      q_j = data2.fixedCharge;
528 >
529 >      if (j_is_Fluctuating)
530 >        q_j += *(idat.flucQ2);
531 >
532        if (idat.excluded) {
533          *(idat.skippedCharge1) += q_j;
534        }
# Line 576 | Line 566 | namespace OpenMD {
566        duduz_j = V3Zero;
567      }
568      
569 +    if (i_is_Fluctuating && j_is_Fluctuating) {
570 +      J1 = Jij[idat.atypes];
571 +      J2 = Jij[make_pair(idat.atypes.second, idat.atypes.first)];
572 +    }
573 +
574      epot = 0.0;
575      dVdr = V3Zero;
576      
# Line 584 | Line 579 | namespace OpenMD {
579        if (j_is_Charge) {
580          if (screeningMethod_ == DAMPED) {
581            // assemble the damping variables
582 <          //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
583 <          //erfcVal = res.first;
584 <          //derfcVal = res.second;
582 >          res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
583 >          erfcVal = res.first;
584 >          derfcVal = res.second;
585  
586 <          erfcVal = erfc(dampingAlpha_ * *(idat.rij));
587 <          derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
586 >          //erfcVal = erfc(dampingAlpha_ * *(idat.rij));
587 >          //derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
588  
589            c1 = erfcVal * riji;
590            c2 = (-derfcVal + c1) * riji;
# Line 598 | Line 593 | namespace OpenMD {
593            c2 = c1 * riji;
594          }
595  
596 <        preVal =  *(idat.electroMult) * pre11_ * q_i * q_j;
596 >        preVal =  *(idat.electroMult) * pre11_;
597          
598          if (summationMethod_ == esm_SHIFTED_POTENTIAL) {
599            vterm = preVal * (c1 - c1c_);
# Line 620 | Line 615 | namespace OpenMD {
615            if (idat.excluded) {
616              indirect_vpair += preVal * rfVal;
617              indirect_Pot += *(idat.sw) * preVal * rfVal;
618 <            indirect_dVdr += *(idat.sw)  * preVal * 2.0 * rfVal  * riji * rhat;
618 >            indirect_dVdr += *(idat.sw)  * preVal * two * rfVal  * riji * rhat;
619            }
620            
621          } else {
622  
623            vterm = preVal * riji * erfcVal;          
624            dudr  = -  *(idat.sw)  * preVal * c2;
625 +          
626 +        }
627 +        
628 +        vpair += vterm * q_i * q_j;
629 +        epot +=  *(idat.sw)  * vterm * q_i * q_j;
630 +        dVdr += dudr * rhat * q_i * q_j;
631  
632 +        if (i_is_Fluctuating) {
633 +          if (idat.excluded) {
634 +            // vFluc1 is the difference between the direct coulomb integral
635 +            // and the normal 1/r-like  interaction between point charges.
636 +            coulInt = J1->getValueAt( *(idat.rij) );
637 +            vFluc1 = coulInt - (*(idat.sw) * vterm);
638 +          } else {
639 +            vFluc1 = 0.0;
640 +          }
641 +          *(idat.dVdFQ1) += ( *(idat.sw) * vterm + vFluc1 ) * q_j;
642          }
643  
644 <        vpair += vterm;
645 <        epot +=  *(idat.sw)  * vterm;
646 <        dVdr += dudr * rhat;                
644 >        if (j_is_Fluctuating) {
645 >          if (idat.excluded) {
646 >            // vFluc2 is the difference between the direct coulomb integral
647 >            // and the normal 1/r-like  interaction between point charges.
648 >            coulInt = J2->getValueAt( *(idat.rij) );
649 >            vFluc2 = coulInt - (*(idat.sw) * vterm);
650 >          } else {
651 >            vFluc2 = 0.0;
652 >          }
653 >          *(idat.dVdFQ2) += ( *(idat.sw) * vterm + vFluc2 ) * q_i;
654 >        }
655 >          
656 >
657        }
658  
659        if (j_is_Dipole) {
# Line 648 | Line 669 | namespace OpenMD {
669            vpair += vterm;
670            epot +=  *(idat.sw)  * vterm;
671  
672 <          dVdr +=  -preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j);
672 >          dVdr +=  -preSw * (ri3 * (uz_j - three * ct_j * rhat) - preRF2_*uz_j);
673            duduz_j += -preSw * rhat * (ri2 - preRF2_ *  *(idat.rij) );  
674  
675            // Even if we excluded this pair from direct interactions,
# Line 705 | Line 726 | namespace OpenMD {
726            duduz_j += -preSw * pot_term * rhat;
727  
728          }
729 +        if (i_is_Fluctuating) {
730 +          *(idat.dVdFQ1) += ( *(idat.sw) * vterm ) / q_i;
731 +        }
732        }
733  
734        if (j_is_Quadrupole) {
# Line 737 | Line 761 | namespace OpenMD {
761          c2ri = c2 * riji;
762          c3ri = c3 * riji;
763          c4rij = c4 *  *(idat.rij) ;
764 <        rhatdot2 = 2.0 * rhat * c3;
764 >        rhatdot2 = two * rhat * c3;
765          rhatc4 = rhat * c4rij;
766  
767          // calculate the potential
# Line 750 | Line 774 | namespace OpenMD {
774                  
775          // calculate derivatives for the forces and torques
776  
777 <        dVdr += -preSw * ( qxx_j* (cx2*rhatc4 - (2.0*cx_j*ux_j + rhat)*c3ri) +
778 <                           qyy_j* (cy2*rhatc4 - (2.0*cy_j*uy_j + rhat)*c3ri) +
779 <                           qzz_j* (cz2*rhatc4 - (2.0*cz_j*uz_j + rhat)*c3ri));
777 >        dVdr += -preSw * ( qxx_j* (cx2*rhatc4 - (two*cx_j*ux_j + rhat)*c3ri) +
778 >                           qyy_j* (cy2*rhatc4 - (two*cy_j*uy_j + rhat)*c3ri) +
779 >                           qzz_j* (cz2*rhatc4 - (two*cz_j*uz_j + rhat)*c3ri));
780                            
781          dudux_j += preSw * qxx_j * cx_j * rhatdot2;
782          duduy_j += preSw * qyy_j * cy_j * rhatdot2;
783          duduz_j += preSw * qzz_j * cz_j * rhatdot2;
784 +        if (i_is_Fluctuating) {
785 +          *(idat.dVdFQ1) += ( *(idat.sw) * vterm ) / q_i;
786 +        }
787 +
788        }
789      }
790      
# Line 776 | Line 804 | namespace OpenMD {
804            vpair += vterm;
805            epot +=  *(idat.sw)  * vterm;
806            
807 <          dVdr += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i);
807 >          dVdr += preSw * (ri3 * (uz_i - three * ct_i * rhat) - preRF2_ * uz_i);
808            
809            duduz_i += preSw * rhat * (ri2 - preRF2_ *  *(idat.rij) );
810  
# Line 832 | Line 860 | namespace OpenMD {
860            // calculate derivatives for the forces and torques
861            dVdr += preSw * (uz_i * c2ri - ct_i * rhat * sc2 * c3);
862            duduz_i += preSw * pot_term * rhat;
863 +        }
864 +
865 +        if (j_is_Fluctuating) {
866 +          *(idat.dVdFQ2) += ( *(idat.sw) * vterm ) / q_j;
867          }
868 +
869        }
870  
871        if (j_is_Dipole) {
# Line 854 | Line 887 | namespace OpenMD {
887              
888            a1 = 5.0 * ct_i * ct_j - ct_ij;
889              
890 <          dVdr += preSw * 3.0 * ri4 * (a1 * rhat - ct_i * uz_j - ct_j * uz_i);
890 >          dVdr += preSw * three * ri4 * (a1 * rhat - ct_i * uz_j - ct_j * uz_i);
891  
892 <          duduz_i += preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j);
893 <          duduz_j += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_*uz_i);
892 >          duduz_i += preSw * (ri3 * (uz_j - three * ct_j * rhat) - preRF2_*uz_j);
893 >          duduz_j += preSw * (ri3 * (uz_i - three * ct_i * rhat) - preRF2_*uz_i);
894  
895            if (idat.excluded) {
896              indirect_vpair +=  - pref * preRF2_ * ct_ij;
# Line 962 | Line 995 | namespace OpenMD {
995          c2ri = c2 * riji;
996          c3ri = c3 * riji;
997          c4rij = c4 *  *(idat.rij) ;
998 <        rhatdot2 = 2.0 * rhat * c3;
998 >        rhatdot2 = two * rhat * c3;
999          rhatc4 = rhat * c4rij;
1000  
1001          // calculate the potential
# Line 976 | Line 1009 | namespace OpenMD {
1009  
1010          // calculate the derivatives for the forces and torques
1011  
1012 <        dVdr += -preSw * (qxx_i* (cx2*rhatc4 - (2.0*cx_i*ux_i + rhat)*c3ri) +
1013 <                          qyy_i* (cy2*rhatc4 - (2.0*cy_i*uy_i + rhat)*c3ri) +
1014 <                          qzz_i* (cz2*rhatc4 - (2.0*cz_i*uz_i + rhat)*c3ri));
1012 >        dVdr += -preSw * (qxx_i* (cx2*rhatc4 - (two*cx_i*ux_i + rhat)*c3ri) +
1013 >                          qyy_i* (cy2*rhatc4 - (two*cy_i*uy_i + rhat)*c3ri) +
1014 >                          qzz_i* (cz2*rhatc4 - (two*cz_i*uz_i + rhat)*c3ri));
1015  
1016          dudux_i += preSw * qxx_i * cx_i *  rhatdot2;
1017          duduy_i += preSw * qyy_i * cy_i *  rhatdot2;
1018          duduz_i += preSw * qzz_i * cz_i *  rhatdot2;
1019 +
1020 +        if (j_is_Fluctuating) {
1021 +          *(idat.dVdFQ2) += ( *(idat.sw) * vterm ) / q_j;
1022 +        }
1023 +
1024        }
1025      }
1026  
# Line 1012 | Line 1050 | namespace OpenMD {
1050        // indirect reaction field terms.
1051  
1052        *(idat.vpair) += indirect_vpair;
1053 +      
1054 +      (*(idat.excludedPot))[ELECTROSTATIC_FAMILY] +=   (*(idat.sw) * vterm +
1055 +                                                        vFluc1 ) * q_i * q_j;
1056        (*(idat.pot))[ELECTROSTATIC_FAMILY] += indirect_Pot;
1057        *(idat.f1) += indirect_dVdr;
1058        
# Line 1021 | Line 1062 | namespace OpenMD {
1062          *(idat.t2) -= cross(uz_j, indirect_duduz_j);
1063      }
1064  
1024
1065      return;
1066    }  
1067      
1068    void Electrostatic::calcSelfCorrection(SelfData &sdat) {
1069 <    RealType mu1, preVal, chg1, self;
1030 <    
1069 >    RealType mu1, preVal, self;
1070      if (!initialized_) initialize();
1071  
1072      ElectrostaticAtomData data = ElectrostaticMap[sdat.atype];
# Line 1035 | Line 1074 | namespace OpenMD {
1074      // logicals
1075      bool i_is_Charge = data.is_Charge;
1076      bool i_is_Dipole = data.is_Dipole;
1077 +    bool i_is_Fluctuating = data.is_Fluctuating;
1078 +    RealType chg1 = data.fixedCharge;  
1079 +    
1080 +    if (i_is_Fluctuating) {
1081 +      chg1 += *(sdat.flucQ);
1082 +      // dVdFQ is really a force, so this is negative the derivative
1083 +      *(sdat.dVdFQ) -=  *(sdat.flucQ) * data.hardness + data.electronegativity;
1084 +      (*(sdat.excludedPot))[ELECTROSTATIC_FAMILY] += (*sdat.flucQ) *
1085 +        (*(sdat.flucQ) * data.hardness * 0.5 + data.electronegativity);
1086 +    }
1087  
1088      if (summationMethod_ == esm_REACTION_FIELD) {
1089        if (i_is_Dipole) {
# Line 1051 | Line 1100 | namespace OpenMD {
1100        }
1101      } else if (summationMethod_ == esm_SHIFTED_FORCE || summationMethod_ == esm_SHIFTED_POTENTIAL) {
1102        if (i_is_Charge) {        
1054        chg1 = data.charge;
1103          if (screeningMethod_ == DAMPED) {
1104            self = - 0.5 * (c1c_ + alphaPi_) * chg1 * (chg1 + *(sdat.skippedCharge)) * pre11_;
1105          } else {        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines