﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5206	Generate residual equation for nonlinear systems with conditional equations	Francesco Casella	Willi Braun	"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."	defect	closed	high	1.13.0	Backend		fixed		adrien.guironnet@… marianne.saugier@… romain.losseau@…
