-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create independent variables with @independent_variables #2862
Conversation
This would be a breaking change though? For years MTK had made |
I suppose, I think some tests will fail without modification. The alternative, of course, is to require the independent variable to be defined with Just a suggestion for now. Opinions are welcome :) |
I don’t have an opinion on it either way; MTK has bounced between using parameters vs variables for ivs multiples times now, but if this is merged it should only be released within an MTK10 release since it seems like a breaking change. |
We already made the breaking change with v9 that everything documented says to use the global time anyways. using ModelingToolkit: t_nounits as t, D_nounits as D it's in every tutorial and it's in the upgrade guide. |
You need to run the formatter for tests to run. using JuliaFormatter
format(raw"C:\Users\accou\.julia\dev\ModelingToolkit/") # or whatever the path is |
The |
And I thought the migration guide just said that the defaults should be used, not that |
Well we should definitely update any docs that were missed to import the But ultimately, if structural simplify needs it in one form or the other, that determines it. It really didn't seem to matter before, but maybe @YingboMa can comment on why it matters here. |
oh actually I see what's going on. This is a byproduct of initialization, since when initialization is running it has to be treated as a parameter and during that process the structural simplification cares. This means this bug only effects DAEs with non-trivial initialization problems where the non-trivial subset is non-autonomous, i.e. the initialization system is required and an initialization equation is directly a function of But I do want to check in on something. A seemingly unrelated error SciML/SciMLBenchmarks.jl#1007 in dummy derivative sorting in initialization seems suspiciously related. |
Exactly. #2818 is indeed a very simple such example (although with a trivial linear initialization equation). |
If such a change is now being considered, would it perhaps make sense to add metadata to tag an |
So an |
(It just seems like this back and forth between releases switching |
It is also confusing that the independent variable is a parameter (e.g. #564). |
I just "pushed through" on this to see that everything can work as expected with the change. |
We could also export a macro like |
Yes, I think something like that would be a good approach. Though adding metadata at some point would be useful because then a function like |
I think that would be good. And to address Sam's concern of being a breaking change, we can change this to a deprecation warning that the independent variables should be defined with |
I have added an I guess it is possible to treat independent variables as a separate "variable type", but it requires even more work. With a separate treatment, I suppose What do you think? |
Should @variables x y(x)
@named sys = ODESystem([y ~ 0], x) just issue a warning, instead of failing hard? |
To be technically non-breaking, yes.
I think that's fine. We can document everything to use the new macro for now, and then when we get more sophisticated add a warning to just |
Wait, not fully approved because error to warn. |
I suggest this to close #2818 and prevent others from making the same mistake.
This checks that independent variables are
@parameters
, to be consistent witht_nounits
.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.