Integrator
Integrates the input signal with optional gain factor.
An integrator that computes the time integral of the input signal multiplied by a gain factor. The block implements the transfer function 1/s scaled by gain k.
Outputs y = ∫k*u dt
, corresponding to the transfer function \frac{1}{s}
.
This component extends from SISO
Usage
Integrator(x0=0, k=1.0)
Parameters:
Name | Description | Units | Default value |
---|---|---|---|
x0 | Initial value of the integrator state at simulation start | – | 0 |
k | Gain factor applied to the input before integration | – | 1 |
Connectors
u
- This connector represents a real signal as an input to a component (RealInput
)y
- This connector represents a real signal as an output from a component (RealOutput
)
Variables
Name | Description | Units |
---|---|---|
x | Internal state variable that stores the integrated value | – |
Behavior
Source
dyad
# Integrates the input signal with optional gain factor.
#
# An integrator that computes the time integral of the input signal multiplied by a gain factor.
# The block implements the transfer function 1/s scaled by gain k.
#
# ```math
# y(t) = \int_{t_0}^{t} k \cdot u(\tau) d\tau + x_0
# ```
#
# Outputs `y = ∫k*u dt`, corresponding to the transfer function `\frac{1}{s}`.
component Integrator
extends SISO
# Internal state variable that stores the integrated value
variable x::Real
# Initial value of the integrator state at simulation start
parameter x0::Real = 0
# Gain factor applied to the input before integration
parameter k::Real = 1.0
relations
initial x = x0
der(x) = k*u
y = x
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/Integrator.svg"}}}
end
Flattened Source
dyad
# Integrates the input signal with optional gain factor.
#
# An integrator that computes the time integral of the input signal multiplied by a gain factor.
# The block implements the transfer function 1/s scaled by gain k.
#
# ```math
# y(t) = \int_{t_0}^{t} k \cdot u(\tau) d\tau + x_0
# ```
#
# Outputs `y = ∫k*u dt`, corresponding to the transfer function `\frac{1}{s}`.
component Integrator
# Input signal port
u = RealInput() [{
"Dyad": {
"placement": {"icon": {"iconName": "input", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
}
}]
# Output signal port
y = RealOutput() [{
"Dyad": {
"placement": {"icon": {"iconName": "output", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
}
}]
# Internal state variable that stores the integrated value
variable x::Real
# Initial value of the integrator state at simulation start
parameter x0::Real = 0
# Gain factor applied to the input before integration
parameter k::Real = 1.0
relations
initial x = x0
der(x) = k*u
y = x
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/Integrator.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"