Repository navigation
Set the time span on the system symbolic_discretize returns - #116
Merged
ChrisRackauckas merged 1 commit intoSep 8, 2026
Merged
ChrisRackauckas merged 1 commit into
ChrisRackauckas merged 1 commit into
Conversation
generate_system already receives the tspan it returns alongside the system; pass it to the System constructor as well so the discretized system carries its own time span. A caller that keeps only the system can then write ODEProblem(sys, u0) and get the PDE's time interval, instead of having to thread the tuple's second element out of band. The return value is unchanged: symbolic_discretize still returns (system, tspan), which downstream code unpacks. The steady-state branch (t === nothing) builds a NonlinearSystem and is untouched, so a time-independent PDESystem does not acquire a time span. Requires ModelingToolkitBase 1.69, which added the System tspan field. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Agent-Harness: Claude Code 2.1.263 Agent-Model: claude-opus-5 Agent-Session: https://claude.ai/code/session_01H5RuLDtEazwTKPkNbPeZVu Claude-Session: https://claude.ai/code/session_01H5RuLDtEazwTKPkNbPeZVu
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.
What changed and why
generate_systemalready receives thetspanit returns alongside the system. It now also passes it to theSystemconstructor, so the discretized system carries its own time span (thetspanfield added toSystemin ModelingToolkitBase 1.69.0, SciML/ModelingToolkit.jl#5085). A caller that keeps only the system can then writeODEProblem(sys, u0)and get the PDE's own time interval, rather than threading the tuple's second element out of band.Motivation: SciML/ModelOrderReduction.jl#29.
The return type is unchanged.
symbolic_discretizestill returns(system, tspan)andgenerate_systemstill returns that tuple; downstream code that unpacks it, including ModelOrderReduction's test suite, is unaffected. This is purely additive.The steady-state branch (
t === nothing) builds aNonlinearSystemand is untouched, so a time-independentPDESystemdoes not acquire a bogus time span. That is asserted in the new test.[compat]bump:ModelingToolkitBase = "1.69"(was"1.58"). 1.69.0 is registered and merged (JuliaRegistries/General#167382), so this resolves today. PDEBase depends on ModelingToolkitBase directly, so declaring the floor here is sufficient — it does not depend on the ModelingToolkit 11.42.0 release. Version bumped 0.1.34 → 0.1.35.Why here and not in MethodOfLines
The task this came from was framed as a MethodOfLines change, but MethodOfLines constructs no
Systemof its own — it consumesPDEBase.symbolic_discretize, andPDEBase.generate_systemis the single place the discretizedSystemis built. Setting the span from MethodOfLines would mean either duplicating this function or mutating a constructedSystemthrough a non-public setter (@set sys.tspan), since ModelingToolkitBase exposestspanonly as a constructor keyword. Doing it at the construction site is one line and fixes every PDEBase-based discretizer, not justMOLFiniteDifference.The companion MethodOfLines PR is SciML/MethodOfLines.jl#685 — it bumps the PDEBase floor and adds the end-to-end test through a real
MOLFiniteDifferencediscretization.Verification
Julia 1.12.7,
ModelingToolkitBase v1.69.0andModelingToolkit v11.41.0from the registry.The new test fails without the fix
With the one added line (
tspan = tspan,) deleted fromgenerate_systemand everything else identical:The two assertions that pass either way are the
nothing-tspan (steady-state) ones, which is the point of including them.And passes with it
I also checked separately that the span survives the rest of the pipeline, since that is what makes the field useful here — a hand-built
System(...; tspan = (0.0, 3.0))keeps it throughcomplete, throughmtkcompile, and intoODEProblem(simp, nothing).tspan == (0.0, 3.0).Not verified
Pkg.test()here does not exercise them, and the compat floor bump means downstreams need a release before they see this.docs/make.jl) — the only docs change is one paragraph inside an existinggenerate_systemdocstring, no new entries.What a reviewer should push back on
ModelingToolkitBasefloor jumping 1.58 → 1.69 is acceptable, or whether the field should be set behind ahas_tspan-style feature check to keep the floor low. I chose the hard floor because a soft check would silently give the old, tspan-less behaviour on an older ModelingToolkitBase and make the MethodOfLines test flaky depending on resolution.generate_systemdocstring change reads as an instruction to third-party discretizers (it is meant to: a discretizer implementing this hook should set the span too).Ignore this PR until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H5RuLDtEazwTKPkNbPeZVu