public void testIntegratorControls() throws DerivativeException, IntegratorException {

    TestProblem3 pb = new TestProblem3(0.999);
    GraggBulirschStoerIntegrator integ =
        new GraggBulirschStoerIntegrator(
            0, pb.getFinalTime() - pb.getInitialTime(), 1.0e-8, 1.0e-10);

    double errorWithDefaultSettings = getMaxError(integ, pb);

    // stability control
    integ.setStabilityCheck(true, 2, 1, 0.99);
    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
    integ.setStabilityCheck(true, -1, -1, -1);

    integ.setStepsizeControl(0.5, 0.99, 0.1, 2.5);
    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
    integ.setStepsizeControl(-1, -1, -1, -1);

    integ.setOrderControl(10, 0.7, 0.95);
    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
    integ.setOrderControl(-1, -1, -1);

    integ.setInterpolationControl(true, 3);
    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
    integ.setInterpolationControl(true, -1);
  }
  public void testKepler() throws DerivativeException, IntegratorException {

    final TestProblem3 pb = new TestProblem3(0.9);
    double minStep = 0;
    double maxStep = pb.getFinalTime() - pb.getInitialTime();
    double absTolerance = 1.0e-6;
    double relTolerance = 1.0e-6;

    FirstOrderIntegrator integ =
        new GraggBulirschStoerIntegrator(
            minStep, maxStep,
            absTolerance, relTolerance);
    integ.addStepHandler(new KeplerStepHandler(pb));
    integ.integrate(
        pb,
        pb.getInitialTime(),
        pb.getInitialState(),
        pb.getFinalTime(),
        new double[pb.getDimension()]);

    assertEquals(integ.getEvaluations(), pb.getCalls());
    assertTrue(pb.getCalls() < 2150);
  }
  public void testVariableSteps() throws DerivativeException, IntegratorException {

    final TestProblem3 pb = new TestProblem3(0.9);
    double minStep = 0;
    double maxStep = pb.getFinalTime() - pb.getInitialTime();
    double absTolerance = 1.0e-8;
    double relTolerance = 1.0e-8;
    FirstOrderIntegrator integ =
        new GraggBulirschStoerIntegrator(
            minStep, maxStep,
            absTolerance, relTolerance);
    integ.addStepHandler(new VariableStepHandler());
    double stopTime =
        integ.integrate(
            pb,
            pb.getInitialTime(),
            pb.getInitialState(),
            pb.getFinalTime(),
            new double[pb.getDimension()]);
    assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
    assertEquals("Gragg-Bulirsch-Stoer", integ.getName());
  }
Ejemplo n.º 4
0
  public void testKepler() throws DerivativeException, IntegratorException {

    final TestProblem3 pb = new TestProblem3(0.9);
    double minStep = 0;
    double maxStep = pb.getFinalTime() - pb.getInitialTime();
    double[] vecAbsoluteTolerance = {1.0e-8, 1.0e-8, 1.0e-10, 1.0e-10};
    double[] vecRelativeTolerance = {1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8};

    FirstOrderIntegrator integ =
        new HighamHall54Integrator(minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
    integ.addStepHandler(new KeplerHandler(pb));
    integ.integrate(
        pb,
        pb.getInitialTime(),
        pb.getInitialState(),
        pb.getFinalTime(),
        new double[pb.getDimension()]);
    assertEquals("Higham-Hall 5(4)", integ.getName());
  }
Ejemplo n.º 5
0
  public void testSanityChecks() {
    try {
      final TestProblem3 pb = new TestProblem3(0.9);
      double minStep = 0;
      double maxStep = pb.getFinalTime() - pb.getInitialTime();

      try {
        FirstOrderIntegrator integ =
            new HighamHall54Integrator(minStep, maxStep, new double[4], new double[4]);
        integ.integrate(
            pb,
            pb.getInitialTime(),
            new double[6],
            pb.getFinalTime(),
            new double[pb.getDimension()]);
        fail("an exception should have been thrown");
      } catch (IntegratorException ie) {
        // expected behavior
      }

      try {
        FirstOrderIntegrator integ =
            new HighamHall54Integrator(minStep, maxStep, new double[4], new double[4]);
        integ.integrate(
            pb, pb.getInitialTime(), pb.getInitialState(), pb.getFinalTime(), new double[6]);
        fail("an exception should have been thrown");
      } catch (IntegratorException ie) {
        // expected behavior
      }

      try {
        FirstOrderIntegrator integ =
            new HighamHall54Integrator(minStep, maxStep, new double[2], new double[4]);
        integ.integrate(
            pb,
            pb.getInitialTime(),
            pb.getInitialState(),
            pb.getFinalTime(),
            new double[pb.getDimension()]);
        fail("an exception should have been thrown");
      } catch (IntegratorException ie) {
        // expected behavior
      }

      try {
        FirstOrderIntegrator integ =
            new HighamHall54Integrator(minStep, maxStep, new double[4], new double[2]);
        integ.integrate(
            pb,
            pb.getInitialTime(),
            pb.getInitialState(),
            pb.getFinalTime(),
            new double[pb.getDimension()]);
        fail("an exception should have been thrown");
      } catch (IntegratorException ie) {
        // expected behavior
      }

      try {
        FirstOrderIntegrator integ =
            new HighamHall54Integrator(minStep, maxStep, new double[4], new double[4]);
        integ.integrate(
            pb,
            pb.getInitialTime(),
            pb.getInitialState(),
            pb.getInitialTime(),
            new double[pb.getDimension()]);
        fail("an exception should have been thrown");
      } catch (IntegratorException ie) {
        // expected behavior
      }

    } catch (Exception e) {
      fail("wrong exception caught: " + e.getMessage());
    }
  }