Package org.apache.commons.math.ode.nonstiff

Examples of org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator


    @Test
    public void testHighAccuracyExternalDifferentiation()
        throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
        double hP = 1.0e-12;
        SummaryStatistics residualsP0 = new SummaryStatistics();
        SummaryStatistics residualsP1 = new SummaryStatistics();
        for (double b = 2.88; b < 3.08; b += 0.001) {
            Brusselator brusselator = new Brusselator(b);
            double[] y = { 1.3, b };
            integ.integrate(brusselator, 0, y, 20.0, y);
            double[] yP = { 1.3, b + hP };
            brusselator.setParameter(0, b + hP);
            integ.integrate(brusselator, 0, yP, 20.0, yP);
            residualsP0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
            residualsP1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
        }
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) > 0.02);
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.03);
View Full Code Here


    @Test
    public void testInternalDifferentiation()
        throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, 1.0e-4, 1.0e-4);
        double hP = 1.0e-12;
        SummaryStatistics residualsP0 = new SummaryStatistics();
        SummaryStatistics residualsP1 = new SummaryStatistics();
        for (double b = 2.88; b < 3.08; b += 0.001) {
            Brusselator brusselator = new Brusselator(b);
            brusselator.setParameter(0, b);
            double[] z = { 1.3, b };
            double[][] dZdZ0 = new double[2][2];
            double[][] dZdP  = new double[2][1];
            double hY = 1.0e-12;
            FirstOrderIntegratorWithJacobians extInt =
                new FirstOrderIntegratorWithJacobians(integ, brusselator, new double[] { b },
                                                      new double[] { hY, hY }, new double[] { hP });
            extInt.setMaxEvaluations(5000);
            extInt.integrate(0, z, new double[][] { { 0.0 }, { 1.0 } }, 20.0, z, dZdZ0, dZdP);
            Assert.assertEquals(5000, extInt.getMaxEvaluations());
            Assert.assertTrue(extInt.getEvaluations() > 2000);
            Assert.assertTrue(extInt.getEvaluations() < 2500);
            Assert.assertEquals(4 * integ.getEvaluations(), extInt.getEvaluations());
            residualsP0.addValue(dZdP[0][0] - brusselator.dYdP0());
            residualsP1.addValue(dZdP[1][0] - brusselator.dYdP1());
        }
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.006);
        Assert.assertTrue(residualsP0.getStandardDeviation() < 0.0009);
View Full Code Here

    @Test
    public void testAnalyticalDifferentiation()
        throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, 1.0e-4, 1.0e-4);
        SummaryStatistics residualsP0 = new SummaryStatistics();
        SummaryStatistics residualsP1 = new SummaryStatistics();
        for (double b = 2.88; b < 3.08; b += 0.001) {
            Brusselator brusselator = new Brusselator(b);
            brusselator.setParameter(0, b);
            double[] z = { 1.3, b };
            double[][] dZdZ0 = new double[2][2];
            double[][] dZdP  = new double[2][1];
            FirstOrderIntegratorWithJacobians extInt =
                new FirstOrderIntegratorWithJacobians(integ, brusselator);
            extInt.setMaxEvaluations(5000);
            extInt.integrate(0, z, new double[][] { { 0.0 }, { 1.0 } }, 20.0, z, dZdZ0, dZdP);
            Assert.assertEquals(5000, extInt.getMaxEvaluations());
            Assert.assertTrue(extInt.getEvaluations() > 510);
            Assert.assertTrue(extInt.getEvaluations() < 610);
            Assert.assertEquals(integ.getEvaluations(), extInt.getEvaluations());
            residualsP0.addValue(dZdP[0][0] - brusselator.dYdP0());
            residualsP1.addValue(dZdP[1][0] - brusselator.dYdP1());
        }
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.004);
        Assert.assertTrue(residualsP0.getStandardDeviation() < 0.0008);
View Full Code Here

    }

    @Test
    public void testFinalResult() throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
        double[] y = new double[] { 0.0, 1.0 };
        Circle circle = new Circle(y, 1.0, 1.0, 0.1);
        double[][] dydy0 = new double[2][2];
        double[][] dydp  = new double[2][3];
        double t = 18 * Math.PI;
 
View Full Code Here

    }

    @Test
    public void testStepHandlerResult() throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
        double[] y = new double[] { 0.0, 1.0 };
        final Circle circle = new Circle(y, 1.0, 1.0, 0.1);
        double[][] dydy0 = new double[2][2];
        double[][] dydp  = new double[2][3];
        double t = 18 * Math.PI;
 
View Full Code Here

    }

    @Test
    public void testEventHandler() throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
        double[] y = new double[] { 0.0, 1.0 };
        final Circle circle = new Circle(y, 1.0, 1.0, 0.1);
        double[][] dydy0 = new double[2][2];
        double[][] dydp  = new double[2][3];
        double t = 18 * Math.PI;
 
View Full Code Here

  @Override
  public void setUp() {
    pb = new TestProblem3(0.9);
    double minStep = 0;
    double maxStep = pb.getFinalTime() - pb.getInitialTime();
    integ = new DormandPrince54Integrator(minStep, maxStep, 1.0e-8, 1.0e-8);
  }
View Full Code Here

  @Override
  public void setUp() {
    pb = new TestProblem3(0.9);
    double minStep = 0;
    double maxStep = pb.getFinalTime() - pb.getInitialTime();
    integ = new DormandPrince54Integrator(minStep, maxStep, 1.0e-8, 1.0e-8);
  }
View Full Code Here

        // essentially noise.
        // This test is taken from Hairer, Norsett and Wanner book
        // Solving Ordinary Differential Equations I (Nonstiff problems),
        // the curves dy/dp = g(b) are in figure 6.5
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4, 1.0e-4 }, new double[] { 1.0e-4, 1.0e-4 });
        double hP = 1.0e-12;
        SummaryStatistics residualsP0 = new SummaryStatistics();
        SummaryStatistics residualsP1 = new SummaryStatistics();
        for (double b = 2.88; b < 3.08; b += 0.001) {
            Brusselator brusselator = new Brusselator(b);
            double[] y = { 1.3, b };
            integ.integrate(brusselator, 0, y, 20.0, y);
            double[] yP = { 1.3, b + hP };
            brusselator.setParameter(0, b + hP);
            integ.integrate(brusselator, 0, yP, 20.0, yP);
            residualsP0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
            residualsP1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
        }
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) > 600);
        Assert.assertTrue(residualsP0.getStandardDeviation() > 30);
View Full Code Here

    @Test
    public void testHighAccuracyExternalDifferentiation()
        throws IntegratorException, DerivativeException {
        FirstOrderIntegrator integ =
            new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-10, 1.0e-10 }, new double[] { 1.0e-10, 1.0e-10 });
        double hP = 1.0e-12;
        SummaryStatistics residualsP0 = new SummaryStatistics();
        SummaryStatistics residualsP1 = new SummaryStatistics();
        for (double b = 2.88; b < 3.08; b += 0.001) {
            Brusselator brusselator = new Brusselator(b);
            double[] y = { 1.3, b };
            integ.integrate(brusselator, 0, y, 20.0, y);
            double[] yP = { 1.3, b + hP };
            brusselator.setParameter(0, b + hP);
            integ.integrate(brusselator, 0, yP, 20.0, yP);
            residualsP0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
            residualsP1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
        }
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) > 0.02);
        Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.03);
View Full Code Here

TOP

Related Classes of org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.