-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modelingtoolkitize
UndefVarError with CellMLToolkit
#12
Comments
Can you share the generated code? It would be good to get this to an example without CellML involved. |
how? |
print out the ModelingToolkit model that is generated, and then start to simplify out pieces until something works. That last piece removed is causing the issue. |
This is almost certainly not an MTK issue. |
You can run the code indirectly using compiled source code. Try ml = CellModel("bertram_satin_pedersen_luciani_sherman_2007.cellml"; dependency=false) Note, CellMLToolkit.generate_functions("bertram.jl", ml) Load the generated code by tspan = (0, 100.0)
prob = ODEProblem(f!, u0, tspan, p)
sol = solve(prob) Let us know if this works and the results are correct. |
Thanks @shahriariravanian but I'm getting julia> CellMLToolkit.generate_functions("bertram.jl", ml)
ERROR: MethodError: no method matching arguments(::Sym{Real})
Closest candidates are:
arguments(::Term) at /home/sippycups/.julia/packages/SymbolicUtils/oQKim/src/types.jl:279
arguments(::SymbolicUtils.Add) at /home/sippycups/.julia/packages/SymbolicUtils/oQKim/src/types.jl:508
arguments(::SymbolicUtils.Mul) at /home/sippycups/.julia/packages/SymbolicUtils/oQKim/src/types.jl:635
...
Stacktrace:
[1] prerequisite(s::Set{Any}, op::Sym{Real})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:295
[2] (::CellMLToolkit.var"#38#39"{Set{Any}})(x::Sym{Real})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:298
[3] iterate
@ ./generator.jl:47 [inlined]
[4] _collect(c::Vector{SymbolicUtils.Symbolic{Real}}, itr::Base.Generator{Vector{SymbolicUtils.Symbolic{Real}}, CellMLToolkit.var"#38#39"{Set{Any}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:691
[5] collect_similar(cont::Vector{SymbolicUtils.Symbolic{Real}}, itr::Base.Generator{Vector{SymbolicUtils.Symbolic{Real}}, CellMLToolkit.var"#38#39"{Set{Any}}})
@ Base ./array.jl:606
[6] map(f::Function, A::Vector{SymbolicUtils.Symbolic{Real}})
@ Base ./abstractarray.jl:2288
[7] prerequisite(s::Set{Any}, op::Term{Real})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:298
[8] generate_algebraics(io::IOStream, ml::CellModel)
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:56
[9] generate_f(io::IOStream, ml::CellModel, p::Vector{Pair{Sym{Real}, Float64}}, u0::Vector{Pair{Sym{Real}, Float64}})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:81
[10] generate_functions(name::String, ml::CellModel, jac::Bool; p::Vector{Pair{Sym{Real}, Float64}}, u0::Vector{Pair{Sym{Real}, Float64}}, level::Int64)
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:12
[11] generate_functions(name::String, ml::CellModel, jac::Bool)
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:5
[12] top-level scope
@ REPL[39]:1 |
My guess is that some things assume you'll always have |
You need to open ml with ml = CellModel("bertram_satin_pedersen_luciani_sherman_2007.cellml"; dependency=false) Running the model, I get this for t: 11-element Array{Float64,1}:
0.0
0.3376740539428432
3.105262526747927
8.22575658459543
14.89623871826478
24.39020306613328
37.36122503195609
54.48047163071409
74.35621616003688
92.75535185187566
100.0
u: 11-element Array{Array{Float64,1},1}:
[-60.0, 345.0, 164.0, 11.1, 2.16, 1137.0, 0.4, 0.0, 0.17, 301.0, 0.2]
[-59.99821279400321, 344.9998990555587, 163.98672325008326, 11.09999853044865, 2.1602791584109093, 1136.9991055965816, 0.4000016051893339, 2.523641100451437e-6, 0.1700083211135837, 300.99973183783237, 0.1999850648083851]
[-59.98385945435487, 344.9990848298836, 163.9130678013866, 11.100000439306225, 2.162568042966136, 1136.9919866517287, 0.4000141442398096, 2.1709833685807436e-5, 0.1700757311460878, 300.9975327767293, 0.1998690001027819]
[-59.95854932247251, 344.99763885393264, 163.86236501142827, 11.100037915104581, 2.166807051580714, 1136.9793530651584, 0.4000362972539013, 5.104927887695163e-5, 0.1701971318539981, 300.9934585360071, 0.19967892019238415]
[-59.927600732987464, 344.9958692790502, 163.8474023391969, 11.100107015084811, 2.1723373913701916, 1136.963273608548, 0.4000658036019622, 7.981197843359349e-5, 0.1703495146329244, 300.9881400733758, 0.19947054771049227]
[-59.886624712420314, 344.9935638150261, 163.84419311325357, 11.100212624151695, 2.1802245547257204, 1136.9406479058396, 0.4001109842216233, 0.00010769609246100086, 0.17055609170248145, 300.9805490704017, 0.19923994012992857]
[-59.834918881063366, 344.99079602249617, 163.84330484402864, 11.100358531914843, 2.1910305582946874, 1136.9100381782455, 0.4001795703140473, 0.000130298786515959, 0.17082041377033289, 300.9701374330893, 0.1990342315172749]
[-59.77194300703174, 344.9877692114668, 163.8441282072496, 11.100552396316655, 2.2053458496736233, 1136.870123870872, 0.40028252312375057, 0.00014559921283135502, 0.1711410700654406, 300.9563244783898, 0.19892600273359398]
[-59.704038683738425, 344.9850710967021, 163.86982352418426, 11.100788018361436, 2.222042386707716, 1136.8245654180062, 0.4004196188728381, 0.00015404138495405515, 0.1714785684932087, 300.9401852291678, 0.1989893570825818]
[-59.644829054726145, 344.983284309262, 163.93183213156433, 11.101019528248106, 2.2375714409940173, 1136.783394626606, 0.40056370403500696, 0.00015822721097799887, 0.17176254248168307, 300.9251471967913, 0.19919217786220203]
[-59.62229517454481, 344.9827544632601, 163.8538854873426, 11.101071319405397, 2.2437052284862338, 1136.7666448899697, 0.4006272981773115, 0.00015943195075457064, 0.17186835724096433, 300.9192001839837, 0.19929556217349595] |
Sorry for the delay. Yes I was using Could you maybe share your using CellMLToolkit, DifferentialEquations, ModelingToolkit
ml = CellModel("bertram_satin_pedersen_luciani_sherman_2007.cellml"; dependency=false)
tspan = (0, 100.0)
prob = ODEProblem(ml, tspan)
# both of these error
sol = solve(prob)
modelingtoolkitize(prob) The julia> CellMLToolkit.generate_functions("bertram.jl", ml)
ERROR: MethodError: no method matching arguments(::Sym{Real, Nothing})
Closest candidates are:
arguments(::Term) at /home/sippycups/.julia/packages/SymbolicUtils/1wpGA/src/types.jl:342
arguments(::SymbolicUtils.Add) at /home/sippycups/.julia/packages/SymbolicUtils/1wpGA/src/types.jl:572
arguments(::SymbolicUtils.Mul) at /home/sippycups/.julia/packages/SymbolicUtils/1wpGA/src/types.jl:715
...
Stacktrace:
[1] prerequisite(s::Set{Any}, op::Sym{Real, Nothing})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:295
[2] (::CellMLToolkit.var"#38#39"{Set{Any}})(x::Sym{Real, Nothing})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:298
[3] iterate
@ ./generator.jl:47 [inlined]
[4] _collect(c::Vector{SymbolicUtils.Symbolic{Real}}, itr::Base.Generator{Vector{SymbolicUtils.Symbolic{Real}}, CellMLToolkit.var"#38#39"{Set{Any}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:691
[5] collect_similar(cont::Vector{SymbolicUtils.Symbolic{Real}}, itr::Base.Generator{Vector{SymbolicUtils.Symbolic{Real}}, CellMLToolkit.var"#38#39"{Set{Any}}})
@ Base ./array.jl:606
[6] map(f::Function, A::Vector{SymbolicUtils.Symbolic{Real}})
@ Base ./abstractarray.jl:2288
[7] prerequisite(s::Set{Any}, op::Term{Real, Nothing})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:298
[8] generate_algebraics(io::IOStream, ml::CellModel)
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:56
[9] generate_f(io::IOStream, ml::CellModel, p::Vector{Pair{Sym{Real, Nothing}, Float64}}, u0::Vector{Pair{Sym{Real, Nothing}, Float64}})
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:81
[10] generate_functions(name::String, ml::CellModel, jac::Bool; p::Vector{Pair{Sym{Real, Nothing}, Float64}}, u0::Vector{Pair{Sym{Real, Nothing}, Float64}}, level::Int64)
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:12
[11] generate_functions(name::String, ml::CellModel, jac::Bool)
@ CellMLToolkit ~/.julia/dev/CellMLToolkit/src/generator.jl:5
[12] top-level scope
@ REPL[9]:1 |
Running into a modelingtoolkitize error with this cellml model
I don't know if this is error in the cellml file or the code. I also noted that both errors reference
RuntimeGeneratedFunctions
The text was updated successfully, but these errors were encountered: