@@ -86,7 +86,7 @@ Generate sine signal.
86
86
- `offset`: Offset of output signal
87
87
- `start_time`: [s] Output `y = offset` for `t < start_time`
88
88
- `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=δ`.
90
90
91
91
# Connectors:
92
92
- `output`
@@ -104,8 +104,8 @@ function Sine(; name,
104
104
offset + ifelse (t < start_time, 0 ,
105
105
amplitude * sin (2 * pi * frequency * (t - start_time) + phase))
106
106
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)
109
109
end
110
110
111
111
eqs = [
@@ -125,7 +125,7 @@ Generate cosine signal.
125
125
- `offset`: Offset of output signal
126
126
- `start_time`: [s] Output `y = offset` for `t < start_time`
127
127
- `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=δ`.
129
129
130
130
# Connectors:
131
131
- `output`
@@ -144,8 +144,8 @@ function Cosine(; name,
144
144
offset + ifelse (t < start_time, zero (t),
145
145
amplitude * cos (2 * pi * frequency * (t - start_time) + phase))
146
146
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)
149
149
end
150
150
eqs = [
151
151
output. u ~ equation,
@@ -183,7 +183,7 @@ Generate ramp signal.
183
183
- `offset`: Offset of output signal
184
184
- `start_time`: [s] Output `y = offset` for `t < start_time`
185
185
- `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=δ`.
187
187
188
188
# Connectors:
189
189
- `output`
@@ -201,8 +201,8 @@ function Ramp(; name,
201
201
ifelse (t < (start_time + duration), (t - start_time) * height / duration,
202
202
height))
203
203
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)
206
206
end
207
207
208
208
eqs = [
@@ -221,15 +221,13 @@ Generate smooth square signal.
221
221
- `offset`: Offset of output signal
222
222
- `start_time`: [s] Output `y = offset` for `t < start_time`
223
223
- `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=δ`.
225
225
226
226
# Connectors:
227
227
- `output`
228
228
"""
229
229
function Square (; name, frequency = 1.0 , amplitude = 1.0 ,
230
230
offset = 0.0 , start_time = 0.0 , smooth = false )
231
- δ = 1e-5
232
-
233
231
@named output = RealOutput ()
234
232
pars = @parameters begin
235
233
frequency = frequency
@@ -241,8 +239,8 @@ function Square(; name, frequency = 1.0, amplitude = 1.0,
241
239
equation = if smooth == false
242
240
square (t, frequency, amplitude, offset, start_time)
243
241
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)
246
244
end
247
245
248
246
eqs = [
@@ -262,25 +260,25 @@ Generate step signal.
262
260
- `offset`: Offset of output signal
263
261
- `start_time`: [s] Output `y = offset` for `t < start_time` and thereafter `offset+height`.
264
262
- `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=δ`.
267
265
268
266
# Connectors:
269
267
- `output`
270
268
"""
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 )
272
270
@named output = RealOutput ()
273
271
duration_numeric = duration
274
272
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
276
274
offset + ifelse ((start_time < t) & (t < start_time + duration), height, 0 )
277
275
else
278
- δ = 1e-5
276
+ smooth === true && (smooth = 1e-5 )
279
277
if duration_numeric == Inf
280
- smooth_step (t, δ , height, offset, start_time)
278
+ smooth_step (t, smooth , height, offset, start_time)
281
279
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)
284
282
end
285
283
end
286
284
@@ -302,7 +300,7 @@ Generate exponentially damped sine signal.
302
300
- `offset`: Offset of output signal
303
301
- `start_time`: [s] Output `y = offset` for `t < start_time`
304
302
- `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=δ`.
306
304
307
305
# Connectors:
308
306
- `output`
@@ -323,8 +321,9 @@ function ExpSine(; name,
323
321
amplitude * exp (- damping * (t - start_time)) *
324
322
sin (2 * pi * frequency * (t - start_time) + phase))
325
323
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)
328
327
end
329
328
330
329
eqs = [
@@ -343,7 +342,7 @@ Generate smooth triangular signal for frequencies less than or equal to 25 Hz
343
342
- `offset`: Offset of output signal.
344
343
- `start_time`: [s] Output `y = offset` for `t < start_time`
345
344
- `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=δ`.
347
346
348
347
# Connectors:
349
348
- `output`
@@ -361,8 +360,8 @@ function Triangular(; name, amplitude = 1.0, frequency = 1.0,
361
360
equation = if smooth == false
362
361
triangular (t, frequency, amplitude, offset, start_time)
363
362
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)
366
365
end
367
366
368
367
eqs = [
0 commit comments