Opened 6 years ago
Closed 6 years ago
#5206 closed defect (fixed)
Generate residual equation for nonlinear systems with conditional equations
Reported by: | Francesco Casella | Owned by: | Willi Braun |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | Backend | Version: | |
Keywords: | Cc: | adrien.guironnet@…, marianne.saugier@…, romain.losseau@… |
Description
Please consider the following model, which represents the steady-state initialization of a proportional controller with saturation.
If the reference value of y
, y_ref
, is compatible with the saturation limit of the controller, then the set point value is initialized to produce exactly that output; otherwise, the control variable u
before saturation is initialized to a value somewhat higher than the saturation, and then the corresponding set point is computed.
model NonSatIntEq Real x; Real y; Real usat; Real u; parameter Real y0(fixed = false, start = 8); parameter Real T = 1; parameter Real k = 10; parameter Real uMin = 0; parameter Real uMax = 1; parameter Real y_ref = 8; initial equation der(x) = 0; if u > usat then u = usat + 1; else y = y_ref; end if; equation T * der(x) = usat - x; y = k * x; usat = homotopy(actual = smooth(0, if u > uMax then uMax else if u < uMin then uMin else u), simplified = u); u = y0 - y; end NonSatIntEq;
When trying to run this model, the following error is generated:
[1] 01:33:51 Translation Error Internal error function createNonlinearResidualEquations failed [2] 01:33:51 Translation Error [C:/dev/OM64bit/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 3289:7-3289:48]: Internal error createOdeSystem2 failed for Generic Jacobian via directional derivatives [3] 01:33:51 Translation Error [C:/dev/OM64bit/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 3182:9-3182:50]: Internal error function createOdeSystem failed for component {6, 5, 2, 4:3, 2, 4, 6} Size: 4 Generic Jacobian via directional derivatives [4] 01:33:51 Translation Error [C:/dev/OM64bit/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 1369:5-1369:77]: Internal error createEquationsForSystems failed [5] 01:33:51 Translation Error [C:/dev/OM64bit/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 637:5-637:146]: Internal error function createSimCode failed [Transformation from optimised DAE to simulation code structure failed]
I tested the model in Dymola, and it works fine, producing the expected result.
Change History (8)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Component: | Code Generation → Backend |
---|---|
Status: | new → accepted |
Summary: | Problems with Jacobians of nonlinear systems with conditional equations → Generate residual equation for nonlinear systems with conditional equations |
The actually issue here is to transform if equations into
one residual equation, here it's the equation:
if u > usat then u = usat + 1; else y = y_ref; end if;
which could not transformed into a if expression.
comment:3 by , 6 years ago
I guess it should be something like
(if u > usat then u - (usat + 1) else y - y_ref) = 0;
right?
comment:6 by , 6 years ago
I tried the test model with the new nightly in OMEdit and the transformational debugger.
If I use the equation of comment:3, the back-end solves the system of 4 nonlinear equations in the initialization problem using tearing, using u
as tearing variable, and solves the problem correctly.
If I use the original model with the conditional equation, I get a "Matrix singular" warning, then the simulation starts but it's not in steady state, which is quite bad, because it means that a wrong solution of the initialization problem is accepted.
The debugger mentions a system of 4 coupled initial equations in u, usat, x, y
which are not torn, but then it only shows me three residuals. The one corresponding to
usat = homotopy(actual = smooth(0, if u > uMax then uMax else if u < uMin then uMin else u), simplified = u);
is missing. I guess there's something wrong in the implementation, can you please double-check?
Thanks!
follow-up: 8 comment:7 by , 6 years ago
Ah, the issue is, that such equations are not supported by the tearing methods, the "omcTearing" has even StackOverflow on this model. But it gets solved, if you provide for the non-teared system start values. So tearing implementation needs to be checked to support such if equations.
comment:8 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Replying to wbraun:
Ah, the issue is, that such equations are not supported by the tearing methods, the "omcTearing" has even StackOverflow on this model. But it gets solved, if you provide for the non-teared system start values. So tearing implementation needs to be checked to support such if equations.
Opened new ticket #5226 on this specific topic
For the record, the previous example should initialize in non-saturated state.
This one should initialize in saturated state, since the maximum output that the saturated controller can provide is
y = 10
.This example also works in Dymola.