Repository navigation
Support time-literal references in ArrayDiscretization - #665
Merged
ChrisRackauckas merged 1 commit intoAug 30, 2026
Merged
ChrisRackauckas merged 1 commit into
ChrisRackauckas merged 1 commit into
Conversation
utkuyilmaz1903
force-pushed
the
feature/array-time-literal-references
branch
from
August 28, 2026 09:52
44b78dd to
cd446b2
Compare
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
force-pushed
the
feature/array-time-literal-references
branch
from
August 29, 2026 19:25
7a6e76e to
8cf01c9
Compare
| `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. |
Member
There was a problem hiding this comment.
we should probably just remove this lol
Member
Author
There was a problem hiding this comment.
Yeah, it’s gotten pretty unwieldy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #623. Continues #626.
Interior
u(0, x)(and mixedu(0, 1),u(0, 0, y)) stay in array form. The discrete unknown isU(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 leavesu(0, x_i). No bitwise claim against that leftover residual.Results
+ u(0, x),u(0,x) ~ sinpi(x)successful_retcode; DAE and ODE codegenu(0.0, x)0/0.0f(u0,p,0)not tiny; trajectory not identically zero+ u(0, x, y)successful_retcode+ u(0, 1)+ u(0, 0, y)+ v(0, x)u(0,x) ~ v(0,x)resolves+ u(0, x)successful_retcode+ u(0, x)u(0, x)*Dx(u)successful_retcodeFalls back
u(1, x)on[0, 1],Dx(u(0, x)),Dt(u(0, x)), off-edgeu(0, 0.5).Dx(u(t, 1))stays #664.