Open
Description
Describe the bug 🐞
Hello!
The example here :
https://docs.sciml.ai/ModelingToolkit/stable/basics/Validation/#DynamicQuantities-Literals
Does not work as intended. Its goal is to validate the dimensionalitty of the equations according to the units given.
Expected behavior
It should return "true" but does return "false".
Minimal Reproducible Example 👇
using ModelingToolkit, DynamicQuantities
@parameters τ [unit = u"ms"]
@variables t [unit = u"ms"] E(t) [unit = u"kJ"] P(t) [unit = u"MW"]
D = Differential(t)
eqs = eqs = [D(E) ~ P - E / τ,
0 ~ P]
ModelingToolkit.validate(eqs)
Error & Stacktrace
┌ Warning: in eq. #1right, in sum P(t) + (-E(t)) / τ, units [1.0e6 m² kg s⁻³, 1.0 m² kg s⁻³] do not match.
└ @ ModelingToolkit ~/.julia/packages/ModelingToolkit/US9uJ/src/systems/unit_check.jl:181
false
Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
[06fc5a27] DynamicQuantities v1.8.0
[961ee093] ModelingToolkit v10.7.0
- Output of
versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 20 × 13th Gen Intel(R) Core(TM) i7-13800H
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, goldmont)
Threads: 1 default, 0 interactive, 1 GC (on 20 virtual cores)
Additional context
Question first raised here (https://discourse.julialang.org/t/unit-validation-and-inspection-with-mtk-error-in-the-documentation/112145) . Please tell me if I do not use the right form in that issue, this is my first time doing so.