ptolemy.domains.continuous.kernel
Class ContinuousODESolver

java.lang.Object
  extended by ptolemy.domains.continuous.kernel.ContinuousODESolver
Direct Known Subclasses:
ExplicitRK23Solver, ExplicitRK45Solver

public abstract class ContinuousODESolver
extends java.lang.Object

Abstract base class for ODE solvers. A complete integration consists of one or more rounds of executions. One round of execution requires the model time to be advanced and this advancement is handled by the Continuous director. Derived classes need to tell how many rounds of execution are necessary and how much time to advance for each round.

How many rounds are needed in one integration is solver dependent. For some solving algorithms, (i.e. the so called explicit methods) the number of rounds is fixed. For some others (i.e. implicit methods), the number of rounds can not be decided beforehand.

A round counter is a counter for the number of rounds in one integration. It helps the solvers to decide how to behave under different rounds. The round counter can be increated by the calling the _incrementRound() method. The _reset() method always resets the counter to 0. These methods are protected because they are only used by Continuous directors.

Conceptually, ODE solvers do not maintain simulation parameters, like step sizes and error tolerance. They get these parameters from the director. So the same set of parameters are shared by all the solvers in a simulation.

Since:
Ptolemy II 6.0
Version:
$Id: ContinuousODESolver.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Haiyang Zheng, Edward A. Lee
Accepted Rating:
Green (hyzheng)
Proposed Rating:
Green (hyzheng)

Field Summary
protected  ContinuousDirector _director
          The Continuous director that contains this solver.
 
Constructor Summary
ContinuousODESolver()
           
 
Method Summary
protected  void _debug(java.lang.String message)
          Report a debug message via the director.
protected abstract  int _getRound()
          Return the current round.
protected abstract  double _getRoundTimeIncrement()
          Get the current round factor.
protected  boolean _isDebugging()
          Return true if debugging is turned on in the director.
protected abstract  boolean _isStepFinished()
          Return true if the current integration step is finished.
protected  void _makeSolverOf(ContinuousDirector director)
          Make this solver the solver of the given Director.
protected abstract  void _reset()
          Reset the solver, indicating to it that we are starting an integration step.
protected abstract  void _setRound(int round)
          Set the round for the next integration step.
abstract  int getIntegratorAuxVariableCount()
          Return the number of auxiliary variables that an integrator should provide when solving the ODE.
abstract  void integratorIntegrate(ContinuousIntegrator integrator)
          Perform one integration step.
abstract  boolean integratorIsAccurate(ContinuousIntegrator integrator)
          Return true if the current integration step is accurate from the argument integrator's point of view.
abstract  double integratorSuggestedStepSize(ContinuousIntegrator integrator)
          The suggestedStepSize() method of the integrator delegates to this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_director

protected ContinuousDirector _director
The Continuous director that contains this solver.

Constructor Detail

ContinuousODESolver

public ContinuousODESolver()
Method Detail

getIntegratorAuxVariableCount

public abstract int getIntegratorAuxVariableCount()
Return the number of auxiliary variables that an integrator should provide when solving the ODE. Auxiliary variables are variables in integrators to store integrator-dependent intermediate results when solving an ODE.
For example, the fixed-step solvers need 0 auxiliary variable, but the RK23 solver needs 4 auxiliary variables to store the temporary derivatives at different time points during an integration.

Returns:
The number of auxiliary variables.

integratorIntegrate

public abstract void integratorIntegrate(ContinuousIntegrator integrator)
                                  throws IllegalActionException
Perform one integration step. The fire() method of integrators delegates to this method. Derived classes need to implement the details. This method does not produce any outputs.

Parameters:
integrator - The integrator that calls this method.
Throws:
IllegalActionException - Not thrown in this base class.

integratorIsAccurate

public abstract boolean integratorIsAccurate(ContinuousIntegrator integrator)
Return true if the current integration step is accurate from the argument integrator's point of view. The isStepSizeAccurate() method of integrators delegates to this method. Derived classes need to implement the details.

Parameters:
integrator - The integrator that calls this method.
Returns:
True if the integrator finds the step accurate.

integratorSuggestedStepSize

public abstract double integratorSuggestedStepSize(ContinuousIntegrator integrator)
The suggestedStepSize() method of the integrator delegates to this method. Derived classes need to implement the details.

Parameters:
integrator - The integrator that calls this method.
Returns:
The suggested next step size by the given integrator.

_debug

protected final void _debug(java.lang.String message)
Report a debug message via the director.

Parameters:
message - The message.

_getRoundTimeIncrement

protected abstract double _getRoundTimeIncrement()
Get the current round factor. If the rounds are finished, then return 1.0.

Returns:
The current round factor.
See Also:
_isStepFinished()

_getRound

protected abstract int _getRound()
Return the current round.

Returns:
The current round.

_isDebugging

protected final boolean _isDebugging()
Return true if debugging is turned on in the director.

Returns:
True if debugging is turned on.

_isStepFinished

protected abstract boolean _isStepFinished()
Return true if the current integration step is finished. For example, solvers with a fixed number of rounds in an integration step will return true when that number of rounds are complete. Solvers that iterate to a solution will return true when the solution is found.

Returns:
Return true if the solver has finished an integration step.

_makeSolverOf

protected final void _makeSolverOf(ContinuousDirector director)
Make this solver the solver of the given Director. This method should only be called by CT directors, when they instantiate solvers according to the ODESolver parameters.

Parameters:
director - The CT director that contains this solver.

_reset

protected abstract void _reset()
Reset the solver, indicating to it that we are starting an integration step. This method also sets a flag indicating that we have not converged to a solution if the ODE solver is implicit.


_setRound

protected abstract void _setRound(int round)
Set the round for the next integration step. This must be between zero and the value returned by getIntegratorAuxVariableCount().

Parameters:
round - The round for the next integration step.
See Also:
getIntegratorAuxVariableCount()