Skip to content

Support mixed derivatives in ArrayDiscretization - #625

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:array-mixed-derivs
Closed

ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:array-mixed-derivs

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Note

Draft — please ignore until reviewed by @ChrisRackauckas.

What changed and why

This adds mixed first-derivative support such as Dx(Dy(u)) to ArrayDiscretization. The implementation builds a tensor-product centered stencil, applies simultaneous shifted slices with per-axis periodic wrapping, and accounts for the centered mixed stencil when determining array-interior bands. Unsupported higher combinations continue to use the existing scalar fallback.

The branch is rebased onto master at 483d2b90. The previously stacked periodic-boundary commit was already present upstream and was dropped during the rebase; the mixed-derivative implementation was integrated with the newer nonlinear/spherical Laplacian, staggered-grid, and functional WENO array paths.

Result

For Dt(u) ~ Dxx(u) + Dyy(u) + 0.5Dx(Dy(u)) with Dirichlet boundaries, the array form remains at nine equations for 11×11, 21×21, and 41×41 grids, while the scalar form grows from 121 to 1,681 equations. The tests cover uniform and nonuniform grids, variable coefficients, 3D derivatives, periodic directions, approximation orders 2/4/6, band width, and fallback behavior.

Regression evidence

The exact new band-width assertion was run against clean master (483d2b90) before applying this commit:

Mixed derivative alone sets the band width: Test Failed
  Expression: narrayeqs_interior(sys) == 1
   Evaluated: 0 == 1
Test Summary:                              | Fail  Total     Time
Mixed derivative alone sets the band width |    1      1  2m56.9s

The same script against this branch passes:

Test Summary:                              | Pass  Total     Time
Mixed derivative alone sets the band width |    1      1  3m39.8s

Local verification

  • GROUP=Array_Discretization julia +release --startup-file=no --project=. -e 'using Pkg; Pkg.test()'

    Array_Discretization | 3218   3218  35m01.7s
    Testing MethodOfLines tests passed
    
  • GROUP=Mixed_Derivatives julia +release --startup-file=no --project=. -e 'using Pkg; Pkg.test()'

    Mixed_Derivatives | 2 pass, 3 pre-existing broken, 5 total | 7m50.2s
    Testing MethodOfLines tests passed
    
  • GROUP=QA julia +release --startup-file=no --project=. -e 'using Pkg; Pkg.test()'

    QA | 12 pass, 6 pre-existing broken, 18 total | 10m49.9s
    Testing MethodOfLines tests passed
    
  • Runic 1.9.0 check over all changed Julia files: exit 0, no diff.

  • typos over added diff lines: exit 0, no findings.

  • After developing the checkout into the docs environment, julia +release --startup-file=no --project=docs docs/make.jl executed every example and resolved all cross-references. It then failed only on unauthenticated GitHub link checks returning HTTP 429; no example, doctest, or source-reference error occurred. A separate strict one-page API build exited 0.

  • GitHub CI on this rebased head: 69/69 checks successful.

Not verified locally

  • GROUP=Everything
  • GPU, Julia pre-release, and downstream jobs

Remaining ArrayDiscretization gaps are tracked at #623.

The feature was merged through #648 as eb6ae16 while this draft's CI was running. This draft is therefore superseded.

`Dx(Dy(u))` caused the whole equation to fall back to pointwise discretization.
The scalar scheme (`mixed_central_difference`) is the tensor product of the two
centered first order stencils, which is translation invariant across the interior
in both directions at once, so it has a slice form: the same broadcasted sum of
shifted slices `array_central_difference` builds, with a second shifted axis.

- `array_shifted_slice` generalises `array_slice` to shifts along several axes,
  each wrapped independently where its direction is periodic, mirroring the two
  separately `bwrap`ped tap sets the scalar path takes the product of.
- `array_interior_stencil` factors the interior `(weights, taps)` out of
  `array_central_difference` so both it and the mixed form take their weights from
  the same `DerivativeOperator`s the scalar path uses.
- `array_bands` gains the directions a mixed derivative reaches along: those use
  the *centered* first order stencil, which at higher approximation orders is wider
  than the winding stencil the order 1 entry of `pdeorders` would select. Without
  this an equation whose only derivative in a direction is the mixed one builds a
  band that reaches past the grid and degrades to pointwise.

Mixed patterns the scalar path has no scheme for, such as a mixed derivative of
higher order in one direction, still reach `arrayify` with a spatial differential
in place and fall back (and raise under `StrictArrayDiscretization`).

The discretized equation sets are identical to `ScalarizedDiscretization`: on a
2D diffusion equation with `0.5*Dxy(u)` on 11x11, 21x21 and 41x41 grids the array
form is 9 equations at every resolution against 121/441/1681 scalar ones, with
both the right hand side at a random state and the solution matching bitwise
(maxdiff 0.0).

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Closing as superseded by #648, which @ChrisRackauckas merged as eb6ae16 while this draft's CI was running.

This branch was rebased onto 483d2b90, integrated with the intervening ArrayDiscretization work, and validated before the upstream refresh. The regression failed on the unfixed base and passed here; local ArrayDiscretization, Mixed_Derivatives, QA, Runic, spelling, and docs-source checks completed, and GitHub CI finished 69/69 successful on a3fcfc9c2c963e95048e01f831e5a5c00e8b08a6.

The merged PR contains the equivalent mixed-derivative implementation plus its cleanup and additional tests, so no unique feature change remains to rebase from this draft.

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.

3 participants