Skip to content

Support Complex-typed dependent variables in PDE splitting - #131

Merged
ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/130-complex-typed
Sep 24, 2026
Merged

ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/130-complex-typed

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Change

Complex-typed Symbolics dependent variables are Complex{Num} values whose equations and boundary conditions arrive as already split real/imaginary expressions. PDEBase now extracts the underlying dependent-variable call, preserves nested equation vectors, renames typed real/imaginary components directly, and splits complex initial pairs into real fields. The regression covers conj, real, imag, abs2, both cubic forms, and boundary values; the workflow docs now recommend @variables ψ(..)::Complex, and the patch version is 0.1.38.

This branch is stacked on the head of #126 as requested. That head contains two follow-up commits after the merged #126 commit, so they also appear in this PR's diff against master.

Verification

Before the fix, with only the new regression test present:

$ GROUP=Core /home/crackauc/.juliaup/bin/julia +1.11 --project=. -e 'using Pkg; Pkg.test()'
Complex-typed dependent variable splitting: Error During Test at test/complex_splitting.jl:56
  MethodError: no method matching operation(::Complex{Symbolics.Num})
    [1] chain_flatten_array_variables(dvs::Vector{Complex{Symbolics.Num}})
Test Summary:                                          | Pass  Error  Total
Core/complex_splitting.jl                              |    4      1      5
ERROR: Package PDEBase errored during testing

After the fix, with TMPDIR and JULIA_DEPOT_PATH directed to this job's scratch directories and OPENBLAS_NUM_THREADS=4:

$ GROUP=Core /home/crackauc/.juliaup/bin/julia +1.11 --project=. -e 'using Pkg; Pkg.test()'
Core/complex_splitting.jl |   16     16  17.1s
Core/discrete_initialization.jl |   18     18  8.3s
Core/interface.jl |   25     25  10.0s
Core/public_api.jl |   46     46  2.2s
Core/system_tspan.jl |    5      5  1m19.2s
     Testing PDEBase tests passed
$ GROUP=QA /home/crackauc/.juliaup/bin/julia +1.11 --project=. -e 'using Pkg; Pkg.test()'
QA/qa.jl |   20     20  4m00.1s
     Testing PDEBase tests passed
$ /home/crackauc/.juliaup/bin/julia +1.11 --project=docs -e 'using Pkg; Pkg.develop(path="."); Pkg.instantiate(); include("docs/make.jl")'
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.
[ Info: Automatic `version="0.1.38"` for inventory from ../Project.toml

Runic --check on the changed Julia files, typos on the diff, and git diff --check all exited 0. In a scratch environment with this PDEBase checkout and a scratch MethodOfLines clone containing the typed-symbol indexing diff in the job report, the proposed NLS test printed:

Complex-typed cubic NLS plane wave |    4      4  1m33.7s
NLS abs2 retcode=Success maxerr=5.893235022763416e-12
NLS conj retcode=Success maxerr=5.893235022763416e-12

Review round 1 follow-up

The typed-field regression now runs handle_complex followed by make_pdesys_compatible, matching symbolic_discretize, and also checks the reverse order. A mixed ψ::Complex and untyped u system now raises an explicit ArgumentError from handle_complex; the workflow docs state this limitation.

Before this follow-up, the new mixed-field assertion failed with:

Mixed complex-typed and untyped dependent variables: Test Failed
  Expected: "Complex-typed and real dependent variables cannot be mixed"
   Message: "ArgumentError: Collection has multiple elements, must contain exactly 1 element"

After the follow-up, with the same scratch TMPDIR/depot and OPENBLAS_NUM_THREADS=4:

$ GROUP=Core /home/crackauc/.juliaup/bin/julia +1.11 --project=. -e 'using Pkg; Pkg.test()'
Core/complex_splitting.jl |   29     29  19.3s
     Testing PDEBase tests passed
$ GROUP=QA /home/crackauc/.juliaup/bin/julia +1.11 --project=. -e 'using Pkg; Pkg.test()'
QA/qa.jl      |   20     20  5m56.9s
     Testing PDEBase tests passed
$ /home/crackauc/.juliaup/bin/julia +1.11 --project=docs -e 'using Pkg; Pkg.develop(path="."); Pkg.instantiate(); include("docs/make.jl")'
[ Info: CheckDocument: running document checks.
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.

Runic, typos, and git diff --check exited 0 on the follow-up diff.

Limits and review

The full MethodOfLines test group and documentation build were not run. Its tutorial and test updates, plus the solution indexing change needed for sol[ψ(t,x)] when ψ is Complex{Num}, are recorded as an exact diff in /home/crackauc/sandbox/agent-jobs/PDEBase.jl/jobs/130-codex/REPORT.md; no MethodOfLines PR was opened. GPU and downstream packages beyond this scratch MethodOfLines scenario were not tested. Please review the explicit mixed-field limitation and the stacked follow-up commits from #126.

Part of #130. Please ignore this draft until reviewed by @ChrisRackauckas.

🤖 Generated with Codex CLI 0.156.1 (model: gpt-6-sol); session: local transcript at /home/crackauc/sandbox/agent-jobs/PDEBase.jl/jobs/130-codex/log.txt on amdci2.julia.csail.mit.edu

Risk assessment

  • Risk: low

  • Blast radius: Only PDE systems whose dependent variables are Complex{Num}, meaning they were declared @variables ψ(..)::Complex. That input used to hit MethodError: no method matching operation(::Complex{Symbolics.Num}) in chain_flatten_array_variables, so no working user code can depend on the old behaviour. Real and untyped systems still go through the same code: _dependent_variable_term falls back to safe_unwrap, and typed_dvs is false when no dependent variable is Complex{Num}. The one general change is that apply_lhs_rhs now recurses into nested AbstractVector equations, where it used to throw. That only affects inputs that errored before. Downstream, MethodOfLines and PDESystemLibrary would see the change through symbolic_discretize, and their downstream CI lanes pass. The users most likely to hit problems are people who follow the new docs advice to declare fields ::Complex. End-to-end use in MethodOfLines (sol[ψ(t,x)]) needs a solution-indexing change that exists only as a local diff and has not been opened as a PR. The description says this.

  • Evidence: All 26 checks on head 386079242c561bc5e4c5b4914cfbacb9e3a6e843 pass, so there are no failures to compare against master. They include:

    • tests / Core on Julia 1, 1 x86 and lts
    • tests / QA (julia 1)
    • Documentation / Build and Deploy Documentation
    • Downgrade / Downgrade Tests
    • Runic, Spell Check with Typos, benchmark (1) and benchmark (lts)
    • all 13 MethodOfLines.jl/* downstream groups and PDESystemLibrary.jl/Core

    Master's latest commit 7853500fcec1443aaecb9b680dfc379c3d153311 (from Add get_system_unknowns so discretizers can keep array-valued unknowns #124) passes the same checks. tests / Core (julia pre) passes in 33 s on the PR because the workflow skips it on purpose: Julia 1.13.0 is not a release candidate. The same skip-as-pass happens on master, so the pre lane gave no signal. The branch is 3 commits ahead of master and 0 behind. It is a draft with no reviews and no review or issue comments.

    Other findings:

  • Independent review: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated it low risk, high confidence: the new code only runs for Complex{Num} dependent variables, which used to crash, and every CI lane passes on the head commit.

  • Merge: needs human review. Findings:

    1. The PR is a draft and its body says to ignore it until @ChrisRackauckas has reviewed it, including the mixed complex/real limitation.
    2. The docs now recommend ::Complex fields, but MethodOfLines can't index those solutions until its unopened change lands.
    3. The version bump makes merging a release decision that also ships Add get_system_unknowns so discretizers can keep array-valued unknowns #124 and Cover complex Dirichlet splitting and clean helper #129, and the body doesn't say so.
    4. The body's claim that Fix real-imaginary coupling in complex PDEs #126's follow-up commits are in this diff is out of date.

Links:


🤖 Risk assessment added by an AI agent — harness: Devin CLI 3000.11.3 · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium (independent review run as devin -p; posted by the fleet-master session, Devin CLI / Fusion Claude Opus 5.5 Medium + SWE-2 Medium)
Conversation: local, non-interactive run; output at ~/sandbox/fleet-master/assess-0924/out-PDEBase.jl-131.md on Chris's Mac (no session URL)

ChrisRackauckas and others added 3 commits September 23, 2026 18:53
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.156.1
Agent-Model: gpt-6-sol
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/PDEBase.jl/jobs/130-codex/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.156.1
Agent-Model: gpt-6-sol
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/PDEBase.jl/jobs/130-codex/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.156.1
Agent-Model: gpt-6-sol
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/PDEBase.jl/jobs/130-codex/log.txt on amdci2.julia.csail.mit.edu
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the agent/130-complex-typed branch 2 times, most recently from 114ded6 to 3860792 Compare September 23, 2026 23:10
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 24, 2026 08:51
@ChrisRackauckas
ChrisRackauckas merged commit 6bf3551 into SciML:master Sep 24, 2026
26 checks passed
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