Skip to content

Fix PDESystem analytic generation with defaulted parameters - #5033

Draft
ChrisRackauckas-Claude wants to merge 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix/pdesystem-analytic-default-pairs
Draft

Fix PDESystem analytic generation with defaulted parameters#5033
ChrisRackauckas-Claude wants to merge 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix/pdesystem-analytic-default-pairs

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Important

Ignore this PR until it has been reviewed by @ChrisRackauckas.

This is stacked on #5031 and should be reviewed only after that prerequisite. Until the prerequisite merges, this PR includes its compatibility commit in the comparison.

What changed

PDESystem accepts parameter defaults as pairs such as h => 1, but analytic-function generation passed those pairs directly to DestructuredArgs. The generated function consequently attempted to use a Pair as an assignment target and failed with syntax: invalid assignment location Pair(...).

This change unwraps only Pair entries while building the analytic function's parameter arguments and adds a regression test beside the existing bare-parameter test. It deliberately does not change the system's stored parameter/default representation.

Regression evidence

The same focused test failed before the source fix:

$ timeout 3600 ~/.juliaup/bin/julia +1.10 --project=/home/crackauc/tmp/jl_eq71VG lib/ModelingToolkitBase/test/pdesystem.jl
Error During Test at /home/crackauc/sandbox/tmp_20260825_180339_53321/pdesystem-defaults-bisect/lib/ModelingToolkitBase/test/pdesystem.jl:41
  Test threw exception
  Expression: all(((pdesys_with_default.analytic_func[u(t, x)])([2], disct, discx) ≈ analytic_function([2], disct, discx) for disct = dt, discx = dx))
  syntax: invalid assignment location "Pair{Symbolics.Num, Int64}(..., second=1)" around /home/crackauc/.julia/packages/RuntimeGeneratedFunctions/AgFU2/src/RuntimeGeneratedFunctions.jl:243
ERROR: LoadError: There was an error during testing

The generated Pair payload in the syntax-error line is shortened above; the exception type, source location, expression, and second=1 value are verbatim from the run.

With the fix applied, the exact same command exited 0:

Test Summary:                       | Pass  Total  Time
PDESystem property accessor (sys.x) |   21     21  0.3s
Test Summary:                    | Pass  Total  Time
PDESystem input and output roles |   14     14  0.8s
Test Summary:                                  | Pass  Total  Time
PDESystem property accessor without parameters |    3      3  0.0s
Test Summary:                               | Pass  Total  Time
PDESystem property accessor with subsystems |    2      2  0.1s

The regression boundary is the adjacent history pair f04331935f96737b7160874a8cc281f0feead01c (passes) and b54d08729b600479f1ab467f9b1081fbf61da64e (fails). The latter commit fixed bare-symbol parameters but replaced the earlier pair extraction instead of supporting both representations.

Verification

Full relevant group:

$ GROUP=InterfaceII timeout 7200 ~/.juliaup/bin/julia +1.10 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()'
Test Summary:         | Pass  Total  Time
PDE Construction Test |   43     43  6.0s
Test Summary:                       | Pass  Broken  Total      Time
Optimal Control + Constraints Tests |   31       2     33  24m20.3s
4082.851622 seconds (1.92 G allocations: 338.855 GiB, 3.40% gc time, 52.43% compilation time: 3% of which was recompilation)
     Testing ModelingToolkitBase tests passed

The Julia 1.11 QA group passed with the two independently identified clean-master prerequisites applied temporarily: fork commit 26a70733803c43dc137b531f429c867a83f54154 and SymbolicUtils = "=4.45.0". Neither temporary prerequisite is included in this branch.

$ GROUP=QA timeout 3600 ~/.juliaup/bin/julia +1.11 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()'
Test Summary: | Pass  Total     Time
JET Tests     |   54     54  4m22.6s
Test Summary: | Pass  Total     Time
Aqua Tests    |   21     21  6m51.2s
681.806365 seconds (413.20 M allocations: 20.613 GiB, 3.97% gc time, 28.61% compilation time: 7% of which was recompilation)
     Testing ModelingToolkitBase tests passed

Formatting and spelling:

$ ~/.juliaup/bin/julia +1.12 --project=@runic -m Runic --check --diff lib/ModelingToolkitBase/src/systems/pde/pdesystem.jl lib/ModelingToolkitBase/test/pdesystem.jl
$ typos --format brief lib/ModelingToolkitBase/src/systems/pde/pdesystem.jl lib/ModelingToolkitBase/test/pdesystem.jl
$ git diff --check

All three exited 0 with no output.

Scope and current blockers

The normalization is intentionally local to analytic-function code generation. A mixed pair/bare collection generates and evaluates its analytic function, but broader PDESystem parameter/default normalization remains outside this PR.

A fresh unmodified resolution currently selects SymbolicUtils 4.46.0 and exposes a fixed-but-unreleased Symbolics 7.36.0 ImmutableDict bug. Separately, clean-master ModelingToolkitBase ExplicitImports QA failures are tracked in #5032. Docs were not built because this changes neither documentation nor public API. GPU and downstream groups were not run.

Links

🤖 Generated with Claude Code
https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512

ChrisRackauckas and others added 3 commits August 26, 2026 15:52
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>

Co-Authored-By: Claude <noreply@anthropic.com>

Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>

Co-Authored-By: Claude <noreply@anthropic.com>

Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512
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