Skip to content

Commit 0068343

Browse files
committed
refactor: use @structural_parameters to pass functions to StaticNonLinearity, TimeVaryingFunction
1 parent a79497f commit 0068343

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Blocks/math.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ If the given function is not composed of simple core methods (e.g. sin, abs, ...
221221
- `output`
222222
"""
223223
@mtkmodel StaticNonLinearity begin
224-
@parameters begin
224+
@structural_parameters begin
225225
func
226226
end
227227
@extend u, y = siso = SISO()
228228
@equations begin
229-
y ~ first(getdefault(func))(u)
229+
y ~ func(u)
230230
end
231231
end
232-
StaticNonLinearity.f(func; name) = StaticNonLinearity.f(; name = name, func = [func])
232+
StaticNonLinearity.f(func; name) = StaticNonLinearity(; func, name)
233233

234234
"""
235235
Abs(; name)

src/Blocks/sources.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ The input variable `t` can be changed by passing a different variable as the key
9797
- `output`
9898
"""
9999
@mtkmodel TimeVaryingFunction begin
100-
@parameters begin
100+
@structural_parameters begin
101101
f
102102
end
103103
@components begin
104104
output = RealOutput()
105105
end
106106
@equations begin
107-
output.u ~ first(getdefault(f))(t)
107+
output.u ~ f(t)
108108
end
109109
end
110-
TimeVaryingFunction.f(f; name) = TimeVaryingFunction.f(; f = [f], name)
110+
TimeVaryingFunction.f(f; name) = TimeVaryingFunction(; f, name)
111111

112112
"""
113113
Sine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,

0 commit comments

Comments
 (0)