Class Derivative

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class Derivative
    extends TypedAtomicActor
    A crude approximation to a derivative in the continuous domain. In continuous-time modeling, one should generally avoid taking derivatives directly. It is better to use an Integrator actor in a feedback loop. The input to the Integrator is the derivative of its output. The reason for avoiding taking derivatives directly is that small amounts of noise on the input of a derivative actor result in large output fluctuations. Since continuous-time simulation involves choosing step sizes, the choice of step size will strongly affect the resulting output of the derivative. Derivatives tend to be very noisy, with considerable fluctuations in value. Moreover, if the input to this actor has discontinuities, the output will not be piecewise continuous, and at the discontinuity, the results could be difficult to control. If an Integrator is downstream, then the solver will be forced to use its smallest step size.

    That said, if you have read this far, you are probably determined to compute a derivative. Hence, we provide this actor, which performs a simple operation and provides a simple (partial) guarantee. Specifically, a correctly connected Derivative followed by an Integrator is (almost) an identity function. And an Integrator followed by a Derivative is also (almost) an identity function. The reason for the "almost" is that very first derivative output of the Derivative actor is always zero. Determining a derivative without any past history requires seeing the future. Although in principle it might be possible for this actor to collaborate with the solver to speculatively execute into the future to get the derivative, we have not done that here.

    Upon firing, this actor produces an output on the derivative port, and may also produce an output on the impulse port. The derivative output value is the difference between the input at the current time and the previous input divided by the time between these inputs, unless that time is zero. If the time between this input and the previous one is zero, and the value of the previous input and the current one is non-zero, then this actor will be produce the value difference on the impulse output and will produce whatever it previously produced on the derivative output.

    On the very first firing after being initialized, this actor always produces zero on the derivative output. If the input is non-zero, then it will produce the value of the input on the impulse output. This ensures that if the impulse output is connected to the impulse input of a downstream Integrator, that the Integrator will be correctly initialized.

    The impulse output should be interpreted as a Dirac delta function. It is a discrete output. If it is connected to the impulse input of the Integrator actor, and the derivative output is connected to the derivative input of the Integrator actor, then the cascade of two actors will be an identity function for all input signals.

    If upon any firing the input is absent, then both outputs will be absent, and the actor will reinitialize. Hence, on the next firing where the input is present, this actor will behave as if that firing is a first firing.

    Note that this actor exercises no control at all over step sizes. It simply works with whatever step sizes are provided. Thus, it is mathematically questionable to use it in any model except where its input comes from an Integrator or its outputs go to an Integrator. The Integrator actor will exercise control over step sizes.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Edward A. Lee and Janette Cardoso
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)