From 06de0c17b95803a490b22fe6f115b010e337c043 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Tue, 26 Sep 2023 10:04:59 -0400 Subject: [PATCH 1/2] Fix heterogeneous parameters handling for `linearize_function` Co-authored-by: Fredrik Bagge Carlson --- src/Blocks/analysis_points.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Blocks/analysis_points.jl b/src/Blocks/analysis_points.jl index a6b90866d..9b4fec8b2 100644 --- a/src/Blocks/analysis_points.jl +++ b/src/Blocks/analysis_points.jl @@ -450,10 +450,17 @@ end # Methods above are implemented in terms of linearization_function, the method below creates wrappers for linearize for f in [:get_sensitivity, :get_comp_sensitivity, :get_looptransfer] - @eval function $f(sys, ap, args...; loop_openings = nothing, kwargs...) - lin_fun, ssys = $(Symbol(string(f) * "_function"))(sys, ap, args...; loop_openings, + @eval function $f(sys, + ap, + args...; + loop_openings = nothing, + op = Dict(), + p = DiffEqBase.NullParameters(), + kwargs...) + lin_fun, ssys = $(Symbol(string(f) * "_function"))(sys, ap, args...; op, p, + loop_openings, kwargs...) - ModelingToolkit.linearize(ssys, lin_fun; kwargs...), ssys + ModelingToolkit.linearize(ssys, lin_fun; op, p, kwargs...), ssys end end From 47a07ff0e1ada83a33ca01cb10cc176dd459a053 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Tue, 26 Sep 2023 11:28:21 -0400 Subject: [PATCH 2/2] Relax tests --- test/Thermal/thermal.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Thermal/thermal.jl b/test/Thermal/thermal.jl index d8f69fd41..bf8b39383 100644 --- a/test/Thermal/thermal.jl +++ b/test/Thermal/thermal.jl @@ -240,7 +240,7 @@ end @test sol.retcode == Success @test sol[T_winding.T] == sol[winding.T] @test sol[T_core.T] == sol[core.T] - @test sol[-core.port.Q_flow] == + @test sol[-core.port.Q_flow] ≈ sol[coreLosses.port.Q_flow + convection.solid.Q_flow + winding2core.port_b.Q_flow] @test sol[T_winding.T][end] >= 500 # not good but better than nothing @test sol[T_core.T] <= sol[T_winding.T]