ptolemy.domains.ct.kernel.solver
Class ExplicitRK23Solver

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

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,v 1.58.2.1 2004/07/31 16:57:57 cxh Exp $
Author:
Jie Liu
See Also:
Serialized Form
Accepted Rating:
Yellow (liuxj)
Proposed Rating:
Yellow (liuj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ExplicitRK23Solver()
          Construct a solver in the default workspace.
ExplicitRK23Solver(ptolemy.kernel.util.Workspace workspace)
          Construct a solver in the given workspace.
 
Method Summary
 int getHistoryCapacityRequirement()
          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)
          Provide the fire() method for integrators under this solver.
 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.
 boolean resolveStates()
          Advance the current time by the current step size, and resolve the state of the integrators at that time.
 
Methods inherited from class ptolemy.domains.ct.kernel.ODESolver
_makeSolverOf, _prefireIfNecessary, getContainer, getRound, incrementRound, resetRound
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setName, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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(ptolemy.kernel.util.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

getHistoryCapacityRequirement

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

Specified by:
getHistoryCapacityRequirement 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 ptolemy.kernel.util.IllegalActionException
Provide the fire() method for integrators under this solver. This performs the ODE solving algorithm.

Specified by:
integratorFire in class ODESolver
Parameters:
integrator - The integrator of that calls this method.
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director.

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.

resolveStates

public boolean resolveStates()
                      throws ptolemy.kernel.util.IllegalActionException
Advance the current time by the current step size, and resolve the state of the integrators at that time. This method always returns true since this class implements an explicit method. xIt gets the state transition schedule from the scheduler and fire for one iteration, (which consists of 4 rounds).

Specified by:
resolveStates in class ODESolver
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director, no scheduler, or one of the actors throw it in its fire() method or emitTentativeOutput() method.