Open BenChung opened 3 years ago
@named fol_separate = ODESystem([ RHS ~ (1 - x)/τ,
D(x) ~ RHS ])
prob = ODEProblem(structural_simplify(fol_separate), [x=>0.0, RHS=>0.0], (0.0,10.0), [τ => 3.0])
This doesn't address the issue? Yes, there are a number of ways to solve this particular problem (I'd note, tangentially, that the shown isn't exactly one of them; the desired result is where x
is a vector of size 2. I'm aware of these approaches, but the most elegant of them - the aforementioned @variables x[1:2](t)
isn't mentioned in the documentation.
I'm not claiming a functional issue here. Instead, I'm pointing out that the documentation doesn't do a good job of describing how to have vectors of symbolic variables in the system, and that the error messages surrounding one obvious way to do so (where one assumes that vectors work implicitly) do not point the user in a direction where they may find this solution.
There's other issues with vector symbolics, cf. for example #892. Documentation should be included for the new, clean way of handling vectors that's indicated in the referenced issue (?)
Yeah, I'd note that all of these cases need to get documented, but we also should be making all of it towards the coming array symbolics system and not what we have now.
It's now better documented https://symbolics.juliasymbolics.org/stable/manual/arrays/ but we should make a whole MTK level tutorial on this.
In order to create a symbolic vector, the notation
@variables x[1:2](t)
needs to be used (using
@variables
as an example). This doesn't appear in the documentation for ModelingToolkit (in an example, for instance), though it is described in the docstring from Symbolics.jl. It would be clearer if there was some example in the documentation that demonstrated a simple use case of@variables
with a symbolic vector.Additionally, the error message that's produced when a scalar variable is passed a vector argument is unclear, for example,
produces
(snipping the stack trace). This error suggests that the problem is initialization of the integrator cache, rather than in the definition of the problem; it would make it easier to understand and fix if the problem could be caught before attempting to initialize the integrator.