As mentioned here [MTK -- how to set initial unknowns introduced by MTK?] and here [GitHub · Where software is built], there are many cases where it is helpful to specify initial equations, i.e. specifying initial values is insufficient (or at least inconvenient).
I see here [Initialization of ODESystems · ModelingToolkit.jl] that it is possible to pass initial equations to the ODEProblem. However, is it possible to specify initial equations as a macro?
As an example, this works:
begin
fluid_model = outlet.fluid_model
ρ_init = calc_prop(h_init, p_init, "HmassP_INPUTS", "D", fluid_model)
u_init = h_init - p_init/ρ_init
end
@variables begin
h(t) = h_init
p(t) = p_init
ρ(t) = ρ_init
m(t)
u(t) = u_init
Dm(t)
end
But this would be more idiomatic, especially for those coming from Modelica: Is something like this possible?
@variables begin
h(t) = h_init
p(t) = p_init
ρ(t)
m(t)
u(t)
Dm(t)
end
@initialization_eqs begin
ρ ~ calc_prop(h_init, p_init, "HmassP_INPUTS", "D", fluid_model)
u ~ h_init - p_init/ρ
end
This is probably a trivial example, as the initial equations are linear. However any advice would be appreciated.