ModelingToolkit.jl
ModelingToolkit.jl copied to clipboard
Unhelpful error message
Do you see the error here? It's a result of switching from an array-based definition to the more modern definition of an MTK model
@equations begin
D(A) ~ 1/VA*(QCSF*(c_in - A) - Qosc*(A-B)),
D(B) ~ 1/VB*(QCSF+Qosc)*(A-B)
end
Spoiler alert, it's the comma. However, the error message is:
ERROR: MethodError: no method matching -(::Equation, ::SymbolicUtils.BasicSymbolic{Real})
Could we get a better error message?
There is an extra comma after the equation. So it ends up being
D(A) ~ (((1 / VA) * (QCSF * (c_in - A) - Qosc * (A - B)), D(B)) ~ (1 / VB) * (QCSF + Qosc) * (A - B)))
i.e one equation with two ~
s, instead of
[D(A) ~ (1 / VA) * (QCSF * (c_in - A) - Qosc * (A - B)), D(B) ~ (1 / VB) * (QCSF + Qosc) * (A - B))]
The following should fix it:
@equations begin
D(A) ~ 1/VA*(QCSF*(c_in - A) - Qosc*(A-B))
D(B) ~ 1/VB*(QCSF+Qosc)*(A-B)
end
I'll have mtkmodel
throw an error for this.