@Test
public void testIssue965()
throws DimensionMismatchException, NumberIsTooSmallException,
MaxCountExceededException, NoBracketingException {
ExpandableStatefulODE equation =
new ExpandableStatefulODE(new FirstOrderDifferentialEquations() {
public int getDimension() {
return 1;
}
public void computeDerivatives(double t, double[] y, double[] yDot) {
yDot[0] = 2.0;
}
});
equation.setTime(0.0);
equation.setPrimaryState(new double[1]);
equation.addSecondaryEquations(new SecondaryEquations() {
public int getDimension() {
return 1;
}
public void computeDerivatives(double t, double[] primary,
double[] primaryDot, double[] secondary,
double[] secondaryDot) {
secondaryDot[0] = -3.0;
}
});
int index = equation.getSecondaryMappers()[0].getFirstIndex();
DormandPrince853Integrator integrator = new DormandPrince853Integrator(0.001, 1000, 1.0e-14, 1.0e-14);
integrator.addEventHandler(new SecondaryStateEvent(index, -3.0), 0.1, 1.0e-9, 1000);
integrator.setInitialStepSize(3.0);
integrator.integrate(equation, 30.0);
Assert.assertEquals( 1.0, equation.getTime(), 1.0e-10);
Assert.assertEquals( 2.0, equation.getPrimaryState()[0], 1.0e-10);
Assert.assertEquals(-3.0, equation.getSecondaryState(0)[0], 1.0e-10);
}