}
public void testEventsNoConvergence() throws Exception {
final TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
double scalAbsoluteTolerance = 1.0e-8;
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ =
new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance, scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
integ.addEventHandler(new EventHandler() {
public int eventOccurred(double t, double[] y, boolean increasing) {
return EventHandler.CONTINUE;
}
public double g(double t, double[] y) {
double middle = (pb.getInitialTime() + pb.getFinalTime()) / 2;
double offset = t - middle;
return (offset > 0) ? (offset + 0.5) : (offset - 0.5);
}
public void resetState(double t, double[] y) {
}
private static final long serialVersionUID = 935652725339916361L;
}, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 3);
try {
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
fail("an exception should have been thrown");
} catch (IntegratorException ie) {
assertTrue(ie.getCause() != null);
assertTrue(ie.getCause() instanceof ConvergenceException);
}