MVT API

math.numerics
Class ODE1

java.lang.Object
  |
  +--math.numerics.ODE1

public class ODE1
extends java.lang.Object

The ODE1 class contains all the methods for solving first-order Ordinary Differential Equations numerically.

Since:
JDK1.1
Author:
Peter Staab for the Mathematical Visualization Project for the Department of Applied Mathematics, University of Colorado at Boulder

Constructor Summary
ODE1()
           
 
Method Summary
 java.awt.geom.Point2D.Double[] adaptRK45()
          Solves the ODE numerically using an adaptive 4th and 5th order Runge-Kutta schemes.
 java.awt.geom.Point2D.Double[] euler()
          Solves the ODE numerically using forward Euler's method.
 double getDepIC()
          gets the initial condition for the dependent variable
 Variable getDepVar()
          gets the dependent variable for this class
 Function getFunction()
          gets the Function for this class
 double getIndIC()
          gets the initial condition for the independent variable
 double getIndMax()
          gets the max.
 Variable getIndVar()
          gets the independent variable for this class
 double getNumSteps()
          Gets the number of steps used for the solver
 double getStepSize()
          gets the step size for this class
 java.awt.geom.Point2D.Double[] huenmethod()
          Solves the ODE numerically using a Runge-Kutta 2nd order method.
 java.awt.geom.Point2D.Double[] rungeKutta4()
          Solves the ODE numerically using the standard fourth-order Runge-Kutta method.
 void setDepIC(double ic)
          sets the initial condition for the dependent variable
 void setDepVar(Variable var)
          sets the dependent variable for this class
 void setFunction(Function f)
          sets the Function for this class
 void setIndIC(double ic)
          sets the initial condition for the independent variable
 void setIndMax(double max)
          sets the max.
 void setIndVar(Variable var)
          sets the independent variable for this class
 void setNumSteps(int num)
          Sets the number of steps used for the solver
 void setStepSize(double s)
          sets the step size for this class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ODE1

public ODE1()
Method Detail

euler

public java.awt.geom.Point2D.Double[] euler()
                                     throws VariableUndefinedException,
                                            UnacceptableVariableException,
                                            InfinityException
Solves the ODE numerically using forward Euler's method. If the number of steps is negative, it uses the stepSize variable as the step size. If the number of steps is positive, it determines the step size from the number of steps.

Returns:
an array of Point2D.Double objects
Throws:
VariableUndefinedException - thrown if the independent variable or dependent variable is not one of the variables of the function.
UnacceptableVariableException - thrown if one of the variables is not of the proper form
InfinityException - thrown if the dependent variable reaches infinity or negative infinity within the domain of the independent variable.

huenmethod

public java.awt.geom.Point2D.Double[] huenmethod()
                                          throws VariableUndefinedException,
                                                 UnacceptableVariableException,
                                                 InfinityException
Solves the ODE numerically using a Runge-Kutta 2nd order method. In this case, we have chosen huen's method as the RK2 Method. If the number of steps is negative, it uses the stepSize variable as the step size. If the number of steps is positive, it determines the step size from the number of steps.

Returns:
an array of Point2D.Double objects
Throws:
VariableUndefinedException - thrown if the independent variable or dependent variable is not one of the variables of the function.
UnacceptableVariableException - thrown if one of the variables is not of the proper form
InfinityException - thrown if the dependent variable reaches infinity or negative infinity within the domain of the independent variable.

rungeKutta4

public java.awt.geom.Point2D.Double[] rungeKutta4()
                                           throws VariableUndefinedException,
                                                  UnacceptableVariableException,
                                                  InfinityException
Solves the ODE numerically using the standard fourth-order Runge-Kutta method. If the number of steps is negative, it uses the stepSize variable as the step size. If the number of steps is positive, it determines the step size from the number of steps.

Returns:
an array of Point2D.Double objects
Throws:
VariableUndefinedException - thrown if the independent variable or dependent variable is not one of the variables of the function.
UnacceptableVariableException - thrown if one of the variables is not of the proper form
InfinityException - thrown if the dependent variable reaches infinity or negative infinity within the domain of the independent variable.

adaptRK45

public java.awt.geom.Point2D.Double[] adaptRK45()
                                         throws VariableUndefinedException,
                                                UnacceptableVariableException,
                                                InfinityException,
                                                MinimumStepSizeException
Solves the ODE numerically using an adaptive 4th and 5th order Runge-Kutta schemes. See Burden and Faires, 4th Ed. for details on this algorithm.

Returns:
an array of Point2D.Double objects
Throws:
VariableUndefinedException - thrown if the independent variable or dependent variable is not one of the variables of the function.
UnacceptableVariableException - thrown if one of the variables is not of the proper form
InfinityException - thrown if the dependent variable reaches infinity or negative infinity within the domain of the independent variable.
MinimumStepSizeException

setFunction

public void setFunction(Function f)
sets the Function for this class

Parameters:
f - -- a Function object

getFunction

public Function getFunction()
gets the Function for this class

Returns:
Function -- the function representing the ODE for this class.

setStepSize

public void setStepSize(double s)
sets the step size for this class

Parameters:
s - -- a double representing the step size

getStepSize

public double getStepSize()
gets the step size for this class

Returns:
stepSize -- a double representing the step size

getIndVar

public Variable getIndVar()
gets the independent variable for this class

Returns:
indVar -- A variable representing the Independent variable

setIndVar

public void setIndVar(Variable var)
sets the independent variable for this class

Parameters:
var - -- A variable representing the Independent variable

getDepVar

public Variable getDepVar()
gets the dependent variable for this class

Returns:
depVar -- A variable representing the Independent variable

setDepVar

public void setDepVar(Variable var)
sets the dependent variable for this class

Parameters:
var - -- A variable representing the dependent variable

getIndIC

public double getIndIC()
gets the initial condition for the independent variable


setIndIC

public void setIndIC(double ic)
sets the initial condition for the independent variable


setDepIC

public void setDepIC(double ic)
sets the initial condition for the dependent variable

Parameters:
ic - -- the initial condition

getDepIC

public double getDepIC()
gets the initial condition for the dependent variable

Returns:
ic -- the initial condition for the dependent variable

getIndMax

public double getIndMax()
gets the max. value for the independent variable


setIndMax

public void setIndMax(double max)
sets the max. value for the independent variable

Parameters:
max - -- the maximum value of the domain

setNumSteps

public void setNumSteps(int num)
Sets the number of steps used for the solver


getNumSteps

public double getNumSteps()
Gets the number of steps used for the solver

Returns:
an integer representing the number of steps

MVT API

mvt.icons