Skip to content

Commit 2dd943f

Browse files
committed
Delay removed from switch and moved to step (in the test)
1 parent 559b540 commit 2dd943f

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/Electrical/Analog/ideal_components.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,21 @@ R = R_const + pos * R_ref * (1 + alpha * (port.T - T_ref))
393393
end
394394

395395
"""
396-
Switch(; state_init = false, Gon = 1e5, τ = 1e-3)
396+
Switch(; Gon = 1e5, state_init = false)
397397
398398
An electrical switch that is controlled by a boolean input.
399399
400+
The switch is modelled as follows:
401+
- i = G*v
402+
- G = state*G_on
403+
- state: boolean input
404+
405+
G will therefore be 0 when the input is false [0] and G_on when the input is true [1].
406+
400407
# States
401408
402409
- See [OnePort](@ref)
403410
- `state(t)`: Boolean input
404-
- `state_filtered(t)`: Filtered delay of state(t)
405411
- `G(t)`: Conductance
406412
407413
# Connectors
@@ -412,18 +418,13 @@ An electrical switch that is controlled by a boolean input.
412418
413419
# Parameters:
414420
415-
- `state_init`: Initial switch state of type Bool. false: switch is open. true: switch is closed.
416-
- `Gon`: [`S`] Conductance when switch is closed.
417-
- `τ`: Parameter for filtered delay.
421+
- `Gon`: [`S`] Conductance when switch is closed. Value should be finite to avoid a singularity.
418422
"""
419423
@mtkmodel Switch begin
420424
@extend v, i = oneport = OnePort()
421425

422426
@parameters begin
423-
state_init = false,
424-
[description = "Initial switch state of type Bool. false: switch is open. true: switch is closed."]
425427
Gon = 1e5, [description = "Conductance when switch is closed"]
426-
τ = 1e-3, [description = "Parameter for filtered delay"]
427428
end
428429

429430
@components begin
@@ -432,14 +433,12 @@ An electrical switch that is controlled by a boolean input.
432433

433434
@variables begin
434435
state(t)::Bool
435-
state_filtered(t) = Real(state_init)
436436
G(t)
437437
end
438438

439439
@equations begin
440440
state ~ input.u
441-
D(state_filtered) ~ (state - state_filtered)/τ
442-
G ~ state_filtered*Gon
441+
G ~ state*Gon
443442
i ~ G*v
444443
end
445444
end

test/Electrical/analog.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ end
719719
end
720720

721721
@components begin
722-
step = Step(start_time = 10.0, height = true, smooth = false)
722+
step = Step(start_time = 10.0, height = true, smooth = 1e-5)
723723
switch = Switch()
724724
voltage = Voltage()
725725
resistor = Resistor(R = R)

0 commit comments

Comments
 (0)