|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnr.ode.ODE
public abstract class ODE
solves one step of an Ordinal Differential Equation. The constructor takes a vector function that returns dx/dt for a given x (note the notation here is different from Numerical Recipes chapter 16, which uses dy/dx as a function of x. The solver also takes a desired accuracy, epsilon. The interpretation of epsilon is entirely dependent on the implementation of this abstract class
Each call to the method solve(x,h) updates the vector x with the new values time h later.
Assumes dx/dt is independent of t (is a function only of x). If dxd/t is time-dependent, add a new variable to x with x[n] = start time on input and dxdt[n] = 1 always. *
Nested Class Summary | |
---|---|
static class |
ODE.Factory
an ODE factory that allows changing the algorithm. |
Field Summary | |
---|---|
static int |
MAX_ITERATIONS
|
Constructor Summary | |
---|---|
ODE(VecFunction dxdt)
Creates a new instance of ODE |
Method Summary | |
---|---|
static java.lang.String |
description()
a description of this ODE solving algorithm, for selection and display. |
double |
getEpsilon()
return the relative accuracy parameter |
double |
maxRatio(Vec numer,
Vec denom,
double max)
utility method to calculate the maximum ratio of elements of two arrays. |
static java.lang.String |
name()
the name of this ODE solving algorithm, for selection and display. |
void |
setEpsilon(double epsilon)
set the desired relative accuracy parameter. |
void |
solve(Vec x,
double endT)
solve the ODE starting from x at time 0 to time endT, updating x |
void |
solve(Vec x,
double[] h)
solve the ODE starting from x at time 0 to time less than or equal (in absolute value) to endT, updating x |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_ITERATIONS
Constructor Detail |
---|
public ODE(VecFunction dxdt)
dxdt
- the VecFunction that describes this odeMethod Detail |
---|
public void setEpsilon(double epsilon)
public double getEpsilon()
public void solve(Vec x, double endT) throws DidNotConvergeException
x
- the starting vector. On return, the ending vectorendT
- the ending time. endT is allowed to be negative.
DidNotConvergeException
- if the solver could not
converge on a solutionpublic void solve(Vec x, double[] h) throws DidNotConvergeException
x
- the starting vector. On return, the ending vector.h
- a two-element array. h[0] is the stepsize to
try initially, and h[1] is the maximum stepsize. This
routine may use any step size it wants, up to h[1]. Note that
h[0] and h[1] may be negative but both will have the same sign and
abs(h[0]) <= abs(h[1]); this is assured by the calling method.
On return, h[0] is the predicted ideal step size for the next step
and h[1] is the step actually taken
DidNotConvergeException
- if the solver could not
converge on a solutionpublic double maxRatio(Vec numer, Vec denom, double max)
numer
- the vector of numeratorsdenom
- the vector of denominatorsmax
- the minimum value to return.public static java.lang.String name()
public static java.lang.String description()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |