Skip to content

Commit 92c564b

Browse files
authored
Merge branch 'main' into vk/logictables
2 parents 2f22d7a + 56e4bd9 commit 92c564b

File tree

3 files changed

+42
-37
lines changed

3 files changed

+42
-37
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkitStandardLibrary"
22
uuid = "16a59e39-deab-5bd0-87e4-056b12336739"
33
authors = ["Chris Rackauckas and Julia Computing"]
4-
version = "1.10.0"
4+
version = "1.11.0"
55

66
[deps]
77
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
@@ -11,8 +11,8 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1111

1212
[compat]
1313
IfElse = "0.1"
14-
ModelingToolkit = "8"
15-
Symbolics = "4, 5"
14+
ModelingToolkit = "8.26"
15+
Symbolics = "4.9, 5"
1616
julia = "1.6"
1717

1818
[extras]

src/Blocks/continuous.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,20 +425,26 @@ end
425425
426426
A linear, time-invariant state-space system on the form.
427427
```math
428-
ẋ = Ax + Bu
429-
y = Cx + Du
428+
\\begin{aligned}
429+
ẋ &= Ax + Bu \\\\
430+
y &= Cx + Du
431+
\\end{aligned}
430432
```
431433
Transfer functions can also be simulated by converting them to a StateSpace form.
432434
433435
`y0` and `u0` can be used to set an operating point, providing them changes the dynamics from an LTI system to the affine system
434436
```math
435-
ẋ = Ax + B(u - u0)
436-
y = Cx + D(u - u0) + y0
437+
\\begin{aligned}
438+
ẋ &= Ax + B(u - u0) \\\\
439+
y &= Cx + D(u - u0) + y0
440+
\\end{aligned}
437441
```
438442
For a nonlinear system
439443
```math
440-
ẋ = f(x, u)
441-
y = h(x, u)
444+
\\begin{aligned}
445+
ẋ &= f(x, u) \\\\
446+
y &= h(x, u)
447+
\\end{aligned}
442448
```
443449
linearized around the operating point `x₀, u₀`, we have `y0, u0 = h(x₀, u₀), u₀`.
444450
"""

src/Blocks/sources.jl

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Generate sine signal.
8686
- `offset`: Offset of output signal
8787
- `start_time`: [s] Output `y = offset` for `t < start_time`
8888
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
89-
It uses a smoothing factor of `δ=1e-5`
89+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
9090
9191
# Connectors:
9292
- `output`
@@ -104,8 +104,8 @@ function Sine(; name,
104104
offset + ifelse(t < start_time, 0,
105105
amplitude * sin(2 * pi * frequency * (t - start_time) + phase))
106106
else
107-
δ = 1e-5
108-
smooth_sin(t, δ, frequency, amplitude, phase, offset, start_time)
107+
smooth === true && (smooth = 1e-5)
108+
smooth_sin(t, smooth, frequency, amplitude, phase, offset, start_time)
109109
end
110110

111111
eqs = [
@@ -125,7 +125,7 @@ Generate cosine signal.
125125
- `offset`: Offset of output signal
126126
- `start_time`: [s] Output `y = offset` for `t < start_time`
127127
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
128-
It uses a smoothing factor of `δ=1e-5`
128+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
129129
130130
# Connectors:
131131
- `output`
@@ -144,8 +144,8 @@ function Cosine(; name,
144144
offset + ifelse(t < start_time, zero(t),
145145
amplitude * cos(2 * pi * frequency * (t - start_time) + phase))
146146
else
147-
δ = 1e-5
148-
smooth_cos(t, δ, frequency, amplitude, phase, offset, start_time)
147+
smooth === true && (smooth = 1e-5)
148+
smooth_cos(t, smooth, frequency, amplitude, phase, offset, start_time)
149149
end
150150
eqs = [
151151
output.u ~ equation,
@@ -183,7 +183,7 @@ Generate ramp signal.
183183
- `offset`: Offset of output signal
184184
- `start_time`: [s] Output `y = offset` for `t < start_time`
185185
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
186-
It uses a smoothing factor of `δ=1e-5`
186+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
187187
188188
# Connectors:
189189
- `output`
@@ -201,8 +201,8 @@ function Ramp(; name,
201201
ifelse(t < (start_time + duration), (t - start_time) * height / duration,
202202
height))
203203
else
204-
δ = 1e-5
205-
smooth_ramp(t, δ, height, duration, offset, start_time)
204+
smooth === true && (smooth = 1e-5)
205+
smooth_ramp(t, smooth, height, duration, offset, start_time)
206206
end
207207

208208
eqs = [
@@ -221,15 +221,13 @@ Generate smooth square signal.
221221
- `offset`: Offset of output signal
222222
- `start_time`: [s] Output `y = offset` for `t < start_time`
223223
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
224-
It uses a smoothing factor of `δ=1e-5`
224+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
225225
226226
# Connectors:
227227
- `output`
228228
"""
229229
function Square(; name, frequency = 1.0, amplitude = 1.0,
230230
offset = 0.0, start_time = 0.0, smooth = false)
231-
δ = 1e-5
232-
233231
@named output = RealOutput()
234232
pars = @parameters begin
235233
frequency = frequency
@@ -241,8 +239,8 @@ function Square(; name, frequency = 1.0, amplitude = 1.0,
241239
equation = if smooth == false
242240
square(t, frequency, amplitude, offset, start_time)
243241
else
244-
δ = 1e-5
245-
smooth_square(t, δ, frequency, amplitude, offset, start_time)
242+
smooth === true && (smooth = 1e-5)
243+
smooth_square(t, smooth, frequency, amplitude, offset, start_time)
246244
end
247245

248246
eqs = [
@@ -262,25 +260,25 @@ Generate step signal.
262260
- `offset`: Offset of output signal
263261
- `start_time`: [s] Output `y = offset` for `t < start_time` and thereafter `offset+height`.
264262
- `duration`: [s] If `duration < Inf` is supplied, the output will revert to `offset` after `duration` seconds.
265-
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
266-
It uses a smoothing factor of `δ=1e-5`
263+
- `smooth`: If `true`, returns a smooth wave. Defaults to `true`
264+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
267265
268266
# Connectors:
269267
- `output`
270268
"""
271-
function Step(; name, height = 1, offset = 0, start_time = 0, duration = Inf, smooth = true)
269+
function Step(; name, height = 1, offset = 0, start_time = 0, duration = Inf, smooth = 1e-5)
272270
@named output = RealOutput()
273271
duration_numeric = duration
274272
pars = @parameters offset=offset start_time=start_time height=height duration=duration
275-
equation = if !smooth
273+
equation = if smooth == false # use comparison in case smooth is a float
276274
offset + ifelse((start_time < t) & (t < start_time + duration), height, 0)
277275
else
278-
δ = 1e-5
276+
smooth === true && (smooth = 1e-5)
279277
if duration_numeric == Inf
280-
smooth_step(t, δ, height, offset, start_time)
278+
smooth_step(t, smooth, height, offset, start_time)
281279
else
282-
smooth_step(t, δ, height, offset, start_time) -
283-
smooth_step(t, δ, height, 0, start_time + duration)
280+
smooth_step(t, smooth, height, offset, start_time) -
281+
smooth_step(t, smooth, height, 0, start_time + duration)
284282
end
285283
end
286284

@@ -302,7 +300,7 @@ Generate exponentially damped sine signal.
302300
- `offset`: Offset of output signal
303301
- `start_time`: [s] Output `y = offset` for `t < start_time`
304302
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
305-
It uses a smoothing factor of `δ=1e-5`
303+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
306304
307305
# Connectors:
308306
- `output`
@@ -323,8 +321,9 @@ function ExpSine(; name,
323321
amplitude * exp(-damping * (t - start_time)) *
324322
sin(2 * pi * frequency * (t - start_time) + phase))
325323
else
326-
δ = 1e-5
327-
smooth_damped_sin(t, δ, frequency, amplitude, damping, phase, offset, start_time)
324+
smooth === true && (smooth = 1e-5)
325+
smooth_damped_sin(t, smooth, frequency, amplitude, damping, phase, offset,
326+
start_time)
328327
end
329328

330329
eqs = [
@@ -343,7 +342,7 @@ Generate smooth triangular signal for frequencies less than or equal to 25 Hz
343342
- `offset`: Offset of output signal.
344343
- `start_time`: [s] Output `y = offset` for `t < start_time`
345344
- `smooth`: If `true`, returns a smooth wave. Defaults to `false`
346-
It uses a smoothing factor of `δ=1e-5`
345+
It uses a default smoothing factor of `δ=1e-5`, but this can be changed by supplying `smooth=δ`.
347346
348347
# Connectors:
349348
- `output`
@@ -361,8 +360,8 @@ function Triangular(; name, amplitude = 1.0, frequency = 1.0,
361360
equation = if smooth == false
362361
triangular(t, frequency, amplitude, offset, start_time)
363362
else
364-
δ = 1e-5
365-
smooth_triangular(t, δ, frequency, amplitude, offset, start_time)
363+
smooth === true && (smooth = 1e-5)
364+
smooth_triangular(t, smooth, frequency, amplitude, offset, start_time)
366365
end
367366

368367
eqs = [

0 commit comments

Comments
 (0)