Class 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)
    • 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​(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 TypedCompositeActor
        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.
      • _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.