@@ -0,0 +1,1038 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public%0A * License, v. 2.0. If a copy of the MPL was not distributed with this%0A * file, You can obtain one at http://mozilla.org/MPL/2.0/. */%0A%0Apackage etomica.potential;%0A%0A/**%0A * Torsion potential expressed as power series in cos(theta)%0A * https://doi.org/10.1063/1.474882%0A */%0Apublic class P4BondTorsionPow implements IPotentialBondTorsion %7B%0A%0A    protected double%5B%5D a;%0A%0A    public P4BondTorsionPow(double%5B%5D a) %7B%0A        this.a = a;%0A    %7D%0A%0A    @Override%0A    public double u(double costheta) %7B%0A        double rv = a%5B0%5D;%0A        double ctp = costheta;%0A        for (int i=1; i%3Ca.length; i++) %7B%0A            rv += a%5Bi%5D*ctp;%0A            ctp *= costheta;%0A        %7D%0A        return rv;%0A    %7D%0A%0A    @Override%0A    public void udu(double costheta, double%5B%5D u, double%5B%5D du) %7B%0A        u%5B0%5D = a%5B0%5D;%0A        du%5B0%5D = 0;%0A        double ctp = 1;%0A        for (int i=1; i%3Ca.length; i++) %7B%0A            du%5B0%5D += i*a%5Bi%5D*ctp;%0A            ctp *= costheta;%0A            u%5B0%5D += a%5Bi%5D*ctp;%0A        %7D%0A    %7D%0A%7D%0A

add torsion potential explicitly expressed as power series in costheta