Skip to content

Add a symbolic_discretize driver for optimization-system discretizations - #120

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:optimization-driver
Sep 12, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:optimization-driver

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Note: please ignore this PR until it has been reviewed by @ChrisRackauckas.

What changed and why

AbstractOptimizationSystemDiscretization existed but had no driver of its own: it shared the finite-difference symbolic_discretize, which selects an equation variable per PDE, derives the coordinate map from it, loops only over PDEs and hands boundary conditions to the equation discretizer through a boundary map whose parser asserts that every condition sits on a domain boundary. Mesh-free discretizations lower every equation and boundary condition independently on its own residual domain and accept interior conditions, so the NeuralPDE parser rewrite (SciML/NeuralPDE.jl#1161, review item 7) needs a generalized driver to be shared infrastructure rather than a parallel parser.

This adds symbolic_discretize(pdesys, ::AbstractOptimizationSystemDiscretization) in src/symbolic_discretize.jl. After the shared normalization (handle_complex, cardinalize_eqs!, make_pdesys_compatible, VariableMap, interface_errors) it calls

  1. construct_disc_state(disc);
  2. construct_discrete_space(v, pdesys, disc) — new 3-argument hook (the space may depend on the boundary conditions, e.g. to keep interior collocation points off the boundaries); the default forwards to the existing 2-argument method;
  3. construct_differential_discretizer(pdesys, s, disc, orders);
  4. discretize_equation!(disc_state, eq, kind, s, derivweights, disc) — new 6-argument hook, called for every PDE (kind = :pde) and then every boundary condition (kind = :bc);
  5. generate_metadata(s, disc, pdesys, nothing, complexmap, []) and generate_system(disc_state, s, nothing, nothing, metadata, disc; checks), whose return value is returned as is.

The equation-system driver is untouched (its method is now restricted to AbstractEquationSystemDiscretization, which was the only concrete case). NeuralPDE implements these hooks in its rewrite PR. Version 0.1.35 → 0.1.36.

Verification

New test/optimization_driver.jl with a minimal recording discretization, including an interior condition u(0.5, x) ~ 0 that the boundary-map parser would reject. GROUP=Core julia --project -e 'using Pkg; Pkg.test()' on Julia 1.11.9:

Test Summary:               | Pass  Total  Time
Core/optimization_driver.jl |   11     11  1.0s
Test Summary:      | Pass  Total  Time
Core/public_api.jl |   46     46  2.4s
Test Summary:        | Pass  Total     Time
Core/system_tspan.jl |    5      5  1m13.6s
     Testing PDEBase tests passed

Before the change the same test errors because symbolic_discretize runs the equation-system driver on the optimization discretization (get_eqvar returns nothing and ivs(nothing, v) fails), and the interior condition trips the boundary assertion in parse_bcs.

Not verified

QA group, Julia 1.10 and downstream (MethodOfLines) were not run locally; the equation-system path is unchanged apart from the method signature restriction.

🤖 Generated with Claude Code (model: claude-fable-5-1)

https://claude.ai/code/session_01WYPUXLxE9jVu2jXLFRd8ax

`AbstractOptimizationSystemDiscretization` existed but shared the finite-difference
driver, which selects an equation variable per PDE, derives the coordinate map from it
and parses a boundary map that requires every condition to sit on a domain boundary.
Mesh-free discretizations (physics-informed neural networks, SciML/NeuralPDE.jl#1161)
lower every equation and boundary condition independently on its own residual domain,
so give them their own driver: after the shared normalization (`handle_complex`,
`cardinalize_eqs!`, `make_pdesys_compatible`, `VariableMap`, `interface_errors`) it calls
`construct_disc_state`, `construct_discrete_space(v, pdesys, disc)`,
`construct_differential_discretizer`, `discretize_equation!(state, eq, kind, s,
derivweights, disc)` for each PDE and boundary condition, `generate_metadata` and
`generate_system`. New hook defaults forward to the existing ones.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Agent-Harness: 2.1.269 (Claude Code)
Agent-Model: claude-fable-5-1
Agent-Session: https://claude.ai/code/session_01WYPUXLxE9jVu2jXLFRd8ax
Claude-Session: https://claude.ai/code/session_01WYPUXLxE9jVu2jXLFRd8ax
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 12, 2026 21:03
@ChrisRackauckas
ChrisRackauckas merged commit ca99527 into SciML:master Sep 12, 2026
25 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 23, 2026
Ships #126: complex equation normalization preserves the real/imaginary coupling in already-split equation pairs, distributes complex arithmetic across dependent fields, and declares the generated component fields real. Patch — a correctness fix, no API change. (#120's symbolic_discretize driver was already released in 0.1.36; that commit carried the bump.)

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas added a commit that referenced this pull request Sep 23, 2026
Ships #126: complex equation normalization preserves the real/imaginary coupling in already-split equation pairs, distributes complex arithmetic across dependent fields, and declares the generated component fields real. Patch — a correctness fix, no API change. (#120's symbolic_discretize driver was already released in 0.1.36; that commit carried the bump.)



Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)

Co-authored-by: Claude <[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