ModelingToolkit -- news?

There seems to be a few changes to the latest versions of ModelingToolkit:

  • Constructor ODESystem now requires the independent variable as second argument [e.g., ODESystem(eqs,t) – in the past, the constructor tried to infer the independent variable, i.e., ODESystem(eqs) would often work]. Is this correct?

  • Field (and function) states of systems has been changed to unknowns?

In the initial example of MTK:

using ModelingToolkit: t_nounits as t, D_nounits as D
  • Does this mean that now, ModelingToolkit has built-in names for the time variable (t_nounits) and time differentiation (D_nounits)? And that the examples choose t and D, respectively, as aliases for t_nounits and D_nounits?
  • If my above guess is correct, I assume that the purpose of this is to (i) avoid having to define these when using MTK and possibly getting more efficient code, (ii) that the user can choose her/his own aliases, and (iii) make sure that all libraries use the same name for the time variable [t_nounits].
  • The “casual user” can still define time as @variables t and differentiation as D = Differial(t), but then this code will not work in conjunction with, e.g., ModelingToolkitStandardLibrary. Right?

correct

correct

correct

correct

not really

you can, but you could that before as well

the symbolic name of the time variable is t, it’s the julia variable that is called t_nounits

julia> ModelingToolkit.t_nounits
t

I think it would work anyway, but there is no need to define these yourself anymore

But in principle, I could alias t_nounits to time and D_nounits to der, like in Modelica? And MTK would understand that time is the same as t used in ModelingToolkitStandardLibrary?

Not that I would do it, though.
__
Anyways, I like the changes!

Absolutely, the name of the julia variable you use is not even known to MTK, so your choice cannot possibly have any effect on the result :slight_smile:

1 Like