You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an equation has a constant and a variable, both with symbolic units, it throws an error.
Expected behavior
There shouldn't be an error if the units are correct.
Minimal Reproducible Example 👇
using ModelingToolkit, DynamicQuantities
using ModelingToolkit: t
@constants c =1 [unit =us"mol/nmol"]
@variablesk(t) [unit =us"mol/nmol"]
NonlinearSystem([k ~ c], [k], []; name=:example)
Error & Stacktrace ⚠️
┌ Warning:in eq. #1right, in sum c - k(t), units [1.0 , 9.999999999999999e8 ] do not match.
└ @ ModelingToolkit ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/unit_check.jl:180
ERROR: ModelingToolkit.ValidationError("Some equations had invalid units. See warnings for details.")
Stacktrace:
[1] check_units(::Val{:DynamicQuantities}, eqs::Vector{Equation})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/unit_check.jl:313
[2] _
@ ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/nonlinear/nonlinearsystem.jl:102 [inlined]
[3] NonlinearSystem
@ ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/nonlinear/nonlinearsystem.jl:93 [inlined]
[4] NonlinearSystem(eqs::Vector{…}, unknowns::Vector{…}, ps::Vector{…}; observed::Vector{…}, name::Symbol, default_u0::Dict{…}, default_p::Dict{…}, defaults::Dict{…}, systems::Vector{…}, connector_type::Nothing, continuous_events::Nothing, discrete_events::Nothing, checks::Bool, parameter_dependencies::Vector{…}, metadata::Nothing, gui_metadata::Nothing)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/nonlinear/nonlinearsystem.jl:160
[5] top-level scope
...
Environment (please complete the following information):
Which happens because of the oneunit call here. The equation k ~ c is converted to c - k and when getting the units of -k it runs get_unit(*, [-1, k]).
Describe the bug 🐞
If an equation has a constant and a variable, both with symbolic units, it throws an error.
Expected behavior
There shouldn't be an error if the units are correct.
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
The text was updated successfully, but these errors were encountered: