public class OdeRungeKutta extends ODE
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.
Modifier and Type | Class and Description |
---|---|
static class |
OdeRungeKutta.DidNotConvergeException
The iteration did not converge within the maximum number of steps allowed (default 500).
|
static interface |
OdeRungeKutta.Function
Public interface for user supplied function to
OdeRungeKutta object. |
static class |
OdeRungeKutta.ToleranceTooSmallException
Tolerance is too small or the problem is stiff.
|
AFTER_SUCCESSFUL_STEP, AFTER_UNSUCCESSFUL_STEP, BEFORE_STEP, ERROR_NORM_ABS, ERROR_NORM_EUCLIDEAN, ERROR_NORM_MAX, ERROR_NORM_MINABSREL
Constructor and Description |
---|
OdeRungeKutta(OdeRungeKutta.Function function)
Constructs an ODE solver to solve the initial value
problem dy/dt = f(t,y)
|
Modifier and Type | Method and Description |
---|---|
void |
setMaximumStepsize(double stepsize)
Sets the maximum internal step size.
|
void |
solve(double t,
double tEnd,
double[] y)
Integrates the ODE system from
t to tEnd . |
examineStep, getFloor, getInitialStepsize, getMaximumStepsize, getMaxSteps, getMinimumStepsize, getNorm, getScale, getTolerance, setFloor, setInitialStepsize, setMaxSteps, setMinimumStepsize, setNorm, setScale, setTolerance, vnorm
public OdeRungeKutta(OdeRungeKutta.Function function)
function
- implementation of interface Function
that defines the right-hand side function
f(t,y)public void solve(double t, double tEnd, double[] y) throws OdeRungeKutta.ToleranceTooSmallException, OdeRungeKutta.DidNotConvergeException
t
to tEnd
.
On all but the first call to solve, the value of t
must
equal the value of tEnd
from the previous call.t
- double
specifying the independent variabletEnd
- double
specifying the value of t
at which the
solution is desiredy
- on input, double
array containing the initial values.
On output, double
array containing the approximate solution.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.public void setMaximumStepsize(double stepsize)
setMaximumStepsize
in class ODE
stepsize
- a double
specifying the maximum internal step size. stepsize
must be
greater than zero.
Default: stepsize
= 2Copyright © 2020 Rogue Wave Software. All rights reserved.