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

Array parameters and callbacks #3154

Closed
ArnoStrouwen opened this issue Oct 26, 2024 · 3 comments · Fixed by #3190
Closed

Array parameters and callbacks #3154

ArnoStrouwen opened this issue Oct 26, 2024 · 3 comments · Fixed by #3190
Assignees
Labels
bug Something isn't working

Comments

@ArnoStrouwen
Copy link
Member

@mtkmodel DECAY begin
    @parameters begin
        unrelated[1:2] = zeros(2)
        k = 0.0
    end
    @variables begin
        x(t) = 10.0
    end
    @equations begin
        D(x) ~ -k*x
    end
    @discrete_events begin
        (t == 1.0) => [k~1.0]
    end
end
@mtkbuild decay = DECAY()
prob = ODEProblem(decay, [], (0.0, 10.0), [])
sol = solve(prob, Tsit5(),tstops=[1.0])
julia> sol = solve(prob, Tsit5(),tstops=[1.0])
ERROR: MethodError: no method matching view(::Float64, ::UnitRange{Int64})
The function `view` exists, but no method is defined for this combination of argument types.

Removing the array works.

@ArnoStrouwen
Copy link
Member Author

Please reopen, this was not actually fixed for me:

(TESTER) pkg> st ModelingToolkit
Status `C:\Users\arno\Desktop\TESTER\Project.toml`
  [961ee093] ModelingToolkit v9.50.0
julia> sol = solve(prob, Tsit5(),tstops=[1.0])
ERROR: MethodError: no method matching view(::Float64, ::UnitRange{Int64})
The function `view` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  view(::Base.JuliaSyntax.SourceFile, ::AbstractUnitRange)
   @ Base C:\workdir\base\JuliaSyntax\src\source_files.jl:113
  view(::RecursiveFactorization.NotIPIV, ::AbstractUnitRange)
   @ RecursiveFactorization C:\Users\arno\.julia\packages\RecursiveFactorization\zhyWn\src\lu.jl:30
  view(::StructArrays.StructArray{T, N, C}, ::Any...) where {T, N, C}
   @ StructArrays C:\Users\arno\.julia\packages\StructArrays\CjQ4L\src\structarray.jl:356
  ...

Stacktrace:
  [1] macro expansion
    @ C:\Users\arno\.julia\packages\SymbolicUtils\jf8aQ\src\code.jl:387 [inlined]
  [2] macro expansion
    @ C:\Users\arno\.julia\packages\RuntimeGeneratedFunctions\M9ZX8\src\RuntimeGeneratedFunctions.jl:163 [inlined]
  [3] macro expansion
    @ .\none:0 [inlined]
  [4] generated_callfunc
    @ .\none:0 [inlined]
  [5] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…})(::Vector{…}, ::Float64, ::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ RuntimeGeneratedFunctions C:\Users\arno\.julia\packages\RuntimeGeneratedFunctions\M9ZX8\src\RuntimeGeneratedFunctions.jl:150
  [6] apply_discrete_callback!
    @ C:\Users\arno\.julia\packages\DiffEqBase\frOsk\src\callbacks.jl:606 [inlined]
  [7] handle_callbacks!
    @ C:\Users\arno\.julia\packages\OrdinaryDiffEqCore\2K6jv\src\integrators\integrator_utils.jl:355 [inlined]
  [8] _loopfooter!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ OrdinaryDiffEqCore C:\Users\arno\.julia\packages\OrdinaryDiffEqCore\2K6jv\src\integrators\integrator_utils.jl:243
  [9] loopfooter!
    @ C:\Users\arno\.julia\packages\OrdinaryDiffEqCore\2K6jv\src\integrators\integrator_utils.jl:207 [inlined]
 [10] solve!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ OrdinaryDiffEqCore C:\Users\arno\.julia\packages\OrdinaryDiffEqCore\2K6jv\src\solve.jl:579
 [11] #__solve#75
    @ C:\Users\arno\.julia\packages\OrdinaryDiffEqCore\2K6jv\src\solve.jl:7 [inlined]
 [12] __solve
    @ C:\Users\arno\.julia\packages\OrdinaryDiffEqCore\2K6jv\src\solve.jl:1 [inlined]
 [13] solve_call(_prob::ODEProblem{…}, args::Tsit5{…}; merge_callbacks::Bool, kwargshandle::Nothing, kwargs::@Kwargs{})
    @ DiffEqBase C:\Users\arno\.julia\packages\DiffEqBase\frOsk\src\solve.jl:612
 [14] solve_call
    @ C:\Users\arno\.julia\packages\DiffEqBase\frOsk\src\solve.jl:569 [inlined]
 [15] #solve_up#53
    @ C:\Users\arno\.julia\packages\DiffEqBase\frOsk\src\solve.jl:1092 [inlined]
 [16] solve_up
    @ C:\Users\arno\.julia\packages\DiffEqBase\frOsk\src\solve.jl:1078 [inlined]
 [17] #solve#51
    @ C:\Users\arno\.julia\packages\DiffEqBase\frOsk\src\solve.jl:1015 [inlined]
 [18] top-level scope
    @ REPL[32]:1
Some type information was truncated. Use `show(err)` to see complete types.

@AayushSabharwal
Copy link
Member

Could you share the full status and status -m output?

@ArnoStrouwen
Copy link
Member Author

My mistake, I thought this merged before the latest release, but it is not yet included.
Could you do a release, me and @SebastianM-C need this functionality.

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
Development

Successfully merging a pull request may close this issue.

2 participants