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

A mysterious crash with defaults #2817

Closed
hersle opened this issue Jun 25, 2024 · 0 comments · Fixed by #2821
Closed

A mysterious crash with defaults #2817

hersle opened this issue Jun 25, 2024 · 0 comments · Fixed by #2821
Assignees
Labels
bug Something isn't working

Comments

@hersle
Copy link
Contributor

hersle commented Jun 25, 2024

For reasons I do not understand, the example

using ModelingToolkit

@parameters A1 A2 B1 B2 # it fails with this line uncommented
#@parameters A1 A2=1-A1 B1=A1 B2=A2 # it works with this line uncommented
@variables t x1(t) x2(t)
@named sys = ODESystem([
    x1 ~ B1,
    x2 ~ B2,
], t; defaults = [
    A2 => 1 - A1,
    B1 => A1,
    B2 => A2
])
prob = ODEProblem(structural_simplify(sys), [], (0.0, 1.0), [A1 => 0.3])

mysteriously crashes with

ERROR: UndefRefError: access to undefined reference
Stacktrace:
  [1] getindex
    @ ./essentials.jl:13 [inlined]
  [2] iterate
    @ ./array.jl:945 [inlined]
  [3] narrow_buffer_type(buffer::Vector{Real})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/parameter_buffer.jl:196
  [4] _broadcast_getindex_evalf
    @ ./broadcast.jl:709 [inlined]
  [5] _broadcast_getindex
    @ ./broadcast.jl:682 [inlined]
  [6] #31
    @ ./broadcast.jl:1118 [inlined]
  [7] ntuple
    @ ./ntuple.jl:48 [inlined]
  [8] copy
    @ ./broadcast.jl:1118 [inlined]
  [9] materialize(bc::Base.Broadcast.Broadcasted{…})
    @ Base.Broadcast ./broadcast.jl:903
 [10] ModelingToolkit.MTKParameters(sys::ODESystem, p::Dict{…}, u0::Vector{…}; tofloat::Bool, use_union::Bool)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/parameter_buffer.jl:159
 [11] ModelingToolkit.MTKParameters(sys::ODESystem, p::Dict{SymbolicUtils.BasicSymbolic{Real}, Float64}, u0::Vector{Any})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/parameter_buffer.jl:16
 [12] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{…}, parammap::Vector{…}; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), guesses::Dict{…}, t::Float64, warn_initialize_determined::Bool, build_initializeprob::Bool, initialization_eqs::Vector{…}, kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:875
 [13] process_DEProblem
    @ ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:766 [inlined]
 [14] (ODEProblem{})(sys::ODESystem, u0map::Vector{…}, tspan::Tuple{…}, parammap::Vector{…}; callback::Nothing, check_length::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:1018
 [15] (ODEProblem{})(sys::ODESystem, u0map::Vector{…}, tspan::Tuple{…}, parammap::Vector{…})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:1008
 [16] (ODEProblem{true})(::ODESystem, ::Vector{Any}, ::Vararg{Any}; kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:995
 [17] (ODEProblem{true})(::ODESystem, ::Vector{Any}, ::Vararg{Any})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:994
 [18] ODEProblem(::ODESystem, ::Vector{Any}, ::Vararg{Any}; kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:984
 [19] ODEProblem(::ODESystem, ::Vector{Any}, ::Vararg{Any})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/353ne/src/systems/diffeqs/abstractodesystem.jl:983
 [20] top-level scope
    @ REPL[16]:1
Some type information was truncated. Use `show(err)` to see complete types.

This is with ] status

  [0c46a032] DifferentialEquations v7.13.0
  [961ee093] ModelingToolkit v9.19.0
  [1dea7af3] OrdinaryDiffEq v6.84.0
  [2efcf032] SymbolicIndexingInterface v0.3.22
  [d1185830] SymbolicUtils v2.0.2
  [0c5d862f] Symbolics v5.30.3
  ...

Is anyone able to reproduce this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants