|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.domains.ct.kernel.ODESolver
public abstract class ODESolver
Abstract base class for ODE solvers. The key methods for the class
are fireDynamicActors()
and fireStateTransitionActors()
. CT directors call these methods to
resolve the initial states in a future time in the continuous phase
of execution of a complete iteration. See CTMultiSolverDirector
for explanation of initial states and phases
of executions. The process of resolving the initial states in a
future time is also known as an integration. A complete integration
is composed of one or more rounds of executions. One round of
execution consists of calling fireDynamicActors() once followed by
calling fireStateTransitionActors() once. How the states are
resolved are solver dependent. Derived classes need to implement
these methods according to their ODE solving algorithms.
The behavior of integrators also changes when changing the ODE solver, so this class provides some methods for the integrators too, including the fire() method and the step size control related methods. Here we use the strategy and delegation design patterns. CTBaseIntegrator delegates its corresponding methods to this class. And subclasses of this class provide concrete implementations of these methods.
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 retrieved by the _getRoundCount() method. The _incrementRoundCount() method will increase the counter by one, and _resetRoundCount() will always reset the counter to 0. These methods are protected because they are only used by solvers and CT directors.
In this class, two methods _isConverged
and _voteForConverged(boolean)
are defined to let CT directors know the status
of resolved states. If multiple integrators exist, only when all of
them vote true for converged, will the _isConverged() return
true. Another related method is resolveStates()
, which
always returns true in this base class. However, in the solvers
that implement the implicit solving methods, this method may return
false if the maximum number of iterations is reached but states
have not been resolved.
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.
Green (hyzheng) |
Green (hyzheng) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private CTDirector |
_director
|
private boolean |
_isConverged
|
private int |
_roundCount
|
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 | |
---|---|
ODESolver(Workspace workspace)
Construct a solver in the given workspace with a null string name. |
Method Summary | |
---|---|
protected void |
_advanceModelTime()
Advance the current model time. |
protected int |
_getRoundCount()
Return the number of the round counter. |
protected CTSchedule |
_getSchedule()
Get the current schedule. |
protected void |
_incrementRoundCount()
Increase the round counter by one. |
protected boolean |
_isConverged()
Return true if all integrators agree that the current states have converged to a fixed point. |
protected void |
_makeSolverOf(CTDirector director)
Make this solver the solver of the given Director. |
protected void |
_resetRoundCount()
Reset the round counter to 0. |
protected void |
_setConverged(boolean converged)
Set a flag to indicate whether the fixed point of states has been reached. |
protected void |
_voteForConverged(boolean converged)
An integrator calls this method to vote whether a fixed point has been reached. |
void |
fireDynamicActors()
Fire dynamic actors. |
void |
fireStateTransitionActors()
Fire state transition actors. |
abstract int |
getAmountOfHistoryInformation()
Return the amount of history information needed by this solver. |
NamedObj |
getContainer()
Return the director that contains this solver. |
abstract int |
getIntegratorAuxVariableCount()
Return the number of auxiliary variables that an integrator should provide when solving the ODE. |
abstract void |
integratorFire(CTBaseIntegrator integrator)
Perform one integration step. |
abstract boolean |
integratorIsAccurate(CTBaseIntegrator integrator)
Return true if the current integration step is accurate from the argument integrator's point of view. |
abstract double |
integratorPredictedStepSize(CTBaseIntegrator integrator)
The predictedStepSize() method of the integrator delegates to this method. |
boolean |
resolveStates()
Return true if the states of the system have been resolved successfully. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private CTDirector _director
private boolean _isConverged
private int _roundCount
Constructor Detail |
---|
public ODESolver(Workspace workspace)
workspace
- Object for synchronization and version trackingMethod Detail |
---|
public void fireDynamicActors() throws IllegalActionException
IllegalActionException
- If schedule can not be found or
dynamic actors throw it from their fire() methods.public void fireStateTransitionActors() throws IllegalActionException
CTScheduler
for
explanation of state transition actors. Derived classes may
increase the round count.
IllegalActionException
- If schedule can not be found or
state transition actors throw it from their fire() methods.public abstract int getAmountOfHistoryInformation()
public final NamedObj getContainer()
getContainer
in interface Nameable
getContainer
in class NamedObj
public abstract int getIntegratorAuxVariableCount()
public abstract void integratorFire(CTBaseIntegrator integrator) throws IllegalActionException
integrator
- The integrator that calls this method.
IllegalActionException
- Not thrown in this base class.public abstract boolean integratorIsAccurate(CTBaseIntegrator integrator)
integrator
- The integrator that calls this method.
public abstract double integratorPredictedStepSize(CTBaseIntegrator integrator)
integrator
- The integrator that calls this method.
public boolean resolveStates() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.protected void _advanceModelTime() throws IllegalActionException
IllegalActionException
- Not thrown in this abstract base class.protected int _getRoundCount()
protected CTSchedule _getSchedule() throws IllegalActionException
IllegalActionException
- If this solver is not contained by
a CT director, or the director does not have a scheduler.protected void _incrementRoundCount()
protected boolean _isConverged()
protected void _makeSolverOf(CTDirector director)
director
- The CT director that contains this solver.protected void _resetRoundCount()
protected void _setConverged(boolean converged)
This method should not be called by individual integrators. If an integrator thinks the states have not converged, it should call the _voteForConverged() method, which influences the convergence of the solver.
converged
- The flag setting._voteForConverged(boolean)
protected void _voteForConverged(boolean converged)
converged
- True if vote for convergence.integratorFire(ptolemy.domains.ct.kernel.CTBaseIntegrator)
,
_setConverged(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |