Package ptolemy.domains.continuous.lib
Class DifferentialSystem
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity
-
- ptolemy.kernel.CompositeEntity
-
- ptolemy.actor.CompositeActor
-
- ptolemy.actor.TypedCompositeActor
-
- ptolemy.domains.continuous.lib.DifferentialSystem
-
- All Implemented Interfaces:
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:- For each input in u, create an input port. Each input may have any name, since you will refer to it by name rather than by the symbol u. This actor will automatically create a parameter with the same name as the input port. That parameter will have its value set during execution to match the value of the input. Note that at this time, multiport inputs are not supported.
- Fill in the stateVariableNames parameter, which is an array of strings, with the names of the state variables in x. These names can be anything you like, since you will refer them to by name rather than by the symbol x.
- For each state variable name in stateVariableNames, create a parameter with a value equal to the initial value of that particular state variable.
- Specify an update function (part of f above) for each state variable by creating a parameter named name_dot, where name is the name of the state variable. The value of this parameter should be an expression giving the rate of change of this state variable as a function of any of the state variables, any input, any other actor parameter, and (possibly), the variable t, representing current time.
- For each output in y, create an output port. The output may have any name. This actor will automatically create a parameter with the same name as the output port.
- For each parameter matching an output port, set its value to be an expression giving the output value as a function of the state variables, the inputs, any other actor parameter, and (possibly), the variable t, representing current time.
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$
- Author:
- Jie Liu and Edward A. Lee
- See Also:
Integrator
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (liuj)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description 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, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addPort(Port port)
Add a port to this actor.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, _destinationTypeConstraints, attributeTypeChanged, isBackwardTypeInferenceEnabled, newPort, newRelation, resolveTypes, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, clone, connectionsChanged, createReceivers, createSchedule, getCausalityInterface, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isOpaque, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort, wrapup
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, 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, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, clone, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
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
-
-
-
-
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.
-
-
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 classTypedCompositeActor
- 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 interfaceExecutable
- Overrides:
fire
in classCompositeActor
- 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 interfaceInitializable
- Overrides:
preinitialize
in classCompositeActor
- 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 classTypedCompositeActor
- 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.
-
-