Repository navigation
Recommend the inputs keyword for interactive external signals - #5087
Merged
ChrisRackauckas merged 1 commit intoSep 7, 2026
Merged
Conversation
The interactive-integrator page reached for a top-level `@parameters` declaration as the external signal. That works for a scalar you declare yourself, but it does not apply to models assembled from component libraries, where the input arrives as an unconnected `RealInput` connector and there is nothing to declare — and it diverges from every other input tutorial, which uses `mtkcompile(...; inputs)`. Lead with the `inputs` keyword instead: an input variable named to `mtkcompile` becomes a parameter of the compiled system, so the same `integrator.ps[u] = value; step!(integrator, dt, true)` loop drives it. Add a ModelingToolkitStandardLibrary example that leaves a `Force` input connector unconnected, and show the unbalanced-system error that results from omitting the keyword. The `@parameters` form is kept for the scalar case. Raised in review of SciML#5055. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam
ChrisRackauckas
marked this pull request as ready for review
September 7, 2026 09:11
This was referenced Sep 7, 2026
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 7, 2026
The interactive-integrator page tells you to name the input variable to `mtkcompile`, which assumes you know which variable carries the external signal. For a model you did not build, or one assembled programmatically, that is the part you are missing. `unbound_inputs` reports the input variables the connection structure leaves external, and its result can be passed straight to `mtkcompile`. Follow-up to #5087. Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[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.
What changed and why
Raised in review of #5055
(#5055 (comment)): the
interactive-integrator page reached for a top-level
@parametersdeclaration as theexternal signal. That works for a scalar you declare yourself, but it does not apply to
models assembled from component libraries — there the input arrives as an unconnected
RealInputconnector and there is nothing to declare — and it diverges from every otherinput tutorial, all of which use
mtkcompile(...; inputs).The page now leads with the intended pattern: the user declares the input variable, names
it to
mtkcompile, and it becomes a parameter that the integrator steps with.and then the component-library case, which is the one the review was about:
The page also shows the error you get from omitting the keyword, since that is the wall a
component-library user actually hits and nothing in it points at the unconnected connector.
The
@parametersform is kept for the scalar case.Verification
The page uses plain ```julia fences, so Documenter does not execute them. Every added line
was run by hand against ModelingToolkit 11.41.0 + ModelingToolkitStandardLibrary:
The scalar case was also checked against the analytic solution: from
x(0) = 0withu = 1for one second,x(1) = 1 - e^{-1} = 0.6321204555; then withu = -1for a second,x(2) = -1 + (0.6321 + 1)e^{-1} = -0.3995753539. Both match to displayed precision.Full docs build (
julia --project=docs docs/make.jl) exits 0.Also run:
typoson the changed file.Things a reviewer should push back on
unbound_inputs(model)as a way todiscover the connector name. I removed it: it reports
force.f.ufor aForcewith anunconnected input, but returns empty for a
VoltagewhoseRealInputis equallyunconnected, so documenting it would point users at something that silently does nothing
for a common component. I have not established the cause and am not claiming one here;
it is worth its own issue. The page recommends naming the input explicitly, which is
reliable and is also the pattern the rest of the input tutorials use.
mtkcompilecould name unconnected inputs in theExtraVariablesSystemExceptionwhen they are the extra variables. That would make this discoverable rather than something
the docs have to warn about, but it is a code change and does not belong in a docs PR.
Not verified
Nothing beyond the docs build and the hand-run blocks above; this PR changes no code.
This PR should be ignored until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code
https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam