org.apache.commons.math3.ode.FirstOrderDifferentialEquations Java Examples

The following examples show how to use org.apache.commons.math3.ode.FirstOrderDifferentialEquations. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTooLargeFirstStep() {

    RungeKuttaIntegrator integ = new ClassicalRungeKuttaIntegrator(0.5);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #2
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTooLargeFirstStep() {

    RungeKuttaIntegrator integ = new ClassicalRungeKuttaIntegrator(0.5);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #3
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTooLargeFirstStep() {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #4
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTooLargeFirstStep() {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #5
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTooLargeFirstStep() {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #6
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTooLargeFirstStep() {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #7
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #8
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #9
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #10
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #11
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #12
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #13
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #14
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #15
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #16
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #17
Source File: GraggBulirschStoerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new GraggBulirschStoerIntegrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}
 
Example #18
Source File: DormandPrince853IntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTooLargeFirstStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    AdaptiveStepsizeIntegrator integ =
            new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
    final double start = 0.0;
    final double end   = 0.001;
    FirstOrderDifferentialEquations equations = new FirstOrderDifferentialEquations() {

        public int getDimension() {
            return 1;
        }

        public void computeDerivatives(double t, double[] y, double[] yDot) {
            Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
            Assert.assertTrue(t <= FastMath.nextAfter(end,   Double.POSITIVE_INFINITY));
            yDot[0] = -100.0 * y[0];
        }

    };

    integ.setStepSizeControl(0, 1.0, 1.0e-6, 1.0e-8);
    integ.integrate(equations, start, new double[] { 1.0 }, end, new double[1]);

}