Describe the bug π
The documented transfer function for FirstOrder(lowpass=false) differs from the implementation when k β
1.
The docstring gives (sT + 1 - k)/(sT + 1), but the component equations imply k*sT/(sT + 1).
These agree at the default k=1. For k=2, their DC gains are β1 and 0, respectively.
Expected behavior
The documentation and implementation should describe the same transfer function. Iβm unsure which
behavior is intended.
Minimal Reproducible Example π
using ModelingToolkit, Symbolics
using ModelingToolkit: t_nounits as t, D_nounits as D
using ModelingToolkitStandardLibrary.Blocks: FirstOrder, Constant
@named input = Constant()
@named filter = FirstOrder(lowpass=false)
@named model = System(
[connect(input.output, filter.input)], t;
systems=[input, filter],
)
eqs = equations(expand_connections(model))
rate = only(eq.rhs for eq in eqs if isequal(eq.lhs, D(filter.x)))
output = only(
eq.rhs for eq in eqs
if isequal(eq.lhs, filter.y) &&
any(v -> isequal(v, filter.x), Symbolics.get_variables(eq.rhs))
)
values = Dict(filter.u => 1, filter.x => 2, filter.k => 2, filter.T => 1)
evaluate(expr) = Symbolics.unwrap_const(Symbolics.unwrap(
Symbolics.simplify(Symbolics.substitute(expr, values))
))
@show evaluate(rate) # 0: the state is stationary
@show evaluate(output) # 0: actual output
@show (1 - 2) * 1 # -1: documented DC gain times input
Error & Stacktrace β οΈ
No exception occurs. The discrepancy is in the output:
evaluate(rate) = 0
evaluate(output) = 0
(1 - 2) * 1 = -1
Environment (please complete the following information):
Julia 1.11.9. Relevant entries from using Pkg; Pkg.status():
β [961ee093] ModelingToolkit v11.20.0
β
[16a59e39] ModelingToolkitStandardLibrary v2.29.4
β [0c5d862f] Symbolics v7.18.1
Additional context
Found using our formal property prover system.
Describe the bug π
The documented transfer function for FirstOrder(lowpass=false) differs from the implementation when k β
1.
The docstring gives (sT + 1 - k)/(sT + 1), but the component equations imply k*sT/(sT + 1).
These agree at the default k=1. For k=2, their DC gains are β1 and 0, respectively.
Expected behavior
The documentation and implementation should describe the same transfer function. Iβm unsure which
behavior is intended.
Minimal Reproducible Example π
Error & Stacktraceβ οΈ
No exception occurs. The discrepancy is in the output:
evaluate(rate) = 0
evaluate(output) = 0
(1 - 2) * 1 = -1
Environment (please complete the following information):
Julia 1.11.9. Relevant entries from using Pkg; Pkg.status():
β [961ee093] ModelingToolkit v11.20.0
β [16a59e39] ModelingToolkitStandardLibrary v2.29.4
β [0c5d862f] Symbolics v7.18.1
Additional context
Found using our formal property prover system.