Skip to content
Step.md

Step

Generates a step signal that transitions from offset to height+offset at the specified time.

The step component produces an output y that changes from the offset value to height+offset when the simulation time reaches start_time. This provides a way to model abrupt changes in signals for testing system responses. The behavior is defined by the equation:

y={height+offsetif timestart_timeoffsetotherwise

This component extends from Signal

Usage

Step(start_time=0.0, offset=0.0, height)

Parameters:

NameDescriptionUnitsDefault value
start_timeTime at which the signal starts changing from its offset values0
offsetConstant value added to the signal output0
heightMagnitude of the step change

Connectors

  • y - This connector represents a real signal as an output from a component (RealOutput)

Behavior

y(t)=ifelse(tstart_time,height+offset,offset)

Source

dyad
# Generates a step signal that transitions from `offset` to `height+offset` at the specified time.
#
# The step component produces an output y that changes from the `offset` value to `height+offset`
# when the simulation time reaches `start_time`. This provides a way to model abrupt changes
# in signals for testing system responses. The behavior is defined by the equation:
#
# ```math
# y = \begin{cases}
# \text{height} + \text{offset} & \text{if time} \geq \text{start\_time} \\
# \text{offset} & \text{otherwise}
# \end{cases}
# ```
component Step
  extends Signal
  # Magnitude of the step change
  parameter height::Real
relations
  y = if time>=start_time then height+offset else offset
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/Step.svg"}}}
end
Flattened Source
dyad
# Generates a step signal that transitions from `offset` to `height+offset` at the specified time.
#
# The step component produces an output y that changes from the `offset` value to `height+offset`
# when the simulation time reaches `start_time`. This provides a way to model abrupt changes
# in signals for testing system responses. The behavior is defined by the equation:
#
# ```math
# y = \begin{cases}
# \text{height} + \text{offset} & \text{if time} \geq \text{start\_time} \\
# \text{offset} & \text{otherwise}
# \end{cases}
# ```
component Step
  # Real-valued output connector for the component
  y = RealOutput() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
  # Time at which the signal starts changing from its offset value
  parameter start_time::Time = 0.0
  # Constant value added to the signal output
  parameter offset::Real = 0.0
  # Magnitude of the step change
  parameter height::Real
relations
  y = if time>=start_time then height+offset else offset
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/Step.svg"}}}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using BlockComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(BlockComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/BlockComponents/77kIK/test/snapshots"