How to print ODEs after create ODEProblem

Hi everyone,
I would like to ask how to print the equations of the system after creating a problem by function ODEProblem() following:

sys = ODESystem(eqs)
prob = ODEProblem(sys,u0,tspan)

I tried to use the equations(prob), but I got the message:

MethodError: no method matching equations(::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x1c387064, 0x74ec2d83, 0x8ad760c2, 0xdb0e98f0, 0xabc816c2), Expr}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x53ba6645, 0x88658262, 0xed4600ac, 0xd28f2b69, 0x1d18b114), Expr}}, Matrix{Float64}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#565#generated_observed#528"{Bool, ODESystem, Dict{Any, Any}}, Nothing, ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem})

Please help me on how could I print the equations of system?

Try instead:

equations(sys)

I think sys is the symbolic form of the equations, while prob is the symbolic equations converted to a numeric form.

So, If I want to show the equations in numeric form after creating an ODE problem, there are any functions to do that?

What do you mean/expect when you say “equations in numeric form”? I should say that when I write “equations in numeric form”, I don’t really mean equations. I should probably have said a data structure containing conversion of the mathematical equations into a Julia function, in combination with initial states, time span, model parameters, etc.

I’m not a developer, so I don’t know the inner workings of this. The only thing that might be of interest (to me, i.e.), would be to learn how MTK converts symbolic equations into a function containing the model, similar to the function you have to write “manually” if you instead code the function yourself. Anyways, this is not something I would care to do. I think MTK has a method that converts a manually written function of ODEs/DAEs into an MTK model. I don’t know whether there is a method that does the inverse.

OK – seems like you can do:

modelingtoolkitize(prob)

and this should give you back your sys. But you don’t get the actual function that you would write if you code the function manually, see examples from DifferentialEquations.jl. Unless there is some options to modelingtoolkitize.

Thank you for your information. Because my initial equations are DAEs and I would like to show the equations of the system after converting it into an ODE problem by MTK.

Use the expression keyword argument.

1 Like