Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

Fixes MethodError in staggered_discretize.jl by passing prob.p instead of nothing to prob.f calls.

This resolves the error MethodError: no method matching view(::Nothing, ::UnitRange{Int64}) that occurred when using staggered grids with periodic boundary conditions.

Problem

The symbolic_trace function in src/discretization/staggered_discretize.jl was calling prob.f with nothing as the parameters argument, but the generated ODEFunction expected actual parameters to perform view operations on parameter arrays.

Solution

Changed lines 33-34 to pass prob.p instead of nothing:

du1 = prob.f(tracevec_1, prob.p, 0.0);
du2 = prob.f(tracevec_2, prob.p, 0.0);

Test plan

  • Tested with the example from the discourse post
  • Verified that discretization completes successfully
  • Verified that the solve runs without errors

Fixes: https://discourse.julialang.org/t/methodoflines-staggered-grids-methoderror-by-function-discretize/133312

🤖 Generated with Claude Code

Fix MethodError in staggered_discretize.jl by passing prob.p instead of nothing
to prob.f calls. This resolves "MethodError: no method matching view(::Nothing, ::UnitRange{Int64})"
that occurred when using staggered grids with periodic boundary conditions.

The symbolic_trace function was calling prob.f with nothing as the parameters argument,
but the generated ODEFunction expected actual parameters to perform view operations.

Fixes: https://discourse.julialang.org/t/methodoflines-staggered-grids-methoderror-by-function-discretize/133312

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas merged commit 522a3c3 into SciML:master Oct 23, 2025
54 of 65 checks passed
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

Successfully merging this pull request may close these issues.

2 participants