Class AdaptiveStepsizeIntegrator
- java.lang.Object
-
- org.hipparchus.ode.AbstractIntegrator
-
- org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator
-
- All Implemented Interfaces:
ODEIntegrator
- Direct Known Subclasses:
EmbeddedRungeKuttaIntegrator
,GraggBulirschStoerIntegrator
,MultistepIntegrator
public abstract class AdaptiveStepsizeIntegrator extends AbstractIntegrator
This abstract class holds the common part of all adaptive stepsize integrators for Ordinary Differential Equations.These algorithms perform integration with stepsize control, which means the user does not specify the integration step but rather a tolerance on error. The error threshold is computed as
threshold_i = absTol_i + relTol_i * max (abs (ym), abs (ym+1))
where absTol_i is the absolute tolerance for component i of the state vector and relTol_i is the relative tolerance for the same component. The user can also use only two scalar values absTol and relTol which will be used for all components.
If the Ordinary Differential Equations is an
extended ODE
rather than abasic ODE
, then only theprimary part
of the state vector is used for stepsize control, not the complete state vector.If the estimated error for ym+1 is such that
sqrt((sum (errEst_i / threshold_i)^2 ) / n) < 1
(where n is the main set dimension) then the step is accepted, otherwise the step is rejected and a new attempt is made with a new stepsize.
-
-
Constructor Summary
Constructors Constructor Description AdaptiveStepsizeIntegrator(String name, double minStep, double maxStep, double[] vecAbsoluteTolerance, double[] vecRelativeTolerance)
Build an integrator with the given stepsize bounds.AdaptiveStepsizeIntegrator(String name, double minStep, double maxStep, double scalAbsoluteTolerance, double scalRelativeTolerance)
Build an integrator with the given stepsize bounds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getMaxStep()
Get the maximal step.double
getMinStep()
Get the minimal step.protected StepsizeHelper
getStepSizeHelper()
Get the stepsize helper.double
initializeStep(boolean forward, int order, double[] scale, ODEStateAndDerivative state0)
Initialize the integration step.protected void
resetInternalState()
Reset internal state to dummy values.protected void
sanityChecks(ODEState initialState, double t)
Check the integration span.void
setInitialStepSize(double initialStepSize)
Set the initial step size.void
setStepSizeControl(double minimalStep, double maximalStep, double[] absoluteTolerance, double[] relativeTolerance)
Set the adaptive step size control parameters.void
setStepSizeControl(double minimalStep, double maximalStep, double absoluteTolerance, double relativeTolerance)
Set the adaptive step size control parameters.-
Methods inherited from class org.hipparchus.ode.AbstractIntegrator
acceptStep, addEventDetector, addStepEndHandler, addStepHandler, clearEventDetectors, clearStepEndHandlers, clearStepHandlers, computeDerivatives, getCurrentSignedStepsize, getEquations, getEvaluations, getEvaluationsCounter, getEventDetectors, getMaxEvaluations, getName, getStepEndHandlers, getStepHandlers, getStepSize, getStepStart, initIntegration, isLastStep, resetOccurred, setIsLastStep, setMaxEvaluations, setStateInitialized, setStepSize, setStepStart
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hipparchus.ode.ODEIntegrator
integrate, integrate
-
-
-
-
Constructor Detail
-
AdaptiveStepsizeIntegrator
public AdaptiveStepsizeIntegrator(String name, double minStep, double maxStep, double scalAbsoluteTolerance, double scalRelativeTolerance)
Build an integrator with the given stepsize bounds. The default step handler does nothing.- Parameters:
name
- name of the methodminStep
- minimal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than thismaxStep
- maximal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than thisscalAbsoluteTolerance
- allowed absolute errorscalRelativeTolerance
- allowed relative error
-
AdaptiveStepsizeIntegrator
public AdaptiveStepsizeIntegrator(String name, double minStep, double maxStep, double[] vecAbsoluteTolerance, double[] vecRelativeTolerance)
Build an integrator with the given stepsize bounds. The default step handler does nothing.- Parameters:
name
- name of the methodminStep
- minimal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than thismaxStep
- maximal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than thisvecAbsoluteTolerance
- allowed absolute errorvecRelativeTolerance
- allowed relative error
-
-
Method Detail
-
setStepSizeControl
public void setStepSizeControl(double minimalStep, double maximalStep, double absoluteTolerance, double relativeTolerance)
Set the adaptive step size control parameters.A side effect of this method is to also reset the initial step so it will be automatically computed by the integrator if
setInitialStepSize
is not called by the user.- Parameters:
minimalStep
- minimal step (must be positive even for backward integration), the last step can be smaller than thismaximalStep
- maximal step (must be positive even for backward integration)absoluteTolerance
- allowed absolute errorrelativeTolerance
- allowed relative error
-
setStepSizeControl
public void setStepSizeControl(double minimalStep, double maximalStep, double[] absoluteTolerance, double[] relativeTolerance)
Set the adaptive step size control parameters.A side effect of this method is to also reset the initial step so it will be automatically computed by the integrator if
setInitialStepSize
is not called by the user.- Parameters:
minimalStep
- minimal step (must be positive even for backward integration), the last step can be smaller than thismaximalStep
- maximal step (must be positive even for backward integration)absoluteTolerance
- allowed absolute errorrelativeTolerance
- allowed relative error
-
getStepSizeHelper
protected StepsizeHelper getStepSizeHelper()
Get the stepsize helper.- Returns:
- stepsize helper
- Since:
- 2.0
-
setInitialStepSize
public void setInitialStepSize(double initialStepSize)
Set the initial step size.This method allows the user to specify an initial positive step size instead of letting the integrator guess it by itself. If this method is not called before integration is started, the initial step size will be estimated by the integrator.
- Parameters:
initialStepSize
- initial step size to use (must be positive even for backward integration ; providing a negative value or a value outside of the min/max step interval will lead the integrator to ignore the value and compute the initial step size by itself)
-
sanityChecks
protected void sanityChecks(ODEState initialState, double t) throws MathIllegalArgumentException
Check the integration span.- Overrides:
sanityChecks
in classAbstractIntegrator
- Parameters:
initialState
- initial statet
- target time for the integration- Throws:
MathIllegalArgumentException
- if integration span is too small
-
initializeStep
public double initializeStep(boolean forward, int order, double[] scale, ODEStateAndDerivative state0) throws MathIllegalArgumentException, MathIllegalStateException
Initialize the integration step.- Parameters:
forward
- forward integration indicatororder
- order of the methodscale
- scaling vector for the state vector (can be shorter than state vector)state0
- state at integration start time- Returns:
- first integration step
- Throws:
MathIllegalStateException
- if the number of functions evaluations is exceededMathIllegalArgumentException
- if arrays dimensions do not match equations settings
-
resetInternalState
protected void resetInternalState()
Reset internal state to dummy values.
-
getMinStep
public double getMinStep()
Get the minimal step.- Returns:
- minimal step
-
getMaxStep
public double getMaxStep()
Get the maximal step.- Returns:
- maximal step
-
-