Skip to content

Add StrongForm divergence split, slot form and analyse - #148

Merged
xtalax merged 17 commits into
SciML:masterfrom
xtalax-droid:forge/strongform-2-divergence
Oct 28, 2026
Merged

xtalax merged 17 commits into
SciML:masterfrom
xtalax-droid:forge/strongform-2-divergence

Conversation

@xtalax-droid

Copy link
Copy Markdown
Contributor

Depends on #146 (StrongForm skeleton, stages 0 and a). This PR is stacked on it; review the commits after #146's.

This PR adds stages b and c of the strong-form analysis that a finite-element discretizer builds its weak form from, plus the analyse driver for volume equations. Every equation is written as e = m⋅u̇ + Σᵢ ∂ᵢGᵢ + R in symbolic quadrature-point slots.

What this adds

  • split_divergence(spatial, sivs, policy) (stage b) writes the spatial part of each equation as Σᵢ ∂ᵢGᵢ + R. It uses the single product rule c⋅Dᵢ(w′) = Dᵢ(c⋅w′) − (Dᵢc)⋅w′, which covers divergence form, cross terms, vector fluxes, non-divergence a(x)Δu and u⋅Δu. First-order terms stay in R in advective form. It rejects:

    • operators of order three or more, naming the true order ("third-order operator needs a mixed or C¹ formulation");
    • second derivatives outside a divergence-compatible position.
  • Coefficient smoothness:

    • On the product-rule path, a coefficient containing ifelse, abs, max, min, sign, floor, mod and the like, or a function with no derivative rule, is rejected: "coefficient … is not differentiable; write the equation in divergence form or register the derivative". The full list is NONSMOOTH_FUNCTIONS.
    • Wherever a derivative is expanded (the remainder, the inner w′, mass coefficients), a discontinuous function of that variable is rejected so that a jump's delta term is never silently dropped. That list is DISCONTINUOUS_FUNCTIONS, and a NaN in the derivative is rejected as well. Continuous functions such as abs(u) remain allowed there.
  • Integration-by-parts policies:

    • ProductRule() is the default. It warns when a nonzero correction is actually generated, because the stiffness matrix is then non-symmetric.
    • Weighted(w) analyses w⋅e. Weighted(r²) recovers the symmetric spherical Laplacian.
    • Reject() errors on any term that would need the product rule.
  • SlotContext and slot_volume (stage c) write mass, flux, remainder and the strong residual in StateSlots. Array parameters are given one P slot per element. Leftover symbols raise "unresolved symbols … register the derivative".

  • analyse(pdesys, v, boundarymap; ibp) is the only export of StrongForm. It returns a StrongFormAnalysis with:

    • mass[e] = Σ_f m_ef⋅Ud_f;
    • strong, flux and remainder;
    • the conormal coefficients ∂(G⋅N)/∂G.

    Policies keyed by an Equation are matched through PDEBase's preprocessing, including array-variable flattening. Keys that match no equation, or that conflict, raise an error. The input system is never mutated. Boundary conditions are refused with a clear error until the next PR in the series.

  • An opaque registered coefficient with no derivative rule is accepted in divergence form, as in Dx(a(x)*Dx(u)). strong may then hold an unevaluated derivative of it. The new public check_evaluable(ex) rejects such expressions, and analyse guarantees that mass, flux, remainder and conormal never hold one.

  • StrongForm and make_pdesys_compatible are declared public, with a new docs page, "Strong-Form Analysis".

Tests (test/strongform_analyse.jl, Core)

  • Cases (i), (ii), (ii-b), (ii-c) and (iii) of the design, in slot form.
  • The reconstruction identity strong = mass + Σᵢ ∂ᵢGᵢ + R at random slot values, with a reusable helper in test/shared/strongform_identity.jl.
  • The collocation strong kernel vanishes at an exact solution (≤ 1e-13).
  • Accepted rows: mixed partials, multi-field coupled flux, algebraic row, wave as a first-order system, time-dependent coefficients, ifelse in divergence form, continuous state fluxes, and an opaque coefficient in divergence form.
  • Rejections: KdV and other third-order cases, including inside a nonlinearity; the biharmonic; sin(Δu); u_x⋅u_xx; non-smooth coefficients (ifelse, mod, rem, clamp, abs(x−½)) in non-divergence form; jumps under first-order derivatives and in mass coefficients; unregistered coefficients.
  • Weighted(r²) versus ProductRule, and integration-by-parts key matching and its errors.

Local results: Core passes on all 13 files; QA passes 20/20; Runic is clean. The full Documenter build was not run locally.


Reviewed by Codex (forge codex-review, approve) after three rounds by an independent Claude Opus subagent while the Codex workspace was out of credits.

🤖 Posted by an AI agent · harness: Claude Code 2.1.310 · model: claude-opus-5-5
Review: unreviewed
Session: 70c8f395-69e3-4537-a58e-403f04ff7912

xtalax and others added 9 commits October 24, 2026 21:26
split_divergence writes each equation's spatial part as a divergence plus remainder by the product rule, with the IBP policies, the coefficient smoothness check and order-naming rejections; slot_volume and SlotContext put mass, flux, remainder and the strong residual into slots; analyse ties the stages together and computes the conormal coefficients. split_time now distributes derivatives over sums so stage b sees one second-order factor per term. Boundary conditions are refused until the next PR.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…ng, skip vanishing corrections

Review findings: an array parameter became one scalar P slot, so a[1] could not be rebuilt; each element now has its own slot (column-major, in parameter order) and indexed parameters are matched before descending. Equation-keyed ibp policies stopped matching once cardinalize_eqs! rewrote the equation; keys now match by residual up to sign, and a key matching no equation is an error. Product-rule corrections that cancel, as for (sin² + cos²)Δu split apart by expand, no longer warn or trip Reject().

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
Review findings: mod, rem, clamp and other discontinuous functions passed the smoothness check, leaving a NaN-valued correction; they are now listed, and a coefficient whose derivative is piecewise in the variable or NaN is rejected too. Terms of order three or more inside a nonlinearity now get the ordinal message. Conflicting ibp keys for one equation are an error, keys written with array-variable fields are flattened like the system before matching, the correction warning names the policy, and distribute_derivatives drops derivatives of numeric constants.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
Interpolating the policy printed it module-qualified under SciMLTesting (PDEBase.StrongForm.ProductRule()), so the warning text depended on the caller's imports; the type name is stable.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
Review findings: a jump under a first-order derivative, such as Dx(ifelse(...)*u), or inside the inner w′ of a second-order term was accepted and lost its delta when slot_volume expanded the derivative. Every spatial derivative that will be expanded now needs a differentiable argument, raising the existing not-differentiable error; the divergence form Dx(ifelse(...)*Dx(u)) stays accepted because c⋅w′ enters the flux undifferentiated. ibp keys that are neither Equations nor integers now get a clear error, and the docstring says integer keys index the flattened equation list.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…check mass coefficients

Review findings: the jump check also rejected continuous non-smooth fluxes such as Dx(abs(u)) that are differentiated correctly almost everywhere. Expanded derivatives now only reject DISCONTINUOUS_FUNCTIONS (NONSMOOTH_FUNCTIONS minus abs, max, min, clamp) and NaN derivatives, while the product-rule correction keeps the full M1 list. Mass coefficients such as Dx(jump)*Dt(u) skipped the check and now go through it. The message says expression rather than coefficient when the state is involved.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…eck_evaluable

Dt(u) ~ Dx(a(x)*Dx(u)) with a registered without a derivative rule was rejected because the strong residual is derivative-expanded, although spec §8.2 accepts it: the flux a⋅∇u needs no derivative of a. The strong residual now keeps such derivatives in slot coordinates. check_evaluable names any unevaluated derivative, since build_function would compile it to zero; consumers call it on strong, and analyse asserts it on mass, flux, remainder and conormal.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
FiniteElementMethod reaches PDEBase.StrongForm and runs make_pdesys_compatible in its own pipeline, so both are declared public. make_pdesys_compatible gets a docstring and a docs entry, and a Strong-Form Analysis page renders the StrongForm API.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…names

names(PDEBase) lists public names too on Julia 1.11+, and StrongForm is now public.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…bles

Fields followed VariableMap's discovery order, so a system declared [u, w] whose equations mention w first got fields [w, u]. StrongForm now numbers fields by the declared order of pdesys's dependent variables (declared_fields), leaving VariableMap unchanged; SlotContext takes the system for this.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 26, 2026
Resolves the import and public-API lists, and moves the boundary tests to SlotContext(pdesys, v) now that fields follow the system's declared order.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: 70c8f395-69e3-4537-a58e-403f04ff7912
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 85a2102 (fast-forward): StrongForm now numbers fields in the declared order of pdesys.dvs (new public StrongForm.declared_fields(pdesys, v); SlotContext(pdesys, v) replaces SlotContext(v)); VariableMap is unchanged. Regression test declares [u, w] with w first in the equations. Codex: approve, 0 findings.


🤖 Posted by an AI agent · harness: Claude Code 2.1.310 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

xtalax and others added 6 commits October 28, 2026 00:44
…to forge/strongform-2-divergence

Integration only.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…ry order

At the lowest compat the derivative of mod is not the piecewise form is_piecewise looks for, and depvars comes out in a different order. is_smooth already rejects mod and rem by name, so the test now checks that; the field-order test runs both declared orders, one of which differs from discovery whichever it is.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
…e/strongform-2-divergence

Integration only.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
split_divergence raised on the first term of order > 2 in the order the sum was given, so a system mixing third- and fourth-order terms (PDESystemLibrary gen1..gen3) was rejected with the third- or the fourth-order message depending on the Julia version's term ordering. Check all terms up front and name the highest order, so the rejection is identical on every Julia version.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
(cherry picked from commit 9b8862def4eee5073e0d1dc96285577483f5d8a3)
…trongform-2-divergence

Integration only; docs/src/strongform.md conflict resolved by keeping the fuller page already on this branch.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
Integration only: resolved src/PDEBase.jl by taking the union of the @public/include/export additions of both sides.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: no conflicts; carries the resolved SciML#146/SciML#148/SciML#149 tips and upstream/master.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: no conflicts; carries the resolved SciML#146/SciML#148/SciML#149/SciML#150 tips and upstream/master.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
@xtalax
xtalax marked this pull request as ready for review October 28, 2026 19:44
Integration only: src/PDEBase.jl (@public list) and test/public_api.jl (developer API names) conflicted; kept the union of both sides' entries.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
@xtalax
xtalax merged commit 050fbdc into SciML:master Oct 28, 2026
27 checks passed
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: clean merge of master (SciML#148); no conflicts.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: clean merge of master (SciML#148); no conflicts.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: clean merge of master (SciML#148); no conflicts.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: clean merge of master (SciML#148); no conflicts.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#148, SciML#149 and SciML#150.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#148, SciML#149 and SciML#150.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#148, SciML#149 and SciML#150.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[email protected]>
xtalax-droid pushed a commit to xtalax-droid/PDEBase.jl that referenced this pull request Oct 28, 2026
Integration only: master now contains SciML#148, SciML#149 and SciML#150.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <[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