Repository navigation
Support array (slice-form) equations in initialization and nonlinear normalization - #97
Merged
ChrisRackauckas merged 3 commits intoJul 20, 2026
Conversation
…tion Slice-form array equations (e.g. from MethodOfLines' ArrayDiscretization) differentiate whole slices like D(u[2:n-1]); expand these to their elements in _discrete_initialization so elementwise initial conditions still generate initialization equations. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S1dxUEPGysx27SSSpxtiQ9
…st zero checks - Add _normalize_nonlinear_eq: array (slice-form) equations cannot equate an array with scalar zero, so normalize with a broadcast subtraction and a zero array of matching size - Use symtype-based _is_array_valued (SymbolicUtils.Symbolic does not exist in SymbolicUtils v4) - Test both fixes; bump version to 0.1.30 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S1dxUEPGysx27SSSpxtiQ9
ExplicitImports QA flags Broadcast.materialize/broadcasted as non-public. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S1dxUEPGysx27SSSpxtiQ9
ChrisRackauckas
marked this pull request as ready for review
July 20, 2026 10:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Draft — please ignore until reviewed by @ChrisRackauckas.
Summary
Two small fixes needed so that discretizers can emit unscalarized array equations over slices of array variables (e.g.
D(u[2:n-1]) ~ broadcast(...)), as MethodOfLines.jl's newArrayDiscretizationstrategy does (SciML/MethodOfLines.jl#428):_discrete_initialization: slice-form equations differentiate whole slices likeD(u[2:n-1]), so the differentiated variables are now expanded to their elements before matching against elementwise initial-condition keys. Without this, elementwise ICs silently generate no initialization equations for array equations.generate_system(NonlinearSystem branch): the0 ~ rhs - lhsnormalization fails on array equations (~cannot equate an array with a scalar, and-between a literal zero array and a symbolic array term is not defined). New_normalize_nonlinear_eqnormalizes array equations with a broadcast subtraction against a zero array of matching size, leaving scalar equations unchanged.Also fixes a latent portability issue:
SymbolicUtils.Symbolicdoes not exist in SymbolicUtils v4, so array-valuedness checks usesymtype(which falls back totypeoffor non-symbolic values).Scalar-path behavior is unchanged: for scalar equations both functions reduce to exactly the previous code paths.
Tests
Added testsets to
test/discrete_initialization.jlcovering initialization-equation generation from a slice-form array equation and the nonlinear normalization of array and scalar equations. Ran locally on Julia 1.12.4: all pass (existingDiscrete initializationtestset 11/11, new testsets 5/5). Downstream, the MethodOfLinesArrayDiscretizationtest suite (41 tests, SciML/MethodOfLines.jl PR to follow) passes against this branch, including solution-equality checks vs the scalarized path.Release
Version bumped to 0.1.30 (additive fix). The MethodOfLines array-equations PR sets
PDEBase = "0.1.30"compat and needs this released first.🤖 Generated with Claude Code
https://claude.ai/code/session_01S1dxUEPGysx27SSSpxtiQ9