/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package etomica.potential;

/**
 * Methods for properties obtained for a soft, differentiable pair potential.
 *
 * @author David Kofke
 */
public interface Potential2Soft extends PotentialSoft, Potential2Spherical {

    /**
     * Integral used to evaluate correction to truncation of potential.
     */
    public double integral(double rC);

    /**
     * The derivative of the pair energy, times the separation r: r du/dr.
     */
    public double du(double r2);

    default void u012add(double r2, double[] u012) {
        u012[0] += u(r2);
        u012[1] += du(r2);
        u012[2] += d2u(r2);
    }

    /**
     * The second derivative of the pair energy, times the square of the
     * separation:  r^2 d^2u/dr^2.
     */
    double d2u(double r2);


    default void u01TruncationCorrection(double[] uCorrection, double[] duCorrection) {

    }
}

@@ -227,16 +227,160 @@
 ntial;%0A%0A
+import etomica.atom.IAtom;%0Aimport etomica.atom.IAtomList;%0Aimport etomica.exception.MethodNotImplementedException;%0Aimport etomica.space.Vector;%0A%0A
 /**%0A * M
@@ -557,16 +557,32 @@
 pherical
+, IPotentialPair
  %7B%0A%0A    
@@ -665,31 +665,24 @@
      */%0A    
-public 
 double integ
@@ -793,23 +793,16 @@
  */%0A    
-public 
 double d
@@ -1205,10 +1205,742 @@
 %0A%0A    %7D%0A
-%7D
 %0A
+    default double u(Vector dr12, IAtom atom1, IAtom atom2) %7B%0A        return u(dr12.squared());%0A    %7D%0A%0A    default double udu(Vector dr12, IAtom atom1, IAtom atom2, Vector f1, Vector f2) %7B%0A        double%5B%5D u012 = new double%5B3%5D;%0A        double r2 = dr12.squared();%0A        u012add(r2, u012);%0A        Vector f = Vector.d(f1.getD());%0A        f.E(dr12);%0A        f.TE(u012%5B1%5D / r2);%0A        f1.PE(f);%0A        f2.ME(f);%0A        return u012%5B0%5D;%0A    %7D%0A%0A    default double uduTorque(Vector dr12, IAtom atom1, IAtom atom2, Vector f1, Vector f2, Vector t1, Vector t2) %7B%0A        return udu(dr12, atom1, atom2, f1, f2);%0A    %7D%0A%0A    default Vector%5B%5D%5B%5D gradientAndTorque(IAtomList atoms) %7B%0A        throw new MethodNotImplementedException();%0A    %7D%0A%0A%7D

allow spherical potentials to be used in non-spherical compute