Repository navigation
Default every time-dependent problem constructor to the system's tspan - #5085
Merged
ChrisRackauckas merged 2 commits intoSep 7, 2026
Merged
Conversation
System can now carry its own default tspan, used by ODEProblem when no tspan is passed explicitly. Symbolic (parameter-valued) tspan resolution is not yet supported.
Extend the tspan default from ODEProblem to DAEProblem, DDEProblem, SDEProblem, SDDEProblem, BVProblem, DiscreteProblem and ImplicitDiscreteProblem. Omitting the timespan when the system has none now throws MissingTspanError naming the system and both fixes, rather than silently building a problem with a nothing timespan. Drop symbolic_tspan, which namespaced nothing and duplicated the already-public get_tspan, and fix Base.copy calling copy on a Tuple. JumpProblem keeps its required timespan: a two-argument method with an untyped operating point is ambiguous with JumpProcesses' own JumpProblem(prob, jumps...) family. 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
ChrisRackauckas-Claude
force-pushed
the
tspan-defaults
branch
from
September 7, 2026 06:41
0d02808 to
a7ba911
Compare
ChrisRackauckas
marked this pull request as ready for review
September 7, 2026 09:40
This was referenced Sep 7, 2026
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 7, 2026
The SDE-with-brownians __mtkcompile path rebuilds the System field by field rather than through @set!, so it dropped the tspan field added in #5085. Carry it, raise the ModelingToolkitBase floor to the version that has the field, and run the tspan suite from the root InterfaceII group, where ModelingToolkit is loaded and this path is reachable. 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 Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]>
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.
Ignore this PR until reviewed by @ChrisRackauckas.
Completes #5027, whose only review comment was "Missing many integrations, SDEProblem, DAEProblem, etc." The first commit here is @carldlund's original, cherry-picked with authorship preserved; the second finishes it. Fixes #847. If this lands, #5027 can be closed.
A
Systemcan now carry a time span, and every time-dependent problem constructor falls back to it when the caller omits one.What the first commit already did
Adds the
tspan::Union{Nothing, Tuple}field toSystem, threads it through the inner constructor, the keyword constructor,flatten,copyandisapprox, and defaults it in twoODEProblemmethods.This adds no new public name.
:tspanwas already inSYS_PROPS, soget_tspan/has_tspanalready existed, were already@public, were already in the pinnedREEXPORTED_APIQA list, and already had@docsentries indocs/src/API/System_accessors.md. Only the field was missing; the accessors were vestigial and threw.What the second commit adds
Coverage. The default now applies to
DAEProblem,DDEProblem,SDEProblem,SDDEProblem,BVProblem,DiscreteProblemandImplicitDiscreteProblem, alongsideODEProblem.@fallback_iip_specializepropagates an optional positional argument to the bare and{iip}forms automatically, so each constructor needed one line. The::Type{ODEProblem{iip, spec}}method inodeproblem.jlis the internal_ode_problemhelper and is always called with an explicit tspan, so it deliberately has no default.JumpProblemis excluded, deliberately. Giving it a default creates a two-argumentJumpProblem(sys::System, op)with untypedop, which is ambiguous withJumpProcesses' ownJumpProblem(prob, jumps...)family; Aqua reports exactly 14 ambiguities. Constrainingopwould fix it, butoplegitimately ranges over vectors, dicts, tuples, NamedTuples, StaticArrays andnothing, so narrowing it is a guess. There is a comment saying so at the top ofjumpproblem.jl, and atspan_defaultflag onproblem_docstringso its docstring does not advertise an option it does not have. This is the main thing to push back on if you disagree.Omitting the tspan when neither source has one throws instead of silently succeeding.
get_tspanreturnsnothing, andODEProblem(sys, op, nothing)is legal and used internally, so defaulting toget_tspan(sys)would build an unsolvable problem withtspan === nothing. The default isdefault_tspan(sys), which throwsMissingTspanErrornaming the system and both fixes. Default expressions only evaluate when the argument is omitted, so passingnothingexplicitly still works.Two bugs in #5027 as it stands.
Base.copy(sys::System)calledcopy(get_tspan(sys)), and there is nocopy(::Tuple), so copying any system with a timespan threw aMethodError. Andsymbolic_tspanwas removed: unlikesymbolic_tstopsit does no namespacing and aggregates nothing from subsystems, a timespan is never symbolic, andget_tspanalready exists.extenddoes not forwardtstopseither, sotspanis left out there too, for parity. Deliberate, not an oversight.Known gap, deliberately left for a follow-up
This PR is confined to
lib/ModelingToolkitBase. There is one more site that drops the field, and it lives in the root package:src/systems/systems.jlrebuilds theSystemfield by field on the SDE-with-brownians__mtkcompilepath rather than going through@set!. Measured with fullModelingToolkitloaded:The one-line fix is to pass
tspan = get_tspan(sys)alongside the existingtstops = symbolic_tstops(sys)there. I have not included it, because the root package would then needModelingToolkitBase = "1.69", and a floor pointing at an unregistered version makes every downstream job fail to resolve:That is what 14 red downstream checks on the first push of this PR were; not a single one was a test failure. The house pattern is for the root floor to point at an already-released sublibrary, so the correct sequencing is: merge this, release
ModelingToolkitBase1.69.0, then a follow-up PR carries thesystems.jlline, the floor bump, and a regression test for it. Note that the MTKBase test suite cannot catch this gap on its own, since the offending method is only defined once the root package is loaded; the follow-up test has to live in the root suite.Verification
All run locally on Julia 1.12.7, on the rebased branch unless noted.
New test file, 58 assertions:
The same file on unmodified master:
tspanis absent from the accepted keyword list, which is the discriminating difference.The
ModelingToolkitBaseInterfaceIgroup, on the exact tree of this PR:Runic --check .,typos, andgit diff --checkall exit 0 on the rebased branch.Not verified
sublibrary-ci / lib/ModelingToolkitBase [QA]fails only its JET test, 234 possible errors, Aqua 20 pass / 1 fail / 21. Master run 34072226043 on 1049de4 gives the identical 234 and the identical 20 / 1 / 21. All 234 are Moshi@matchcodegen false positives, tracked at ModelingToolkitBase QA lane red since #4832: JET typo mode reports 263 errors, 234 of them from Moshi@matchcodegen #5063 and blocked on fix(match): emit flat && chains so guards see defined pattern variables Roger-luo/Moshi.jl#93. Notably the checks that would catch a problem introduced here all pass: Method ambiguity, Public API documentation, and No unapproved public reexports.downgrade-mtkbase (QA)fails Aqua's Stale dependencies and Persistent tasks, 17 pass / 2 fail / 19, with JET passing 54/54. Master run 34002306761 on 32403e8 gives the identical two failures and the identical 17 / 2 / 19.GROUP=InterfaceII, the docs build, and the QA comparison above were run by an earlier pass on a superset of this branch, before the rebase onto current master and before the root-package half was split out.GROUP=InterfaceIwas re-run on the exact tree and is reported above.DynamicOptProblemconstructors do take a tspan but live in the JuMP/InfiniteOpt/CasADi/Pyomo extensions, whereprocess_tspantreats a symbolic final time as free-final-time. That needs its own design thought and its own tests, and those extensions could not be run locally. Left alone.SteadyStateProblem,NonlinearProblem,LinearProblem,OptimizationProblem,IntervalNonlinearProblemandHomotopyNonlinearProblemtake no tspan. TheSciMLFunctionconstructors andInitializationProblemtake a scalart, not a span.remakeoperates on a built problem. All out of scope.Versions
ModelingToolkitBase1.68.3 → 1.69.0. A minor bump: this is additive public API, no existing signature changes, and behavior is unchanged whenever a tspan is passed explicitly. The root package is untouched by this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01H5RuLDtEazwTKPkNbPeZVu