ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Unhelpful error message

Open elbert5770 opened this issue 1 year ago • 1 comments

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?

elbert5770 avatar Feb 05 '24 16:02 elbert5770

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.

ven-k avatar Feb 08 '24 14:02 ven-k