|
|||||||||
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.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.ct.kernel.CTBaseIntegrator
public class CTBaseIntegrator
The base class for integrators in the continuous-time (CT) domain. An integrator has one input port and one output port. Conceptually, the input is the derivative of the output w.r.t. time. So an ordinary differential equation (ODE) dx/dt = f(x, t) can be built by:
+---------------+ dx/dt | | x +--------->| Integrator |---------+-----> | | | | | +---------------+ | | | | |---------| | +-------------| f(x, t) |<-----------+ |---------|
An integrator is a dynamic actor that can emit a token (a state) at a time without knowing the input at that time. An integrator is a step size control actor that can control the accuracy of the ODE solution by adjusting step sizes. An integrator has memory, which is its state.
To help solving the ODE, a set of internal variables are used:
state: This is the value of the state variable at a time point,
which has beed confirmed by all the step size control actors.
tentative state: This is the value of the state variable
which has not been confirmed. It is a starting point for other actors
to estimate the accuracy of this integration step.
history: The previous states and their derivatives. History may
be used by multistep integration methods.
For different ODE solving methods, the functionality of an integrator may be different. The delegation and strategy design patterns are used in this class, basic abstract ODESolver class, and the concrete ODE solver classes. Some solver-dependent methods of integrators delegate to the concrete ODE solvers.
An integrator has one parameter: the initialState. At the initialization stage of the simulation, the state of the integrator is set to the initial state. Changes of the initialState made during execution cause the state to be reset to the specified value. The default value of the parameter is 0.0 of type double.
An integrator can possibly have several auxiliary variables for the the ODE solvers to use. The number of the auxiliary variables is checked before each iteration. The ODE solver class provides the number of variables needed for that particular solver. The auxiliary variables can be set and get by setAuxVariables() and getAuxVariables() methods.
ODESolver
,
CTDirector
,
Serialized Form
Red (yuhong) |
Yellow (hyzheng) |
Nested Class Summary | |
---|---|
private static class |
CTBaseIntegrator.DoubleDouble
A data structure for storing two double numbers. |
protected class |
CTBaseIntegrator.History
The history information, state and derivatives, at equidistance past time points. |
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private double[] |
_auxVariables
|
private double |
_derivative
|
protected CTBaseIntegrator.History |
_history
The history of states and their derivative. |
private double |
_state
|
private double |
_storedState
|
private boolean |
_successful
|
private double |
_tentativeDerivative
|
private double |
_tentativeState
|
Parameter |
initialState
The initial state of type DoubleToken. |
TypedIOPort |
input
The input port. |
TypedIOPort |
output
The output port. |
Fields inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
CTBaseIntegrator(CompositeEntity container,
java.lang.String name)
Construct an integrator, with a name and a container. |
Method Summary | |
---|---|
void |
attributeChanged(Attribute attribute)
If the specified attribute is initialState, then reset the state of the integrator to its value. |
void |
clearHistory()
Clear the history information. |
void |
emitCurrentStates()
Emit the tentative output, which is the current state of the integrator. |
void |
fire()
Delegate to the integratorFire() method of the current ODE solver. |
double[] |
getAuxVariables()
Return the auxiliary variables in a double array. |
double |
getDerivative()
Return the derivative of the latest updated resolved state. |
double[] |
getHistory(int index)
Return the history information of the last index-th step. |
int |
getHistoryCapacity()
Return the history capacity. |
double |
getState()
Return the state of the integrator. |
double |
getTentativeDerivative()
Return the tentative derivative. |
double |
getTentativeState()
Return the tentative state. |
int |
getValidHistoryCount()
Return the number of valid history entries. |
void |
goToMarkedState()
Go to the marked state. |
void |
initialize()
Initialize the integrator. |
boolean |
isOutputAccurate()
Always return true because an integrator's output is always accurate no matter what step size is chosen. |
boolean |
isStateAccurate()
Return true if the state is resolved successfully. |
void |
markState()
Mark and remember the current state. |
boolean |
postfire()
Update the state and its derivative, and push them into history if the history capacity is bigger than 0. |
double |
predictedStepSize()
Return the predicted next step size. |
boolean |
prefire()
Setup the integrator to operate with the current ODE solver. |
void |
preinitialize()
Override the base class to declare that the output does not depend on the input in a firing. |
double |
refinedStepSize()
Return the estimation of the refined next step size. |
void |
setAuxVariables(int index,
double value)
Set the value of an auxiliary variable. |
void |
setHistoryCapacity(int cap)
Set history capacity. |
void |
setTentativeDerivative(double value)
Set the tentative derivative, dx/dt. |
void |
setTentativeState(double value)
Set the tentative state. |
Methods inherited from class ptolemy.actor.TypedAtomicActor |
---|
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints |
Methods inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, removeInitializable, wrapup |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, removeInitializable, wrapup |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, removeInitializable, wrapup |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
public TypedIOPort input
public TypedIOPort output
public Parameter initialState
protected CTBaseIntegrator.History _history
private double[] _auxVariables
private double _derivative
private double _state
private double _storedState
private boolean _successful
private double _tentativeDerivative
private double _tentativeState
Constructor Detail |
---|
public CTBaseIntegrator(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name.
NameDuplicationException
- If the name is used by another
actor in the container.
IllegalActionException
- If ports can not be created, or
thrown by the super class.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that has changed.
IllegalActionException
- If the new parameter value
is not valid.public void clearHistory()
public void emitCurrentStates() throws IllegalActionException
emitCurrentStates
in interface CTDynamicActor
IllegalActionException
- If the data transfer can not be
completed.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor
IllegalActionException
- If thrown by integratorFire()
of the solver.public double[] getAuxVariables()
setAuxVariables(int, double)
public final double getDerivative()
public double[] getHistory(int index)
index
- The index.
public final int getHistoryCapacity()
setHistoryCapacity(int)
public final double getState()
public double getTentativeDerivative()
setTentativeDerivative(double)
public double getTentativeState()
setTentativeState(double)
public final int getValidHistoryCount()
public void goToMarkedState()
goToMarkedState
in interface CTStatefulActor
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor
IllegalActionException
- If there's no director,
or, the director is not a CT director, or the director has
no ODE solver, or thrown in the super class, or the initialState
parameter does not contain a valid token.public boolean isOutputAccurate()
isOutputAccurate
in interface CTStepSizeControlActor
public boolean isStateAccurate()
isStateAccurate
in interface CTStepSizeControlActor
public void markState()
markState
in interface CTStatefulActor
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor
IllegalActionException
- Not thrown in this base class.public double predictedStepSize()
predictedStepSize
in interface CTStepSizeControlActor
public boolean prefire() throws IllegalActionException
This method also adjusts the history information w.r.t. the current ODE solver and the current step size.
prefire
in interface Executable
prefire
in class AtomicActor
IllegalActionException
- If there's no director or
the director has no ODE solver.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class AtomicActor
IllegalActionException
- If the superclass throws it.public double refinedStepSize()
refinedStepSize
in interface CTStepSizeControlActor
public void setAuxVariables(int index, double value) throws InvalidStateException
index
- The index in the auxVariables array.value
- The value to be set.
InvalidStateException
- If the index is out of the range
of the auxiliary variable array.getAuxVariables()
public final void setHistoryCapacity(int cap)
cap
- The capacity.getHistoryCapacity()
public final void setTentativeDerivative(double value)
value
- The value to be set.getTentativeDerivative()
public final void setTentativeState(double value)
value
- The value to be set.getTentativeState()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |