<commit_before>package etomica.potential;
import etomica.Default;
import etomica.EtomicaElement;
import etomica.EtomicaInfo;
import etomica.Space;
import etomica.potential.Potential2SoftSpherical;
import etomica.units.Dimension;

/**
 * Weeks-Chandler-Andersen potential.  Obtained by truncating the Lennard-Jones
 * potential at the separation where it has its minimum, and shifting it upwards so the
 * minimum is at zero energy.  The resulting potential has a value and first
 * derivative that is continuous at the point of truncation.
 *
 * @author <NAME> (edited by <NAME> and <NAME>)
 */
public class P2WCA extends Potential2SoftSpherical implements EtomicaElement {

    /**
     * Constructs potential using default sigma and epsilon given by Default class.
     */
    public P2WCA(Space space) {
        this(space, Default.ATOM_SIZE, Default.POTENTIAL_WELL);
    }
    
    public P2WCA(Space space, double sigma, double epsilon) {
        super(space);
        setSigma(sigma);
        setEpsilon(epsilon);
    }
    
    public static EtomicaInfo getEtomicaInfo() {
        EtomicaInfo info = new EtomicaInfo("Weeks-Chandler-Andersen potential");
        return info;
    }
    
    /**
     * Returns the range of the potential, which is the point of truncation.  This
     * is equal to 2^(1/6) * sigma.
     */
    public double getRange() {
        return range;
    }

    /**
     * The energy u.
     */
    public double u(double r2) {
        if(r2 < rangeSquared) {
            double s2 = sigmaSquared/r2;
            s6 = s2*s2*s2;
            return epsilon4*s6*(s6 - 1.0) + epsilon;
        }
        else return 0.0;
     }


    /**
     * The derivative r*du/dr.
     */
    public double du(double r2) {
        if(r2 < rangeSquared) {
            double s2 = sigmaSquared/r2;
            s6 = s2*s2*s2;
            return -epsilon48*s6*(s6 - 0.5);
        }
        else return 0.0;
    }

   /**
    * The second derivative of the pair energy, times the square of the
    * separation:  r^2 d^2u/dr^2.
    */
    public double d2u(double r2) {
        if(r2 < rangeSquared) {
            double s2 = sigmaSquared/r2;
            s6 = s2*s2*s2;
            return epsilon624*s6*(s6 - _168div624);
        }
        else return 0.0;
      }
            
    /**
     *  Returns zero, since there is no long-range correction.<commit_msg>minor code rearrangment for debugging<commit_after>package etomica.potential;
import etomica.Default;
import etomica.EtomicaElement;
import etomica.EtomicaInfo;
import etomica.Space;
import etomica.potential.Potential2SoftSpherical;
import etomica.units.Dimension;

/**
 * Weeks-Chandler-Andersen potential.  Obtained by truncating the Lennard-Jones
 * potential at the separation where it has its minimum, and shifting it upwards so the
 * minimum is at zero energy.  The resulting potential has a value and first
 * derivative that is continuous at the point of truncation.
 *
 * @author <NAME> (edited by <NAME> and <NAME>)
 */
public class P2WCA extends Potential2SoftSpherical implements EtomicaElement {

    /**
     * Constructs potential using default sigma and epsilon given by Default class.
     */
    public P2WCA(Space space) {
        this(space, Default.ATOM_SIZE, Default.POTENTIAL_WELL);
    }
    
    public P2WCA(Space space, double sigma, double epsilon) {
        super(space);
        setSigma(sigma);
        setEpsilon(epsilon);
    }
    
    public static EtomicaInfo getEtomicaInfo() {
        EtomicaInfo info = new EtomicaInfo("Weeks-Chandler-Andersen potential");
        return info;
    }
    
    /**
     * Returns the range of the potential, which is the point of truncation.  This
     * is equal to 2^(1/6) * sigma.
     */
    public double getRange() {
        return range;
    }

    /**
     * The energy u.
     */
    public double u(double r2) {
        if(r2 < rangeSquared) {
            double s2 = sigmaSquared/r2;
            s6 = s2*s2*s2;
            return epsilon4*s6*(s6 - 1.0) + epsilon;
        }
        else return 0.0;
     }


    /**
     * The derivative r*du/dr.
     */
    public double du(double r2) {
        double du = 0.0;
        if(r2 < rangeSquared) {
            double s2 = sigmaSquared/r2;
            s6 = s2*s2*s2;
            du = -epsilon48*s6*(s6 - 0.5);
        }
//        System.out.println("r2, du: "+r2 + "  "+du);
        return du;
    }

   /**
    * The second derivative of the pair energy, times the square of the
    * separation:  r^2 d^2u/dr^2.
    */
    public double d2u(double r2) {
        if(r2 < rangeSquared) {
            double s2 = sigmaSquared/r2;
            s6 = s2*s2*s2;
            return epsilon624*s6*(s6 - _168div624);
        }
        else return 0.0;
      }
            
    /**
     *  Returns zero, since there is no long-range correction.
{'fraction_non_alphanumeric': 0.09747516556291391, 'fraction_numerical': 0.026903973509933773, 'mean_word_length': 2.1180645161290323, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7433012', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1534, 'n_words': 437}