Skip to content
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

Closed
anandijain opened this issue Feb 27, 2021 · 9 comments
Closed

modelingtoolkitize UndefVarError with CellMLToolkit #12

anandijain opened this issue Feb 27, 2021 · 9 comments

Comments

@anandijain
Copy link
Contributor

Running into a modelingtoolkitize error with this cellml model

using CellMLToolkit, DifferentialEquations, ModelingToolkit
ml = CellModel("bertram_satin_pedersen_luciani_sherman_2007.cellml")
tspan = (0, 100.0)
prob = ODEProblem(ml, tspan)

# both of these error 
sol = solve(prob)
modelingtoolkitize(prob)

I don't know if this is error in the cellml file or the code. I also noted that both errors reference RuntimeGeneratedFunctions

julia> sol = solve(prob)
ERROR: UndefVarError: bottomo not defined
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/SymbolicUtils/KfAAB/src/code.jl:306 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/ModelingToolkit/pr3qG/src/build_function.jl:302 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/SymbolicUtils/KfAAB/src/code.jl:264 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/RuntimeGeneratedFunctions/tJEmP/src/RuntimeGeneratedFunctions.jl:104 [inlined]
  [5] macro expansion
    @ ./none:0 [inlined]
  [6] generated_callfunc
    @ ./none:0 [inlined]
  [7] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)})(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)
    @ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/tJEmP/src/RuntimeGeneratedFunctions.jl:92
  [8] f
    @ ~/.julia/packages/ModelingToolkit/pr3qG/src/systems/diffeqs/abstractodesystem.jl:132 [inlined]
  [9] ODEFunction
    @ ~/.julia/packages/SciMLBase/eghDQ/src/scimlfunctions.jl:324 [inlined]
 [10] initialize!(integrator::OrdinaryDiffEq.ODEIntegrator{CompositeAlgorithm{Tuple{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Vector{Vector{Float64}}, OrdinaryDiffEq.ODECompositeSolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem}, CompositeAlgorithm{Tuple{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, OrdinaryDiffEq.CompositeInterpolationData{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}}, OrdinaryDiffEq.Rosenbrock23Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.Rosenbrock23Tableau{Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, Vector{Float64}}, DefaultLinSolve, FiniteDiff.JacobianCache{Vector{Float64}, Vector{Float64}, Vector{Float64}, UnitRange{Int64}, Nothing, Val{:forward}(), Float64}, FiniteDiff.GradientCache{Nothing, Vector{Float64}, Vector{Float64}, Float64, Val{:forward}(), Float64, Val{true}()}}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}}, DiffEqBase.DEStats}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}}, OrdinaryDiffEq.Rosenbrock23Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.Rosenbrock23Tableau{Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, Vector{Float64}}, DefaultLinSolve, FiniteDiff.JacobianCache{Vector{Float64}, Vector{Float64}, Vector{Float64}, UnitRange{Int64}, Nothing, Val{:forward}(), Float64}, FiniteDiff.GradientCache{Nothing, Vector{Float64}, Vector{Float64}, Float64, Val{:forward}(), Float64, Val{true}()}}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryMinHeap{Float64}, DataStructures.BinaryMinHeap{Float64}, Nothing, Nothing, Int64, Tuple{}, Tuple{}, Tuple{}}, Vector{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, cache::OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}})
    @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/Iu97h/src/perform_step/low_order_rk_perform_step.jl:623
 [11] initialize!(integrator::OrdinaryDiffEq.ODEIntegrator{CompositeAlgorithm{Tuple{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Vector{Vector{Float64}}, OrdinaryDiffEq.ODECompositeSolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem}, CompositeAlgorithm{Tuple{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, OrdinaryDiffEq.CompositeInterpolationData{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}}, OrdinaryDiffEq.Rosenbrock23Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.Rosenbrock23Tableau{Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, Vector{Float64}}, DefaultLinSolve, FiniteDiff.JacobianCache{Vector{Float64}, Vector{Float64}, Vector{Float64}, UnitRange{Int64}, Nothing, Val{:forward}(), Float64}, FiniteDiff.GradientCache{Nothing, Vector{Float64}, Vector{Float64}, Float64, Val{:forward}(), Float64, Val{true}()}}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}}, DiffEqBase.DEStats}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}}, OrdinaryDiffEq.Rosenbrock23Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.Rosenbrock23Tableau{Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, Vector{Float64}}, DefaultLinSolve, FiniteDiff.JacobianCache{Vector{Float64}, Vector{Float64}, Vector{Float64}, UnitRange{Int64}, Nothing, Val{:forward}(), Float64}, FiniteDiff.GradientCache{Nothing, Vector{Float64}, Vector{Float64}, Float64, Val{:forward}(), Float64, Val{true}()}}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryMinHeap{Float64}, DataStructures.BinaryMinHeap{Float64}, Nothing, Nothing, Int64, Tuple{}, Tuple{}, Tuple{}}, Vector{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, cache::OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}}, OrdinaryDiffEq.Rosenbrock23Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.Rosenbrock23Tableau{Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, Vector{Float64}}, DefaultLinSolve, FiniteDiff.JacobianCache{Vector{Float64}, Vector{Float64}, Vector{Float64}, UnitRange{Int64}, Nothing, Val{:forward}(), Float64}, FiniteDiff.GradientCache{Nothing, Vector{Float64}, Vector{Float64}, Float64, Val{:forward}(), Float64, Val{true}()}}}, OrdinaryDiffEq.AutoSwitchCache{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}})
    @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/Iu97h/src/perform_step/composite_perform_step.jl:39
 [12] __init(prob::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem}, alg::CompositeAlgorithm{Tuple{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}}, AutoSwitch{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}, timeseries_init::Tuple{}, ts_init::Tuple{}, ks_init::Tuple{}, recompile::Type{Val{true}}; saveat::Tuple{}, tstops::Tuple{}, d_discontinuities::Tuple{}, save_idxs::Nothing, save_everystep::Bool, save_on::Bool, save_start::Bool, save_end::Nothing, callback::Nothing, dense::Bool, calck::Bool, dt::Float64, dtmin::Nothing, dtmax::Float64, force_dtmin::Bool, adaptive::Bool, gamma::Rational{Int64}, abstol::Nothing, reltol::Nothing, qmin::Rational{Int64}, qmax::Int64, qsteady_min::Int64, qsteady_max::Int64, qoldinit::Rational{Int64}, fullnormalize::Bool, failfactor::Int64, beta1::Nothing, beta2::Nothing, maxiters::Int64, internalnorm::typeof(DiffEqBase.ODE_DEFAULT_NORM), internalopnorm::typeof(LinearAlgebra.opnorm), isoutofdomain::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), unstable_check::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), verbose::Bool, timeseries_errors::Bool, dense_errors::Bool, advance_to_tstop::Bool, stop_at_next_tstop::Bool, initialize_save::Bool, progress::Bool, progress_steps::Int64, progress_name::String, progress_message::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), userdata::Nothing, allow_extrapolation::Bool, initialize_integrator::Bool, alias_u0::Bool, alias_du0::Bool, initializealg::OrdinaryDiffEq.DefaultInit, kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:default_set, :second_time, :jac), Tuple{Bool, Bool, Bool}}})
    @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/Iu97h/src/solve.jl:431
 [13] __solve(::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem}, ::CompositeAlgorithm{Tuple{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}}, AutoSwitch{Tsit5, Rosenbrock23{0, false, DefaultLinSolve, DataType}, Rational{Int64}, Int64}}; kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:default_set, :second_time, :jac), Tuple{Bool, Bool, Bool}}})
    @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/Iu97h/src/solve.jl:4
 [14] __solve(::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem}, ::Nothing; default_set::Bool, kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol, Symbol}, NamedTuple{(:second_time, :jac), Tuple{Bool, Bool}}})
    @ DifferentialEquations ~/.julia/packages/DifferentialEquations/HSWeG/src/default_solve.jl:7
 [15] #__solve#70
    @ ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:235 [inlined]
 [16] #solve_call#56
    @ ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:61 [inlined]
 [17] solve_call
    @ ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:48 [inlined]
 [18] #solve_up#58
    @ ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:85 [inlined]
 [19] solve_up
    @ ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:75 [inlined]
 [20] #solve#57
    @ ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:70 [inlined]
 [21] solve(::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/gtaOc/src/solve.jl:68
 [22] top-level scope
    @ REPL[9]:1

julia> modelingtoolkitize(prob)
ERROR: UndefVarError: bottomo not defined
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/SymbolicUtils/KfAAB/src/code.jl:306 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/ModelingToolkit/pr3qG/src/build_function.jl:302 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/SymbolicUtils/KfAAB/src/code.jl:264 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/RuntimeGeneratedFunctions/tJEmP/src/RuntimeGeneratedFunctions.jl:104 [inlined]
  [5] macro expansion
    @ ./none:0 [inlined]
  [6] generated_callfunc
    @ ./none:0 [inlined]
  [7] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)})(::Vector{Num}, ::Vector{Num}, ::Vector{Num}, ::Num)
    @ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/tJEmP/src/RuntimeGeneratedFunctions.jl:92
  [8] (::ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}})(du::Vector{Num}, u::Vector{Num}, p::Vector{Num}, t::Num)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/pr3qG/src/systems/diffeqs/abstractodesystem.jl:132
  [9] (::ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing})(::Vector{Num}, ::Vararg{Any, N} where N)
    @ SciMLBase ~/.julia/packages/SciMLBase/eghDQ/src/scimlfunctions.jl:324
 [10] modelingtoolkitize(prob::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#240"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xe95eadb4, 0x7549851d, 0xe4f6e13d, 0xd24b7c0c, 0x2d3091d1)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#260"), Symbol("##arg#258"), Symbol("##arg#259"), :time), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x84832a8f, 0xdf565945, 0x4d31072d, 0xa0ab47c8, 0xa1e6bfe9)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}}, SciMLBase.StandardODEProblem})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/pr3qG/src/systems/diffeqs/modelingtoolkitize.jl:28
 [11] top-level scope
    @ REPL[10]:1
@ChrisRackauckas
Copy link
Member

Can you share the generated code? It would be good to get this to an example without CellML involved.

@anandijain
Copy link
Contributor Author

how?

@ChrisRackauckas
Copy link
Member

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.

@YingboMa
Copy link
Member

This is almost certainly not an MTK issue.

@YingboMa YingboMa transferred this issue from SciML/ModelingToolkit.jl Feb 27, 2021
@shahriariravanian
Copy link
Collaborator

You can run the code indirectly using compiled source code. Try

ml = CellModel("bertram_satin_pedersen_luciani_sherman_2007.cellml"; dependency=false)

Note, dependency = false is required here. Then, generate compiled source by

CellMLToolkit.generate_functions("bertram.jl", ml)

Load the generated code by include("bertram.jl"). It adds four variables to the global scope, f!, J!, u0, and p. Now, you can use it

tspan = (0, 100.0)
prob = ODEProblem(f!, u0, tspan, p)
sol = solve(prob)

Let us know if this works and the results are correct.

@anandijain
Copy link
Contributor Author

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

@ChrisRackauckas
Copy link
Member

My guess is that some things assume you'll always have x' =x+y while you might get y' = x, in which case the RHS can parse to a Sym instead of a Term. That said, all of this generate_functions stuff should not be in this repository at all, and instead it should just use the ModelingToolkit ODESystem which is robust to these kinds of things already. So #14 is a good solution there.

@shahriariravanian
Copy link
Collaborator

You need to open ml with dependency=false.

ml = CellModel("bertram_satin_pedersen_luciani_sherman_2007.cellml"; dependency=false)

Running the model, I get this for sol:

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]

@anandijain
Copy link
Contributor Author

Sorry for the delay. Yes I was using dependency=false.

Could you maybe share your ]status? Because the code below errors with what I originally posted.

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 generate_function does not work on my end either:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants