Repository navigation
Conversation
Propagate ModelingToolkitTearing's array equation groups through alias elimination and brownian handling, and make map_variables_to_equations understand preserved array equations. Co-authored-by: Cursor <cursoragent@cursor.com>
…and docs - `mtkcompile(sys; preserve_array_equations = true)` emits intact array differential equations as single equations over scalar unknowns. - `build_function_wrapper` rewrites `array_literal`s of consecutive buffer elements into `vcat`s of `view`s so generated code for preserved array equations does not grow with the array size. - Alias elimination keeps array-equation rows out of the integer-linear elimination instead of restoring them afterwards. - Document the design in the mtkcompile internals page; bump MTKTearing compat to 1.21. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The status notes belong in the PR description, not in the built docs. Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts: # Project.toml # lib/ModelingToolkitBase/Project.toml
…ts as alias targets Documents `preserve_array_equations = :strict`, which throws an `ArrayEquationNotPreservedError` naming the equation, the transformation and the element instead of scalarizing an array differential equation, and the warning that `true` now gives for array differential equations that cannot be grouped. The SDE noise extraction passes its reason to `dirty_array_group!`. Needs the companion StateSelection.jl change to ModelingToolkitTearing. Alias elimination now prefers an element of an intact array differential equation as the alias target among the highest-priority candidates. For `x[k] ~ m` with both differential, eliminating `x[k]` left the row of `D(x[k])` solved for `D(m)` and scalarized the whole array equation; keeping `x[k]` keeps it intact. This applies whether or not `preserve_array_equations` is set. Stacked on SciML#5102 (18af7bb) via array-groups-base. 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>
Runic wants the closing parenthesis of multi-line mtkcompile calls on its own line; this fixes the failing Runic Format Check on PR SciML#5306. Agent-Harness: Claude Code 2.1.308 Agent-Model: claude-sonnet-5-5 Agent-Session: fbf12fae-28a4-496f-b740-3339fe3ac7a1 Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Conflicts: lib/ModelingToolkitBase/src/systems/codegen_utils.jl (this branch's array-literal compression helpers and master's find_arrvars_recurse were both added after find_arrvars_is_atomic; kept both), lib/ModelingToolkitBase/src/systems/systems.jl (mtkcompile docstring: kept both the preserve_array_equations entry and master's verbose / print_underconstrained_variables entries), src/systems/alias_elimination.jl (pick_alias_target gained both master's verbose::MTKVerbosity argument and this branch's array_elems argument, now (state, group_vars, irreducibles, verbose, array_elems = Set()); call site passes both). Agent-Harness: Claude Code 2.1.312 Agent-Model: claude-sonnet-5-5 Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Conflict in codegen_utils.jl: kept both the array_literal compression helpers and the RHS chunking constants. Agent-Harness: Claude Code 2.1.312 Agent-Model: claude-sonnet-5-5 Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
|
Pushed 🤖 Posted by an AI agent · harness: Claude Code 2.1.312 · model: claude-sonnet-5-5 |
Agent-Harness: Claude Code 2.1.318 Agent-Model: claude-sonnet-5-5 Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
|
Pushed 🤖 Posted by an AI agent · harness: Claude Code 2.1.318 · model: claude-sonnet-5-5 |
Agent-Harness: Claude Code 2.1.319 Agent-Model: claude-sonnet-5-5 Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
|
Pushed 🤖 Posted by an AI agent · harness: Claude Code 2.1.319 · model: claude-sonnet-5-5 |
Stacked on #5102. The base branch
array-groups-base(05003d5) is SciML master 9cde066 with #5102 (998d0df, 8768e37, 9094576, 7507240, 18af7bb) merged in. #5102 lives on ChrisRackauckas-Claude's fork, so it can't be this PR's base; review only the last commit (4b56525). It needs the ModelingToolkitTearing side, JuliaComputing/StateSelection.jl#174, which is stacked on JuliaComputing/StateSelection.jl#158. Without it the new three-argumentdirty_array_group!call andMTKTearing.ArrayEquationNotPreservedErrordon't exist.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
mtkcompiledocstring anddocs/src/internals/mtkcompile.mddescribepreserve_array_equations = :strictand the warningtruenow gives for array differential equations that can't be grouped. The SDE noise extraction passes a reason todirty_array_group!. The behaviour itself is in StateSelection.jl#174.pick_alias_targetprefers an element of an intact array differential equation. Forx[k] ~ mwith both differential, the old choice eliminatedx[k], which left the row ofD(x[k])solved forD(m)and scalarized all N−2 rows. This changes default state selection too, with or withoutpreserve_array_equations: it applies whenever an alias group contains an element of a still-intact array differential equation. It could be gated on the flag if a flag-independent choice isn't wanted.Evidence
The fixture is PDEComponents.jl's generated
HeatRod(N = 50)and lumped components, plus a free heater. They were loaded through a shim that skips DyadInterface, because the test machine only has the General registry. "Base" meansarray-groups-basewith #158. "Branch" means this PR with StateSelection.jl#174. Solutions use DFBDF with abstol = reltol = 1e-10 and are compared on t ∈ 0.5:0.5:10.rod.T[25] ~ mass.T,trueheater.port.Tandrod.T[2:49] \ rod.T[25]are the unknownsD(rod.T[2:49]), and nothing else;rod.T[25]is the unknown andmass.Tis observed; also compiles under:strictmass.T(the defaultfalsepath: 5.4e-9 K)rod.T[25] - rod.T[26] ~ 0,:strictArrayEquationNotPreservedErrorwith reasonindex reduction differentiated the row (Pantelides eq_derivative!)and elementrod.T[25]mol_broadcastresidual form,trueHeatedPlate,:strictD(plate.T[2:70, 2:70]); 5.1 stest/structural_transformation/array_equations.jlgains 18 tests covering these (:stricton the rod withu[k] - u[k+1] ~ 0, an intact group and the pendulum; the ungrouped-equation warning;u[k] ~ maliasing, solved against the default path).Tests
Julia 1.12.6,
Pkg.testwith ModelingToolkitTearing from the respective StateSelection branch.Not verified
PDETransientAnalysis.🤖 Posted by an AI agent · harness: Claude Code 2.1.306 · model: claude-opus-5-5
Review: unreviewed
Session: aa65e380-52df-443a-9f57-8c20c56babb9