Skip to content

docs: update MTK example for ModelingToolkit v11 - #200

Merged
baggepinnen merged 2 commits into
masterfrom
docs/mtk-v11-example
Jul 24, 2026
Merged

baggepinnen merged 2 commits into
masterfrom
docs/mtk-v11-example

Conversation

@baggepinnen

Copy link
Copy Markdown
Member

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 @mtkmodel DSL 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 @equations block becomes a plain eqs = [...] vector, and the intermediate begin ... end block of local assignments becomes ordinary code).
  • Array-variable defaults must now match the variable size: 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) (defaults is 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]:

p: [1.611987373192685, 1.599185391084847, 4.877360360086102, 0.2044771473506988]

The printed output block, the @btime timing, and the tested-version note in the warning admonition are updated to match.

🤖 Generated with Claude Code

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

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.49%. Comparing base (f1af47c) to head (49e8a04).

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           
Flag Coverage Δ
unittests 89.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
@baggepinnen
baggepinnen merged commit bfc0f7c into master Jul 24, 2026
0 of 2 checks passed
@baggepinnen
baggepinnen deleted the docs/mtk-v11-example branch July 24, 2026 07:21
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.

1 participant