Skip to content

Support time-literal references in ArrayDiscretization - #665

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
utkuyilmaz1903:feature/array-time-literal-references
Aug 30, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
utkuyilmaz1903:feature/array-time-literal-references

Conversation

@utkuyilmaz1903

Copy link
Copy Markdown
Member

Part of #623. Continues #626.

Interior u(0, x) (and mixed u(0, 1), u(0, 0, y)) stay in array form. The discrete unknown is U(t); U(t0) is not an unknown, so the matching IC formula is evaluated on the slice and held as one term. Same leftover-free bar as #626 — the scalar path leaves u(0, x_i). No bitwise claim against that leftover residual.

Results

Case Array eqs Check
1D + u(0, x), u(0,x) ~ sinpi(x) 1 leftover-free; treesize equal at n=11 vs 41; successful_retcode; DAE and ODE codegen
u(0.0, x) 1 same; 0 / 0.0
Nonzero IC drives the residual 1 f(u0,p,0) not tiny; trajectory not identically zero
2D + u(0, x, y) 1 leftover-free; successful_retcode
Mixed + u(0, 1) 1 leftover-free
2D face + u(0, 0, y) 1 leftover-free
Coupled + v(0, x) 2 leftover-free; nested u(0,x) ~ v(0,x) resolves
Nonuniform + u(0, x) 1 successful_retcode
Periodic + u(0, x) 1 leftover-free on wrap boxes too
Winding u(0, x)*Dx(u) 1 leftover-free; successful_retcode

Falls back

u(1, x) on [0, 1], Dx(u(0, x)), Dt(u(0, x)), off-edge u(0, 0.5). Dx(u(t, 1)) stays #664.

@utkuyilmaz1903
utkuyilmaz1903 force-pushed the feature/array-time-literal-references branch from 44b78dd to cd446b2 Compare August 28, 2026 09:52
@utkuyilmaz1903
utkuyilmaz1903 marked this pull request as ready for review August 28, 2026 21:04
Interior u(0, x) stays one array term: the matching IC formula is evaluated on the slice because the discrete unknown is U(t), not U(t0). Nested ICs resolve; the held field is one term so treesize does not grow with the grid.
@utkuyilmaz1903
utkuyilmaz1903 force-pushed the feature/array-time-literal-references branch from 7a6e76e to 8cf01c9 Compare August 29, 2026 19:25
`should_transform`: Whether to automatically transform the system to make it compatible with MethodOfLines where possible, defaults to true. If your system has no mixed derivatives, all derivatives are purely of a dependent variable i.e. `Dx(u_aux(t,x))` not `Dx(v(t,x)*u(t,x))`, excepting nonlinear and spherical Laplacians for which this holds for the innermost derivative argument, and no expandable derivatives, this can be set to false for better discretization performance at the cost of generality, if you perform these transformations yourself.

MethodOfLines generates the interior of each PDE as a single symbolic array equation over slices of the discretized variables, e.g. `D(u[2:n-1]) - (u[1:n-2] .- 2u[2:n-1] .+ u[3:n]) ./ dx^2 ~ 0`. This keeps the number of symbolic equations independent of the grid resolution and scales much better during symbolic processing. Nonlinear Laplacians `Dx(a(u) * Dx(u))`, spherical Laplacians `r^-2 Dr(r^2 Dr(u))`, mixed derivatives `Dx(Dy(u))` and higher two-direction combinations such as `Dx^2(Dy(u))`, WENO / functional advection (on uniform grids, and on nonuniform grids — periodic or not — for schemes that provide a coefficient split; WENO does; user schemes opt in by defining a method on `MethodOfLines.array_scheme_split`), staggered grids, self-periodic interfaces, two-domain interface boundaries, boundary values appearing inside an interior equation (e.g. `u(t, 1)`), derivatives of those values in a pinned direction (e.g. `Dx(u(t, 1))`), integrals (a trapezoidal running sum or a weighted `sum` along one axis — a reduction, not a stencil), and lower-dimensional fields broadcast onto the equation axes (`v(t, x)` or `S(t)` in a `u(t, x, y)` equation) are included in the array form, including on wrap boxes near a periodic or two-domain seam. A two-domain join whose interface axis occupies different argument positions, or whose remaining axes have different discrete lengths, is rejected rather than remapped. Patterns without a slice representation (nonuniform advection schemes without a coefficient split, schemes that read the grid coordinate, linear operators on a nonuniform two-domain interface, a higher-dimensional field whose extra axes are free, time-literal references such as `u(0, x)`, boundary values on edge-aligned grids, tangential or mixed derivatives of a boundary value, stationary systems) automatically fall back to pointwise scalar equations for the affected equation.
MethodOfLines generates the interior of each PDE as a single symbolic array equation over slices of the discretized variables, e.g. `D(u[2:n-1]) - (u[1:n-2] .- 2u[2:n-1] .+ u[3:n]) ./ dx^2 ~ 0`. This keeps the number of symbolic equations independent of the grid resolution and scales much better during symbolic processing. Nonlinear Laplacians `Dx(a(u) * Dx(u))`, spherical Laplacians `r^-2 Dr(r^2 Dr(u))`, mixed derivatives `Dx(Dy(u))` and higher two-direction combinations such as `Dx^2(Dy(u))`, WENO / functional advection (on uniform grids, and on nonuniform grids — periodic or not — for schemes that provide a coefficient split; WENO does; user schemes opt in by defining a method on `MethodOfLines.array_scheme_split`), staggered grids, self-periodic interfaces, two-domain interface boundaries, boundary values appearing inside an interior equation (e.g. `u(t, 1)`), derivatives of those values in a pinned direction (e.g. `Dx(u(t, 1))`), time-literal references such as `u(0, x)`, integrals (a trapezoidal running sum or a weighted `sum` along one axis — a reduction, not a stencil), and lower-dimensional fields broadcast onto the equation axes (`v(t, x)` or `S(t)` in a `u(t, x, y)` equation) are included in the array form, including on wrap boxes near a periodic or two-domain seam. A two-domain join whose interface axis occupies different argument positions, or whose remaining axes have different discrete lengths, is rejected rather than remapped. Patterns without a slice representation (nonuniform advection schemes without a coefficient split, schemes that read the grid coordinate, linear operators on a nonuniform two-domain interface, a higher-dimensional field whose extra axes are free, derivatives of time-literals, boundary values on edge-aligned grids, tangential or mixed derivatives of a boundary value, stationary systems) automatically fall back to pointwise scalar equations for the affected equation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably just remove this lol

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it’s gotten pretty unwieldy.

@ChrisRackauckas
ChrisRackauckas merged commit 57b9385 into SciML:master Aug 30, 2026
69 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