Evolution of Components

In Causal, the simulation of a model is performed by individual evolution of components (see Modeling and Simulation for more information of modeling and simulation adopted in Causal). Basically, when triggered through its trigger pin, based on its type, a component takes a forward step as follows,

  1. The next clock time t is read from its trigger pin.
  2. The next input value u(t) is read from from its input port,
  3. The component evolves from its current time t - dt to the current clock time t
  4. Using the state variable x(t) at time t, current clock time t and u(t), the next output value y(t) is computed.
  5. The component writes true to its handshake pin to signal that taking step is performed with success.

or a backward step as follows.

  1. The next clock time t is read from its trigger pin.
  2. Using the state variable x(t - dt) at time t - dt, current component time t - dt and u(t - dt), the next output value y(t) is computed.
  3. The next input value u(t) is read from from its input port,
  4. The component evolves from its current time t - dt to the current clock time t
  5. The component writes true to its handshake pin to signal that taking step is performed with success.

Here dt is the simulation step size.

Reading Time

Reading State

Causal.readstateFunction
readstate(comp)

Returns the state of comp if comp is AbstractDynamicSystem. Otherwise, returns nothing.

source

Reading Input

Writing Output

Causal.writeoutput!Function
writeoutput!(comp, out)

Writes out to the output of comp if the output of comp is Outport. Otherwise, does nothing.

source

Computing Output

Causal.computeoutputFunction

Computes the output of comp according to its readout if readout is not nothing. Otherwise, nothing is done. x is the state, u is the value of input, t is the time.

source

Evolve

Causal.evolve!Function
evolve!(comp::AbstractSource, u, t)

Does nothing. u is the value of input and t is time.

evolve!(comp::AbstractSink, u, t)

Writes t to time buffer timebuf and u to databuf of comp. u is the value of input and t is time.

evolve!(comp::AbstractStaticSystem, u, t)

Writes u to buffer of comp if comp is an AbstractMemory. Otherwise, nothing is done. u is the value of input and t is time.

evolve!(comp::AbstractDynamicSystem, u, t)

Solves the differential equation of the system of comp for the time interval (comp.t, t) for the inital condition x where x is the current state of comp . u is the input function defined for (comp.t, t). The comp is updated with the computed state and time t.

source

Taking Steps

Causal.forwardstepFunction
forwardstep(comp, t)

Makes comp takes a forward step. The input value u and state x of comp are read. Using x, u and time t, comp is evolved. The output y of comp is computed and written into the output bus of comp.

source
Causal.backwardstepFunction
backwardstep(comp, t)

Reads the state x. Using the time t and x, computes and writes the ouput value y of comp. Then, the input value u is read and comp is evolved.

source
Causal.approve!Function
approve!(comp)

Read handshake link of comp. When not approved or false is read from the handshake link, the task launched for the trigger link of comp gets stuck during comp is taking step.

source
approve!(comp)

Approves comp by approving each subcomponent of comp. See also: approve!(comp::AbstractComponent)

source
Causal.terminate!Function
terminate!(comp)

Closes the trigger link and output bus of comp.

source
terminate!(comp)

Terminates comp by terminating each subcomponent of comp. See also: terminate!(comp::AbstractComponent)

source
terminate!(model)

Terminates model by terminating all the components of the model, i.e., the components tasks in the task manager of the model is terminated.

source