Skip to content

Cardinalize equations on a copy in symbolic_discretize - #141

Merged
xtalax merged 1 commit into
SciML:masterfrom
xtalax-droid:forge/cardinalize-copy
Oct 28, 2026
Merged

xtalax merged 1 commit into
SciML:masterfrom
xtalax-droid:forge/cardinalize-copy

Conversation

@xtalax-droid

Copy link
Copy Markdown
Contributor

Problem. cardinalize_eqs! rewrites the equation vector of the PDESystem it is given. The symbolic_discretize drivers called it on a system derived from the user's, so they depended on handle_complex happening to return a fresh vector to keep the caller's pdesys.eqs untouched. A direct call on a user's pdesys does mutate it. (Part of the shared-layer work for the FiniteElementMethod.jl design, spec section 4.6.)

Fix. Add cardinalize_eqs(pdesys), which builds a new PDESystem with equations in lhs - rhs ~ 0 form and leaves its input alone. Both symbolic_discretize drivers use it. cardinalize_eqs! is unchanged, because MethodOfLines' get_discrete calls it and keeps using the same pdesys.

Tests. A new testset in test/optimization_driver.jl checks that pdesys.eqs is unchanged after symbolic_discretize and after cardinalize_eqs, and that the returned equations are cardinalized. It errors on master because cardinalize_eqs does not exist there; it was not otherwise run against master. GROUP=Core passes (about 49 s); QA was not run.

Review notes. cardinalize_eqs rebuilds the PDESystem with the same keyword arguments as make_pdesys_compatible (src/make_pdesys_compatible.jl:104); please check no field is dropped. MethodOfLines is left on the mutating variant.


🤖 Posted by an AI agent · harness: Claude Code 2.1.310 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

cardinalize_eqs! rewrote the PDESystem's equation vector in place. Add a copying cardinalize_eqs that returns a new PDESystem and use it in both symbolic_discretize drivers; keep cardinalize_eqs! for downstream callers that rely on the mutation.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
@xtalax
xtalax merged commit c8d9034 into SciML:master Oct 28, 2026
27 checks passed
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#141 and SciML#160.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#141 and SciML#160.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#141 and SciML#160.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#141 and SciML#160.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#141, SciML#142, SciML#143, SciML#144 and SciML#160.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
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