﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5459	Unnecessary choice of dynamic state selection leads to code generation failure	Francesco Casella	Karim Adbdelhak	"Please consider [https://libraries.openmodelica.org/branches/master/Modelica_3.2.3/files/Modelica_3.2.3_Modelica.Fluid.Examples.HeatingSystem.err Modelica.Fluid.Examples.HeatingSystem]. 

The backend uses dynamic state selection
{{{
 * Number of states: 10 
($STATESET1.x[4],$STATESET1.x[3],$STATESET1.x[2],$STATESET1.x[1],
 radiator.mediums[1].p,radiator.mediums[1].h,pipe.mediums[1].p,
 pipe.mediums[1].h,pipe.mediums[2].p,pipe.mediums[2].h)
}}}
but then later fails to generate the code:
{{{
[/var/lib/jenkins/ws/OpenModelicaLibraryTestingWork/OpenModelica/OMCompiler/Compiler/SimCode/SimCodeUtil.mo:4450:9-4450:59:writable] Error: Internal error function createStateSetsSets failed.
[/var/lib/jenkins/ws/OpenModelicaLibraryTestingWork/OpenModelica/OMCompiler/Compiler/SimCode/SimCodeUtil.mo:737:5-737:146:writable] Error: Internal error function createSimCode failed [Transformation from optimised DAE to simulation code structure failed]
}}}
Dymola manages to make the following static state selection:
{{{
Statically selected continuous time states
heater.mediums[1].h
heater.mediums[1].p
pipe.mediums[1].h
pipe.mediums[1].p
pipe.mediums[2].h
pipe.mediums[2].p
radiator.mediums[1].h
radiator.mediums[1].p
tank.level
tank.medium.h
}}}
which is also the one I would expect as a modeller for this system. In fact, it reports that
{{{
We cannot differentiate equations for the following variables
having stateSelect = StateSelect.prefer.
They will be treated as if they had stateSelect = StateSelect.default:
pump.medium.h
pump.medium.p
}}}
which may be relevant to the discussion.

Karim, Andreas, Lennart, do you think you can fix the state selection algorithm so that it leads to the above-mentioned fixed state selection?"	defect	closed	blocker	1.16.0	Backend		fixed		Andreas Heuermann Lennart Ochel Andrea Bartolini Adrian Pop giovanni.mangola@…
