de.grogra.numeric
Class FirstOrderIntegratorAdapter

java.lang.Object
  extended by de.grogra.numeric.FirstOrderIntegratorAdapter
All Implemented Interfaces:
Solver

public class FirstOrderIntegratorAdapter
extends java.lang.Object
implements Solver

This class is a wrapper to Apache Commons Math. There is a subtle bug in Apache Commons Math (up to version 2.2 till now), namely if there are multiple event handlers that trigger simultaneously and one of them causes the integration to stop, then subsequent handlers will not be executed. An intrusive solution would be to modify the responsible code in Apache Commons Math, which seems to be in method acceptStep in AbstractIntegrator. A workaround is to simply always stop integration when an event triggers and handle events afterwards. This is what is implemented for now.

Author:
Reinhard Hemmerling

Field Summary
static double CONVERGENCE
           
static double MAX_CHECK_INTERVAL
           
static int MAX_ITERATION_COUNT
           
 
Constructor Summary
FirstOrderIntegratorAdapter(org.apache.commons.math.ode.FirstOrderIntegrator integrator)
           
 
Method Summary
 void integrate(ODE ode, double t0, double[] y0, double t1, double[] y)
          Integrate ode from t0 to t1.
 void setMonitor(int n, Monitor monitor)
          Set monitor functions.
 void setOptions(java.util.Map options)
          Set additional options for the integration process.
 void setTolerances(double[] absTol, double[] relTol)
          Set element-specific absolute and relative tolerance values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERGENCE

public static final double CONVERGENCE
See Also:
Constant Field Values

MAX_CHECK_INTERVAL

public static final double MAX_CHECK_INTERVAL
See Also:
Constant Field Values

MAX_ITERATION_COUNT

public static final int MAX_ITERATION_COUNT
See Also:
Constant Field Values
Constructor Detail

FirstOrderIntegratorAdapter

public FirstOrderIntegratorAdapter(org.apache.commons.math.ode.FirstOrderIntegrator integrator)
Method Detail

integrate

public void integrate(ODE ode,
                      double t0,
                      double[] y0,
                      double t1,
                      double[] y)
               throws NumericException
Description copied from interface: Solver
Integrate ode from t0 to t1. Initial state is passed in y0. Final state is stored in memory provided by y1 (can be the same as y0).

Specified by:
integrate in interface Solver
Parameters:
ode - equations
t0 - initial time
y0 - initial state
t1 - final time
y - memory to return state at t1, may refer to same object as y0
Throws:
NumericException

setMonitor

public void setMonitor(int n,
                       Monitor monitor)
Description copied from interface: Solver
Set monitor functions. A previously set monitor will be replaced by this one. A monitor can be disabled by passing zero for parameter n. The parameter monitor may be null in this case.

Specified by:
setMonitor in interface Solver

setOptions

public void setOptions(java.util.Map options)
Description copied from interface: Solver
Set additional options for the integration process. Options are provided as mapping from keys to values. Note that supported keys and the data format of associated values depends on the implementation of the solver.

Specified by:
setOptions in interface Solver

setTolerances

public void setTolerances(double[] absTol,
                          double[] relTol)
Description copied from interface: Solver
Set element-specific absolute and relative tolerance values. A value of null for either array indicates that element-specific tolerances should be disabled for this tolerance type. An value of zero in any of the arrays indicates that the integrator should provide a default tolerance value instead. Note that if any of the specified are really used is up to the implementation of the integrator.

Specified by:
setTolerances in interface Solver
Parameters:
absTol - element-specific absolute tolerance values, or null
relTol - element-specific relative tolerance values, or null