﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5210	The back-end drops vectorized function calls coming from NF-flattened models	Francesco Casella	Per Östlund	"Please check [https://libraries.openmodelica.org/branches/newInst/Modelica_trunk/files/Modelica_trunk_Modelica.Fluid.Examples.Explanatory.MeasuringTemperature.err Modelica.Fluid.Examples.Explanatory.MeasuringTemperature]. The flattened model is balanced, but when finally getting to matching, the back-end complains about an unbalanced system
{{{
Error: Too few equations, under-determined system. The model has 164 equation(s) and 170 variable(s).
}}}
I managed to reproduced the problem with a simplified model where I removed some of the components, please find it attached for reference. 

The old FE outputs this flattened equation
{{{
  openTankHot3.portInDensities[1] = Modelica.Fluid.Vessels.OpenTank$openTankHot3.Medium.density(Modelica.Fluid.Vessels.OpenTank$openTankHot3.Medium.setState_phX(openTankHot3.vessel_ps_static[1], junctionIdeal.port_2.h_outflow, {}, 0, 0));
}}}
while the NF flattens it to
{{{
  openTankHot3.portInDensities[1] = MeasuringTemperature4.openTankHot3.Medium.density(MeasuringTemperature4.openTankHot3.Medium.setState_phX(openTankHot3.vessel_ps_static[1], junctionIdeal.port_2.h_outflow, {}, 0, 0));
}}}

The backend processes the equation flattened by the OF correctly, and in fact the original system [https://libraries.openmodelica.org/branches/master/Modelica_trunk/files/Modelica_trunk_Modelica.Fluid.Examples.Explanatory.MeasuringTemperature.sim simulates successfully] and [https://libraries.openmodelica.org/branches/master/Modelica_trunk/Modelica_trunk.html passess verification].

When confronted with the equation generated by the NF, the {{{normalInlineFunction}}} module of the backend instead turns it into
{{{
51/51 (1): openTankHot3.portInDensities[1] = {}   [dynamic |0|0|0|0|] 
}}}
which is obviously wrong, and eventually causes the backend to fail.

I guess there is something missing in the data structure output by the NF which is not immediately apparent from the textural output, but which causes the inlining to fail.

I only carried out the analysis for this model, but I suspect that there are many others affected in the Fluid library and in all libraries (e.g. Buildings) using it."	defect	closed	high	2.0.0	New Instantiation		fixed		
