﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5200	The backend does not handle reductions correctly	Francesco Casella	Lennart Ochel	"Please consider the following test model
{{{
model TestMixture
  package Medium = Modelica.Media.IdealGases.MixtureGases.FlueGasSixComponents;
  Medium.BaseProperties medium;
  Medium.MolarMass MM[:] = Medium.data.MM;
equation 
  medium.p = 1e5;
  medium.T = 300;
  medium.X[1] = time;
  medium.X[2] = 1 - time;
  medium.X[3:6] = zeros(4);
end TestMixture;
}}}
Run it with the new front-end ({{{-d=newInst}}}), as the old front-end does not flatten it correctly. The following error is reported
{{{
assert | debug | division by zero at time 0, (a=1) / (b=0), where divisor b expression is:
sum(medium.state.X[j] / ({0.0280134, 0.00201588, 0.0280101, 0.0319988, 0.01801528, 0.0440095})[j] for j in 1:6)
}}}
This comes from the inlining of the molarMass function
{{{
function TestMixture.Medium.molarMass
  input Medium.ThermodynamicState state;
  output Real MM(quantity = ""MolarMass"", unit = ""kg/mol"", min = 0.001, max = 0.25, nominal = 0.032);
algorithm
  MM := 1.0 / sum(state.X[j] / {0.0280134, 0.00201588, 0.0280101, 0.0319988, 0.01801528, 0.0440095}[j] for j in 1:6);
end TestMixture.Medium.molarMass;
}}}
that contains an expression with a reduction, which is not handled correctly. Reductions in equations are normally handled by the front-end, but in this case the equation is created by inlining, so the back-end must handle it.

Apparently the back-end cannot handle this properly. So far this kind of expression never showed up, because the old front-end was flattening it incorrectly, but in fact it shows up in all the models using mixture gases from Modelica.Media, so it should definitely be handled correctly when the NF is rolled out, and possibly already with 1.14.0, so that models using mixture gases can actually be used in OMC even before the NF replaces the OF - this has been an open problem for a long time, see #2858.

"	defect	closed	blocker	1.14.0	New Instantiation		fixed		Martin Sjölund Willi Braun Per Östlund
