Package com.imsl.math
Class ODE
java.lang.Object
com.imsl.math.ODE
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
OdeAdamsGear,OdeRungeKutta
ODE represents and solves an initial-value problem for ordinary differential
equations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUsed by methodexamineStepto indicate examining after a successful stepstatic final intUsed by methodexamineStepto indicate examining after an unsuccessful stepstatic final intUsed by methodexamineStepto indicate examining before the next stepstatic final intUsed by methodsetNormto indicate that the error norm to be used is to be the absolute error, equals \(max(|e_i|)\)static final intUsed by methodsetNormto indicate that the error norm to be used is to be the scaled Euclidean norm defined as $${s = \sqrt {\sum_{i=1}^{neq}{\frac{{e_i}^2}{{w_i}^2}}}}$$ where \(w_i = e_i/max(|y_i(t)|,1.0)\) and \(neq\) is the number of equationsstatic final intUsed by methodsetNormto indicate that the error norm to be used is to be the maximum of \(e_i/max(|y_i(t)|, floor)\) whereflooris set viasetFloorstatic final intUsed by methodsetNormto indicate that the error norm to be used is to be the minimum of the absolute error and the relative error, equals the maximum of \(e_i/max(|y_i(t)|, 1)\) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexamineStep(int state, double t, double[] y) Called before and after each internal step.doublegetFloor()Returns the value used in the norm computation.doubleReturns the initial internal step size.doubleReturns the maximum internal step size.intReturns the maximum number of internal steps allowed.doubleReturns the minimum internal step size.intgetNorm()Returns the switch for determining the error norm.doublegetScale()Returns the scaling factor.doubleReturns the error tolerance.voidsetFloor(double floor) Sets the value used in the norm computation.voidsetInitialStepsize(double stepsize) Sets the initial internal step size.voidsetMaximumStepsize(double stepsize) Sets the maximum internal step size.voidsetMaxSteps(int maxSteps) Sets the maximum number of internal steps allowed.voidsetMinimumStepsize(double stepsize) Sets the minimum internal step size.voidsetNorm(int normMethod) Sets the switch for determining the error norm.voidsetScale(double scale) Sets the scaling factor.voidsetTolerance(double tolerance) Sets the error tolerance.protected doublevnorm(double[] v, double[] y, double[] ymax) Returns the norm of a vector.
-
Field Details
-
BEFORE_STEP
public static final int BEFORE_STEPUsed by methodexamineStepto indicate examining before the next step- See Also:
-
AFTER_SUCCESSFUL_STEP
public static final int AFTER_SUCCESSFUL_STEPUsed by methodexamineStepto indicate examining after a successful step- See Also:
-
AFTER_UNSUCCESSFUL_STEP
public static final int AFTER_UNSUCCESSFUL_STEPUsed by methodexamineStepto indicate examining after an unsuccessful step- See Also:
-
ERROR_NORM_MINABSREL
public static final int ERROR_NORM_MINABSRELUsed by methodsetNormto indicate that the error norm to be used is to be the minimum of the absolute error and the relative error, equals the maximum of \(e_i/max(|y_i(t)|, 1)\)- See Also:
-
ERROR_NORM_ABS
public static final int ERROR_NORM_ABSUsed by methodsetNormto indicate that the error norm to be used is to be the absolute error, equals \(max(|e_i|)\)- See Also:
-
ERROR_NORM_MAX
public static final int ERROR_NORM_MAXUsed by methodsetNormto indicate that the error norm to be used is to be the maximum of \(e_i/max(|y_i(t)|, floor)\) whereflooris set viasetFloor- See Also:
-
ERROR_NORM_EUCLIDEAN
public static final int ERROR_NORM_EUCLIDEANUsed by methodsetNormto indicate that the error norm to be used is to be the scaled Euclidean norm defined as $${s = \sqrt {\sum_{i=1}^{neq}{\frac{{e_i}^2}{{w_i}^2}}}}$$ where \(w_i = e_i/max(|y_i(t)|,1.0)\) and \(neq\) is the number of equations- See Also:
-
-
Constructor Details
-
ODE
public ODE()
-
-
Method Details
-
examineStep
protected void examineStep(int state, double t, double[] y) Called before and after each internal step. This method can be over-ridden by the user to examine intermediate values oftandy.- Parameters:
state- anint, one ofBEFORE_STEP,AFTER_SUCCESSFUL_STEPorAFTER_UNSUCCESSFUL_STEP.t-doublerepresenting the independent variable.y-doublearray containing the dependent variables.
-
setFloor
public void setFloor(double floor) Sets the value used in the norm computation.- Parameters:
floor- adoubleused in the norm computation.floormust be greater than zero.
Default:floor= 1.0
-
setInitialStepsize
public void setInitialStepsize(double stepsize) Sets the initial internal step size.- Parameters:
stepsize- adoublespecifying the initial internal step size.stepsizemust be greater than or equal to zero. Default:stepsize= 0.0
-
setMaximumStepsize
public void setMaximumStepsize(double stepsize) Sets the maximum internal step size.- Parameters:
stepsize- adoublespecifying the maximum internal step size.stepsizemust be greater than zero.
Default: See thesetMaximumStepsizemethod in the subclasses for the default values used.
-
setMaxSteps
public void setMaxSteps(int maxSteps) Sets the maximum number of internal steps allowed.- Parameters:
maxSteps- anintspecifying the maximum number of internal steps allowed.maxStepsmust be greater than zero. Default:maxSteps= 500
-
setMinimumStepsize
public void setMinimumStepsize(double stepsize) Sets the minimum internal step size.- Parameters:
stepsize- adoublespecifying the minimum internal step size.stepsizemust be greater than or equal to zero. Default:stepsize= 0.0
-
setNorm
public void setNorm(int normMethod) Sets the switch for determining the error norm.- Parameters:
normMethod- anintspecifying the switch for determining the error norm.
Default:normMethod=ERROR_NORM_MINABSREL
In the following table, \(e_i\) is the absolute value for an estimate of the error in \(y_i(t)\).normMethod Constraint ERROR_NORM_MINABSRELMinimum of the absolute error and the relative error, equals the maximum of \(e_i/max(|y_i(t)|, 1)\) ERROR_NORM_ABSAbsolute error, equals \(max(e_i)\) ERROR_NORM_MAXMaximum of \(e_i/max(|y_i(t)|, floor)\) ERROR_NORM_EUCLIDEANScaled Euclidean norm defined as $${s = \sqrt {\sum_{i=1}^{neq}{\frac{{e_i}^2}{{w_i}^2}}}}$$ where \(w_i = e_i/max(|y_i(t)|,1.0)\) and \(neq\) is the number of equations
-
setScale
public void setScale(double scale) Sets the scaling factor.- Parameters:
scale- adoublespecifying the scaling factor.scalemust be greater than zero.
Default:scale= 1.0
-
setTolerance
public void setTolerance(double tolerance) Sets the error tolerance.- Parameters:
tolerance- adoublespecifying the error tolerance.tolerancemust be greater than zero. Default:tolerance= 1.0e-6
-
getTolerance
public double getTolerance()Returns the error tolerance.- Returns:
- a
doublespecifying the error tolerance.
-
getInitialStepsize
public double getInitialStepsize()Returns the initial internal step size.- Returns:
- a
doublespecifying the initial internal step size.
-
getMinimumStepsize
public double getMinimumStepsize()Returns the minimum internal step size.- Returns:
- a
doublespecifying the minimum internal step size.
-
getMaximumStepsize
public double getMaximumStepsize()Returns the maximum internal step size.- Returns:
- a
doublespecifying the maximum internal step size.
-
getScale
public double getScale()Returns the scaling factor.- Returns:
- a
doublespecifying the scaling factor.
-
getNorm
public int getNorm()Returns the switch for determining the error norm.- Returns:
- an
intspecifying the switch for determining the error norm. In the following, \(e_i\) is the absolute value for an estimate of the error in \(y_i(t)\).normMethod Constraint ERROR_NORM_MINABSRELMinimum of the absolute error and the relative error, equals the maximum of \(e_i/max(|y_i(t)|, 1)\) ERROR_NORM_ABSAbsolute error, equals \(max(e_i)\) ERROR_NORM_MAXMaximum of \(e_i/max(|y_i(t)|, floor)\) ERROR_NORM_EUCLIDEANScaled Euclidean norm defined as $${s = \sqrt {\sum_{i=1}^{neq}{\frac{{e_i}^2}{{w_i}^2}}}}$$ where \(w_i = e_i/max(|y_i(t)|,1.0)\) and \(neq\) is the number of equations
-
getFloor
public double getFloor()Returns the value used in the norm computation.- Returns:
- a
doubleused in the norm computation.
-
getMaxSteps
public int getMaxSteps()Returns the maximum number of internal steps allowed.- Returns:
- an
intspecifying the maximum number of internal steps allowed.
-
vnorm
protected double vnorm(double[] v, double[] y, double[] ymax) Returns the norm of a vector. This method can be over-ridden by the user to supply a different norm than those available throughsetNorm.- Parameters:
v- adoublearray containing the vector whose norm is to be computedy- adoublearray containing the values of the dependent variableymax- adoublearray containing the maximum y values computed thus far- Returns:
- a
doublescalar value representing the norm of the vector v
-