﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3102	Models using the IF97 water medium are slow due to lack of common subexpression elimination	Francesco Casella	Lennart Ochel	"The Modelica.Media IF97 water/steam model was designed in order to provide efficient performance (i.e., no duplicate calls to core computations) assuming that the {{{LateInline}}} annotation and common subexpression elimination were supported by the compiler.

The former requirement has been satisfied in OMC for a while, the latter is currently not yet fulfilled. As a result, the function Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph (which is very computationally expensive) is called many times with exactly the same argument, leading to an outrageous slow-down of the simulation process, possibly leading to time-outs (see, e.g., {{{ThermoPower.Examples.CISE.CISESim180503}}} or {{{ThermoPower.Test.DistributedParameterComponents.TestWaterFlow1DFEM_A}}}). 

The analysis is confirmed by turning on {{{+d=dumpSimCode}}} and by running the profiler on test cases.

This is also the root cause of the very slow simulation of {{{simulation/libraries/3rdParty/ThermoPower/Bug2537.mos}}}, which was reported by Martin Sjoelund on Jan 12 as being the critical path preventing the testsuite speed-up by parallelization.

Since the IF97 model is essential for the modelling of most power production systems, and usually gobbles up most of the CPU time, I would recommend to implement at least a very rudimentary CSE scheme that is able to handle the case of calls to the same function with the same arguments, e.g., {{{Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(hex.p, hex.h[1], 0.0, 0)}}}."	defect	closed	blocker	1.11.0	Backend	trunk	fixed		Martin Sjölund Vitalij Ruge Lennart Ochel jan.hagemann@… Patrick Täuber stetrab@…
