--- branches/development/src/nonbonded/Electrostatic.cpp 2012/08/29 18:13:11 1787 +++ branches/development/src/nonbonded/Electrostatic.cpp 2012/11/27 21:13:48 1814 @@ -746,18 +746,30 @@ namespace OpenMD { // Obtain all of the required radial function values from the // spline structures: - if (a_is_Charge && b_is_Charge) { - v01 = v01s->getValueAt( *(idat.rij) ); + // needed for fields (and forces): + if (a_is_Charge || b_is_Charge) { v02 = v02s->getValueAt( *(idat.rij) ); } - if ((a_is_Charge && b_is_Dipole) || (b_is_Charge && a_is_Dipole)) { - v11 = v11s->getValueAt( *(idat.rij) ); + if (a_is_Dipole || b_is_Dipole) { v12 = v12s->getValueAt( *(idat.rij) ); v13 = v13s->getValueAt( *(idat.rij) ); } - if ((a_is_Charge && b_is_Quadrupole) || - (b_is_Charge && a_is_Quadrupole) || - (a_is_Dipole && b_is_Dipole)) { + if (a_is_Quadrupole || b_is_Quadrupole) { + v23 = v23s->getValueAt( *(idat.rij) ); + v24 = v24s->getValueAt( *(idat.rij) ); + } + + // needed for potentials (and torques): + if (a_is_Charge && b_is_Charge) { + v01 = v01s->getValueAt( *(idat.rij) ); + } + if ((a_is_Charge && b_is_Dipole) || (b_is_Charge && a_is_Dipole)) { + v11 = v11s->getValueAt( *(idat.rij) ); + } + if ((a_is_Charge && b_is_Quadrupole) || (b_is_Charge && a_is_Quadrupole)) { + v21 = v21s->getValueAt( *(idat.rij) ); + v22 = v22s->getValueAt( *(idat.rij) ); + } else if (a_is_Dipole && b_is_Dipole) { v21 = v21s->getValueAt( *(idat.rij) ); v22 = v22s->getValueAt( *(idat.rij) ); v23 = v23s->getValueAt( *(idat.rij) ); @@ -941,7 +953,7 @@ namespace OpenMD { F -= pref * (DadDb * rhat + rdDb * D_a + rdDa * D_b)*v23; F -= pref * (rdDa * rdDb) * v24 * rhat; Ta += pref * ( v21 * DaxDb - v22 * rdDb * rxDa); - Tb += pref * (-v21 * DaxDb + v22 * rdDa * rxDb); + Tb += pref * (-v21 * DaxDb - v22 * rdDa * rxDb); // Even if we excluded this pair from direct interactions, we // still have the reaction-field-mediated dipole-dipole @@ -995,7 +1007,7 @@ namespace OpenMD { F += pref * (rdDb * rdQar * rhat * v35); Ta += pref * ((-2.0*cross(DbdQa, rhat) + 2.0*DbxQar)*v31 + 2.0*rdDb*rxQar*v32); - Tb += pref * ((trQa*rxDb + 2.0 * DbxQar)*v31 + rxDb*rdQar*v32); + Tb += pref * ((trQa*rxDb - 2.0 * DbxQar)*v31 + rxDb*rdQar*v32); } if (b_is_Quadrupole) { pref = pre44_ * *(idat.electroMult);