|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jscience.mathematics.analysis.ode.AdaptiveStepsizeIntegrator
public abstract class AdaptiveStepsizeIntegrator
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 estimated error for ym+1 is such that
sqrt((sum (errEst_i / threshold_i)^2 ) / n) < 1(where n is the state vector dimension) then the step is accepted, otherwise the step is rejected and a new attempt is made with a new stepsize.
Field Summary | |
---|---|
protected StepHandler |
handler
Step handler. |
protected double |
scalAbsoluteTolerance
Allowed absolute scalar error. |
protected double |
scalRelativeTolerance
Allowed relative scalar error. |
protected SwitchingFunctionsHandler |
switchesHandler
Switching functions handler. |
protected double[] |
vecAbsoluteTolerance
Allowed absolute vectorial error. |
protected double[] |
vecRelativeTolerance
Allowed relative vectorial error. |
Constructor Summary | |
---|---|
AdaptiveStepsizeIntegrator(double minStep,
double maxStep,
double[] vecAbsoluteTolerance,
double[] vecRelativeTolerance)
Build an integrator with the given stepsize bounds. |
|
AdaptiveStepsizeIntegrator(double minStep,
double maxStep,
double scalAbsoluteTolerance,
double scalRelativeTolerance)
Build an integrator with the given stepsize bounds. |
Method Summary | |
---|---|
void |
addSwitchingFunction(SwitchingFunction function,
double maxCheckInterval,
double convergence)
Add a switching function to the integrator. |
protected double |
filterStep(double h,
boolean acceptSmall)
Filter the integration step. |
double |
getMaxStep()
Get the maximal step. |
double |
getMinStep()
Get the minimal step. |
StepHandler |
getStepHandler()
Get the step handler for this integrator. |
double |
initializeStep(FirstOrderDifferentialEquations equations,
boolean forward,
int order,
double[] scale,
double t0,
double[] y0,
double[] yDot0,
double[] y1,
double[] yDot1)
Initialize the integration step. |
abstract void |
integrate(FirstOrderDifferentialEquations equations,
double t0,
double[] y0,
double t,
double[] y)
Integrate the differential equations up to the given time |
void |
setInitialStepSize(double initialStepSize)
Set the initial step size. |
void |
setStepHandler(StepHandler handler)
Set the step handler for this integrator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jscience.mathematics.analysis.ode.FirstOrderIntegrator |
---|
getName |
Field Detail |
---|
protected double scalAbsoluteTolerance
protected double scalRelativeTolerance
protected double[] vecAbsoluteTolerance
protected double[] vecRelativeTolerance
protected StepHandler handler
protected SwitchingFunctionsHandler switchesHandler
Constructor Detail |
---|
public AdaptiveStepsizeIntegrator(double minStep, double maxStep, double scalAbsoluteTolerance, double scalRelativeTolerance)
minStep
- minimal step (must be positive even for backward
integration), the last step can be smaller than thismaxStep
- maximal step (must be positive even for backward
integration)scalAbsoluteTolerance
- allowed absolute errorscalRelativeTolerance
- allowed relative errorpublic AdaptiveStepsizeIntegrator(double minStep, double maxStep, double[] vecAbsoluteTolerance, double[] vecRelativeTolerance)
minStep
- minimal step (must be positive even for backward
integration), the last step can be smaller than thismaxStep
- maximal step (must be positive even for backward
integration)vecAbsoluteTolerance
- allowed absolute errorvecRelativeTolerance
- allowed relative errorMethod Detail |
---|
public void setInitialStepSize(double initialStepSize)
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.
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)public void setStepHandler(StepHandler handler)
setStepHandler
in interface FirstOrderIntegrator
handler
- handler for the accepted stepspublic StepHandler getStepHandler()
getStepHandler
in interface FirstOrderIntegrator
public void addSwitchingFunction(SwitchingFunction function, double maxCheckInterval, double convergence)
addSwitchingFunction
in interface FirstOrderIntegrator
function
- switching functionmaxCheckInterval
- 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 searchpublic double initializeStep(FirstOrderDifferentialEquations equations, boolean forward, int order, double[] scale, double t0, double[] y0, double[] yDot0, double[] y1, double[] yDot1) throws DerivativeException
equations
- differential equations setforward
- forward integration indicatororder
- order of the methodscale
- scaling vector for the state vectort0
- start timey0
- state vector at t0yDot0
- first time derivative of y0y1
- work array for a state vectoryDot1
- work array for the first time derivative of y1
DerivativeException
- this exception is propagated to
the caller if the underlying user function triggers oneprotected double filterStep(double h, boolean acceptSmall) throws IntegrationException
h
- signed stepacceptSmall
- if true, steps smaller than the minimal value
are silently increased up to this value, if false such small
steps generate an exception
IntegrationException
- if the step is too small and acceptSmall is falsepublic abstract void integrate(FirstOrderDifferentialEquations equations, double t0, double[] y0, double t, double[] y) throws DerivativeException, IntegrationException
FirstOrderIntegrator
integrate
in interface FirstOrderIntegrator
equations
- differential equations to integratet0
- initial timey0
- initial value of the state vector at t0t
- target time for the integration (can be set to a value smaller
thant t0
for backward integration)y
- placeholder where to put the state vector at each successful
step (and hence at the end of integration), can be the same
object as y0
DerivativeException
- this exception is propagated to the caller
if the underlying user function triggers one
IntegrationException
- if the integrator cannot perform
integrationpublic double getMinStep()
public double getMaxStep()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |