Package org.hipparchus.ode.events
Class DetectorBasedEventState
- java.lang.Object
-
- org.hipparchus.ode.events.DetectorBasedEventState
-
- All Implemented Interfaces:
EventState
public class DetectorBasedEventState extends Object implements EventState
This class handles the state for oneevent handlerduring integration steps.Each time the integrator proposes a step, the event handler switching function should be checked. This class handles the state of one handler during one integration step, with references to the state at the end of the preceding step. This information is used to decide if the handler should trigger an event or not during the proposed step.
-
-
Constructor Summary
Constructors Constructor Description DetectorBasedEventState(ODEEventDetector detector)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventOccurrencedoEvent(ODEStateAndDerivative state)Notify the user's listener of the event.booleanevaluateStep(ODEStateInterpolator interpolator)Evaluate the impact of the proposed step on the handler.ODEEventDetectorgetEventDetector()Get the underlying event detector.doublegetEventTime()Get the occurrence time of the event triggered in the current step.voidinit(ODEStateAndDerivative s0, double t)Initialize handler at the start of an integration.voidreinitializeBegin(ODEStateInterpolator interpolator)Reinitialize the beginning of the step.booleantryAdvance(ODEStateAndDerivative state, ODEStateInterpolator interpolator)Try to accept the current history up to the given time.
-
-
-
Constructor Detail
-
DetectorBasedEventState
public DetectorBasedEventState(ODEEventDetector detector)
Simple constructor.- Parameters:
detector- event detector- Since:
- 3.0
-
-
Method Detail
-
getEventDetector
public ODEEventDetector getEventDetector()
Get the underlying event detector.- Returns:
- underlying event detector
- Since:
- 3.0
-
init
public void init(ODEStateAndDerivative s0, double t)
Initialize handler at the start of an integration.This method is called once at the start of the integration. It may be used by the handler to initialize some internal data if needed.
- Specified by:
initin interfaceEventState- Parameters:
s0- initial statet- target time for the integration
-
reinitializeBegin
public void reinitializeBegin(ODEStateInterpolator interpolator) throws MathIllegalStateException
Reinitialize the beginning of the step.- Parameters:
interpolator- valid for the current step- Throws:
MathIllegalStateException- if the interpolator throws one because the number of functions evaluations is exceeded
-
evaluateStep
public boolean evaluateStep(ODEStateInterpolator interpolator) throws MathIllegalArgumentException, MathIllegalStateException
Evaluate the impact of the proposed step on the handler.- Specified by:
evaluateStepin interfaceEventState- Parameters:
interpolator- step interpolator for the proposed step- Returns:
- true if the event handler triggers an event before the end of the proposed step
- Throws:
MathIllegalArgumentException- if the event cannot be bracketedMathIllegalStateException- if the interpolator throws one because the number of functions evaluations is exceeded
-
getEventTime
public double getEventTime()
Get the occurrence time of the event triggered in the current step.- Specified by:
getEventTimein interfaceEventState- Returns:
- occurrence time of the event triggered in the current step or infinity if no events are triggered
-
tryAdvance
public boolean tryAdvance(ODEStateAndDerivative state, ODEStateInterpolator interpolator)
Try to accept the current history up to the given time.It is not necessary to call this method before calling
doEvent(ODEStateAndDerivative)with the same state. It is necessary to call this method before you calldoEvent(ODEStateAndDerivative)on some other event detector.- Parameters:
state- to try to accept.interpolator- to use to find the new root, if any.- Returns:
- if the event detector has an event it has not detected before that is on or
before the same time as
state. In other wordsfalsemeans continue on whiletruemeans stop and handle my event first.
-
doEvent
public EventOccurrence doEvent(ODEStateAndDerivative state)
Notify the user's listener of the event. The event occurs wholly within this method call including a call toODEEventHandler.resetState(ODEEventDetector, ODEStateAndDerivative)if necessary.- Specified by:
doEventin interfaceEventState- Parameters:
state- the state at the time of the event. This must be at the same time as the current value ofEventState.getEventTime().- Returns:
- the user's requested action and the new state if the action is
Action.RESET_STATE. Otherwise the new state isstate. The stop time indicates what time propagation should stop if the action isAction.STOP. This guarantees the integration will stop on or after the root, so that integration may be restarted safely.
-
-