public class Derivative extends TypedAtomicActor
Integratoractor 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.
|Modifier and Type||Field and Description|
The derivative output port.
The impulse output port.
The input port.
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
|Constructor and Description|
Construct a derivative actor.
|Modifier and Type||Method and Description|
Produce outputs as specified in the class comment.
Ensure that the next invocation of the fire() method is treated as a first firing.
Record the current input and time.
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, 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, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
public TypedIOPort derivative
public TypedIOPort impulse
public TypedIOPort input
public Derivative(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
public void fire() throws IllegalActionException
public void initialize() throws IllegalActionException
public boolean postfire() throws IllegalActionException