Class FieldEventState<T extends RealFieldElement<T>>
- java.lang.Object
-
- org.apache.commons.math3.ode.events.FieldEventState<T>
-
- Type Parameters:
T- the type of the field elements
public class FieldEventState<T extends RealFieldElement<T>> extends java.lang.ObjectThis 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.
- Since:
- 3.6
-
-
Field Summary
Fields Modifier and Type Field Description private TconvergenceConvergence threshold for event localization.private booleanforwardIntegration direction.private Tg0Value of the events handler at the beginning of the step.private booleang0PositiveSimulated sign of g0 (we cheat when crossing events).private FieldEventHandler<T>handlerEvent handler.private booleanincreasingVariation direction around pending event.private doublemaxCheckIntervalMaximal time interval between events handler checks.private intmaxIterationCountUpper limit in the iteration count for event localization.private ActionnextActionNext action indicator.private booleanpendingEventIndicator of event expected during the step.private TpendingEventTimeOccurrence time of the pending event.private TpreviousEventTimeOccurrence time of the previous event.private BracketedRealFieldUnivariateSolver<T>solverRoot-finding algorithm to use to detect state events.private Tt0Time at the beginning of the step.
-
Constructor Summary
Constructors Constructor Description FieldEventState(FieldEventHandler<T> handler, double maxCheckInterval, T convergence, int maxIterationCount, BracketedRealFieldUnivariateSolver<T> solver)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanevaluateStep(FieldStepInterpolator<T> interpolator)Evaluate the impact of the proposed step on the event handler.TgetConvergence()Get the convergence threshold for event localization.FieldEventHandler<T>getEventHandler()Get the underlying event handler.TgetEventTime()Get the occurrence time of the event triggered in the current step.doublegetMaxCheckInterval()Get the maximal time interval between events handler checks.intgetMaxIterationCount()Get the upper limit in the iteration count for event localization.voidreinitializeBegin(FieldStepInterpolator<T> interpolator)Reinitialize the beginning of the step.FieldODEState<T>reset(FieldODEStateAndDerivative<T> state)Let the event handler reset the state if it wants.voidstepAccepted(FieldODEStateAndDerivative<T> state)Acknowledge the fact the step has been accepted by the integrator.booleanstop()Check if the integration should be stopped at the end of the current step.
-
-
-
Field Detail
-
handler
private final FieldEventHandler<T extends RealFieldElement<T>> handler
Event handler.
-
maxCheckInterval
private final double maxCheckInterval
Maximal time interval between events handler checks.
-
convergence
private final T extends RealFieldElement<T> convergence
Convergence threshold for event localization.
-
maxIterationCount
private final int maxIterationCount
Upper limit in the iteration count for event localization.
-
t0
private T extends RealFieldElement<T> t0
Time at the beginning of the step.
-
g0
private T extends RealFieldElement<T> g0
Value of the events handler at the beginning of the step.
-
g0Positive
private boolean g0Positive
Simulated sign of g0 (we cheat when crossing events).
-
pendingEvent
private boolean pendingEvent
Indicator of event expected during the step.
-
pendingEventTime
private T extends RealFieldElement<T> pendingEventTime
Occurrence time of the pending event.
-
previousEventTime
private T extends RealFieldElement<T> previousEventTime
Occurrence time of the previous event.
-
forward
private boolean forward
Integration direction.
-
increasing
private boolean increasing
Variation direction around pending event. (this is considered with respect to the integration direction)
-
nextAction
private Action nextAction
Next action indicator.
-
solver
private final BracketedRealFieldUnivariateSolver<T extends RealFieldElement<T>> solver
Root-finding algorithm to use to detect state events.
-
-
Constructor Detail
-
FieldEventState
public FieldEventState(FieldEventHandler<T> handler, double maxCheckInterval, T convergence, int maxIterationCount, BracketedRealFieldUnivariateSolver<T> solver)
Simple constructor.- Parameters:
handler- event handlermaxCheckInterval- maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)convergence- convergence threshold in the event time searchmaxIterationCount- upper limit of the iteration count in the event time searchsolver- Root-finding algorithm to use to detect state events
-
-
Method Detail
-
getEventHandler
public FieldEventHandler<T> getEventHandler()
Get the underlying event handler.- Returns:
- underlying event handler
-
getMaxCheckInterval
public double getMaxCheckInterval()
Get the maximal time interval between events handler checks.- Returns:
- maximal time interval between events handler checks
-
getConvergence
public T getConvergence()
Get the convergence threshold for event localization.- Returns:
- convergence threshold for event localization
-
getMaxIterationCount
public int getMaxIterationCount()
Get the upper limit in the iteration count for event localization.- Returns:
- upper limit in the iteration count for event localization
-
reinitializeBegin
public void reinitializeBegin(FieldStepInterpolator<T> interpolator) throws MaxCountExceededException
Reinitialize the beginning of the step.- Parameters:
interpolator- valid for the current step- Throws:
MaxCountExceededException- if the interpolator throws one because the number of functions evaluations is exceeded
-
evaluateStep
public boolean evaluateStep(FieldStepInterpolator<T> interpolator) throws MaxCountExceededException, NoBracketingException
Evaluate the impact of the proposed step on the event handler.- 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:
MaxCountExceededException- if the interpolator throws one because the number of functions evaluations is exceededNoBracketingException- if the event cannot be bracketed
-
getEventTime
public T getEventTime()
Get the occurrence time of the event triggered in the current step.- Returns:
- occurrence time of the event triggered in the current step or infinity if no events are triggered
-
stepAccepted
public void stepAccepted(FieldODEStateAndDerivative<T> state)
Acknowledge the fact the step has been accepted by the integrator.- Parameters:
state- state at the end of the step
-
stop
public boolean stop()
Check if the integration should be stopped at the end of the current step.- Returns:
- true if the integration should be stopped
-
reset
public FieldODEState<T> reset(FieldODEStateAndDerivative<T> state)
Let the event handler reset the state if it wants.- Parameters:
state- state at the beginning of the next step- Returns:
- reset state (may by the same as initial state if only derivatives should be reset), or null if nothing is reset
-
-