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

The following examples show how to use org.apache.commons.math.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: ThreeEighthesIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #2
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if (equations instanceof ExtendedFirstOrderDifferentialEquations) {
        mainSetDimension = ((ExtendedFirstOrderDifferentialEquations) equations).getMainSetDimension();
    } else {
        mainSetDimension = equations.getDimension();
    }

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != mainSetDimension)) {
        throw new IntegratorException(
                LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != mainSetDimension)) {
        throw new IntegratorException(
                LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecRelativeTolerance.length);
    }

}
 
Example #3
Source File: MidpointIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new MidpointIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #4
Source File: GillIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new GillIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #5
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " absolute tolerance vector has dimension {1}",
                y0.length, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " relative tolerance vector has dimension {1}",
                y0.length, vecRelativeTolerance.length);
    }

}
 
Example #6
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #7
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " absolute tolerance vector has dimension {1}",
                y0.length, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " relative tolerance vector has dimension {1}",
                y0.length, vecRelativeTolerance.length);
    }

}
 
Example #8
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " absolute tolerance vector has dimension {1}",
                y0.length, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " relative tolerance vector has dimension {1}",
                y0.length, vecRelativeTolerance.length);
    }

}
 
Example #9
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if (equations instanceof ExtendedFirstOrderDifferentialEquations) {
        mainSetDimension = ((ExtendedFirstOrderDifferentialEquations) equations).getMainSetDimension();
    } else {
        mainSetDimension = equations.getDimension();
    }

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != mainSetDimension)) {
        throw new IntegratorException(
                LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != mainSetDimension)) {
        throw new IntegratorException(
                LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecRelativeTolerance.length);
    }

}
 
Example #10
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if (equations instanceof ExtendedFirstOrderDifferentialEquations) {
        mainSetDimension = ((ExtendedFirstOrderDifferentialEquations) equations).getMainSetDimension();
    } else {
        mainSetDimension = equations.getDimension();
    }

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != mainSetDimension)) {
        throw new IntegratorException(
                LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != mainSetDimension)) {
        throw new IntegratorException(
                LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecRelativeTolerance.length);
    }

}
 
Example #11
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " absolute tolerance vector has dimension {1}",
                y0.length, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " relative tolerance vector has dimension {1}",
                y0.length, vecRelativeTolerance.length);
    }

}
 
Example #12
Source File: MidpointIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new MidpointIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #13
Source File: ThreeEighthesIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #14
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                Assert.assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #15
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " absolute tolerance vector has dimension {1}",
                y0.length, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " relative tolerance vector has dimension {1}",
                y0.length, vecRelativeTolerance.length);
    }

}
 
Example #16
Source File: EulerIntegratorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStepSize()
  throws MathUserException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new EulerIntegrator(step);
    integ.addStepHandler(new StepHandler() {
      public void handleStep(StepInterpolator interpolator, boolean isLast) {
          if (! isLast) {
              Assert.assertEquals(step,
                           interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                           1.0e-12);
          }
      }
      public void reset() {
      }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
                        public void computeDerivatives(double t, double[] y, double[] dot) {
                            dot[0] = 1.0;
                        }
                        public int getDimension() {
                            return 1;
                        }
                    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #17
Source File: AdaptiveStepsizeIntegrator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Perform some sanity checks on the integration parameters.
 * @param equations differential equations set
 * @param t0 start time
 * @param y0 state vector at t0
 * @param t target time for the integration
 * @param y placeholder where to put the state vector
 * @exception IntegratorException if some inconsistency is detected
 */
@Override
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
                            final double t0, final double[] y0,
                            final double t, final double[] y)
    throws IntegratorException {

    super.sanityChecks(equations, t0, y0, t, y);

    if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " absolute tolerance vector has dimension {1}",
                y0.length, vecAbsoluteTolerance.length);
    }

    if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
        throw new IntegratorException(
                "dimensions mismatch: state vector has dimension {0}," +
                " relative tolerance vector has dimension {1}",
                y0.length, vecRelativeTolerance.length);
    }

}
 
Example #18
Source File: ThreeEighthesIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }          
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #19
Source File: ThreeEighthesIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #20
Source File: ThreeEighthesIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #21
Source File: MidpointIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new MidpointIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #22
Source File: GillIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new GillIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #23
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #24
Source File: GillIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new GillIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #25
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #26
Source File: MidpointIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new MidpointIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #27
Source File: EulerIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new EulerIntegrator(step);
    integ.addStepHandler(new StepHandler() {
      public void handleStep(StepInterpolator interpolator, boolean isLast) {
          if (! isLast) {
              assertEquals(step,
                           interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                           1.0e-12);
          }
      }
      public boolean requiresDenseOutput() {
          return false;
      }
      public void reset() {
      }          
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
                        private static final long serialVersionUID = 0L;
                        public void computeDerivatives(double t, double[] y, double[] dot) {
                            dot[0] = 1.0;
                        }
                        public int getDimension() {
                            return 1;
                        }
                    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #28
Source File: ClassicalRungeKuttaIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #29
Source File: GillIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new GillIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}
 
Example #30
Source File: GillIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testStepSize()
  throws DerivativeException, IntegratorException {
    final double step = 1.23456;
    FirstOrderIntegrator integ = new GillIntegrator(step);
    integ.addStepHandler(new StepHandler() {
        public void handleStep(StepInterpolator interpolator, boolean isLast) {
            if (! isLast) {
                assertEquals(step,
                             interpolator.getCurrentTime() - interpolator.getPreviousTime(),
                             1.0e-12);
            }
        }
        public boolean requiresDenseOutput() {
            return false;
        }
        public void reset() {
        }
    });
    integ.integrate(new FirstOrderDifferentialEquations() {
        private static final long serialVersionUID = 0L;
        public void computeDerivatives(double t, double[] y, double[] dot) {
            dot[0] = 1.0;
        }
        public int getDimension() {
            return 1;
        }
    }, 0.0, new double[] { 0.0 }, 5.0, new double[1]);
}