You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/07/14 16:51:34 UTC
svn commit: r676610 -
/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java
Author: luc
Date: Mon Jul 14 07:51:33 2008
New Revision: 676610
URL: http://svn.apache.org/viewvc?rev=676610&view=rev
Log:
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.
Modified:
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java?rev=676610&r1=676609&r2=676610&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java Mon Jul 14 07:51:33 2008
@@ -177,7 +177,7 @@
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 @@
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 @@
pendingEventTime = Double.NaN;
return (nextAction == EventHandler.RESET_STATE) ||
- (nextAction == EventHandler.RESET_DERIVATIVES);
+ (nextAction == EventHandler.RESET_DERIVATIVES);
}