Opened 8 years ago
Last modified 7 years ago
#4389 new enhancement
Improve warnings and diagnostics for missing start attributes in nonlinear systems
Reported by: | Francesco Casella | Owned by: | somebody |
---|---|---|---|
Priority: | normal | Milestone: | 2.0.0 |
Component: | Run-time | Version: | |
Keywords: | Cc: | Willi Braun |
Description
When the -d=initialization
flag is turned on, OMC warns for all the iteration variables of nonlinear systems whose start attribute has not been modified and has thus the default value of zero. The rationale is that in case of trouble with the solver convergence, one should provide good enough start attributes for all those variables.
In fact, this is not necessarily the case. Consider the following simple test case:
loadString(" model Test Real x; Real y; Real z; Real w; equation x + 2*y - 3*z = 1; x - 3*y + 4*w = 10; 10*x - 3*y + 5*z = 0; (z-10)*(z+4) + y + w = 10; end Test; ");getErrorString(); setCommandLineOptions("--maxSizeNonlinearTearing=0, -d=initialization");getErrorString(); simulate(Test);getErrorString();
where tearing has been disabled for simplicity.
The system has one strong component containing all the four equations; however, the first three are in fact linear, only the fourth is non-linear.
The Jacobian of the system is
1 | -2 | 3 | 0 |
1 | -3 | 0 | 4 |
10 | -3 | 5 | 0 |
0 | 1 | 2*z-6 | 1 |
Now, solving the system with Newton-like methods actually means to recursively approximate the system with its linearized version around the current solution estimate. If the system is linear, the algorithm will converge to the solution no matter what the initial guess is, in one iteration for a pure Newton method, and in a few iteration for quasi-Newton methods.
In this case it is obvious that the only start value which is relevant to achieve convergence is the value of z
, which affect the linearized version of the system (i.e., its Jacobian). Providing a good initial guess of z
means that the fourth equation is well approximated in the neighbourhood of the solution, while all the other ones are already linear, so they are already exact no matter what the start values are.
A more interesting real-life application is large-scale electrical circuits, with only a few nonlinear components. For example, consider one large RLC circuit with one diode, whose equation is I = I_0*(exp(-V/V_T)-1)
. It is apparent from the above discussion that it is only necessary to provide a good initial guess for the voltage V across the diode, while the initial guesses for all the other currents and voltages in the circuit, which do not affect the Jacobian, are basically useless.
Summing up, instead of reporting the full list of iteration variables which do not have a start attribute, it would be much better to report only those ones which show up explicitly in the Jacobian. It could also be useful to report the list of initial guesses of all (and only) variables that show up in the Jacobian, so that in case of convergence problems one can focus on those values that are really relevant.
In case tearing is used, the concept generalizes to selecting only those iteration variables which directly or indirectly influence the Jacobian - this would require some basic dependency analysis.
Change History (5)
comment:1 by , 8 years ago
Type: | defect → enhancement |
---|
follow-up: 3 comment:2 by , 8 years ago
comment:3 by , 8 years ago
Priority: | high → normal |
---|
Replying to lochel:
Sounds like a good enhancement. However, I think this has no high priority right now.
Sure. I thought this out yesterday while fighting with a model that would not initialize and I thought it was better to put this in writing.
Next time I run into trouble I will raise the priority again :)
comment:4 by , 8 years ago
Cc: | added |
---|
comment:5 by , 7 years ago
Milestone: | 1.12.0 → 2.0.0 |
---|
Sounds like a good enhancement. However, I think this has no high priority right now.