ptolemy.domains.ct.kernel.solver
Class ExplicitRK23Solver

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.domains.ct.kernel.ODESolver
          extended by ptolemy.domains.ct.kernel.solver.ExplicitRK23Solver
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class ExplicitRK23Solver
extends ODESolver

This class implements the Explicit Runge-Kutta 2(3) ODE solving method. For an ODE of the form:

 dx/dt = f(x, t), x(0) = x0
 
it does the following:
 K0 = f(x(n), tn);
 K1 = f(x(n)+0.5*h*K0, tn+0.5*h);
 K2 = f(x(n)+0.75*h*K1, tn+0.75*h);
 x(n+1) = x(n)+(2/9)*h*K0+(1/3)*h*K0+(4/9)*h*K2;
 
, and error control:
 K3 = f(x(n+1), tn+h);
 LTE = h*[(-5.0/72.0)*K0 + (1.0/12.0)*K1 + (1.0/9.0)*K2 + (-1.0/8.0)*K3]
 

If the LTE is less than the error tolerance, then this step is considered successful, and the next integration step is predicted as:

 h' = 0.8*Math.pow((ErrorTolerance/LTE), 1.0/3.0)
 
This is a second order method, but uses a third order procedure to estimate the local truncation error.

Since:
Ptolemy II 0.2
Version:
$Id: ExplicitRK23Solver.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Jie Liu, Haiyang Zheng
See Also:
Serialized Form
Accepted Rating:
Green (hyzheng)
Proposed Rating:
Green (hyzheng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private static double[][] _B
           
private static java.lang.String _DEFAULT_NAME
           
private static double[] _E
           
private static int _order
           
private static double[] _timeInc
           
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ExplicitRK23Solver()
          Construct a solver in the default workspace.
ExplicitRK23Solver(Workspace workspace)
          Construct a solver in the given workspace.
 
Method Summary
protected  void _advanceModelTime()
          Override the method in the base abstract class to advance the model time.
 void fireStateTransitionActors()
          Fire state transition actors.
 int getAmountOfHistoryInformation()
          Return 0 to indicate that no history information is needed by this solver.
 int getIntegratorAuxVariableCount()
          Return 4 to indicate that four auxiliary variables are needed by this solver.
 void integratorFire(CTBaseIntegrator integrator)
          Fire the given integrator.
 boolean integratorIsAccurate(CTBaseIntegrator integrator)
          Return true if the integration is accurate for the given integrator.
 double integratorPredictedStepSize(CTBaseIntegrator integrator)
          Provide the predictedStepSize() method for the integrators under this solver.
 
Methods inherited from class ptolemy.domains.ct.kernel.ODESolver
_getRoundCount, _getSchedule, _incrementRoundCount, _isConverged, _makeSolverOf, _resetRoundCount, _setConverged, _voteForConverged, fireDynamicActors, getContainer, resolveStates
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateExistence, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_DEFAULT_NAME

private static final java.lang.String _DEFAULT_NAME
See Also:
Constant Field Values

_timeInc

private static final double[] _timeInc

_B

private static final double[][] _B

_E

private static final double[] _E

_order

private static final int _order
See Also:
Constant Field Values
Constructor Detail

ExplicitRK23Solver

public ExplicitRK23Solver()
Construct a solver in the default workspace. The solver is added to the list of objects in the workspace. Increment the version number of the workspace. The name of the solver is set to "CT_Runge_Kutta_2_3_Solver".


ExplicitRK23Solver

public ExplicitRK23Solver(Workspace workspace)
Construct a solver in the given workspace. If the workspace argument is null, use the default workspace. The director is added to the list of objects in the workspace. Increment the version number of the workspace. The name of the solver is set to "CT_Runge_Kutta_2_3_Solver".

Parameters:
workspace - Object for synchronization and version tracking.
Method Detail

fireStateTransitionActors

public void fireStateTransitionActors()
                               throws IllegalActionException
Fire state transition actors. Increment the round count. If the current round is the third round, set converged flag to true indicating a fixed-point states have been reached. Reset the round count if the current round is the last one.

Overrides:
fireStateTransitionActors in class ODESolver
Throws:
IllegalActionException - If thrown in the super class.

getAmountOfHistoryInformation

public final int getAmountOfHistoryInformation()
Return 0 to indicate that no history information is needed by this solver.

Specified by:
getAmountOfHistoryInformation in class ODESolver
Returns:
0.

getIntegratorAuxVariableCount

public final int getIntegratorAuxVariableCount()
Return 4 to indicate that four auxiliary variables are needed by this solver.

Specified by:
getIntegratorAuxVariableCount in class ODESolver
Returns:
4.

integratorFire

public void integratorFire(CTBaseIntegrator integrator)
                    throws IllegalActionException
Fire the given integrator. This method performs the ODE solving algorithm described in the class comment.

Specified by:
integratorFire in class ODESolver
Parameters:
integrator - The integrator of that calls this method.
Throws:
IllegalActionException - If there is no director, or can not read input, or can not send output.

integratorIsAccurate

public boolean integratorIsAccurate(CTBaseIntegrator integrator)
Return true if the integration is accurate for the given integrator. This estimates the local truncation error for that integrator and compare it with the error tolerance.

Specified by:
integratorIsAccurate in class ODESolver
Parameters:
integrator - The integrator of that calls this method.
Returns:
True if the integration is successful.

integratorPredictedStepSize

public double integratorPredictedStepSize(CTBaseIntegrator integrator)
Provide the predictedStepSize() method for the integrators under this solver. It uses the algorithm in the class comments to predict the next step size based on the current estimation of the local truncation error.

Specified by:
integratorPredictedStepSize in class ODESolver
Parameters:
integrator - The integrator of that calls this method.
Returns:
The next step size suggested by the given integrator.

_advanceModelTime

protected void _advanceModelTime()
                          throws IllegalActionException
Override the method in the base abstract class to advance the model time. The amount of the increment is decided by the number of the round counter and the current step size. In particular, at the first round, time is incremented by 1/2 of the current step size; at the second round, time is incremented by another 1/4 of the current step size; in the third round, time gets incremented by the last 1/4 of the current step size.

Overrides:
_advanceModelTime in class ODESolver
Throws:
IllegalActionException - If thrown in the super class or the model time can not be set.