TestProblemAbstract pb = problems[k].copy();
double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
Double.POSITIVE_INFINITY, 1.0e-6 * step, 1000);
}
double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
if (functions.length == 0) {
assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);
}
double valueError = handler.getMaximalValueError();
if (i > 4) {
assertTrue(valueError < FastMath.abs(previousValueError));
}
previousValueError = valueError;
double timeError = handler.getMaximalTimeError();
if (i > 4) {
assertTrue(timeError <= FastMath.abs(previousTimeError));
}
previousTimeError = timeError;