ptolemy.domains.continuous.lib
Class DifferentialSystem

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.kernel.CompositeEntity
                      extended by ptolemy.actor.CompositeActor
                          extended by ptolemy.actor.TypedCompositeActor
                              extended by ptolemy.domains.continuous.lib.DifferentialSystem
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class DifferentialSystem
extends TypedCompositeActor

A differential system in the Continuous domain.

The differential system model implements a system whose behavior is defined by:

 dx/dt = f(x, u, t)
 y = g(x, u, t)
 x(0) = x0
 
where x is the state vector, u is the input vector, and y is the output vector, t is the time. To use this actor, proceed through the following steps:

This actor is a higher-order component. Upon preinitialization, the actor will create a subsystem using integrators and expressions. These are not persistent (they are not exported in the MoML file), and will instead by created each time the actor is preinitialized.

This actor is based on the ptolemy.domain.ct.lib.DifferentialSystem actor by Jie Liu.

Since:
Ptolemy II 7.0
Version:
$Id: DifferentialSystem.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Jie Liu and Edward A. Lee
See Also:
Integrator, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (liuj)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
private  boolean _upToDate
          Flag indicating whether the contained model is up to date.
 Parameter stateVariableNames
          The names of the state variables, in an array of strings.
 Parameter t
          The value of current time.
 
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _causalityInterface, _initializables, _notifyingActorFiring, _publishedPorts, _publisherRelations, _stopRequested
 
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
 
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
 
Constructor Summary
DifferentialSystem(CompositeEntity container, java.lang.String name)
          Construct the composite actor with a name and a container.
DifferentialSystem(Workspace workspace)
          Construct a DifferentialSystem in the specified workspace with no container and an empty string as a name.
 
Method Summary
protected  void _addPort(Port port)
          Add a port to this actor.
private  void _checkParameters()
          Check the dimensions of all parameters and ports.
private  void _init()
          Initialize the class.
private  void _requestInitialization()
          Set this composite actor to opaque and request for reinitialization from the director if there is one.
 void attributeChanged(Attribute attribute)
          If the argument is any parameter other than stateVariableNames t, or any parameter matching an input port, then request reinitialization.
 void fire()
          Override the base class to first set the value of the parameter t to match current time, then to set the local parameters that mirror input values, and then to fire the contained actors.
 void preinitialize()
          Create the model inside from the parameter values.
 
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addRelation, _checkTypesFromTo, _typeConstraintsFromTo, newPort, newRelation, resolveTypes, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _getPublishedPort, _setDirector, addActorFiringListener, addInitializable, addPiggyback, clone, connectionsChanged, createReceivers, createSchedule, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isOpaque, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, recordFiring, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, wrapup
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _deepOpaqueEntityList, _description, _exportMoMLContents, _recordDecoratedAttributes, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allCompositeEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
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, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, 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

stateVariableNames

public Parameter stateVariableNames
The names of the state variables, in an array of strings. The default is an ArrayToken of an empty String.


t

public Parameter t
The value of current time. This parameter is not visible in the expression screen except in expert mode. Its value initially is just 0.0, a double, but upon each firing, it is given a value equal to the current time as reported by the director.


_upToDate

private boolean _upToDate
Flag indicating whether the contained model is up to date.

Constructor Detail

DifferentialSystem

public DifferentialSystem(CompositeEntity container,
                          java.lang.String name)
                   throws NameDuplicationException,
                          IllegalActionException
Construct the composite actor with a name and a container. This constructor creates the ports, parameters, and the icon.

Parameters:
container - The container.
name - The name.
Throws:
NameDuplicationException - If another entity already had this name.
IllegalActionException - If there was an internal problem.

DifferentialSystem

public DifferentialSystem(Workspace workspace)
                   throws IllegalActionException,
                          NameDuplicationException
Construct a DifferentialSystem in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace.

Parameters:
workspace - The workspace that will list the actor.
Throws:
IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
NameDuplicationException - If the container already contains an entity with the specified name.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
If the argument is any parameter other than stateVariableNames t, or any parameter matching an input port, then request reinitialization.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the numerator and the denominator matrix is not a row vector.

fire

public void fire()
          throws IllegalActionException
Override the base class to first set the value of the parameter t to match current time, then to set the local parameters that mirror input values, and then to fire the contained actors.

Specified by:
fire in interface Executable
Overrides:
fire in class CompositeActor
Throws:
IllegalActionException - If there is no director, or if the director's fire() method throws it, or if the actor is not opaque.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Create the model inside from the parameter values. This method gets write access on the workspace.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class CompositeActor
Throws:
IllegalActionException - If there is no director, or if any contained actors throws it in its preinitialize() method.

_addPort

protected void _addPort(Port port)
                 throws IllegalActionException,
                        NameDuplicationException
Add a port to this actor. This overrides the base class to add a parameter with the same name as the port. This parameter is not persistent and is visible only in expert mode. It will be used to mirror the values of the inputs.

Overrides:
_addPort in class TypedCompositeActor
Parameters:
port - The TypedIOPort to add to this actor.
Throws:
IllegalActionException - If the port class is not acceptable to this actor, or the port has no name.
NameDuplicationException - If the port name collides with a name already in the actor.

_checkParameters

private void _checkParameters()
                       throws IllegalActionException
Check the dimensions of all parameters and ports.

Throws:
IllegalActionException - If the dimensions are illegal.

_init

private void _init()
            throws IllegalActionException,
                   NameDuplicationException
Initialize the class.

Throws:
IllegalActionException
NameDuplicationException

_requestInitialization

private void _requestInitialization()
Set this composite actor to opaque and request for reinitialization from the director if there is one.