Closed TS-CUBED closed 5 days ago
? There's nothing in here.
Sorry, hit a return too early, just adding the info
Warning: Initialization system is overdetermined. 166 equations for 1 unknowns.
Fix that?
Warning: Initialization system is overdetermined. 166 equations for 1 unknowns.
Fix that?
Why would that show up suddenly and cause a problem? The ODEs are created from an acausal network that's created from the same code as before.
It only showed up with the update to 9.42 on the Github CI run - no changes to the system at all
MTK@9.42 checks that that the observed equations are also satisfied during initialization, so you might have had something working, but it was not satisfying all the constraints in the model. See https://docs.sciml.ai/ModelingToolkit/dev/tutorials/initialization/ for more details on how to investigate this.
MTK@9.42 checks that that the observed equations are also satisfied during initialization, so you might have had something working, but it was not satisfying all the constraints in the model. See https://docs.sciml.ai/ModelingToolkit/dev/tutorials/initialization/ for more details on how to investigate this.
Thanks, that explains the warning. But why does the solver break and give a completely different result? Would that not be considered a breaking change?
The solver can't start since it can't solve the initialization problem to get the u0
.
This is correcting wrong behavior, so I think it's considered a bugfix.
The solver can't start since it can't solve the initialization problem to get the
u0
. This is correcting wrong behavior, so I think it's considered a bugfix.
Edit: removed statement that the solver does run. I does not, it simply gives a solution that consists of the wrong initial conditions. So all's good there.
If you had the tutorial example:
@mtkmodel FOL begin
@parameters begin
Ο = 3.0 # parameters and their values
end
@variables begin
x(t) = 0.0 # dependent variables and their initial conditions
RHS(t)
end
@equations begin
RHS ~ (1 - x) / Ο
D(x) ~ RHS
end
end
prob = ODEProblem(fol, [], (0.0, 10.0), [])
but then changed it to:
prob = ODEProblem(fol, [RHS => 300000.0], (0.0, 10.0), [])
it would have worked. This is because x
is the chosen state and RHS was removed, and it did not check the removed values. This was a bug in the initialization system and let to somewhat obtuse results where changing what states are chosen could change the simulation result. It's also against our policy, which is that all initial equations are supposed to be respected. Instead, since it's impossible that x = 0
and RHS = 300000.0
, that's an invalid initialization and it should error.
With the recent change we now check this better, and correctly error here.
Now in your case, you can see from the warning that you have a ton of extra equations. Most likely you have a ton of extra initial conditions that are not correct. You should really try to understand which initial conditions are required in your system, and which are computed. If they are computed, you should consider using a guess instead of specifying equality.
Ok, I think I understand now what causes the problem. I have quite a few "fallback" initial conditions which were needed at some point because I did not know which equations MTK would give me - and observed weren't usable as initial conditions when I started development. These were not calculated exactly, but just "good enough guesses". But since they are all in the component definitions and the initialisation dict this is now causing problems.
Is that it?
So what do I do?
Yep, that works. All validation tests passed again.
Thanks a lot for the help.
Describe the example
The testcases for CirculatorySystemModels.jl do not run anymore.
Minimal Reproducible Example π
https://github.com/TS-CUBED/CirculatorySystemModels.jl/blob/main/test/runtests.jl
Error & Stacktrace β οΈ
Not Working Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Working Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Add any other context about the problem here.