Skip to content

Fix solution indexing for complex-typed PDE fields - #705

Merged
ChrisRackauckas merged 6 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/704-complex-typed-indexing
Sep 27, 2026
Merged

ChrisRackauckas merged 6 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/704-complex-typed-indexing

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Complex-typed PDE fields now support both direct indexing (sol[ψ(t, x)]) and callable solution queries (sol(t, x; dv=ψ(t, x))). This normalizes the typed symbolic dependent variable for lookup, uses PDEBase's complex component map, adds a cubic NLS plane-wave regression for both abs2(z)*z and z*conj(z)*z, and updates the Schrödinger tutorial to declare ψ(..)::Complex. The callable path also fixes a separate bug for untyped (inferred-complex) fields: src/interface/solution/common.jl read the nonexistent field sol.disc_data_complexmap; it now uses sol.disc_data.complexmap. The PDEBase compat floor is 0.1.38, the released version that contains PDEBase PR #131.

Round-3 follow-up: complex-key normalization previously took only real(key), so sol[conj(z)] and sol[real(z)-2im*imag(z)] silently returned the field. Lookup now accepts only the canonical real(u)+im*imag(u) form and errors on transformed keys (direct, callable, and stationary overloads), with regressions that failed on the previous head and pass after this fix.

Merge / conflict resolution (cont4): merged origin/master (includes #703 Schrödinger phase fix). The only conflict was Project.toml PDEBase compat (0.1.37 on master vs 0.1.38 here); kept 0.1.38.

Risk assessment

  • Risk: low
  • Blast radius: complex-field solution lookup only (src/interface/solution/common.jl: direct, callable and stationary lookup of Complex{Num} dependent variables). No new dependencies or exports. Non-canonical keys such as conj(z) now throw where they used to return the field silently.
  • Evidence:
    • The rejection tests fail 4/4 without the fix and pass 4/4 with it.
    • Local test groups: Complex_Indexing 14+6+2, Complex 2/2, QA 21/21.
    • The reviewer's probes (a stationary problem and a time-dependent cubic NLS) keep valid-key accuracy at about 1e-15.
  • Independent review: Codex (gpt-6-astra), round 4: MERGE, rated low risk with high confidence for the tested lookup paths.
  • Merge: auto-merge candidate once CI is green.
  • Known limitations: sliced typed-key indexing (sol[z, 3, :]) is still a follow-up. Keep discretized dependent variables as array-valued unknowns #701 edits solution indexing in timedep.jl and timeindep.jl; reconcile the two if both merge.

Verification (Julia 1.11, OPENBLAS_NUM_THREADS=4, scratch env scratch/e2e-038 / review probe-env with MethodOfLines developed and registered PDEBase v0.1.38):

  • Pre-fix typed regression (earlier): 2 pass, 4 errors, 6 total — direct indexing MethodError: symbolic_container(::PDESystem); callable MethodError: arguments(::Complex{Num}).
  • Untyped inferred-complex callable before fix: 1 pass, 1 error (disc_data_complexmap); after: 2/2.
  • Round-3 key-rejection before fix (stationary probe, unfixed common.jl):
    conj index max|ans-field|=0.0
    mod index max|ans-field|=0.0
    Test Summary:                                  | Fail  Total  Time
    rejection regressions (expect FAIL before fix) |    4      4  5.7s
    
  • Round-3 key-rejection after fix (same probe):
    conj index threw ErrorException: ... is not a canonical complex dependent variable.
    mod index threw ErrorException: ... is not a canonical complex dependent variable.
    Test Summary:                                 | Pass  Total  Time
    rejection regressions (expect PASS after fix) |    4      4  0.1s
    
  • After round-3, GROUP=Complex_Indexing … Pkg.test("MethodOfLines"):
    Test Summary:                      | Pass  Total     Time
    Complex-typed cubic NLS plane wave |   14     14  5m04.2s
    Test Summary:                              | Pass  Total     Time
    Complex-typed stationary solution indexing |    6      6  1m02.6s
    Test Summary:                      | Pass  Total   Time
    Inferred-complex solution indexing |    2      2  10.7s
         Testing MethodOfLines tests passed
    
  • GROUP=Complex … Pkg.test("MethodOfLines"):
    Test Summary: | Pass  Total     Time
    Complex       |    2      2  5m16.9s
         Testing MethodOfLines tests passed
    
  • GROUP=QA … Pkg.test("MethodOfLines"):
    Test Summary: | Pass  Total      Time
    QA            |   21     21  13m09.8s
         Testing MethodOfLines tests passed
    
  • Runic --check, typos, and git diff --check on changed files: clean.

Not verified: full Everything suite, GPU/CUDA paths, downstream packages, docs linkcheck (previously HTTP 429), runtime composition with still-open #701.

Reviewer attention: PDEBase 0.1.38 is released and required. #701 (array unknowns) still open — source overlap is in other solution files. #703 is on master and merged into this branch. Push back if supporting arbitrary symbolic transforms of complex fields is desired instead of hard rejection.

Closes #704.

Please ignore this draft until reviewed by @ChrisRackauckas.

Cursor Agent CLI 2026.09.26-dd393fe (model: auto); local transcript: /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-codex/log-cont5.txt on amdci2.julia.csail.mit.edu. Prior: Codex CLI 0.156.1 / gpt-6-luna (log.txt); Claude Code cont2 (log-cont2.txt); Cursor Agent cont4 (log-cont4.txt).

Risk assessment

  • Risk: low
  • Blast radius: Only lookups of complex dependent variables on MethodOfLines solutions: sol[z], sol(...; dv = z) and stationary (PDENoTimeSolution) indexing, all in src/interface/solution/common.jl. The new getindex(::PDETimeSeriesSolution/PDENoTimeSolution, ::Complex{Num}) methods only add behaviour; on master these calls hit a MethodError. The untyped callable path changes from reading the nonexistent sol.disc_data_complexmap to sol.disc_data.complexmap[operation(dv)]. That field belongs to MethodOfLines' own MOLMetadata and uses the op → (redv, imdv) dict layout that PDEBase handle_complex returns. The PDEBase compat floor goes from 0.1.37 to 0.1.38, so anyone pinned below 0.1.38 is excluded. The Schrödinger tutorial now declares ψ(..)::Complex. No new dependencies or exports, no non-public dependency internals (it uses Symbolics.unwrap and SymbolicUtils iscall/operation/arguments), no weakened or removed tests, and no SemVer-breaking change.
  • Evidence: Head 3f28d6b has 0 failing checks across 76 contexts, all green. That includes QA, Downgrade, PDESystemLibrary downstream Core, Documentation, Runic, Typos, and the new Complex_Indexing group on lts, 1 and pre. Master's latest Tests run on b5ce411 (https://github.com/SciML/MethodOfLines.jl/actions/runs/35918574444) is 69/69 green, so there are no regressions and nothing pre-existing to excuse. Two caveats:
  • Independent review: Devin CLI (Mac) / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated it low, high confidence: it is a small additive fix to complex-field solution lookup, the canonical-form check mirrors PDEBase's own real(u) detection, and every CI lane is green, including Downgrade and downstream, with regression tests for the typed, untyped and stationary paths.
  • Merge: auto-merge candidate on the no-regression bar, but three things stand in the way:

🤖 Risk assessment posted by an AI agent (fleet master) — harness: Devin CLI (Mac) / fusion-claude-opus-5-5-high-sidekick-swe-2-medium; dispatched by Claude Code head, model claude-opus-5-5[1m]
Conversation: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 on Chris's Mac (session ID, no URL)

ChrisRackauckas and others added 6 commits September 23, 2026 03:24
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.156.1
Agent-Model: gpt-6-luna
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-codex/log.txt on amdci2.julia.csail.mit.edu
Handle Complex{Num} fields in direct and callable solution indexing and document the required field annotation. Require PDEBase 0.1.38, which includes complex-typed dependent-variable support from PDEBase PR SciML#131.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.156.1
Agent-Model: gpt-6-luna
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-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-luna
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-codex/log.txt on amdci2.julia.csail.mit.edu
Resolve Project.toml by keeping PDEBase 0.1.38 (contains complex-typed variable support from PDEBase SciML#131). Bring in SciML#703 Schrödinger phase regression fix.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-codex/log-cont4.txt on amdci2.julia.csail.mit.edu
Validate the full Complex{Num} key against real(u)+im*imag(u) before
lookup so conj(u) and real(u)-2im*imag(u) error instead of aliasing.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-codex/log-cont5.txt on amdci2.julia.csail.mit.edu
Cover direct, callable, and stationary overloads for conj and
real-minus-2imag keys that previously returned the untransformed field.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/MethodOfLines.jl/jobs/704-codex/log-cont5.txt on amdci2.julia.csail.mit.edu
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 27, 2026 03:42
@ChrisRackauckas
ChrisRackauckas merged commit 0bec5b0 into SciML:master Sep 27, 2026
79 checks passed
ChrisRackauckas referenced this pull request Sep 29, 2026
Agent-Harness: Devin CLI 3000.11.3 (Mac)
Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium)
Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

Solution indexing for complex-typed dependent variables (sol[ψ(t,x)] with ψ(..)::Complex)

2 participants