improved robustness in case of events just at integration start

When an event occurs exactly at integration start, the first truncated
steps ends up with zero size. This induced problems with forward/backward
sensing based on this step alone. This also induced an infinite loop in
the calling integrators.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@676610 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-07-14 14:51:33 +00:00
parent 1c3e5de60b
commit 77cd728359
1 changed files with 7 additions and 3 deletions

View File

@ -177,7 +177,7 @@ public class EventState implements Serializable {
double ta = t0;
double ga = g0;
double tb = t0 + ((t1 > t0) ? convergence : -convergence);
double tb = t0 + (interpolator.isForward() ? convergence : -convergence);
for (int i = 0; i < n; ++i) {
// evaluate handler value at the end of the substep
@ -207,7 +207,11 @@ public class EventState implements Serializable {
solver.setAbsoluteAccuracy(convergence);
solver.setMaximalIterationCount(maxIterationCount);
final double root = (ta <= tb) ? solver.solve(ta, tb) : solver.solve(tb, ta);
if (Double.isNaN(previousEventTime) ||
if (Math.abs(root - ta) <= convergence) {
// we have found (again ?) a past event, we simply ignore it
ta = tb;
ga = gb;
} else if (Double.isNaN(previousEventTime) ||
(Math.abs(previousEventTime - root) > convergence)) {
pendingEventTime = root;
if (pendingEvent && (Math.abs(t1 - pendingEventTime) <= convergence)) {
@ -313,7 +317,7 @@ public class EventState implements Serializable {
pendingEventTime = Double.NaN;
return (nextAction == EventHandler.RESET_STATE) ||
(nextAction == EventHandler.RESET_DERIVATIVES);
(nextAction == EventHandler.RESET_DERIVATIVES);
}