What has changed with Symbolics substitute? In the past, I could compose two substitutions, but that doesn’t seem to work any more.
Concretely, I consider:
Asn = substitute(As, Dict(name_s .=> s_ss)) |> x -> substitute(x, default_vals)
Here,
julia> Dict(name_s .=> s_ss)
Dict{SymbolicUtils.BasicSymbolic{Real}, Float64} with 5 entries:
md_e(t) => 2.00009
V(t) => 2.40023
m(t) => 2.40023
md_i(t) => 2.0
h(t) => 0.480045
while:
julia> default_vals = ModelingToolkit.defaults(tank)
Dict{Any, Any} with 5 entries:
h_ς => 3
K => 5
m(t) => 1.5A*ρ
A => 5
ρ => 1
It still works to do:
substitute(As, Dict(name_s .=> s_ss))
and
substitute(As, default_vals)
individually, but I cannot compose the substitutions – I get:
julia> substitute(As, Dict(name_s .=> s_ss)) |> x -> substitute(x, default_vals)
1×1 Matrix{SymbolicUtils.BasicSymbolic{Real}}:
(-K) / (2A*h_ς*sqrt(0.48004505680494347 / h_ς)*ρ)
thus the second substitution is not carried out. Similarly:
julia> substitute(As, default_vals) |> x -> substitute(x, Dict(name_s .=> s_ss))
1×1 Matrix{SymbolicUtils.BasicSymbolic{Real}}:
-1 / (6sqrt((1//3)*h(t)))
and, again, the second substitution is not carried out.
HOWEVER, if I merge the dictionaries, and only carry out one substitute, things seems to work:
julia> substitute(As, merge(default_vals, Dict(name_s .=> s_ss)))
1×1 Matrix{Float64}:
-0.41664711213839595
Question 1: What has changed wrt. substitute
?
In the past, I also needed to pipe the result through an unwrap
function. That doesn’t seem to be the case any more… In other words, in the past, I needed to do:
Asn = substitute(As, Dict(name_s .=> s_ss)) |> x -> substitute(x, default_vals) |> x -> Symbolics.unwrap.(x)
to get the proper matrix, while now, both
substitute(As, merge(default_vals, Dict(name_s .=> s_ss)))
and
substitute(As, merge(default_vals, Dict(name_s .=> s_ss))) |> x -> Symbolics.unwrap.(x)
seems to give the same result.
Question 2: Has the unwrap
function been made redundant?