Skip to content

Support integrals in ArrayDiscretization - #655

Merged
ChrisRackauckas merged 4 commits into
SciML:masterfrom
utkuyilmaz1903:feature/array-integrals
Aug 26, 2026
Merged

ChrisRackauckas merged 4 commits into
SciML:masterfrom
utkuyilmaz1903:feature/array-integrals

Conversation

@utkuyilmaz1903

@utkuyilmaz1903 utkuyilmaz1903 commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

Part of #623.

Summary

Integrals still expanded to one scalar equation per grid point, so both the equation count and the expression size grew with n. They are reductions, not stencils: the pointwise path is the trapezoid rule (I[1] = 0, then a running sum of (Δ/2)*(u[k-1]+u[k])). The array path writes that same arithmetic once.

  • Cumulative Integral(xmin, x)(u): full-axis increments plus a registered prefix scan (axis_cumsum_pad). Same weights as _euler_integral.
  • Whole-domain Integral(xmin, xmax)(u): weighted sum, and only when the integration axis is absent from the equation variable (the existing indexmap / bvar filter). 0D and single-point BCs get the compact sum so the RHS stays O(1) nodes.
  • 0D dependents (S(t), R(t)) bind as scalars, which is what keeps the age-structured SIR I(a,t) equation in slice form.

Scalar sides of an array equation (the ~ 0 residual, a 0D variable) broadcast onto a core slice. fill(0, n) was an array_literal and made the expression grow with the grid.

Same-signature whole-domain (integral(t,x) ~ Ix(u(t,x)) with x on the equation) is still not substituted. That was never a scalar interior scheme; it stays a docs limitation. (a,b) limits and composite integrands are unchanged.

Results

Case Array eqs vs resolution Numerics
1D cumulative Ix(u), xmin..x 2 count and treesize fixed (n=11 vs 41) trapezoid residual ≤ 1e-10; analytic atol=0.36
Nonuniform dx vector 2 treesize fixed (n=11 vs 31) trapezoid residual ≤ 1e-10
2D cumulative along one axis 2 treesize fixed (8×6 vs 16×10) structure only
PIDE Dt(u)+Dx(cumuSum), aux wrap 1 interior treesize fixed (n=12 vs 24) solve(prob) succeeds
Dt(u) ~ Dxx(u) + Ix(u) 1 interior — slice form
0D cumuSum(t) ~ Ix(u) 1 scalar treesize fixed (n=11 vs 41) compact sum; analytic atol=0.3
Rank drop v(t,y) ~ Ix(u(t,x,y)) 2 treesize fixed (8×6 vs 16×10) sum along x
SIR-age (I spatial, S/R 0D) 1 interior 5 eqs at n=10 and n=20 compact sum on S/R; solve(prob) succeeds

Falls back

Unchanged from the scalar path: (a,b) intervals, composite integrands without an aux, stationary systems, and equations that already fall back for another reason. Same-signature whole-domain in the interior is still not a scheme.

The pointwise trapezoid rule is unchanged; the array path writes the same increments once as a scan or a weighted sum.
Broadcast a scalar residual onto a slice instead of fill, which inlined one zero per point. Rename array_zerod_value for the spell checker.
@utkuyilmaz1903
utkuyilmaz1903 force-pushed the feature/array-integrals branch from 50078d7 to 56f57d6 Compare August 23, 2026 19:41
@utkuyilmaz1903

Copy link
Copy Markdown
Member Author

Do not merge this yet.

@utkuyilmaz1903
utkuyilmaz1903 marked this pull request as ready for review August 25, 2026 09:41
@utkuyilmaz1903

Copy link
Copy Markdown
Member Author

@ChrisRackauckas This is now ready for review.

@ChrisRackauckas
ChrisRackauckas merged commit 806d7a8 into SciML:master Aug 26, 2026
69 checks passed
ChrisRackauckas referenced this pull request Aug 27, 2026
v1.1.1 was never registered - AutoMerge rejected it because `import MethodOfLines` failed, and that PR was closed unmerged. The version number is therefore still free, so 1.1.2 would skip it and trips the sequential-version guideline. Restore 1.1.1, keeping the Symbolics 7.38 floor that actually fixes the load failure.



Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

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