﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6068	Illegitimate transformation during translation of HelmholtzMedia function	Francesco Casella	Karim Adbdelhak	"As discussed [https://github.com/thorade/HelmholtzMedia/issues/34 here], we have some issues in the HelmholtzMedia library that can be ultimately traced to a symbolic transformation carried out in a function, namely

  {{{a^b -> exp(log(a)*b)}}}

The Modelica Specification, [https://specification.modelica.org/v3.4/Ch10.html#exponentiation-of-scalars-of-numeric-elements Section 10.6.7] states:

  Exponentiation {{{a^b}}} is defined as {{{pow(double a,double b)}}} in the ANSI C library if both {{{a}}} and {{{b}}} are Real scalars. A Real scalar value is returned. If {{{a}}} or {{{b}}} are Integer scalars, they are automatically promoted to {{{Real}}}. Consequences of exceptional situations, such as ({{{a==0.0}}} and {{{b<=0.0}}}, {{{a<0}}} and {{{b}}} is not an integer) or overflow are undefined.

So, from what I understand, it is perfectly legitimate to compute {{{a^b}}}, where {{{a = -2.5}}} and {{{b = 2.0}}} are two Real numbers, as the ANSI C function can recognize the even integer exponent and handle this correctly. And in fact, even the case of Real {{{a = -2.5}}} and Integer {{{b = 2}}} is first turned into the previous case, at least conceptually, before further processing.

Hence, the above-mentioned symbolic transformation is in general invalid and should be avoided, unless {{{min(a) >= 0}}}, that is.

This issue affects models of HelmholtzMedia that are currently failing for this reason, see e.g. [https://libraries.openmodelica.org/branches/newInst/HelmholtzMedia/files/HelmholtzMedia_HelmholtzMedia.Examples.MediaTestModels.ButaneTestModel_dT_component_ph.sim HelmholtzMedia.Examples.MediaTestModels.ButaneTestModel_dT_component_ph]"	defect	closed	blocker	1.17.0	Backend		fixed		Vitalij Ruge matthis.thorade@…
