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 1584 by gezelter, Fri Jun 17 20:16:35 2011 UTC vs.
Revision 1616 by gezelter, Tue Aug 30 15:45:35 2011 UTC

# Line 34 | Line 34
34   * work.  Good starting points are:
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 < * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
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).                        
40   */
# Line 52 | Line 52 | namespace OpenMD {
52   namespace OpenMD {
53    
54    Electrostatic::Electrostatic(): name_("Electrostatic"), initialized_(false),
55 <                                  forceField_(NULL), info_(NULL) {}
55 >                                  forceField_(NULL), info_(NULL),
56 >                                  haveCutoffRadius_(false),
57 >                                  haveDampingAlpha_(false),
58 >                                  haveDielectric_(false),
59 >                                  haveElectroSpline_(false)
60 >  {}
61    
62    void Electrostatic::initialize() {
63 <
63 >    
64      Globals* simParams_ = info_->getSimParams();
65  
66      summationMap_["HARD"]               = esm_HARD;
67 +    summationMap_["NONE"]               = esm_HARD;
68      summationMap_["SWITCHING_FUNCTION"] = esm_SWITCHING_FUNCTION;
69      summationMap_["SHIFTED_POTENTIAL"]  = esm_SHIFTED_POTENTIAL;
70      summationMap_["SHIFTED_FORCE"]      = esm_SHIFTED_FORCE;    
# Line 97 | Line 103 | namespace OpenMD {
103      screeningMethod_ = UNDAMPED;
104      dielectric_ = 1.0;
105      one_third_ = 1.0 / 3.0;
100    haveCutoffRadius_ = false;
101    haveDampingAlpha_ = false;
102    haveDielectric_ = false;  
103    haveElectroSpline_ = false;
106    
107      // check the summation method:
108      if (simParams_->haveElectrostaticSummationMethod()) {
# Line 115 | Line 117 | namespace OpenMD {
117          sprintf( painCave.errMsg,
118                   "Electrostatic::initialize: Unknown electrostaticSummationMethod.\n"
119                   "\t(Input file specified %s .)\n"
120 <                 "\telectrostaticSummationMethod must be one of: \"none\",\n"
120 >                 "\telectrostaticSummationMethod must be one of: \"hard\",\n"
121                   "\t\"shifted_potential\", \"shifted_force\", or \n"
122                   "\t\"reaction_field\".\n", myMethod.c_str() );
123          painCave.isFatal = 1;
# Line 248 | Line 250 | namespace OpenMD {
250        preRF2_ = 2.0 * preRF_;
251      }
252      
253 <    RealType dx = cutoffRadius_ / RealType(np_ - 1);
253 >    // Add a 2 angstrom safety window to deal with cutoffGroups that
254 >    // have charged atoms longer than the cutoffRadius away from each
255 >    // other.  Splining may not be the best choice here.  Direct calls
256 >    // to erfc might be preferrable.
257 >
258 >    RealType dx = (cutoffRadius_ + 2.0) / RealType(np_ - 1);
259      RealType rval;
260      vector<RealType> rvals;
261      vector<RealType> yvals;
# Line 445 | Line 452 | namespace OpenMD {
452      RealType ct_i, ct_j, ct_ij, a1;
453      RealType riji, ri, ri2, ri3, ri4;
454      RealType pref, vterm, epot, dudr;
455 +    RealType vpair(0.0);
456      RealType scale, sc2;
457      RealType pot_term, preVal, rfVal;
458      RealType c2ri, c3ri, c4rij, cti3, ctj3, ctidotj;
459      RealType preSw, preSwSc;
460      RealType c1, c2, c3, c4;
461 <    RealType erfcVal, derfcVal;
461 >    RealType erfcVal(1.0), derfcVal(0.0);
462      RealType BigR;
463  
464      Vector3d Q_i, Q_j;
# Line 461 | Line 469 | namespace OpenMD {
469      Vector3d rhatdot2, rhatc4;
470      Vector3d dVdr;
471  
472 +    // variables for indirect (reaction field) interactions for excluded pairs:
473 +    RealType indirect_Pot(0.0);
474 +    RealType indirect_vpair(0.0);
475 +    Vector3d indirect_dVdr(V3Zero);
476 +    Vector3d indirect_duduz_i(V3Zero), indirect_duduz_j(V3Zero);
477 +
478      pair<RealType, RealType> res;
479      
480      if (!initialized_) initialize();
# Line 485 | Line 499 | namespace OpenMD {
499      bool j_is_SplitDipole = data2.is_SplitDipole;
500      bool j_is_Quadrupole = data2.is_Quadrupole;
501      
502 <    if (i_is_Charge)
502 >    if (i_is_Charge) {
503        q_i = data1.charge;
504 +      if (idat.excluded) {
505 +        *(idat.skippedCharge2) += q_i;
506 +      }
507 +    }
508  
509      if (i_is_Dipole) {
510        mu_i = data1.dipole_moment;
# Line 519 | Line 537 | namespace OpenMD {
537        duduz_i = V3Zero;
538      }
539  
540 <    if (j_is_Charge)
540 >    if (j_is_Charge) {
541        q_j = data2.charge;
542 +      if (idat.excluded) {
543 +        *(idat.skippedCharge1) += q_j;
544 +      }
545 +    }
546  
547 +
548      if (j_is_Dipole) {
549        mu_j = data2.dipole_moment;
550        uz_j = idat.eFrame2->getColumn(2);
# Line 561 | Line 584 | namespace OpenMD {
584        if (j_is_Charge) {
585          if (screeningMethod_ == DAMPED) {
586            // assemble the damping variables
587 <          res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
588 <          erfcVal = res.first;
589 <          derfcVal = res.second;
587 >          //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
588 >          //erfcVal = res.first;
589 >          //derfcVal = res.second;
590 >
591 >          erfcVal = erfc(dampingAlpha_ * *(idat.rij));
592 >          derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
593 >
594            c1 = erfcVal * riji;
595            c2 = (-derfcVal + c1) * riji;
596          } else {
# Line 582 | Line 609 | namespace OpenMD {
609            dudr  =  *(idat.sw)  * preVal * (c2c_ - c2);
610  
611          } else if (summationMethod_ == esm_REACTION_FIELD) {
612 <          rfVal =  *(idat.electroMult) * preRF_ *  *(idat.rij)  *  *(idat.rij) ;
612 >          rfVal = preRF_ *  *(idat.rij)  *  *(idat.rij);
613 >
614            vterm = preVal * ( riji + rfVal );            
615            dudr  =  *(idat.sw)  * preVal * ( 2.0 * rfVal - riji ) * riji;
616 +          
617 +          // if this is an excluded pair, there are still indirect
618 +          // interactions via the reaction field we must worry about:
619  
620 +          if (idat.excluded) {
621 +            indirect_vpair += preVal * rfVal;
622 +            indirect_Pot += *(idat.sw) * preVal * rfVal;
623 +            indirect_dVdr += *(idat.sw)  * preVal * 2.0 * rfVal  * riji * rhat;
624 +          }
625 +          
626          } else {
590          vterm = preVal * riji * erfcVal;            
627  
628 +          vterm = preVal * riji * erfcVal;          
629            dudr  = -  *(idat.sw)  * preVal * c2;
630  
631          }
595
596        *(idat.vpair) += vterm;
597        epot +=  *(idat.sw)  * vterm;
632  
633 <        dVdr += dudr * rhat;      
633 >        vpair += vterm;
634 >        epot +=  *(idat.sw)  * vterm;
635 >        dVdr += dudr * rhat;                
636        }
637  
638        if (j_is_Dipole) {
# Line 609 | Line 645 | namespace OpenMD {
645            ri3 = ri2 * riji;
646      
647            vterm = - pref * ct_j * ( ri2 - preRF2_ *  *(idat.rij)  );
648 <          *(idat.vpair) += vterm;
648 >          vpair += vterm;
649            epot +=  *(idat.sw)  * vterm;
650  
651            dVdr +=  -preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j);
652            duduz_j += -preSw * rhat * (ri2 - preRF2_ *  *(idat.rij) );  
653  
654 +          // Even if we excluded this pair from direct interactions,
655 +          // we still have the reaction-field-mediated charge-dipole
656 +          // interaction:
657 +
658 +          if (idat.excluded) {
659 +            indirect_vpair += pref * ct_j * preRF2_ * *(idat.rij);
660 +            indirect_Pot += preSw * ct_j * preRF2_ * *(idat.rij);
661 +            indirect_dVdr += preSw * preRF2_ * uz_j;
662 +            indirect_duduz_j += preSw * rhat * preRF2_ *  *(idat.rij);
663 +          }
664 +                      
665          } else {
666            // determine the inverse r used if we have split dipoles
667            if (j_is_SplitDipole) {
# Line 630 | Line 677 | namespace OpenMD {
677  
678            if (screeningMethod_ == DAMPED) {
679              // assemble the damping variables
680 <            res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
681 <            erfcVal = res.first;
682 <            derfcVal = res.second;
680 >            //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
681 >            //erfcVal = res.first;
682 >            //derfcVal = res.second;
683 >            erfcVal = erfc(dampingAlpha_ * *(idat.rij));
684 >            derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
685              c1 = erfcVal * ri;
686              c2 = (-derfcVal + c1) * ri;
687              c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri;
# Line 647 | Line 696 | namespace OpenMD {
696            // calculate the potential
697            pot_term =  scale * c2;
698            vterm = -pref * ct_j * pot_term;
699 <          *(idat.vpair) += vterm;
699 >          vpair += vterm;
700            epot +=  *(idat.sw)  * vterm;
701              
702            // calculate derivatives for forces and torques
# Line 667 | Line 716 | namespace OpenMD {
716            
717          if (screeningMethod_ == DAMPED) {
718            // assemble the damping variables
719 <          res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
720 <          erfcVal = res.first;
721 <          derfcVal = res.second;
719 >          //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
720 >          //erfcVal = res.first;
721 >          //derfcVal = res.second;
722 >          erfcVal = erfc(dampingAlpha_ * *(idat.rij));
723 >          derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
724            c1 = erfcVal * riji;
725            c2 = (-derfcVal + c1) * riji;
726            c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * riji;
# Line 694 | Line 745 | namespace OpenMD {
745                       qyy_j * (cy2*c3 - c2ri) +
746                       qzz_j * (cz2*c3 - c2ri) );
747          vterm = pref * pot_term;
748 <        *(idat.vpair) += vterm;
748 >        vpair += vterm;
749          epot +=  *(idat.sw)  * vterm;
750                  
751          // calculate derivatives for the forces and torques
# Line 722 | Line 773 | namespace OpenMD {
773            ri3 = ri2 * riji;
774  
775            vterm = pref * ct_i * ( ri2 - preRF2_ *  *(idat.rij)  );
776 <          *(idat.vpair) += vterm;
776 >          vpair += vterm;
777            epot +=  *(idat.sw)  * vterm;
778            
779            dVdr += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i);
780            
781            duduz_i += preSw * rhat * (ri2 - preRF2_ *  *(idat.rij) );
782 +
783 +          // Even if we excluded this pair from direct interactions,
784 +          // we still have the reaction-field-mediated charge-dipole
785 +          // interaction:
786 +
787 +          if (idat.excluded) {
788 +            indirect_vpair += -pref * ct_i * preRF2_ * *(idat.rij);
789 +            indirect_Pot += -preSw * ct_i * preRF2_ * *(idat.rij);
790 +            indirect_dVdr += -preSw * preRF2_ * uz_i;
791 +            indirect_duduz_i += -preSw * rhat * preRF2_ *  *(idat.rij);
792 +          }
793              
794          } else {
795            
# Line 745 | Line 807 | namespace OpenMD {
807              
808            if (screeningMethod_ == DAMPED) {
809              // assemble the damping variables
810 <            res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
811 <            erfcVal = res.first;
812 <            derfcVal = res.second;
810 >            //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
811 >            //erfcVal = res.first;
812 >            //derfcVal = res.second;
813 >            erfcVal = erfc(dampingAlpha_ * *(idat.rij));
814 >            derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
815              c1 = erfcVal * ri;
816              c2 = (-derfcVal + c1) * ri;
817              c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri;
# Line 762 | Line 826 | namespace OpenMD {
826            // calculate the potential
827            pot_term = c2 * scale;
828            vterm = pref * ct_i * pot_term;
829 <          *(idat.vpair) += vterm;
829 >          vpair += vterm;
830            epot +=  *(idat.sw)  * vterm;
831  
832            // calculate derivatives for the forces and torques
# Line 785 | Line 849 | namespace OpenMD {
849  
850            vterm = pref * ( ri3 * (ct_ij - 3.0 * ct_i * ct_j) -
851                             preRF2_ * ct_ij );
852 <          *(idat.vpair) += vterm;
852 >          vpair += vterm;
853            epot +=  *(idat.sw)  * vterm;
854              
855            a1 = 5.0 * ct_i * ct_j - ct_ij;
# Line 795 | Line 859 | namespace OpenMD {
859            duduz_i += preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j);
860            duduz_j += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_*uz_i);
861  
862 +          if (idat.excluded) {
863 +            indirect_vpair +=  - pref * preRF2_ * ct_ij;
864 +            indirect_Pot +=    - preSw * preRF2_ * ct_ij;
865 +            indirect_duduz_i += -preSw * preRF2_ * uz_j;
866 +            indirect_duduz_j += -preSw * preRF2_ * uz_i;
867 +          }
868 +
869          } else {
870            
871            if (i_is_SplitDipole) {
# Line 817 | Line 888 | namespace OpenMD {
888            }
889            if (screeningMethod_ == DAMPED) {
890              // assemble damping variables
891 <            res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
892 <            erfcVal = res.first;
893 <            derfcVal = res.second;
891 >            //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
892 >            //erfcVal = res.first;
893 >            //derfcVal = res.second;
894 >            erfcVal = erfc(dampingAlpha_ * *(idat.rij));
895 >            derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
896              c1 = erfcVal * ri;
897              c2 = (-derfcVal + c1) * ri;
898              c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri;
# Line 844 | Line 917 | namespace OpenMD {
917            // calculate the potential
918            pot_term = (ct_ij * c2ri - ctidotj * c3);
919            vterm = pref * pot_term;
920 <          *(idat.vpair) += vterm;
920 >          vpair += vterm;
921            epot +=  *(idat.sw)  * vterm;
922  
923            // calculate derivatives for the forces and torques
# Line 868 | Line 941 | namespace OpenMD {
941  
942          if (screeningMethod_ == DAMPED) {
943            // assemble the damping variables
944 <          res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
945 <          erfcVal = res.first;
946 <          derfcVal = res.second;
944 >          //res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) );
945 >          //erfcVal = res.first;
946 >          //derfcVal = res.second;
947 >          erfcVal = erfc(dampingAlpha_ * *(idat.rij));
948 >          derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2));
949            c1 = erfcVal * riji;
950            c2 = (-derfcVal + c1) * riji;
951            c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * riji;
# Line 896 | Line 971 | namespace OpenMD {
971                       qzz_i * (cz2 * c3 - c2ri) );
972          
973          vterm = pref * pot_term;
974 <        *(idat.vpair) += vterm;
974 >        vpair += vterm;
975          epot +=  *(idat.sw)  * vterm;
976  
977          // calculate the derivatives for the forces and torques
# Line 911 | Line 986 | namespace OpenMD {
986        }
987      }
988  
914    (*(idat.pot))[ELECTROSTATIC_FAMILY] += epot;
915    *(idat.f1) += dVdr;
989  
990 <    if (i_is_Dipole || i_is_Quadrupole)
991 <      *(idat.t1) -= cross(uz_i, duduz_i);
992 <    if (i_is_Quadrupole) {
993 <      *(idat.t1) -= cross(ux_i, dudux_i);
994 <      *(idat.t1) -= cross(uy_i, duduy_i);
995 <    }
996 <    
997 <    if (j_is_Dipole || j_is_Quadrupole)
998 <      *(idat.t2) -= cross(uz_j, duduz_j);
999 <    if (j_is_Quadrupole) {
1000 <      *(idat.t2) -= cross(uz_j, dudux_j);
1001 <      *(idat.t2) -= cross(uz_j, duduy_j);
1002 <    }
990 >    if (!idat.excluded) {
991 >      *(idat.vpair) += vpair;
992 >      (*(idat.pot))[ELECTROSTATIC_FAMILY] += epot;
993 >      *(idat.f1) += dVdr;
994 >      
995 >      if (i_is_Dipole || i_is_Quadrupole)
996 >        *(idat.t1) -= cross(uz_i, duduz_i);
997 >      if (i_is_Quadrupole) {
998 >        *(idat.t1) -= cross(ux_i, dudux_i);
999 >        *(idat.t1) -= cross(uy_i, duduy_i);
1000 >      }
1001 >      
1002 >      if (j_is_Dipole || j_is_Quadrupole)
1003 >        *(idat.t2) -= cross(uz_j, duduz_j);
1004 >      if (j_is_Quadrupole) {
1005 >        *(idat.t2) -= cross(uz_j, dudux_j);
1006 >        *(idat.t2) -= cross(uz_j, duduy_j);
1007 >      }
1008  
1009 <    return;
932 <  }  
1009 >    } else {
1010  
1011 <  void Electrostatic::calcSkipCorrection(InteractionData &idat) {
1011 >      // only accumulate the forces and torques resulting from the
1012 >      // indirect reaction field terms.
1013  
1014 <    if (!initialized_) initialize();
1015 <    
1016 <    ElectrostaticAtomData data1 = ElectrostaticMap[idat.atypes.first];
939 <    ElectrostaticAtomData data2 = ElectrostaticMap[idat.atypes.second];
940 <    
941 <    // logicals
942 <
943 <    bool i_is_Charge = data1.is_Charge;
944 <    bool i_is_Dipole = data1.is_Dipole;
945 <
946 <    bool j_is_Charge = data2.is_Charge;
947 <    bool j_is_Dipole = data2.is_Dipole;
948 <
949 <    RealType q_i, q_j;
950 <    
951 <    // The skippedCharge computation is needed by the real-space cutoff methods
952 <    // (i.e. shifted force and shifted potential)
953 <
954 <    if (i_is_Charge) {
955 <      q_i = data1.charge;
956 <      *(idat.skippedCharge2) += q_i;
957 <    }
958 <
959 <    if (j_is_Charge) {
960 <      q_j = data2.charge;
961 <      *(idat.skippedCharge1) += q_j;
962 <    }
963 <
964 <    // the rest of this function should only be necessary for reaction field.
965 <
966 <    if (summationMethod_ == esm_REACTION_FIELD) {
967 <      RealType riji, ri2, ri3;
968 <      RealType mu_i, ct_i;
969 <      RealType mu_j, ct_j;
970 <      RealType preVal, rfVal, vterm, dudr, pref, myPot(0.0);
971 <      Vector3d dVdr, uz_i, uz_j, duduz_i, duduz_j, rhat;
972 <
973 <      // some variables we'll need independent of electrostatic type:
1014 >      *(idat.vpair) += indirect_vpair;
1015 >      (*(idat.pot))[ELECTROSTATIC_FAMILY] += indirect_Pot;
1016 >      *(idat.f1) += indirect_dVdr;
1017        
975      riji = 1.0 /  *(idat.rij) ;
976      rhat =  *(idat.d)  * riji;
977
978      if (i_is_Dipole) {
979        mu_i = data1.dipole_moment;
980        uz_i = idat.eFrame1->getColumn(2);      
981        ct_i = dot(uz_i, rhat);
982        duduz_i = V3Zero;
983      }
984            
985      if (j_is_Dipole) {
986        mu_j = data2.dipole_moment;
987        uz_j = idat.eFrame2->getColumn(2);      
988        ct_j = dot(uz_j, rhat);
989        duduz_j = V3Zero;
990      }
991    
992      if (i_is_Charge) {
993        if (j_is_Charge) {
994          preVal =  *(idat.electroMult) * pre11_ * q_i * q_j;
995          rfVal = preRF_ *  *(idat.rij)  *  *(idat.rij) ;
996          vterm = preVal * rfVal;
997          myPot +=  *(idat.sw)  * vterm;        
998          dudr  =  *(idat.sw)  * preVal * 2.0 * rfVal * riji;        
999          dVdr += dudr * rhat;
1000        }
1001        
1002        if (j_is_Dipole) {
1003          ri2 = riji * riji;
1004          ri3 = ri2 * riji;        
1005          pref =  *(idat.electroMult) * pre12_ * q_i * mu_j;
1006          vterm = - pref * ct_j * ( ri2 - preRF2_ *  *(idat.rij)  );
1007          myPot +=  *(idat.sw)  * vterm;        
1008          dVdr += - *(idat.sw)  * pref * ( ri3 * ( uz_j - 3.0 * ct_j * rhat) - preRF2_ * uz_j);
1009          duduz_j += - *(idat.sw)  * pref * rhat * (ri2 - preRF2_ *  *(idat.rij) );
1010        }
1011      }
1012      if (i_is_Dipole) {
1013        if (j_is_Charge) {
1014          ri2 = riji * riji;
1015          ri3 = ri2 * riji;        
1016          pref =  *(idat.electroMult) * pre12_ * q_j * mu_i;
1017          vterm = - pref * ct_i * ( ri2 - preRF2_ *  *(idat.rij)  );
1018          myPot +=  *(idat.sw)  * vterm;        
1019          dVdr +=  *(idat.sw)  * pref * ( ri3 * ( uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i);      
1020          duduz_i +=  *(idat.sw)  * pref * rhat * (ri2 - preRF2_ *  *(idat.rij));
1021        }
1022      }
1023      
1024      // accumulate the forces and torques resulting from the self term
1025      (*(idat.pot))[ELECTROSTATIC_FAMILY] += myPot;
1026      *(idat.f1) += dVdr;
1027      
1018        if (i_is_Dipole)
1019 <        *(idat.t1) -= cross(uz_i, duduz_i);
1019 >        *(idat.t1) -= cross(uz_i, indirect_duduz_i);
1020        if (j_is_Dipole)
1021 <        *(idat.t2) -= cross(uz_j, duduz_j);
1021 >        *(idat.t2) -= cross(uz_j, indirect_duduz_j);
1022      }
1023 <  }
1023 >
1024 >
1025 >    return;
1026 >  }  
1027      
1028    void Electrostatic::calcSelfCorrection(SelfData &sdat) {
1029      RealType mu1, preVal, chg1, self;
1030      
1031      if (!initialized_) initialize();
1032 <    
1032 >
1033      ElectrostaticAtomData data = ElectrostaticMap[sdat.atype];
1034    
1035      // logicals
1043
1036      bool i_is_Charge = data.is_Charge;
1037      bool i_is_Dipole = data.is_Dipole;
1038  
# Line 1048 | Line 1040 | namespace OpenMD {
1040        if (i_is_Dipole) {
1041          mu1 = data.dipole_moment;          
1042          preVal = pre22_ * preRF2_ * mu1 * mu1;
1043 <        sdat.pot[2] -= 0.5 * preVal;
1043 >        (*(sdat.pot))[ELECTROSTATIC_FAMILY] -= 0.5 * preVal;
1044          
1045          // The self-correction term adds into the reaction field vector
1046          Vector3d uz_i = sdat.eFrame->getColumn(2);
# Line 1065 | Line 1057 | namespace OpenMD {
1057          } else {        
1058            self = - 0.5 * rcuti_ * chg1 * (chg1 +  *(sdat.skippedCharge)) * pre11_;
1059          }
1060 <        sdat.pot[ELECTROSTATIC_FAMILY] += self;
1060 >        (*(sdat.pot))[ELECTROSTATIC_FAMILY] += self;
1061        }
1062      }
1063    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines