numericalMethods.calculus.odeSolving
Class Extrap

java.lang.Object
  |
  +--numericalMethods.calculus.odeSolving.Extrap
All Implemented Interfaces:
java.lang.Cloneable, OdeSolver, java.io.Serializable

public final class Extrap
extends java.lang.Object
implements OdeSolver, java.io.Serializable, java.lang.Cloneable

A program for numerical solution of a system of first order ordinary differential equations y' = f( x, y).
It uses an Extrapolation-Algorithm (GBS), based on the explicit midpoint rule (with stepsize control, order selection).

This method is described in Section II.9 of the book:
E. Hairer, S.P. Norsett and G. Wanner
Solving ordinary differential eqiations I. Nonstiff problems.
2nd edition, Springer series in computational mathematics,
Springer-Verlag (1993)

This program is a translation of the original FORTRAN code to JAVA.
The original FORTRAN code was written by E. Hairer and G. Wanner Universite de Geneve, Dept. de Mathematiques, CH-1211 Geneve 24, Switzerland
e-mail: Ernst.Hairer@math.unige.ch, Gerhard.Wanner@math.unige.ch
It is avaliable from the prof. Hairer homepage: http://www.unige.ch/math/folks/hairer/software.html

The dence output written by E. Hairer and A. Ostermann is not implemented yet. May be I will do it later.


This program has rather many tuning parameters. During instantiation the default values of the tuning parameters are set. They are good for most situations. If necessary, they can be changed using the methods setIntParameter and setDoubleParameter.

The constructor has 2 forms:
Extrap( int numberOfEquations ) -- recommended
Extrap( int numberOfEquations, int maximalNumberOfColumnsInInterpolationTable)
The variable numberOfEquations denotes the number of dependend variables in our system (the number of Y components). The variable maximalNumberOfColumnsInInterpolationTable sets the maximal possible number of extrapolation points. By default maximalNumberOfColumnsInInterpolationTable = 9.

The class has 4 methods:

void odex ( DoubleArrayValued F , double[] Y, double XEND, double[] H, double[] RTOL, double[] ATOL, int ITOL, DoubleArrayParametrized SOLOUT )
void printStatistics()
void setIntParameter ( int Number , int Parameter )
void setDoubleParameter( int Number , double Parameter )


The method odex ( DoubleArrayValued f , double[] Y, double XEND, double[] H, double[] RTOL, double[] ATOL, int ITOL, IntegerValued SOLOUT, int IOUT) calls the integrator. It has the following parameters:
DoubleArrayValued f -- an instance of user-defined class for calculating the right-hand side of the equation f(x,y).
double[] Y -- an array containing the value of the independent variable x and the values of the dependent variables y.
double XEND -- the end point of the integration interval.
double[] H -- the recommended step of integration. It will be corrected authomatiaclly during the calculation, if necessary.
double[] RTOL -- the relative error tolerance.
double[] ATOL -- the absolute error tolerance.
int ITOL -- this variable allows to chose, if the tolerances are the same for all components of the vector y, or each component has his own tolerances.
DoubleArrayParametrized SOLOUT -- an instance of user-defined class for storing or printing the calculated points.

Y is a real array with numberOfEquations + 1 elements. Before calling the method odex it shold contain the initaial value of the independent variable x: Y [ 0 ] = x and the initial values of the dependent variables y[ k ] : Y[ k ] = y[ k ] , k =1,2,...,numberOfEquations. After calling the method odex the vector containes the variables x and y[ k ] at the end of the integration interval (if the call was a success).

f is an instance of the user-defined class, calculating the right-hand side of the equation. This class should import numericalMethods.function.* and implement DoubleArrayParametrized, and DoubleArrayValued.

The integrator uses the following 2 methods from this class:

setDoubleArrayParameter( double[] Y )
getValue( double [] F )
It assumes, that after calling these 2 methods the array F contains the values of the right-hand side vector F[ k ] = f[ k ](x,y) k =1,2,...,numberOfEquations, calculated at the point x = Y[ 0 ], y[ k ] = Y[ k ]. The entry F[ 0 ] is not used by the integrator and can be set arbitrary.

XEND contains the final x-value. It should be set before calling odex.

SOLOUT is a method



The method printStatistics() prints the following infomation: how many times the right-hand side of the equation was calculated, how many steps were done, how many of them were accepeted, how many of them were rejected.
The method setIntParameter( int Number , int Parameter ) assignes the value Parameter to the array element IWORK[ Number ].
The method setDoubleParameter( int Number , double Parameter ) assignes the value Parameter to the array element WORK[ Number ].


See Also:
Serialized Form

Field Summary
protected  java.beans.PropertyChangeSupport propertyChangeSupport
           
 
Constructor Summary
Extrap()
           
Extrap(int numOfEquations)
           
Extrap(int numOfEquations, int maxTableSize)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void firePropertyChange(java.lang.String propertyName)
           
 void firePropertyChange(java.lang.String propertyName, java.lang.Object newValue, java.lang.Object oldValue)
           
 double getAbsTol()
           
 double getCurrentStepSize()
           
 int getMaxTableSize()
          returns maximal number of columns in interpolation table.
 int getNumOfEquations()
           
 double getRelTol()
           
 void odex(numericalMethods.function.DoubleArrayParametrized p, numericalMethods.function.DoubleArrayValued f, double[] Y, double xEnd)
           
 void odex(numericalMethods.function.DoubleArrayParametrized p, numericalMethods.function.DoubleArrayValued f, double[] Y, double xEnd, double[] H, double[] RTOL, double[] ATOL, int ITOL, numericalMethods.function.DoubleArrayValued solout)
           
 void odex(numericalMethods.function.DoubleArrayParametrized p, numericalMethods.function.DoubleArrayValued f, double[] Y, double xEnd, double[] H, double rtol, double atol)
           
 void odex(numericalMethods.function.DoubleArrayParametrized p, numericalMethods.function.DoubleArrayValued f, double[] Y, double xEnd, double[] H, double rtol, double atol, numericalMethods.function.DoubleArrayValued solout)
           
 void printStatistics()
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setAbsTol(double absTol)
           
 void setCurrentStepSize(double currentStepSize)
           
 void setDoubleParameter(int index, double parameter)
           
 void setIntParameter(int index, int parameter)
           
 void setMaxTableSize(int KM)
          sets the maximal number of columns in interpolation table.
 void setNumOfEquations(int numOfEquations)
           
 void setRelTol(double relTol)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyChangeSupport

protected java.beans.PropertyChangeSupport propertyChangeSupport
Constructor Detail

Extrap

public Extrap(int numOfEquations,
              int maxTableSize)

Extrap

public Extrap(int numOfEquations)

Extrap

public Extrap()
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

firePropertyChange

public void firePropertyChange(java.lang.String propertyName)

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object newValue,
                               java.lang.Object oldValue)

getNumOfEquations

public int getNumOfEquations()
Specified by:
getNumOfEquations in interface OdeSolver

setNumOfEquations

public void setNumOfEquations(int numOfEquations)
Specified by:
setNumOfEquations in interface OdeSolver

getMaxTableSize

public int getMaxTableSize()
returns maximal number of columns in interpolation table.

setMaxTableSize

public void setMaxTableSize(int KM)
sets the maximal number of columns in interpolation table.
Parameters:
KM - must be bigger then 2

getAbsTol

public double getAbsTol()

setAbsTol

public void setAbsTol(double absTol)

getRelTol

public double getRelTol()

setRelTol

public void setRelTol(double relTol)

printStatistics

public void printStatistics()

setIntParameter

public void setIntParameter(int index,
                            int parameter)

setDoubleParameter

public void setDoubleParameter(int index,
                               double parameter)

getCurrentStepSize

public double getCurrentStepSize()

setCurrentStepSize

public void setCurrentStepSize(double currentStepSize)

odex

public void odex(numericalMethods.function.DoubleArrayParametrized p,
                 numericalMethods.function.DoubleArrayValued f,
                 double[] Y,
                 double xEnd)
Specified by:
odex in interface OdeSolver

odex

public void odex(numericalMethods.function.DoubleArrayParametrized p,
                 numericalMethods.function.DoubleArrayValued f,
                 double[] Y,
                 double xEnd,
                 double[] H,
                 double rtol,
                 double atol)

odex

public void odex(numericalMethods.function.DoubleArrayParametrized p,
                 numericalMethods.function.DoubleArrayValued f,
                 double[] Y,
                 double xEnd,
                 double[] H,
                 double rtol,
                 double atol,
                 numericalMethods.function.DoubleArrayValued solout)

odex

public void odex(numericalMethods.function.DoubleArrayParametrized p,
                 numericalMethods.function.DoubleArrayValued f,
                 double[] Y,
                 double xEnd,
                 double[] H,
                 double[] RTOL,
                 double[] ATOL,
                 int ITOL,
                 numericalMethods.function.DoubleArrayValued solout)