Skip to content

Commit 72f9197

Browse files
committed
2 parents c6387ad + 6aa59a8 commit 72f9197

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/Electrical/Analog/ideal_components.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Temperature dependent electrical resistor
210210
alpha = 0, [description = "Temperature coefficient of resistance"]
211211
end
212212
@variables begin
213-
R(t) = R_ref
213+
R(t), [guess = R_ref]
214214
end
215215
@equations begin
216216
R ~ R_ref * (1 + alpha * (heat_port.T - T_ref))

test/Blocks/test_analysis_points.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ prob = ODEProblem(ssys, Pair[], (0, 10))
130130
# sol = solve(prob, Rodas5())
131131
# plot(sol)
132132

133-
matrices, _ = get_sensitivity(sys_outer, :inner_plant_input)
133+
matrices, _ = get_sensitivity(sys_outer, sys_outer.inner.plant_input)
134134

135135
using ControlSystemsBase # This is required to simplify the results to test against known solution
136136
lsys = sminreal(ss(matrices...))
137137
@test lsys.A[] == -2
138138
@test lsys.B[] * lsys.C[] == -1 # either one negative
139139
@test lsys.D[] == 1
140140

141-
matrices_So, _ = get_sensitivity(sys_outer, :inner_plant_output)
141+
matrices_So, _ = get_sensitivity(sys_outer, sys_outer.inner.plant_output)
142142
lsyso = sminreal(ss(matrices_So...))
143143
@test lsys == lsyso || lsys == -1 * lsyso * (-1) # Output and input sensitivities are equal for SISO systems
144144

@@ -241,7 +241,6 @@ Si = ss(matrices...)
241241
t,
242242
systems = [P_inner, feedback, ref])
243243

244-
@test_nowarn Blocks.find_analysis_points(sys_inner)
245244
P_not_broken, _ = linearize(sys_inner, :u, :y)
246245
@test P_not_broken.A[] == -2
247246
P_broken, _ = linearize(sys_inner, :u, :y, loop_openings = [:u])
@@ -265,9 +264,9 @@ Sinner = sminreal(ss(get_sensitivity(sys_inner, :u)[1]...))
265264
t,
266265
systems = [P_outer, sys_inner])
267266

268-
Souter = sminreal(ss(get_sensitivity(sys_outer, :sys_inner_u)[1]...))
267+
Souter = sminreal(ss(get_sensitivity(sys_outer, sys_outer.sys_inner.u)[1]...))
269268

270-
Sinner2 = sminreal(ss(get_sensitivity(sys_outer, :sys_inner_u, loop_openings = [:y2])[1]...))
269+
Sinner2 = sminreal(ss(get_sensitivity(sys_outer, sys_outer.sys_inner.u, loop_openings = [:y2])[1]...))
271270

272271
@test Sinner.nx == 1
273272
@test Sinner == Sinner2
@@ -333,7 +332,7 @@ eqs = [connect(r.output, F.input)
333332
connect(F.output, sys_inner.add.input1)]
334333
sys_outer = ODESystem(eqs, t, systems = [F, sys_inner, r], name = :outer)
335334

336-
matrices, _ = get_sensitivity(sys_outer, [:inner_plant_input, :inner_plant_output])
335+
matrices, _ = get_sensitivity(sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output])
337336

338337
Ps = tf(1, [1, 1]) |> ss
339338
Cs = tf(1) |> ss
@@ -347,7 +346,7 @@ So = CS.feedback(1, Ps * Cs)
347346
@test tf(G[1, 2]) tf(-CS.feedback(Cs, Ps))
348347
@test tf(G[2, 1]) tf(CS.feedback(Ps, Cs))
349348

350-
matrices, _ = get_comp_sensitivity(sys_outer, [:inner_plant_input, :inner_plant_output])
349+
matrices, _ = get_comp_sensitivity(sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output])
351350

352351
G = CS.ss(matrices...) |> sminreal
353352
Ti = CS.feedback(Cs * Ps)
@@ -360,23 +359,23 @@ To = CS.feedback(Ps * Cs)
360359

361360
# matrices, _ = get_looptransfer(sys_outer, [:inner_plant_input, :inner_plant_output])
362361
matrices, _ = get_looptransfer(
363-
sys_outer, :inner_plant_input)
362+
sys_outer, sys_outer.inner.plant_input)
364363
L = CS.ss(matrices...) |> sminreal
365364
@test tf(L) -tf(Cs * Ps)
366365

367366
matrices, _ = get_looptransfer(
368-
sys_outer, :inner_plant_output)
367+
sys_outer, sys_outer.inner.plant_output)
369368
L = CS.ss(matrices...) |> sminreal
370369
@test tf(L[1, 1]) -tf(Ps * Cs)
371370

372371
# Calling looptransfer like below is not the intended way, but we can work out what it should return if we did so it remains a valid test
373-
matrices, _ = get_looptransfer(sys_outer, [:inner_plant_input, :inner_plant_output])
372+
matrices, _ = get_looptransfer(sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output])
374373
L = CS.ss(matrices...) |> sminreal
375374
@test tf(L[1, 1]) tf(0)
376375
@test tf(L[2, 2]) tf(0)
377376
@test sminreal(L[1, 2]) ss(-1)
378377
@test tf(L[2, 1]) tf(Ps)
379378

380-
matrices, _ = linearize(sys_outer, [:inner_plant_input], [:inner_plant_output])
379+
matrices, _ = linearize(sys_outer, [sys_outer.inner.plant_input], [sys_outer.inner.plant_output])
381380
G = CS.ss(matrices...) |> sminreal
382381
@test tf(G) tf(CS.feedback(Ps, Cs))

test/multi_domain.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ end
196196

197197
@mtkbuild sys = ElHeatingCircuit()
198198

199-
prob = ODEProblem(sys, unknowns(sys) .=> 0.0, (0, 6.0))
199+
prob = ODEProblem(sys, [], (0, 6.0); guesses = [sys.heating_resistor.i => 0.0])
200200
sol = solve(prob, Rodas4())
201201
@test sol.retcode == Success
202202
@test sol[sys.source.v * sys.source.i] == -sol[sys.env.port.Q_flow]

0 commit comments

Comments
 (0)