how does @mtkbuild (when I get it to work) compare to the “old way”? From the first example in the updated documentation (Getting Started section):
@mtkmodel FOL begin
@parameters begin
τ # parameters
end
@variables begin
x(t) # dependent variables
end
@equations begin
D(x) ~ (1 - x) / τ
end
end
@mtkbuild fol = FOL()
prob = ODEProblem(fol, [fol.x => 0.0], (0.0, 10.0), [fol.τ => 3.0])
In the “old way”, I always did instantiation followed by structural_simplify before sending the model to ODEProblem.
Does @mtkbuildcombine the instantiation step (@named fol = FOL()) and the structural_simplify?
One reason for my uncertainty… the first example of the subsequent Building component-based, hierarchical models builds the model in the “old way”, i.e., does not use the @mtkbuild macro, and proceeds with @named, etc.
The macro @structural_parameters… I assume that the listed structural parameters, e.g., can be used for switching between different equations in the model?
Parameters vs. “derived parameters”
Sometimes in the past, I have needed to introduce a common (“independent” parameter?), and then two derived parameters (“dependent” parameters?):
@parameters a=1, b=2*a, c=1/a
where a does not appear in the equations. That has caused problems, although the problems are avoided by adding the list of parameters in the ODESystem specification.
Should this case be handled as follows when using @mtkmodel?
@parameters begin
a = 1
end
begin
b = 2*a
c = 1/a
end
Does the order of the various macro blocks (@parameters, etc.) matter within the @mtkmodel block? In other words: do I have to specify parameter values before I use them to set initial values for states, etc.?
That probably even de-mystifies some of the IR. Basically, @mtkmodel is the front-end to ModelingToolkit. It lowers to the intermediate representation (IR). The IR is quite nice to work on though: it’s not like LLVM, the IR is itself the symbolic representation that you previously used to work with. We now just put a face over it.
What version do you have? You need the latest of the latest, the one released like 2 days ago.
is how to to write it in full. Technically, you should’ve been calling complete before: it’s what makes fol.x “work well” (because a completed system by default does not namespace the top level). In practice, I don’t think a lot of people did use complete, and so this will help people do things much more easily.
oh I’ll update that.
Not quite yet. We’ll get that done rather soon though.
@parameters begin
a = 1
b = 2*a
c = 1/a
end
is the intended syntax. I’ll need to check if that works.
I’m not sure if we check that right now, but I think it would be sane to enforce and order. Sometimes a little bit of order makes the world a bit cleaner.
Ah. I did a Pkg.update() before I posted the questions 5 hours ago. I’m trying again – seems like now Symbolics has been updated from v5.8.0 to v5.9.0 within these 5 hours.
ModelingToolkit does not update, but there is a warning associated with it:
Cutting edge makes life exciting
[I’ve been playing around with `@mtkmodel` for a couple of weeks, based on the `ModelingToolkitStandardLibrary` presentation at JuliaCon 2023 + some input from @baggepinnen .]
@BLI, did you open this other thread ? I’m running into the exact same problem with None Sym BasicSymbolic doesn't have a name and so far I don’t understand what to correct…
You write that you run “into the exact same problem with None Sym BasicSymbolic doesn't have a name”.
A couple of questions:
Where in my thread did I say that I had a None Sym BasicSymbolic doesn't have a name message?
If I didn’t have this message, how do we know that your problem is “the exact same problem”?
Can you be a little bit more explicit with what you try to do, and what the problem is?
[My problem was related to the use of the @mtkbuild where it turned out I used an outdated version of ModelingToolkit because another package, MethodOfLines, held back the updating of ModelingToolkit. That problem has long been solved, so your problem is not the same, I think.]
I am not sure this needs a new thread (at least from my perspective) I was just curious if there was already an answer given @BLI 's comment. I’ll open a new thread if I have a concrete example to show. Thanks for the help.