org.simulator.math.odes
Class RosenbrockSolver

java.lang.Object
  extended by org.simulator.math.odes.AbstractDESSolver
      extended by org.simulator.math.odes.AdaptiveStepsizeIntegrator
          extended by org.simulator.math.odes.RosenbrockSolver
All Implemented Interfaces:
java.io.Serializable, org.apache.commons.math.ode.events.EventHandler, DelayValueHolder, DESSolver

public class RosenbrockSolver
extends AdaptiveStepsizeIntegrator

RosenbrockSolver implements the Rosenbrock method to approximate ODE solutions.

References: William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery. Numerical recipes in C. Cambridge Univ. Press Cambridge, 1992, pp. 738-747.

This solver has been adapted from ODE Toolkit: a free application for solving systems of ordinary differential equations.

Since:
0.9
Version:
$Rev: 146 $
Author:
Chris Moore, Roland Keller
See Also:
Serialized Form

Field Summary
static double a21
          Constants for solving
static double a31
          Constants for solving
static double a32
          Constants for solving
static double a41
          Constants for solving
static double a42
          Constants for solving
static double a43
          Constants for solving
static double a51
          Constants for solving
static double a52
          Constants for solving
static double a53
          Constants for solving
static double a54
          Constants for solving
static double c2
          Constants for solving
static double c21
          Constants for solving
static double c3
          Constants for solving
static double c31
          Constants for solving
static double c32
          Constants for solving
static double c4
          Constants for solving
static double c41
          Constants for solving
static double c42
          Constants for solving
static double c43
          Constants for solving
static double c51
          Constants for solving
static double c52
          Constants for solving
static double c53
          Constants for solving
static double c54
          Constants for solving
static double c61
          Constants for solving
static double c62
          Constants for solving
static double c63
          Constants for solving
static double c64
          Constants for solving
static double c65
          Constants for solving
static double d1
           
static double d2
           
static double d3
           
static double d4
           
(package private)  double[] DFDX
          helper array to hold intermediate values
(package private)  double[][] FAC
          helper array to hold intermediate values
static double fac1
          Constants used to adapt the stepsize according to the error in the last step (see rodas.f)
static double fac2
          Constants used to adapt the stepsize according to the error in the last step (see rodas.f)
(package private)  double[] g0
          helper array to hold intermediate values
(package private)  double[] g1
          helper array to hold intermediate values
(package private)  double[] g1x
          helper array to hold intermediate values
(package private)  double[] g2
          helper array to hold intermediate values
(package private)  double[] g2x
          helper array to hold intermediate values
static double gam
          Constants for solving
(package private)  double hAdap
          factor used for adjusting the step size, divide current step size by hAdap to get new step size
(package private)  double[][] I
          helper array to hold intermediate values
(package private)  int[] indx
          helper array to hold intermediate values
(package private)  double[][] JAC
          helper array to hold intermediate values
(package private)  int numEqn
          The number of equations
static double PWR
          Constants used to adapt the stepsize according to the error in the last step (see rodas.f)
static double RELMIN
          the minimum acceptable value of relTol - attempts to obtain higher accuracy than this are usually very expensive
static double SAFETY
          Constants used to adapt the stepsize according to the error in the last step (see rodas.f)
(package private)  double sk
          factor for calculating error value used in adjusting step size
(package private)  boolean stop
          Keep track whether the thread is killed or not
(package private)  double[] ya
          helper array to hold intermediate values
(package private)  double[] yb
          helper array to hold intermediate values
(package private)  double[] yNew
          array that is y with approximated errors added on, used for comparing y to y+yerr
(package private)  double[] yTemp
          helper array to hold intermediate values
 
Fields inherited from class org.simulator.math.odes.AdaptiveStepsizeIntegrator
absTol, relTol
 
Fields inherited from class org.simulator.math.odes.AbstractDESSolver
listenerList
 
Fields inherited from interface org.apache.commons.math.ode.events.EventHandler
CONTINUE, RESET_DERIVATIVES, RESET_STATE, STOP
 
Constructor Summary
RosenbrockSolver()
          default constructor
RosenbrockSolver(int size, double stepsize)
           
RosenbrockSolver(RosenbrockSolver solver)
          clone constructor
 
Method Summary
 AbstractDESSolver clone()
           
 double[] computeChange(DESystem DES, double[] y2, double time, double currentStepSize, double[] change, boolean steadyState)
          Computes the change for a given system at the current time with the current setting for the integration step size.
 java.lang.String getName()
          This gives a human-readable name of this solver that can be displayed in a graphical user interface.
 int getNumEquations()
           
protected  boolean hasSolverEventProcessing()
           
 double step(DESystem DES)
          This function tries to make a time step.
 double unitRoundoff()
          Returns an approximation to the error involved with the current arithmetic implementation
 
Methods inherited from class org.simulator.math.odes.AdaptiveStepsizeIntegrator
getAbsTol, getRelTol, setAbsTol, setRelTol
 
Methods inherited from class org.simulator.math.odes.AbstractDESSolver
additionalResults, addPropertyChangeListener, checkSolution, checkSolution, computeDelayedValue, computeNextState, eventOccurred, firePropertyChange, g, getSerialversionuid, getStepSize, inBetweenSteps, initResultMatrix, initResultMatrix, initResultMatrix, isIncludeIntermediates, isNonnegative, isUnstable, numSteps, processEvents, processEventsAndRules, processRules, removePropertyChangeListener, reset, resetState, setIncludeIntermediates, setNonnegative, setStepSize, setUnstableFlag, solve, solve, solve, solve
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAFETY

public static final double SAFETY
Constants used to adapt the stepsize according to the error in the last step (see rodas.f)

See Also:
Constant Field Values

fac1

public static final double fac1
Constants used to adapt the stepsize according to the error in the last step (see rodas.f)

See Also:
Constant Field Values

fac2

public static final double fac2
Constants used to adapt the stepsize according to the error in the last step (see rodas.f)

See Also:
Constant Field Values

PWR

public static final double PWR
Constants used to adapt the stepsize according to the error in the last step (see rodas.f)

See Also:
Constant Field Values

c2

public static final double c2
Constants for solving

See Also:
Constant Field Values

c3

public static final double c3
Constants for solving

See Also:
Constant Field Values

c4

public static final double c4
Constants for solving

See Also:
Constant Field Values

a21

public static final double a21
Constants for solving

See Also:
Constant Field Values

a31

public static final double a31
Constants for solving

See Also:
Constant Field Values

a32

public static final double a32
Constants for solving

See Also:
Constant Field Values

a41

public static final double a41
Constants for solving

See Also:
Constant Field Values

a42

public static final double a42
Constants for solving

See Also:
Constant Field Values

a43

public static final double a43
Constants for solving

See Also:
Constant Field Values

a51

public static final double a51
Constants for solving

See Also:
Constant Field Values

a52

public static final double a52
Constants for solving

See Also:
Constant Field Values

a53

public static final double a53
Constants for solving

See Also:
Constant Field Values

a54

public static final double a54
Constants for solving

See Also:
Constant Field Values

gam

public static final double gam
Constants for solving

See Also:
Constant Field Values

c21

public static final double c21
Constants for solving

See Also:
Constant Field Values

c31

public static final double c31
Constants for solving

See Also:
Constant Field Values

c32

public static final double c32
Constants for solving

See Also:
Constant Field Values

c41

public static final double c41
Constants for solving

See Also:
Constant Field Values

c42

public static final double c42
Constants for solving

See Also:
Constant Field Values

c43

public static final double c43
Constants for solving

See Also:
Constant Field Values

c51

public static final double c51
Constants for solving

See Also:
Constant Field Values

c52

public static final double c52
Constants for solving

See Also:
Constant Field Values

c53

public static final double c53
Constants for solving

See Also:
Constant Field Values

c54

public static final double c54
Constants for solving

See Also:
Constant Field Values

c61

public static final double c61
Constants for solving

See Also:
Constant Field Values

c62

public static final double c62
Constants for solving

See Also:
Constant Field Values

c63

public static final double c63
Constants for solving

See Also:
Constant Field Values

c64

public static final double c64
Constants for solving

See Also:
Constant Field Values

c65

public static final double c65
Constants for solving

See Also:
Constant Field Values

d1

public static final double d1
See Also:
Constant Field Values

d2

public static final double d2
See Also:
Constant Field Values

d3

public static final double d3
See Also:
Constant Field Values

d4

public static final double d4
See Also:
Constant Field Values

RELMIN

public static final double RELMIN
the minimum acceptable value of relTol - attempts to obtain higher accuracy than this are usually very expensive

See Also:
Constant Field Values

sk

double sk
factor for calculating error value used in adjusting step size


hAdap

double hAdap
factor used for adjusting the step size, divide current step size by hAdap to get new step size


numEqn

int numEqn
The number of equations


yNew

double[] yNew
array that is y with approximated errors added on, used for comparing y to y+yerr


yTemp

double[] yTemp
helper array to hold intermediate values


ya

double[] ya
helper array to hold intermediate values


yb

double[] yb
helper array to hold intermediate values


g0

double[] g0
helper array to hold intermediate values


g1

double[] g1
helper array to hold intermediate values


g2

double[] g2
helper array to hold intermediate values


g1x

double[] g1x
helper array to hold intermediate values


g2x

double[] g2x
helper array to hold intermediate values


DFDX

double[] DFDX
helper array to hold intermediate values


indx

int[] indx
helper array to hold intermediate values


JAC

double[][] JAC
helper array to hold intermediate values


FAC

double[][] FAC
helper array to hold intermediate values


I

double[][] I
helper array to hold intermediate values


stop

boolean stop
Keep track whether the thread is killed or not

Constructor Detail

RosenbrockSolver

public RosenbrockSolver()
default constructor

Parameters:
size -
stepsize -

RosenbrockSolver

public RosenbrockSolver(int size,
                        double stepsize)
Parameters:
size -
stepsize -

RosenbrockSolver

public RosenbrockSolver(RosenbrockSolver solver)
clone constructor

Parameters:
solver -
Method Detail

clone

public AbstractDESSolver clone()
Specified by:
clone in interface DESSolver
Specified by:
clone in class AbstractDESSolver
Returns:
the cloned solver

step

public double step(DESystem DES)
            throws org.apache.commons.math.ode.DerivativeException
This function tries to make a time step.

Parameters:
the - differential equation system
Returns:
the error
Throws:
org.apache.commons.math.ode.DerivativeException

unitRoundoff

public double unitRoundoff()
Returns an approximation to the error involved with the current arithmetic implementation

Returns:
the approximation as described above

getName

public java.lang.String getName()
Description copied from class: AbstractDESSolver
This gives a human-readable name of this solver that can be displayed in a graphical user interface.

Specified by:
getName in class AbstractDESSolver
Returns:
A name that describes the underlying algorithm.

getNumEquations

public int getNumEquations()
Returns:
the number of equations in the system

computeChange

public double[] computeChange(DESystem DES,
                              double[] y2,
                              double time,
                              double currentStepSize,
                              double[] change,
                              boolean steadyState)
                       throws org.apache.commons.math.ode.DerivativeException
Description copied from class: AbstractDESSolver
Computes the change for a given system at the current time with the current setting for the integration step size.

Specified by:
computeChange in class AbstractDESSolver
Parameters:
DES - The system to be simulated.
y2 - The current state of the system.
time - The current simulation time.
change - The vector for the resulting change of the system.
Returns:
The change.
Throws:
org.apache.commons.math.ode.DerivativeException

hasSolverEventProcessing

protected boolean hasSolverEventProcessing()
Specified by:
hasSolverEventProcessing in class AbstractDESSolver
Returns:
Does the solver do the event processing itself?