How to get a numeric value for equations of an MTK system with given numeric inputs

Hi all, new to Julia here. I have created a decently sized MTK system out of connected components. (Thermal fluid system, components connected via ports. That part is several hundred lines of code so I don’t want to post them, as I don’t think it’s relevant to the question)

I then turn it into a NonLinearProbem and solve it.
So far so good:


@named component_a = MyCompA(; name, param1=3 ,.....)
@named component_b = MyCompB(; name, params1=7, .....)

components = [component_1, component_2, .....]
eqs = [connect(component_1, component_2)
connect(component_2, component_3) .....]

@named __sys = System(eqs, t)
@named _sys = compose(__sys, components)
sys = mtkcompile(_sys)
prob = NonlinearProblem(sys, guesses)
sol = solve(prob, alg=RobustMultiNewton())

Now, what I would like to do, is NOT solve the NonLinearProblem (yet), but just merely find the numeric value of the equations of my system, when the unknowns are set to numeric values. I would also like to find the value of the Jacobian as well

unk_vals = [component_1.a.x => 42, component_2.b.y => 34.232, .....]
eqs_vals = HowDoIdoThis(sys, unk_vals) 

Hopefully this is a well posed enough question for the board, thank you in advance.

If I understand correctly, you are maybe looking for the substitute function Expression Manipulation · Symbolics.jl

Or potentially you are looking for the model function f(u,p) for nonlinear systems and f(u,p,t) for ode systems, this can be found in prob.f, you can just evaluate it by providing the values in prob.u0 and prob.p

Thank you that was it as for getting the value of the equations. Is there a way to get the Jacobian as well?