I am getting an error when solving a system of differential equations. I have made the below example to demonstrate.
Julia v1.5.3
ModelingToolkit v5.6.0
OrdinaryDiffEq v5.50.2
using ModelingToolkit, OrdinaryDiffEq, Plots
@variables V_n1 V_n2 V_n_mid
@parameters t
D = Differential(t)
eqs = [ 0 ~ 5.0e-5((D(V_n2)) - (D(V_n_mid)))
0 ~ 1.0e-5((D(V_n_mid)) - (D(V_n1))) + 5.0e-5((D(V_n_mid)) - (D(V_n2)))
0 ~ V_n1 - 0.5 - (sin(80t))]
vars = [V_n1, V_n2, V_n_mid]
params = []
sys = ODESystem(eqs, t, vars, params)
u0 = zeros(length(eqs))
du0 = zeros(length(eqs))
tspan = (0.0,100.0)
prob = ODEProblem(sys,u0,tspan,params)
sol = solve(prob, Trapezoid())
plot(sol)
The error occurs at the solve step and gives message:
ERROR: LoadError: UndefVarError: _derivative not defined
Stacktrace:
[1] macro expansion at /Users/user/.julia/packages/ModelingToolkit/JtDFb/src/build_function.jl:476 [inlined]
[2] macro expansion at /Users/user/.julia/packages/RuntimeGeneratedFunctions/tNQoo/src/RuntimeGeneratedFunctions.jl:95 [inlined]
[3] macro expansion at ./none:0 [inlined]
[4] generated_callfunc at ./none:0 [inlined]
[5] (::RuntimeGeneratedFunctions.
-------- [Very long message] --------
I think I need to use:
prob = DAEProblem(sys, du0, u0, tspan, differential_vars=[true,true,false])
But there is no DAESystem equivalent to ODESystem.
Thanks for the help.