-
Notifications
You must be signed in to change notification settings - Fork 306
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
Questionable handling of initialization of a purely algebraic system with homotopy #10497
Comments
I discussed this with @kabdelhak. Currently there are issues in the way the lambda0 equations are handled in the old backend, stemming from the fact that the runtime has only one array for the unknown of the initialization problem, so you have to keep the same variable numbering for lambda0-initial and initial equations (I hope I understood this correctly). He and @phannebohm are reworking and cleaning up the whole thing in the new backend. Once it's proven to work, it should be back-ported in the old one. |
I fixed it for the first model
As for the last model |
There is in fact the flag
but then keeps on compiling and simulating successfully and concludes with
I guess that first error should let the model fail instead. |
Good, thanks! |
That is not necessary. My point is that if the initial system of equations is singular (also because of a numerically detected singularity), then the initialization should fail. |
Obviously 0 = 0 should trigger a singularity failure.
I agree. Additionally, the equation that gets replaced by an identity should be reported as redundant. Otherwise it is not clear how to fix the singularity. |
BTW, I also find the message
highly questionable. The initialization problem can also be singular because of if initial() equations, or because of lambda = 0 equations (not initial equations) |
BTW, in case one gets a numerically singular (or close to singular, say cond > 1e10), it would be worth considering implementing the nullspace analysis I suggested long time ago in #6386. This would be really helpful to figure out the root cause of the singular behaviour, without any need of sophisticated symbolic analysis. Just basic linear algebra. I can provide more details if needed. |
We are dealing with a model that we cannot share publicly, for which the backend shows weird behaviour at initialization.
The model is purely algebraic, does not contain any
der()
operator nor anyfixed = false
parameter. Hence, I would assume that the initialization problem and the simulation problem are exactly the same. However, it uses homotopy to ease the convergence of the initial equation.The backend first complains that there are seven consistent and redundant equations in the initialization problem and removes them from the problem. This is already questionable: it is only possible to remove initial equations from the initialization problem, if they are made redundant by index reduction, but are consistent with the others. There are no initial equations in this problem, so the backend should not be allowed to remove anything.
Immediately afterwards, it complains that there are seven missing equations from the initialization problem, and then it adds
fixed = true
attributes to some variables, thus adding equations to the system that have nothing to do with the original problem, inevitably leading to initialization failure.I can share the model with you privately, so you can have a look, but before doing that, I'd like you to consider some clues about what I believe are the root causes of the problem.
What I suspect is that the simplified equations introduced by homotopy at
lambda = 0
make the initialization problem singular, and then the backend is trying to somehow "fix the situation". This is not correct. Singularities not involving initial equations should be reported as such, so that the modeller can fix the model; a singular model is never a good thing, except in the case of consistent initial equations made redundant by index reduction.So, I tried to poke the backend on this point with some MWEs, from which I got a response that IMHO is highly questionable. Here they are:
Model
M1
produces the following warning:and then runs successfully. In my view, this is not the correct behaviour. At
lambda = 0
, the system's equations (no initial equation involved!) becomeThis system is obviously structurally singular, because
y
does not appear anywhere. The root cause of this issue is an overly simplified expression in homotopy. The proper solution to this issue is reporting the singularity to the modeller, so he can try to fix the simplified expression and avoid a singular simplified system. Trying to "fix" it by adding an extra initial equation (y = y.start
) is arbitrary and IMHO a very bad idea.This is fundamentally different from adding an initial equation to this system:
This model has one state variable
x
, so in case the initialization problem is singular (because of lacking initial equations) it is ok to addfixed = true
attributes to suitably selected variables. My point is, the backend should addfixed = true
equations to fix singular initialization problems systems only if they involve state variables orfixed = false
parameters, and the number of suchfixed = true
additional initial equations should not exceed the number of states and fixed = false parameters.Model
M2
is handled as expected by the backend, which reports:I would then expect that also model
M3
gives a similar outcome when analyzing theinitial-lambda0
problem. What I get instead is the following warning:and then proceeds to initialize and simulate successfully. IMHO this is rather questionable.
Modellers introduce simplified equations in homotopy operators to ease the convergence of the initialization problem, e.g. by replacing nonlinear equations with linear ones or removing some dependencies. If the outcome of this simplification at
lambda = 0
is a singular system, that's not good: they should receive feedback. Trying to solve this singular system anyway is a bad idea, because there is no control on the outcome. Initialization may succeed, but there is no guarantee that the found solution makes any sense. In this case the simulation somehow runs anyway, because the actual initial problem is linear and non-singular, so it is solved correctly no matter what the homotopy process does. However, you can very well understand that if you get a singularlambda = 0
problem and you manage to solve it somehow, it is very likely that the solution won't be the desired one, and this will later on lead to a failure on the homotopy process if seriously nonlinear equations are involved.Singularities at
lambda = 0
should be reported properly and abort the compilation process, not swept under the carpet :sweat_smileDesired behaviour
fixed = true
attributes that exceeds the number of states and parameters withfixed = false
involved in that (sub)system.lambda = 0
should be reported and abort the compilation processThe text was updated successfully, but these errors were encountered: