diff --git a/IBPSA/Airflow/Multizone/BaseClasses/Examples/package.order b/IBPSA/Airflow/Multizone/BaseClasses/Examples/package.order index e841c46bf2..d11030019d 100644 --- a/IBPSA/Airflow/Multizone/BaseClasses/Examples/package.order +++ b/IBPSA/Airflow/Multizone/BaseClasses/Examples/package.order @@ -1,4 +1,3 @@ -Interpolate PowerLaw PowerLawFixedM WindPressureLowRise diff --git a/IBPSA/Airflow/Multizone/BaseClasses/package.order b/IBPSA/Airflow/Multizone/BaseClasses/package.order index 698bba52a4..ab4a1d1fef 100644 --- a/IBPSA/Airflow/Multizone/BaseClasses/package.order +++ b/IBPSA/Airflow/Multizone/BaseClasses/package.order @@ -6,7 +6,6 @@ PowerLawResistanceParameters TwoWayFlowElement TwoWayFlowElementBuoyancy ZonalFlow -interpolate powerLaw powerLawFixedM windPressureLowRise diff --git a/IBPSA/Airflow/Multizone/Table_m_flow.mo b/IBPSA/Airflow/Multizone/Table_m_flow.mo index f736baf4b8..f17dd0c252 100644 --- a/IBPSA/Airflow/Multizone/Table_m_flow.mo +++ b/IBPSA/Airflow/Multizone/Table_m_flow.mo @@ -2,7 +2,7 @@ within IBPSA.Airflow.Multizone; model Table_m_flow "Mass flow(y-axis) vs Pressure(x-axis) cubic spline fit model based from table data, with last two points linearly interpolated" extends IBPSA.Airflow.Multizone.BaseClasses.PartialOneWayFlowElement( - m_flow = IBPSA.Airflow.Multizone.BaseClasses.interpolate( + m_flow = IBPSA.Utilities.Math.Functions.interpolate( u=dp, xd=dpMea_nominal, yd=mMea_flow_nominal, diff --git a/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_Math_Examples_Interpolate.txt b/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_Math_Examples_Interpolate.txt new file mode 100644 index 0000000000..b7c14e9f57 --- /dev/null +++ b/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_Math_Examples_Interpolate.txt @@ -0,0 +1,9 @@ +last-generated=2024-02-29 +statistics-simulation= +{ + "linear": " ", + "nonlinear": " ", + "numerical Jacobians": "0" +} +time=[0e+00, 5e+02] +int.y=[-8.709000051021576e-02, -8.607897162437439e-02, -8.508513867855072e-02, -8.410613983869553e-02, -8.313964307308197e-02, -8.218330889940262e-02, -8.123478293418884e-02, -8.029171824455261e-02, -7.935179024934769e-02, -7.841263711452484e-02, -7.747191935777664e-02, -7.652729749679565e-02, -7.557642459869385e-02, -7.461696118116379e-02, -7.364656031131744e-02, -7.266288250684738e-02, -7.166357338428497e-02, -7.064630091190338e-02, -6.960871070623398e-02, -6.854847073554993e-02, -6.74632266163826e-02, -6.635063886642456e-02, -6.520836800336838e-02, -6.403406709432602e-02, -6.282539665699005e-02, -6.157999858260155e-02, -6.03080615401268e-02, -5.901877209544182e-02, -5.770833417773247e-02, -5.637295171618462e-02, -5.500881373882294e-02, -5.36121279001236e-02, -5.217909067869186e-02, -5.070589855313301e-02, -4.918875172734261e-02, -4.762385040521622e-02, -4.600739479064941e-02, -4.433558508753777e-02, -4.260461404919624e-02, -4.081068560481071e-02, -3.894999995827675e-02, -3.698130697011948e-02, -3.486191853880882e-02, -3.258588165044785e-02, -3.014722652733326e-02, -2.754000015556812e-02, -2.463850006461143e-02, -2.133000083267689e-02, -1.741999946534634e-02, -1.231999974697828e-02, 0e+00, 1.231999974697828e-02, 1.741999946534634e-02, 2.133000083267689e-02, 2.528040856122971e-02, 2.613032609224319e-02, 2.613095752894878e-02, 2.613155916333199e-02, 2.61321347206831e-02, 2.613268233835697e-02, 2.613320574164391e-02, 2.613370306789875e-02, 2.613417431712151e-02, 2.613462321460247e-02, 2.613504603505135e-02, 2.613544836640358e-02, 2.613582648336887e-02, 2.613618411123753e-02, 2.613652125000954e-02, 2.613683789968491e-02, 2.613713406026363e-02, 2.613740973174572e-02, 2.613766863942146e-02, 2.613791078329086e-02, 2.613813430070877e-02, 2.613834105432034e-02, 2.613853104412556e-02, 2.613870799541473e-02, 2.613886818289757e-02, 2.613901719450951e-02, 2.61391494423151e-02, 2.61392705142498e-02, 2.613938041031361e-02, 2.613947726786137e-02, 2.613956481218338e-02, 2.61396411806345e-02, 2.613970823585987e-02, 2.61397659778595e-02, 2.613981626927853e-02, 2.613985724747181e-02, 2.613989263772964e-02, 2.613992244005203e-02, 2.613994479179382e-02, 2.613996341824532e-02, 2.613997645676136e-02, 2.613998576998711e-02, 2.61399932205677e-02, 2.6139996945858e-02, 2.613999880850315e-02, 2.61400006711483e-02, 2.61400006711483e-02] diff --git a/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Airflow_Multizone_BaseClasses_Examples_Interpolate.txt b/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_Math_Functions_Examples_Interpolate.txt similarity index 100% rename from IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Airflow_Multizone_BaseClasses_Examples_Interpolate.txt rename to IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_Math_Functions_Examples_Interpolate.txt diff --git a/IBPSA/Resources/Scripts/Dymola/Utilities/Math/Examples/Interpolate.mos b/IBPSA/Resources/Scripts/Dymola/Utilities/Math/Examples/Interpolate.mos new file mode 100644 index 0000000000..43a18535fa --- /dev/null +++ b/IBPSA/Resources/Scripts/Dymola/Utilities/Math/Examples/Interpolate.mos @@ -0,0 +1,2 @@ +simulateModel("IBPSA.Utilities.Math.Examples.Interpolate", stopTime=500, tolerance=1e-06, resultFile="InterpolateBlock"); +createPlot(id=1, position={15, 15, 584, 361}, x="int.u", y={"int.y"}, range={-50.0, 50.0, -0.1, 0.04000000000000001}, grid=true, filename="InterpolateBlock.mat", colors={{28,108,200}}, timeUnit="Pa", displayUnits={"kg/s"}); diff --git a/IBPSA/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/Interpolate.mos b/IBPSA/Resources/Scripts/Dymola/Utilities/Math/Functions/Examples/Interpolate.mos similarity index 62% rename from IBPSA/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/Interpolate.mos rename to IBPSA/Resources/Scripts/Dymola/Utilities/Math/Functions/Examples/Interpolate.mos index 8d1f874fd5..a684903a75 100644 --- a/IBPSA/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/Interpolate.mos +++ b/IBPSA/Resources/Scripts/Dymola/Utilities/Math/Functions/Examples/Interpolate.mos @@ -1,2 +1,2 @@ -simulateModel("IBPSA.Airflow.Multizone.BaseClasses.Examples.Interpolate", stopTime=500, tolerance=1e-06, resultFile="Interpolate"); +simulateModel("IBPSA.Utilities.Math.Functions.Examples.Interpolate", stopTime=500, tolerance=1e-06, resultFile="Interpolate"); createPlot(id=1, position={15, 15, 584, 361}, x="dp", y={"m_flow"}, range={-50.0, 50.0, -0.1, 0.04000000000000001}, grid=true, filename="Interpolate.mat", colors={{28,108,200}}, timeUnit="Pa", displayUnits={"kg/s"}); diff --git a/IBPSA/Utilities/Math/Examples/Interpolate.mo b/IBPSA/Utilities/Math/Examples/Interpolate.mo new file mode 100644 index 0000000000..0c63bd0737 --- /dev/null +++ b/IBPSA/Utilities/Math/Examples/Interpolate.mo @@ -0,0 +1,54 @@ +within IBPSA.Utilities.Math.Examples; +model Interpolate "Example model of the Interpolate block" + extends Modelica.Icons.Example; + + parameter Real table[:,:]=[-50,-0.08709; -25,-0.06158; -10,-0.03895; -5,-0.02754; + -3,-0.02133; -2,-0.01742; -1,-0.01232; 0,0; 1,0.01232; 2,0.01742; 3,0.02133; + 4.5,0.02613; 50,0.02614] + "Table of mass flow rate in kg/s (second column) as a function of pressure difference in Pa (first column)"; + parameter Real[:] xd=table[:,1] "x-axis support points"; + parameter Real[size(xd, 1)] yd=table[:,2] "y-axis support points"; + parameter Real[size(xd, 1)] d = + IBPSA.Utilities.Math.Functions.splineDerivatives( + x=xd, + y=yd, + ensureMonotonicity=true) "Derivatives at the support points"; + + IBPSA.Utilities.Math.Interpolate int( + xd=xd, + yd=yd, + d=d) "Interpolate block" + annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); + Modelica.Blocks.Sources.Ramp ramp( + duration=500, + height=100, + offset=-50) "Ramp from -50Pa to +50Pa" + annotation (Placement(transformation(extent={{-60,-10},{-40,10}}))); + +equation + connect(ramp.y, int.u) + annotation (Line(points={{-39,0},{-12,0}}, color={0,0,127})); +annotation ( +experiment( + StopTime=500, + Tolerance=1e-06), + __Dymola_Commands(file="modelica://IBPSA/Resources/Scripts/Dymola/Utilities/Math/Examples/Interpolate.mos" + "Simulate and plot"), Documentation(info=" +

+This example is the same as + +IBPSA.Utilities.Math.Functions.Examples.Interpolate +except that the block is used in place of the function. +

+", revisions=" + + +")); +end Interpolate; diff --git a/IBPSA/Utilities/Math/Examples/package.order b/IBPSA/Utilities/Math/Examples/package.order index 4504982d1f..8dd737c07e 100644 --- a/IBPSA/Utilities/Math/Examples/package.order +++ b/IBPSA/Utilities/Math/Examples/package.order @@ -12,6 +12,7 @@ Factorial FallingFactorial IntegerReplicator IntegratorWithReset +Interpolate InverseXRegularized Polynomial PowerLinearized diff --git a/IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo b/IBPSA/Utilities/Math/Functions/Examples/Interpolate.mo similarity index 62% rename from IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo rename to IBPSA/Utilities/Math/Functions/Examples/Interpolate.mo index d8bc5892ce..3bb1d55d33 100644 --- a/IBPSA/Airflow/Multizone/BaseClasses/Examples/Interpolate.mo +++ b/IBPSA/Utilities/Math/Functions/Examples/Interpolate.mo @@ -1,4 +1,4 @@ -within IBPSA.Airflow.Multizone.BaseClasses.Examples; +within IBPSA.Utilities.Math.Functions.Examples; model Interpolate "Test model for the interpolation function" extends Modelica.Icons.Example; @@ -13,8 +13,8 @@ model Interpolate "Test model for the interpolation function" "Mass flow rate"; protected - parameter Real[:] xd=table[:,1] "X-axis support points"; - parameter Real[size(xd, 1)] yd=table[:,2] "Y-axis support points"; + parameter Real[:] xd=table[:,1] "x-axis support points"; + parameter Real[size(xd, 1)] yd=table[:,2] "y-axis support points"; parameter Real[size(xd, 1)] d(each fixed=false) "Derivatives at the support points"; Modelica.Blocks.Sources.Ramp ramp( @@ -22,28 +22,39 @@ protected height=100, offset=-50) "Ramp from -50Pa to +50Pa"; initial equation - d =IBPSA.Utilities.Math.Functions.splineDerivatives( + d = IBPSA.Utilities.Math.Functions.splineDerivatives( x=xd, y=yd, ensureMonotonicity=true); equation dp=ramp.y; - m_flow =IBPSA.Airflow.Multizone.BaseClasses.interpolate(u=dp,xd=xd,yd=yd,d=d); + m_flow = IBPSA.Utilities.Math.Functions.interpolate(u=dp, xd=xd, yd=yd, d=d); annotation ( experiment( StopTime=500, Tolerance=1e-06), - __Dymola_Commands(file="modelica://IBPSA/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/Interpolate.mos" + __Dymola_Commands(file="modelica://IBPSA/Resources/Scripts/Dymola/Utilities/Math/Functions/Examples/Interpolate.mos" "Simulate and plot"), Documentation(info="

This example demonstrates the function - -IBPSA.Airflow.Multizone.BaseClasses.interpolate. + +IBPSA.Utilities.Math.Functions.interpolate.

", revisions="