Skip to content

Commit

Permalink
Corrected wrong use of getInstanceName
Browse files Browse the repository at this point in the history
This integrates IBPSA, issue 1814. The use of this function is not allowed inside other functions, and causes OpenModelica to fail during translation
  • Loading branch information
mwetter committed Nov 22, 2023
1 parent 23618e9 commit 693248c
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ initial equation
kMed=kMed,
muMed=muMed,
cpMed=cpMed,
m_flow_nominal=m_flow_nominal);
m_flow_nominal=m_flow_nominal,
instanceName=getInstanceName());

annotation (
__Dymola_Commands(file=
Expand All @@ -75,6 +76,13 @@ borehole.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
June 21, 2018, by Massimo Cimmino:<br/>
First implementation.
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ initial equation
kMed=kMed,
muMed=muMed,
cpMed=cpMed,
m_flow_nominal=m_flow_nominal);
m_flow_nominal=m_flow_nominal,
instanceName=getInstanceName());

annotation (
__Dymola_Commands(file=
Expand All @@ -79,6 +80,13 @@ capacity location <code>x</code> is then automatically set to zero.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
June 21, 2018, by Massimo Cimmino:<br/>
First implementation.
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ initial equation
kMed=kMed,
muMed=muMed,
cpMed=cpMed,
m_flow_nominal=m_flow_nominal);
m_flow_nominal=m_flow_nominal,
instanceName=getInstanceName());

annotation (
__Dymola_Commands(file=
Expand All @@ -76,6 +77,13 @@ borehole.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
June 21, 2018, by Massimo Cimmino:<br/>
First implementation.
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ initial equation
kMed=kMed,
muMed=muMed,
cpMed=cpMed,
m_flow_nominal=m_flow_nominal);
m_flow_nominal=m_flow_nominal,
instanceName=getInstanceName());

annotation (
__Dymola_Commands(file=
Expand All @@ -81,6 +82,13 @@ capacity location <code>x</code> is then automatically set to zero.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
June 21, 2018, by Massimo Cimmino:<br/>
First implementation.
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ algorithm
i := i + 1;
end while;
end if;
assert(test, "In " + getInstanceName() + ":\n" +
assert(test, "In " + instanceName + ":\n" +
"Maximum number of iterations exceeded. Check the borehole geometry.
The tubes may be too close to the borehole wall.
Input to the function
Expand Down Expand Up @@ -121,6 +121,13 @@ International Journal of Energy Research, 35:312&ndash;320, 2011.</p>
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
February 7, 2022, by Michael Wetter:<br/>
Changed function to be <code>pure</code>.<br/>
This is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ algorithm
i := i + 1;
end while;
end if;
assert(test, "In " + getInstanceName() + ":\n" +
assert(test, "In " + instanceName + ":\n" +
"Maximum number of iterations exceeded. Check the borehole geometry.
The tubes may be too close to the borehole wall.
Input to the function
Expand Down Expand Up @@ -129,6 +129,13 @@ International Journal of Energy Research, 35:312&ndash;320, 2011.</p>
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
February 7, 2022, by Michael Wetter:<br/>
Changed function to be <code>pure</code>.<br/>
This is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ partial function partialInternalResistances
input Modelica.Units.SI.SpecificHeatCapacity cpMed
"Specific heat capacity of the fluid";
input Modelica.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate";
input String instanceName "undeclared caller"
"Instance name of the model or block that calls this function";

// Outputs
output Real x "Capacity location";
Expand Down Expand Up @@ -71,6 +73,13 @@ the borehole internal resistances.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
June 4, 2023, by Michael Wetter:<br/>
Corrected variability.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1762\">IBPSA, #1762</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ initial equation
kMed=kMed,
muMed=muMed,
cpMed=cpMed,
m_flow_nominal=m1_flow_nominal);
m_flow_nominal=m1_flow_nominal,
instanceName=getInstanceName());

equation
assert(borFieDat.conDat.borCon == Buildings.Fluid.Geothermal.Borefields.Types.BoreholeConfiguration.SingleUTube,
Expand Down Expand Up @@ -159,6 +160,13 @@ International Journal Of Energy Research, 35:312-320, 2011.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
March 7, 2022, by Michael Wetter:<br/>
Removed <code>massDynamics</code>.<br/>
This is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ initial equation
kMed=kMed,
muMed=muMed,
cpMed=cpMed,
m_flow_nominal=m1_flow_nominal);
m_flow_nominal=m1_flow_nominal,
instanceName=getInstanceName());

equation
assert(borFieDat.conDat.borCon == Buildings.Fluid.Geothermal.Borefields.Types.BoreholeConfiguration.DoubleUTubeParallel
Expand Down Expand Up @@ -253,6 +254,13 @@ International Journal Of Energy Research, 35:312-320, 2011.
</html>", revisions="<html>
<ul>
<li>
November 22, 2023, by Michael Wetter:<br/>
Corrected use of <code>getInstanceName()</code> which was called inside a function which
is not allowed.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>.
</li>
<li>
March 7, 2022, by Michael Wetter:<br/>
Removed <code>massDynamics</code>.<br/>
This is for
Expand Down
17 changes: 11 additions & 6 deletions Buildings/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ Each class (i.e., model, block and function) must be used in an example or valid


class Version_10_1_0 "Version 10.1.0"
extends Modelica.Icons.ReleaseNotes;
annotation(
extends
Modelica.Icons.ReleaseNotes;
annotation (
Documentation(info = "<html>
<div class=\"release-summary\">
<p>
Expand Down Expand Up @@ -323,12 +324,16 @@ that do <b style=\"color:red\">not</b> lead to wrong simulation results, e.g.,
units are wrong or errors in documentation):
</p>
<table class=\"releaseTable\" summary=\"summary\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" style=\"border-collapse:collapse;\">
<tr><td colspan=\"2\"><b>xxx</b>
<tr><td colspan=\"2\"><b>Buildings.Fluid.Geothermal.Borefields</b>
</td>
</tr>
<tr><td valign=\"top\">xxx
<tr><td valign=\"top\">Buildings.Fluid.Geothermal.Borefields.BaseClasses.Boreholes.BaseClasses.Functions.internalResistancesOneUTube<br/>
Buildings.Fluid.Geothermal.Borefields.BaseClasses.Boreholes.BaseClasses.Functions.internalResistancesTwoUTube
</td>
<td valign=\"top\">xxx.
<td valign=\"top\">Corrected usage of <code>getInstanceName()</code>, which was called inside
these functions. This does not conform with the Modelica Language Standard, and causes
the compilation to fail in OpenModelica 1.22.0.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1814\">IBPSA, #1814</a>
</td>
</tr>
</table>
Expand Down Expand Up @@ -13221,4 +13226,4 @@ requirements definition or providing feedback regarding the model applicability
to solve specific problems.
</p>
</html>"));
end Buildings;
end Buildings;

0 comments on commit 693248c

Please sign in to comment.