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:
This component extends from Signal
Usage
Step(start_time=0.0, offset=0.0, height)
Parameters:
Name | Description | Units | Default value |
---|---|---|---|
start_time | Time at which the signal starts changing from its offset value | s | 0 |
offset | Constant value added to the signal output | – | 0 |
height | Magnitude of the step change | – |
Connectors
y
- This connector represents a real signal as an output from a component (RealOutput
)
Behavior
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"
Related
Examples
Experiments
Analyses
Tests