ModelingToolkit.jl version management

The ModelingToolkit.jl latest releases have some error popping up associated with the ODESystem. I am a novice to Julia coding and I can’t figure out why the error :

ArgumentError: The name keyword must be provided. Please consider using the @named macro"
happens with the latest versions.

This is not the case with the older releases. This function ODESystem is running well with the previous releases eg: v5.25.0 and is serving my purpose. For testing out this error one can run the sample code that pops up in the help ODESystem.

Thank You

1 Like

The docs were updated for this. You just need to do @named sys = ODESystem(eqs), i.e. add the macro. This is because naming is now required in order to ensure that namespacing always works.

1 Like

I’m not an avid ModelingToolkit user but having had a quick look it seems ODESystems takes a keyword name, that in the newer versions are required (throwing this error if it is not supplied) while in version 5.25.0 it was not required.

So it should probably work if you either supply the keyword name to your system or, as they suggest, use the @named macro (which pretty much does the same thing in the background, just uses your variable name as the supplied name if I understood correct).

using ModelingToolkit
...
eqs = [...]
# First option
mysystem = ODESystem(eqs, name="mysystem")
# Second option
@named mysystem = ODESystem(eqs)

Hope that helps!

2 Likes

Found that running ? ODESystem I get some sample code that is not runnable with the latest version (minor doc, just thought I would mention since you were here).

1 Like

https://github.com/SciML/ModelingToolkit.jl/pull/1251

2 Likes

Thanks a lot Chris … It worked.

@albheim Thanks a lot. That was helpful.

I was just curious about what @named does and stumbled upon this thread.
At least for MTK v8.14.0, it seems that the keyword name ought to be a symbol, so in your example

mysystem = ODESystem(eqs, name=:mysystem)