fixed a problem preventing integration stop when end time was exactly 0

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@676618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-07-14 15:12:36 +00:00
parent e1306edb51
commit 0c125f71ed
3 changed files with 8 additions and 4 deletions

View File

@ -164,12 +164,14 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
* <p>This method can be used to simplify handling of integration end time. * <p>This method can be used to simplify handling of integration end time.
* It leverages the nominal stop condition with the exceptional stop * It leverages the nominal stop condition with the exceptional stop
* conditions.</p> * conditions.</p>
* @param startTime integration start time
* @param endTime desired end time * @param endTime desired end time
* @param manager manager containing the user-defined handlers * @param manager manager containing the user-defined handlers
* @return a new manager containing all the user-defined handlers plus a * @return a new manager containing all the user-defined handlers plus a
* dedicated manager triggering a stop event at entTime * dedicated manager triggering a stop event at entTime
*/ */
protected CombinedEventsManager addEndTimeChecker(final double endTime, protected CombinedEventsManager addEndTimeChecker(final double startTime,
final double endTime,
final CombinedEventsManager manager) { final CombinedEventsManager manager) {
CombinedEventsManager newManager = new CombinedEventsManager(); CombinedEventsManager newManager = new CombinedEventsManager();
for (final EventState state : manager.getEventsStates()) { for (final EventState state : manager.getEventsStates()) {
@ -179,7 +181,9 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
state.getMaxIterationCount()); state.getMaxIterationCount());
} }
newManager.addEventHandler(new EndTimeChecker(endTime), newManager.addEventHandler(new EndTimeChecker(endTime),
Double.POSITIVE_INFINITY, Math.ulp(endTime), 10); Double.POSITIVE_INFINITY,
Math.ulp(Math.max(Math.abs(startTime), Math.abs(endTime))),
100);
return newManager; return newManager;
} }

View File

@ -198,7 +198,7 @@ public abstract class EmbeddedRungeKuttaIntegrator
for (StepHandler handler : stepHandlers) { for (StepHandler handler : stepHandlers) {
handler.reset(); handler.reset();
} }
CombinedEventsManager manager = addEndTimeChecker(t, eventsHandlersManager); CombinedEventsManager manager = addEndTimeChecker(t0, t, eventsHandlersManager);
boolean lastStep = false; boolean lastStep = false;
// main integration loop // main integration loop

View File

@ -113,7 +113,7 @@ public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
for (StepHandler handler : stepHandlers) { for (StepHandler handler : stepHandlers) {
handler.reset(); handler.reset();
} }
CombinedEventsManager manager = addEndTimeChecker(t, eventsHandlersManager); CombinedEventsManager manager = addEndTimeChecker(t0, t, eventsHandlersManager);
boolean lastStep = false; boolean lastStep = false;
// main integration loop // main integration loop