Open casella opened 10 months ago
Keeping @AndreaBartolini in the loop
@phannebohm, @kabdelhak, I tried this with the NB and I got this:
[1] 17:46:54 Translation Error
Internal error NBSlice.fillDependencyArray failed because number of flattened indices 1 for dependency $DER.M could not be divided by the body size 2 without rest.
[2] 17:46:55 Translation Error
Internal error NBAdjacency.Matrix.createPseudo failed for:
[ARRY] (2) $DER.M * X .+ M * $DER.X = {0.0, 0.0} ($RES_SIM_4)
[3] 17:46:55 Translation Error
Internal error NBAdjacency.Matrix.create failed to create adjacency matrix for system:
System Variables (10/11)
**************************
(1) [ALGB] (1) Real T (StateSelect = prefer)
(2) [ALGB] (1) Real rho
(3) [ALGB] (1) Real MMmix
(4) [DER-] (1) Real $DER.M
(5) [ALGB] (1) Real P (StateSelect = prefer)
(6) [DER-] (2) Real[2] $DER.X
(7) [DISC] (1) Integer $FUN_2
(8) [DER-] (1) Real $DER.E
(9) [ALGB] (1) Real V = 2.0 + sin(time)
(10) [ALGB] (1) Real c = Modelica.Math.Vectors.interpolate({1.0, 2.0, 3.0}, {1.0, 3.0, 8.0}, T, 1)[1]
System Equations (9/11)
*************************
(1) [SCAL] (1) MMmix = 1/(X[1] + 0.5 * X[2]) ($RES_SIM_0)
(2) [SCAL] (1) P / rho = (R / MMmix) * T ($RES_SIM_1)
(3) [SCAL] (1) E = c * M * T ($RES_SIM_2)
(4) [TUPL] (2) (c, $FUN_2) = Modelica.Math.Vectors.interpolate({1.0, 2.0, 3.0}, {1.0, 3.0, 8.0}, T, 1) ($RES_$AUX_10)
(5) [SCAL] (1) M = rho * V ($RES_SIM_3)
(6) [ARRY] (2) $DER.M * X .+ M * $DER.X = {0.0, 0.0} ($RES_SIM_4)
(7) [SCAL] (1) $DER.E = 0.0 ($RES_SIM_5)
(8) [SCAL] (1) -(2.0 - V) = sin(time) ($RES_$AUX_9)
(9) [SCAL] (1) $DER.M = 0.0 ($RES_SIM_6)
so the NB is not there, either. I would be grateful if you could have a look at this issue with the OB, this is a blocker for us on an important project. Looks like some weird bug in WrapFunctionCalls and/or causalization.
Thanks!
We have a fairy involved model that generates invalid C code due to a missing definition of a
$cse
variable which is then used in an expression.We were not able to exactly reproduce the issue, but we managed to reproduce one which seems to be closely related and should be fixed anyway. This is the MWE:
If we compile this model and then analyze it with the declarative debugger, we see some weird things happening:
(c, _) := Modelica.Math.Vectors.interpolate({1.0, 2.0, 3.0}, {1.0, 3.0, 8.0}, T, 1);
), instead of being first called and its result stored in a$cse
variable, as it should happen thanks to the WrapFunctionCalls method.$cse1
appears in the variables window, it is used to compute some piece of jacobian, but is never actually computed by solving any equation. This is weird, you cannot compute stuff later on using$cse1
if it hasn't been set to some value previously.$cse2
shows up in a torn equation and in a jacobian equation, but is also apparently never computed$cse3
looks fineWhat we observe is that
cse3
involves differentiating a built-in functionsin(time)
, which is not a big deal, whilecse1
andcse2
involve the interpolate function, which is a true algorithm that require extra steps for differentiation. Maybe that holds the key for the solution of this issue.