Package com.imsl.math
Class OdeRungeKutta
java.lang.Object
com.imsl.math.ODE
com.imsl.math.OdeRungeKutta
- All Implemented Interfaces:
Serializable,Cloneable
Solves an initial-value problem for ordinary differential
equations using the Runge-Kutta-Verner fifth-order and
sixth-order method.
Class OdeRungeKutta finds an approximation to the solution
of a system of first-order differential equations of the form
\(\frac{dy}{dt} = y' = f(t,y)\) with given initial data. The class
attempts to keep the global error proportional to a user-specified tolerance.
This class is efficient for nonstiff systems where the derivative
evaluations are not expensive.
OdeRungeKutta is based on a code designed by Hull, Enright
and Jackson (1976, 1977). It uses Runge-Kutta formulas of order five and
six developed by J. H. Verner.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe iteration did not converge within the maximum number of steps allowed (default 500).static interfacePublic interface for user supplied function toOdeRungeKuttaobject.static classTolerance is too small or the problem is stiff. -
Field Summary
Fields inherited from class com.imsl.math.ODE
AFTER_SUCCESSFUL_STEP, AFTER_UNSUCCESSFUL_STEP, BEFORE_STEP, ERROR_NORM_ABS, ERROR_NORM_EUCLIDEAN, ERROR_NORM_MAX, ERROR_NORM_MINABSREL -
Constructor Summary
ConstructorsConstructorDescriptionOdeRungeKutta(OdeRungeKutta.Function function) Constructs an ODE solver to solve the initial value problem dy/dt = f(t,y) -
Method Summary
Modifier and TypeMethodDescriptionvoidsetMaximumStepsize(double stepsize) Sets the maximum internal step size.voidsolve(double t, double tEnd, double[] y) Integrates the ODE system fromttotEnd.Methods inherited from class com.imsl.math.ODE
examineStep, getFloor, getInitialStepsize, getMaximumStepsize, getMaxSteps, getMinimumStepsize, getNorm, getScale, getTolerance, setFloor, setInitialStepsize, setMaxSteps, setMinimumStepsize, setNorm, setScale, setTolerance, vnorm
-
Constructor Details
-
OdeRungeKutta
Constructs an ODE solver to solve the initial value problem dy/dt = f(t,y)- Parameters:
function- implementation of interface Function that defines the right-hand side function f(t,y)
-
-
Method Details
-
solve
public void solve(double t, double tEnd, double[] y) throws OdeRungeKutta.ToleranceTooSmallException, OdeRungeKutta.DidNotConvergeException Integrates the ODE system fromttotEnd. On all but the first call to solve, the value oftmust equal the value oftEndfrom the previous call.- Parameters:
t-doublespecifying the independent variabletEnd-doublespecifying the value oftat which the solution is desiredy- on input,doublearray containing the initial values. On output,doublearray containing the approximate solution.- Throws:
OdeRungeKutta.DidNotConvergeException- is thrown if the number of internal steps exceeds maxSteps (default 500). This can be an indication that the ODE system is stiff. This exception can also be thrown if the error tolerance condition could not be met.OdeRungeKutta.ToleranceTooSmallException- is thrown if the computation does not converge on some step.
-
setMaximumStepsize
public void setMaximumStepsize(double stepsize) Sets the maximum internal step size.- Overrides:
setMaximumStepsizein classODE- Parameters:
stepsize- adoublespecifying the maximum internal step size.stepsizemust be greater than zero. Default:stepsize= 2
-