Skip to content

Commit

Permalink
Merge branch 'master' into issue1842_wrongAnnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Mar 11, 2024
2 parents cbbaa51 + b3dacd3 commit c3b9533
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
within IBPSA.Airflow.Multizone.BaseClasses.Examples;
model Interpolate "Test model for the function flowElementData"
model Interpolate "Test model for the interpolation function"
extends Modelica.Icons.Example;

parameter Real table[:,:]=[-50,-0.08709; -25,-0.06158; -10,-0.03895; -5,-0.02754;
Expand Down
35 changes: 17 additions & 18 deletions IBPSA/Airflow/Multizone/BaseClasses/interpolate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,22 @@ algorithm
end if;
end for;

// Extrapolate or interpolate the data
if i == 1 then
z:=yd[1]+(u-xd[1])*(yd[2]-yd[1])/(xd[2]-xd[1]); //Interpolate linearly between first and second point
elseif i == (size(xd, 1) - 1) then
z:=yd[end-1]+(u-xd[end-1])*(yd[end]-yd[end-1])/(xd[end]-xd[end-1]); //Interpolate linearly between last and second-to-last point.
z :=IBPSA.Utilities.Math.Functions.cubicHermiteLinearExtrapolation(
x=u,
x1=xd[i],
x2=xd[i + 1],
y1=yd[i],
y2=yd[i + 1],
y1d=d[i],
y2d=d[i + 1]);

else
z :=IBPSA.Utilities.Math.Functions.cubicHermiteLinearExtrapolation(
x=u,
x1=xd[i],
x2=xd[i + 1],
y1=yd[i],
y2=yd[i + 1],
y1d=d[i],
y2d=d[i + 1]);
end if;

annotation (
annotation (smoothOrder = 1,
Documentation(info="<html>
<p>
This function returns the value on a cubic hermite spline through the given support points
and provided spline derivatives at these points with monotonically increasing values.
The last 2 points in the table are linearly interpolated.
Outside the provided support points, the function returns a linear extrapolation with
the same slope as the cubic spline has at the respective support point.
</p>
<p>
A similar model is also used in the CONTAM software (Dols and Walton, 2015).
Expand All @@ -67,6 +60,12 @@ National Institute of Standards and Technology, NIST TN 1887, Sep. 2015. doi:
</html>", revisions="<html>
<ul>
<li>
February 26, 2024, by Hongxiang Fu:<br/>
Correct implementation to make it smooth.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1840\">IBPSA, #1840</a>.
</li>
<li>
February 2, 2022, by Michael Wetter:<br/>
Revised implementation.<br/>
This is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ block SkyClearness "Sky clearness"
Modelica.Blocks.Interfaces.RealInput zen(
quantity="Angle",
unit="rad",
displayUnit="degreeC") "Zenith angle of the sun beam"
displayUnit="deg") "Zenith angle of the sun beam"
annotation (Placement(transformation(extent={{-140,-80},{-100,-40}})));
Modelica.Blocks.Interfaces.RealInput HDifHor(quantity=
"RadiantEnergyFluenceRate", unit="W/m2")
Expand Down Expand Up @@ -66,6 +66,12 @@ is such that the regularization is usually not triggered.
</html>", revisions="<html>
<ul>
<li>
March 4, 2024, by Michael Wetter:<br/>
Corrected <code>displayUnit</code>.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1848\">IBPSA, #1848</a>.
</li>
<li>
September 6, 2021, by Ettore Zanetti:<br/>
Changed <code>lat</code> from being a parameter to an input from weather bus.<br/>
Changed input connector <code>HGloHor</code> to <code>HDirNor</code>.<br/>
Expand Down
Loading

0 comments on commit c3b9533

Please sign in to comment.