-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1845 from ibpsa/issue1844_moveInterpolateToMath
Issue1844 move interpolate to math
- Loading branch information
Showing
17 changed files
with
180 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
Interpolate | ||
PowerLaw | ||
PowerLawFixedM | ||
WindPressureLowRise | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_Math_Examples_Interpolate.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
IBPSA/Resources/Scripts/Dymola/Utilities/Math/Examples/Interpolate.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}); |
2 changes: 1 addition & 1 deletion
2
...zone/BaseClasses/Examples/Interpolate.mos → ...s/Math/Functions/Examples/Interpolate.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="<html> | ||
<p> | ||
This example is the same as | ||
<a href=\"modelica://IBPSA.Utilities.Math.Functions.Examples.Interpolate\"> | ||
IBPSA.Utilities.Math.Functions.Examples.Interpolate</a> | ||
except that the block is used in place of the function. | ||
</p> | ||
</html>", revisions="<html> | ||
<ul> | ||
<li> | ||
February 29, 2024, by Hongxiang Fu:<br/> | ||
First implementation.<br/> | ||
This is for | ||
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1844\">IBPSA, #1844</a>. | ||
</li> | ||
</ul> | ||
</html> | ||
")); | ||
end Interpolate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
within IBPSA.Utilities.Math; | ||
block Interpolate | ||
"Output the cubic hermite spline interpolation of the input signal on the given curve" | ||
extends Modelica.Blocks.Interfaces.SISO; | ||
|
||
parameter Real[:] xd "x-axis support points"; | ||
parameter Real[size(xd, 1)] yd "y-axis support points"; | ||
parameter Real[size(xd, 1)] d "Derivatives at the support points"; | ||
equation | ||
y = IBPSA.Utilities.Math.Functions.interpolate(u=u, xd=xd, yd=yd, d=d); | ||
|
||
annotation ( | ||
defaultComponentName="int", | ||
Documentation(info="<html> | ||
<p> | ||
This block outputs the value on a cubic hermite spline through the given | ||
support points and their spline derivatives at these points, using the function | ||
<a href=\"modelica://IBPSA.Utilities.Math.Functions.interpolate\"> | ||
IBPSA.Utilities.Math.Functions.interpolate</a>. | ||
</p> | ||
</html>", revisions="<html> | ||
<ul> | ||
<li> | ||
February 29, 2024, by Hongxiang Fu:<br/> | ||
First implementation.<br/> | ||
This is for | ||
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1844\">IBPSA, #1844</a>. | ||
</li> | ||
</ul> | ||
</html>"), | ||
Icon(graphics={ | ||
Ellipse( | ||
extent={{-58,-56},{-68,-46}}, | ||
lineColor={28,108,200}, | ||
fillColor={28,108,200}, | ||
fillPattern=FillPattern.Solid), | ||
Line( | ||
points={{-64,-52},{-36,6},{8,40},{78,26}}, | ||
color={28,108,200}, | ||
smooth=Smooth.Bezier), | ||
Ellipse( | ||
extent={{82,20},{72,30}}, | ||
lineColor={28,108,200}, | ||
fillColor={28,108,200}, | ||
fillPattern=FillPattern.Solid), | ||
Ellipse( | ||
extent={{-10,18},{-20,28}}, | ||
lineColor={28,108,200}, | ||
fillColor={28,108,200}, | ||
fillPattern=FillPattern.Solid)})); | ||
end Interpolate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters