docs: update MTK example for ModelingToolkit v11 - #200
Merged
Merged
Conversation
The `@mtkmodel` DSL was removed in ModelingToolkit v11 in favor of the functional component form (`@component function ... System(eqs, t; name) end`). This updates the quad-tank parameter-fitting example accordingly: - `@mtkmodel QuadtankModel begin ... end` -> `@component function QuadtankModel(; name) ... end` - array variable defaults must match size: `h(t)[1:4] = 0` -> `= zeros(4)` - `ModelingToolkit.defaults(io_sys)[pi]` -> `ModelingToolkit.getdefault(pi)` Verified end-to-end on ModelingToolkit v11.36.0; the estimated parameters still match the true values. Output block, benchmark timing, and the tested-version note in the warning are updated to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #200 +/- ##
=======================================
Coverage 89.49% 89.49%
=======================================
Files 15 15
Lines 2722 2722
=======================================
Hits 2436 2436
Misses 286 286
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The prose referred to `discrete_dynamics_mtk` but the code defines the wrapper as `discrete_dynamics_wrapper`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
The ModelingToolkit example (
docs/src/examples/modelingtoolkit.md) claimed to be tested with MTK v10.0.1. On the current release (v11.36.0) it no longer runs, because the@mtkmodelDSL was removed in favor of the functional component form.Changes to make the example run on MTK v11.36.0
@mtkmodel QuadtankModel begin ... end→@component function QuadtankModel(; name) ... System(eqs, t; name) end(the@equationsblock becomes a plaineqs = [...]vector, and the intermediatebegin ... endblock of local assignments becomes ordinary code).h(t)[1:4] = 0→h(t)[1:4] = zeros(4),u(t)[1:2] = 0→zeros(2).ModelingToolkit.defaults(io_sys)[pi]→ModelingToolkit.getdefault(pi)(defaultsis no longer exported/available).Verification
Ran the full example end-to-end on MTK v11.36.0. The estimated parameters still recover the true values
p_true = [1.6, 1.6, 4.9, 0.2]:The printed output block, the
@btimetiming, and the tested-version note in the warning admonition are updated to match.🤖 Generated with Claude Code