diff --git a/IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo b/IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo index d4bcc7a5bc..d8bc5892ce 100644 --- a/IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo +++ b/IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo @@ -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; diff --git a/IBPSA/Airflow/Multizone/BaseClasses/interpolate.mo b/IBPSA/Airflow/Multizone/BaseClasses/interpolate.mo index 7955df7a4b..2b768fe7ab 100644 --- a/IBPSA/Airflow/Multizone/BaseClasses/interpolate.mo +++ b/IBPSA/Airflow/Multizone/BaseClasses/interpolate.mo @@ -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="

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.

A similar model is also used in the CONTAM software (Dols and Walton, 2015). @@ -67,6 +60,12 @@ National Institute of Standards and Technology, NIST TN 1887, Sep. 2015. doi: ", revisions="