ptolemy.domains.ct.lib
Class DifferentialSystem

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

public class DifferentialSystem
extends TypedCompositeActor

A differential system in the CT 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. Users must give the name of the variables by filling in parameters

The actor, upon creation, has no input and no output. Upon filling in the names in the inputVariableNames and outputVariableNames parameters, the ports will be created. The name of the state variables are manually added by filling in the stateVariableNames parameter.

The state equations and output maps must be manually created by users. If there are n state variables x1, ... xn, then users must create n additional parameters, one for each state equation. And the parameters must be named as: "x1_dot", ..., "xn_dot" respectively. Similarly, if the output ports have name y1, ..., yr, then users must create additional r parameters for output maps. These parameters should be named "y1", ... "yr" respectively.

This actor works like a higher-order function. Upon preinitialization, the actor will create a subsystem using integrators and expressions. After that, the actor becomes transparent, and the director takes over the control of the actors contained by this actor.

Since:
Ptolemy II 1.0
Version:
$Id: DifferentialSystem.java,v 1.37 2004/04/13 05:13:16 cxh Exp $
Author:
Jie Liu
See Also:
CTBaseIntegrator, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (liuj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
 Parameter initialStates
          The initial condition for the state variables.
 Parameter stateVariableNames
          The names of the state variables, in an array of strings.
 
Fields inherited from class ptolemy.actor.CompositeActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _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.
 
Method Summary
 void attributeChanged(Attribute attribute)
          If the argument is the initialState parameters, check that it is a row vector; Other sanity checks, like whether a differential equation matches a state variable name, are done in preinitialize() and run time.
 Director getDirector()
          Return the executive director, regardless what isOpaque returns.
 boolean isOpaque()
          Return the opaqueness of this composite actor.
 void preinitialize()
          Sanity check the parameters; if the parameters are legal create a continuous-time subsystem that implement the model, preinitialize all the actors in the subsystem, and set the opaqueness of this actor to true.
 void wrapup()
          Set the opaqueness to true and wrapup.
 
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _typeConstraintsFromTo, newPort, newRelation, resolveTypes, typeConstraintList
 
Methods inherited from class ptolemy.actor.CompositeActor
_finishedAddEntity, _setDirector, clone, connectionsChanged, fire, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newInsideReceiver, newReceiver, outputPortList, postfire, prefire, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _description, _exportMoMLContents, _removeEntity, _removeRelation, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, entityList, entityList, exportLinks, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, numberOfClassDefinitions, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _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, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, initialize, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

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.


initialStates

public Parameter initialStates
The initial condition for the state variables. This must be a vector (double matrix with only one row) whose default value is empty.

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.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
If the argument is the initialState parameters, check that it is a row vector; Other sanity checks, like whether a differential equation matches a state variable name, are done in preinitialize() and run time.

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.

getDirector

public Director getDirector()
Return the executive director, regardless what isOpaque returns.

Specified by:
getDirector in interface Actor
Overrides:
getDirector in class CompositeActor
Returns:
The director responsible for invocation of inside actors.

isOpaque

public boolean isOpaque()
Return the opaqueness of this composite actor. This actor is opaque if it has not been preinitialized after creation or changes of parameters. Otherwise, it is not opaque.

Overrides:
isOpaque in class CompositeActor

preinitialize

public void preinitialize()
                   throws IllegalActionException
Sanity check the parameters; if the parameters are legal create a continuous-time subsystem that implement the model, preinitialize all the actors in the subsystem, and set the opaqueness of this actor to true. This method need the write access on the workspace.

Specified by:
preinitialize in interface Executable
Overrides:
preinitialize in class CompositeActor
Throws:
IllegalActionException - If there is no CTDirector, or any contained actors throw it in its preinitialize() method.

wrapup

public void wrapup()
            throws IllegalActionException
Set the opaqueness to true and wrapup.

Specified by:
wrapup in interface Executable
Overrides:
wrapup in class CompositeActor
Throws:
IllegalActionException - If there is no director.