Skip to content

Commit ca48b2c

Browse files
committed
Test
1 parent 348fef5 commit ca48b2c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ function promote_to_concrete(vs; tofloat = true, use_union = false)
541541
if Base.isconcretetype(T) && (!tofloat || T === float(T)) # nothing to do
542542
vs
543543
else
544-
sym_vs = filter(x->SymbolicUtils.issym(x) || SymbolicUtils.istree(x), vs)
544+
sym_vs = filter(x -> SymbolicUtils.issym(x) || SymbolicUtils.istree(x), vs)
545545
isempty(sym_vs) || throw_missingvars_in_sys(sym_vs)
546546
C = typeof(first(vs))
547547
I = Int8

test/components.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,33 @@ prob = ODAEProblem(sys, u0, (0, 10.0))
4646
sol = solve(prob, Rodas4())
4747
check_rc_sol(sol)
4848

49+
# https://discourse.julialang.org/t/using-optimization-parameters-in-modelingtoolkit/82099
50+
let
51+
@parameters param_r1 param_c1
52+
@named resistor = Resistor(R = param_r1)
53+
@named capacitor = Capacitor(C = param_c1)
54+
@named source = ConstantVoltage(V = 1.0)
55+
@named ground = Ground()
56+
57+
rc_eqs = [connect(source.p, resistor.p)
58+
connect(resistor.n, capacitor.p)
59+
connect(capacitor.n, source.n)
60+
connect(capacitor.n, ground.g)]
61+
62+
@named _rc_model = ODESystem(rc_eqs, t)
63+
@named rc_model = compose(_rc_model,
64+
[resistor, capacitor, source, ground])
65+
sys = structural_simplify(rc_model)
66+
u0 = [
67+
capacitor.v => 0.0,
68+
]
69+
70+
params = [param_r1 => 1.0, param_c1 => 1.0]
71+
tspan = (0.0, 10.0)
72+
73+
@test_throws Any prob=ODAEProblem(sys, u0, tspan, params)
74+
end
75+
4976
let
5077
# 1478
5178
@named resistor2 = Resistor(R = R)

0 commit comments

Comments
 (0)