Check == and <> usages in functions #1915
Labels
enhancement
New feature or enhancement
L: Media
Issue addresses Modelica.Media
P: low
Low priority issue
Reported by otter on 19 Feb 2016 13:31 UTC
In https://trac.modelica.org/Modelica/ticket/1867#comment:41 the following was reported:
The LMS Amesim compiler found several "warnings" related to equality comparison of Real variables. For example, there are lines like if (d_vap <> d_liq) or if abs(m) <= tol or fb == 0.0 . I suspect most other tools just ignore the warnings, like we do. However, it might be nice to clean up as many of them as we can before the v3.2.2 release. This is most likely just a partial list…
Functions that use == comparisons on Real variables:
Functions that use <> comparisons on Real variables:
Although == and <> are allowed in Modelica functions, there might be issues and the functions should be inspected.
I have analyzed the first two (Hubertus, please have a look at the other ones):
Modelica.Media.Common.OneNonLinearEquation.solve
Here the following code is present
This code fragment checks whether the interval of the independent variable (abs(m) <= tol) is small enough or whether the residue is exactly zero. If this is the case, the root was found. The "fb == 0.0" is correct here: We cannot use an eps, abs(fb) <= eps, because the "size" of fb is not known (could be very large or very small). However, if the residue is exactly zero, it is impossible to further reduce the x-interval. Therefore, this check must be present.
Modelica.Media.Water.IF97_Utilities.BaseIF97.Basic.f3
Here the following code fragement is present:
Looks a bit surprising to me and it might be better to have an eps here, such as (but I am unsure):
Migrated-From: https://trac.modelica.org/Modelica/ticket/1915
The text was updated successfully, but these errors were encountered: