Skip to content

error when trying to symbol-index for a parameter which was updated by an event #4030

@TorkelE

Description

@TorkelE

This currently yields an error:

using ModelingToolkit, OrdinaryDiffEqDefault
using ModelingToolkit: SymbolicContinuousCallback,
                       SymbolicDiscreteCallback,
                       t_nounits as t,
                       D_nounits as D
@parameters p(t) d
@variables X(t)
eqs = [
    D(X) ~ p - d*X
]
cevents = [SymbolicContinuousCallback([t ~ 1.0] => [p ~ 1.0]; discrete_parameters = [p])]
@mtkcompile model = System(eqs, t; continuous_events = cevents)

prob = ODEProblem(model, [:X => 1.0, :p => 2.0, :d => 2.0], (0.0, 2.0))
sol = solve(prob)
sol.ps[:p] # ERROR: BoundsError: attempt to access Tuple{Int64, Int64} at index [3]
sol.ps[:d] # 2.0
sol[:X] # 10-element Vector{Float64}:

on [961ee093] ModelingToolkit v10.29.0 and v1.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions