Repository navigation
Conversation
…structural simplification Array equations `D(x[slice]) ~ rhs` are still scalarized into rows of the bipartite graph, so matching, Pantelides, dummy derivatives, tearing and alias elimination see exact per-element incidence. The rows now remember the array equation they came from (`ArrayEquationGroup`, `row_group`, `row_elem`), and every pass that rewrites a row in a way the array equation cannot represent (differentiation, removal, dummy derivative substitution, solving for another variable, inline linear SCCs, clock partition splits) marks the group dirty. Rows of the integer-linear subsystem that belong to a group are kept out of Gaussian elimination so they are neither reduced nor used as pivots. With `preserve_array_equations = true` on `DefaultReassembleAlgorithm` (or as a `mtkcompile` keyword) intact groups are emitted as a single array equation over scalar unknowns; dirty groups are emitted scalarized as before. The default output is unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
…collection Fold the split/merge helpers into linear_subsys_adjmat! via is_intact_array_group_row, and cover the mixed array-DE + linear algebraic case. Co-authored-by: Cursor <cursoragent@cursor.com>
…al forms `preserve_array_equations = :strict` throws `ArrayEquationNotPreservedError` instead of scalarizing an array differential equation. The error names the equation, the transformation that first broke its group and the element at which it broke; `dirty_array_group!` now records both. With `true`, broken groups are still scalarized silently, and array differential equations that cannot be tracked as a group at all are scalarized with a warning that names them. Residual forms are also recognized when the residual is a call that scalarizes like `broadcast` (such as MethodOfLines' `mol_broadcast`, via `scalarization_function`) and the other side is any derivative-free expression rather than a literal zero. Stacked on #158 (35361ef, 1c28107). Agent-Harness: Claude Code 2.1.306 Agent-Model: claude-opus-5-5 Agent-Session: aa65e380-52df-443a-9f57-8c20c56babb9 Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
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.
Stacked on #158. This branch contains #158's two commits (35361ef, 1c28107) plus one commit of its own. #158's branch lives on ChrisRackauckas-Claude's fork, so it can't be this PR's base; review only the last commit. The MTK side is SciML/ModelingToolkit.jl#5306, which is stacked on SciML/ModelingToolkit.jl#5102.
These are gap fixes for the acceptance tests in the PDEComponents P5 experiment (§4 of its report), which measured #5102/#158 against a pre-discretized heat rod (
RodSystem: a thermal mass,HeatRod(N = 50)and a fixed-temperature sink).Changes
preserve_array_equations = :strictthrowsArrayEquationNotPreservedErrorwhen an array differential equation would be scalarized. The error names the equation, the transformation that first broke its group, and the element.dirty_array_group!takes the reason (with a default, so existing two-argument calls still work), andArrayEquationGroupstores the first reason and element.truekeeps the documented lenient behaviour.broadcast(MethodOfLines'mol_broadcast, viaSU.scalarization_function), and when the other side is any derivative-free expression rather than a literal zero. MOL emitsmol_broadcast(+, -R, D(T[s])) ~ mol_broadcast(+, 0, mol_broadcast(*, 0, T[s])).D(x[slice])but can't be grouped is recorded inTearingState.ungrouped_array_eqs. Withtrueit is scalarized with a warning that names it; with:strictit throws.Evidence
The fixture is PDEComponents.jl's generated
HeatRod(N = 50)and lumped components. They were loaded through a shim that skips DyadInterface, because the test machine only has the General registry. "Base" means #158 at 1c28107 with MTK #5102. "Branch" means this PR with the MTK PR.rod.T[25] - rod.T[26] ~ 0,:strict:strict);truesilently gives 24 scalar equationsthe array equation D(rod.T[2:49]) ~ … was scalarized because index reduction differentiated the row (Pantelides eq_derivative!) (element rod.T[25]);trueunchanged, 24 scalar equations, no warningtrueD(rod.T[2:49]); also under:strictHeatedPlate,:strictD(plate.T[2:70, 2:70])T6 (alias targets) is on the MTK side.
Tests
test/runtests.jl, run with MTK at #5102 (base) or the MTK PR (branch), Julia 1.12.6. Base: 28 top-level testsets, 160 passing. Branch: 29 testsets, 181 passing (the 21 new tests). No failures or errors on either.Not verified
PDETransientAnalysis.0 + 0*T[s] + R), becausemol_broadcastterms aren't simplified. Its effect on generated-code size and run time wasn't measured.🤖 Posted by an AI agent · harness: Claude Code 2.1.306 · model: claude-opus-5-5
Review: unreviewed
Session: aa65e380-52df-443a-9f57-8c20c56babb9