rkm
Class RKModel

java.lang.Object
  extended by rkm.RKModel

public class RKModel
extends java.lang.Object

Runge-Kutta algorithm for solving initial value problems. This class takes care of all calculations and remembers the state of the model.


Constructor Summary
RKModel(ODE ode, ButcherMatrix bm)
          Create a new model to solve the given ODE using the given ButcherMatrix.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Add a ChangeListener.
 void fireStateChanged(javax.swing.event.ChangeEvent e)
          Notify all ChangeListeners.
 ButcherMatrix getButcherMatrix()
           
 java.awt.geom.Point2D getEndPoint()
           
 double getError()
           
 int getInnerStagesDone()
           
 ODE getODE()
           
 java.awt.geom.Point2D[] getSamplePoints()
           
 double[] getSamples()
           
 java.awt.geom.Point2D getStartPoint()
           
 rkm.State getState()
           
 double getStepSize()
           
 double getWeightedSamples()
           
 boolean hasInnerStagesRemaining()
           
 boolean init(double x0, double y0, double h)
          Initialize the algoritm with the given initial values.
 void nextInnerStage()
          Sets the state of the model one inner stage further.
 void outerStage()
          Sets the state of the model to indicate that the outer stage is done.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Remove a ChangeListener.
 void setButcherMatrix(ButcherMatrix bm)
          Set the ButcherMatrix to use.
 void setODE(ODE ode)
          Set the ODE to solve.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RKModel

public RKModel(ODE ode,
               ButcherMatrix bm)
Create a new model to solve the given ODE using the given ButcherMatrix. The default ODE is ExampleODE1, the default ButcherMatrix is ForwardEuler.

Method Detail

getODE

public ODE getODE()
Returns:
the ODE that is being solved.

setODE

public void setODE(ODE ode)
Set the ODE to solve. This will reset the model. The default ODE is ExampleODE1 (used if the argument is null).


getButcherMatrix

public ButcherMatrix getButcherMatrix()
Returns:
the ButcherMatrix that is in use.

setButcherMatrix

public void setButcherMatrix(ButcherMatrix bm)
Set the ButcherMatrix to use. This will reset the model. The default ButcherMatrix is ForwardEuler (used if the argument is null).


init

public boolean init(double x0,
                    double y0,
                    double h)
Initialize the algoritm with the given initial values. After this step (if successful) all results are available, regardless of the state of the model.

Returns:
false if the given values are invalid or cannot be used.

hasInnerStagesRemaining

public boolean hasInnerStagesRemaining()
Returns:
whether there are inner stages remaining.

nextInnerStage

public void nextInnerStage()
Sets the state of the model one inner stage further.


outerStage

public void outerStage()
Sets the state of the model to indicate that the outer stage is done.


getState

public rkm.State getState()
Returns:
the state of the model.

getInnerStagesDone

public int getInnerStagesDone()
Returns:
the number of inner stages done.

getStartPoint

public java.awt.geom.Point2D getStartPoint()
Returns:
the initial values used as a starting point.

getEndPoint

public java.awt.geom.Point2D getEndPoint()
Returns:
the approximated solution point.

getStepSize

public double getStepSize()
Returns:
the step size used.

getError

public double getError()
Returns:
the absolute error in the approximated solution point.

getSamplePoints

public java.awt.geom.Point2D[] getSamplePoints()
Returns:
the points in which the slope samples were calculated.

getSamples

public double[] getSamples()
Returns:
the slope samples.

getWeightedSamples

public double getWeightedSamples()
Returns:
a weighted average of slope samples.

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Add a ChangeListener.


removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Remove a ChangeListener.


fireStateChanged

public void fireStateChanged(javax.swing.event.ChangeEvent e)
Notify all ChangeListeners.