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 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC vs.
Revision 1536 by gezelter, Wed Jan 5 14:49:05 2011 UTC

# Line 113 | Line 113 | namespace OpenMD {
113        } else {
114          // throw error
115          sprintf( painCave.errMsg,
116 <                 "SimInfo error: Unknown electrostaticSummationMethod.\n"
116 >                 "Electrostatic::initialize: Unknown electrostaticSummationMethod.\n"
117                   "\t(Input file specified %s .)\n"
118                   "\telectrostaticSummationMethod must be one of: \"none\",\n"
119                   "\t\"shifted_potential\", \"shifted_force\", or \n"
# Line 429 | Line 429 | namespace OpenMD {
429      haveDielectric_ = true;
430    }
431  
432 <  void Electrostatic::calcForce(InteractionData idat) {
432 >  void Electrostatic::calcForce(InteractionData &idat) {
433  
434      // utility variables.  Should clean these up and use the Vector3d and
435      // Mat3x3d to replace as many as we can in future versions:
# Line 591 | Line 591 | namespace OpenMD {
591  
592          }
593  
594 <        idat.vpair += vterm;
594 >        idat.vpair[2] += vterm;
595          epot += idat.sw * vterm;
596  
597          dVdr += dudr * rhat;      
# Line 607 | Line 607 | namespace OpenMD {
607            ri3 = ri2 * riji;
608      
609            vterm = - pref * ct_j * ( ri2 - preRF2_ * idat.rij );
610 <          idat.vpair += vterm;
610 >          idat.vpair[2] += vterm;
611            epot += idat.sw * vterm;
612  
613            dVdr +=  -preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j);
# Line 645 | Line 645 | namespace OpenMD {
645            // calculate the potential
646            pot_term =  scale * c2;
647            vterm = -pref * ct_j * pot_term;
648 <          idat.vpair += vterm;
648 >          idat.vpair[2] += vterm;
649            epot += idat.sw * vterm;
650              
651            // calculate derivatives for forces and torques
# Line 692 | Line 692 | namespace OpenMD {
692                       qyy_j * (cy2*c3 - c2ri) +
693                       qzz_j * (cz2*c3 - c2ri) );
694          vterm = pref * pot_term;
695 <        idat.vpair += vterm;
695 >        idat.vpair[2] += vterm;
696          epot += idat.sw * vterm;
697                  
698          // calculate derivatives for the forces and torques
# Line 720 | Line 720 | namespace OpenMD {
720            ri3 = ri2 * riji;
721  
722            vterm = pref * ct_i * ( ri2 - preRF2_ * idat.rij );
723 <          idat.vpair += vterm;
723 >          idat.vpair[2] += vterm;
724            epot += idat.sw * vterm;
725            
726            dVdr += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i);
# Line 760 | Line 760 | namespace OpenMD {
760            // calculate the potential
761            pot_term = c2 * scale;
762            vterm = pref * ct_i * pot_term;
763 <          idat.vpair += vterm;
763 >          idat.vpair[2] += vterm;
764            epot += idat.sw * vterm;
765  
766            // calculate derivatives for the forces and torques
# Line 783 | Line 783 | namespace OpenMD {
783  
784            vterm = pref * ( ri3 * (ct_ij - 3.0 * ct_i * ct_j) -
785                             preRF2_ * ct_ij );
786 <          idat.vpair += vterm;
786 >          idat.vpair[2] += vterm;
787            epot += idat.sw * vterm;
788              
789            a1 = 5.0 * ct_i * ct_j - ct_ij;
# Line 842 | Line 842 | namespace OpenMD {
842            // calculate the potential
843            pot_term = (ct_ij * c2ri - ctidotj * c3);
844            vterm = pref * pot_term;
845 <          idat.vpair += vterm;
845 >          idat.vpair[2] += vterm;
846            epot += idat.sw * vterm;
847  
848            // calculate derivatives for the forces and torques
# Line 894 | Line 894 | namespace OpenMD {
894                       qzz_i * (cz2 * c3 - c2ri) );
895          
896          vterm = pref * pot_term;
897 <        idat.vpair += vterm;
897 >        idat.vpair[2] += vterm;
898          epot += idat.sw * vterm;
899  
900          // calculate the derivatives for the forces and torques
# Line 909 | Line 909 | namespace OpenMD {
909        }
910      }
911  
912 <    idat.pot += epot;
912 >    idat.pot[2] += epot;
913      idat.f1 += dVdr;
914  
915      if (i_is_Dipole || i_is_Quadrupole)
# Line 929 | Line 929 | namespace OpenMD {
929      return;
930    }  
931  
932 <  void Electrostatic::calcSkipCorrection(SkipCorrectionData skdat) {
932 >  void Electrostatic::calcSkipCorrection(SkipCorrectionData &skdat) {
933  
934      if (!initialized_) initialize();
935      
# Line 963 | Line 963 | namespace OpenMD {
963  
964      if (summationMethod_ == esm_REACTION_FIELD) {
965        RealType riji, ri2, ri3;
966 <      RealType q_i, mu_i, ct_i;
967 <      RealType q_j, mu_j, ct_j;
968 <      RealType preVal, rfVal, vterm, dudr, pref, myPot;
966 >      RealType mu_i, ct_i;
967 >      RealType mu_j, ct_j;
968 >      RealType preVal, rfVal, vterm, dudr, pref, myPot(0.0);
969        Vector3d dVdr, uz_i, uz_j, duduz_i, duduz_j, rhat;
970  
971        // some variables we'll need independent of electrostatic type:
# Line 1020 | Line 1020 | namespace OpenMD {
1020        }
1021        
1022        // accumulate the forces and torques resulting from the self term
1023 <      skdat.pot += myPot;
1023 >      skdat.pot[2] += myPot;
1024        skdat.f1 += dVdr;
1025        
1026        if (i_is_Dipole)
# Line 1030 | Line 1030 | namespace OpenMD {
1030      }
1031    }
1032      
1033 <  void Electrostatic::calcSelfCorrection(SelfCorrectionData scdat) {
1033 >  void Electrostatic::calcSelfCorrection(SelfCorrectionData &scdat) {
1034      RealType mu1, preVal, chg1, self;
1035      
1036      if (!initialized_) initialize();
# Line 1046 | Line 1046 | namespace OpenMD {
1046        if (i_is_Dipole) {
1047          mu1 = data.dipole_moment;          
1048          preVal = pre22_ * preRF2_ * mu1 * mu1;
1049 <        scdat.pot -= 0.5 * preVal;
1049 >        scdat.pot[2] -= 0.5 * preVal;
1050          
1051          // The self-correction term adds into the reaction field vector
1052          Vector3d uz_i = scdat.eFrame.getColumn(2);
# Line 1063 | Line 1063 | namespace OpenMD {
1063          } else {        
1064            self = - 0.5 * rcuti_ * chg1 * (chg1 + scdat.skippedCharge) * pre11_;
1065          }
1066 <        scdat.pot += self;
1066 >        scdat.pot[2] += self;
1067        }
1068      }
1069    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines