Skip to content

Commit

Permalink
New source assuming ideal gas + doku
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGebhart committed Jun 24, 2024
1 parent f2400ae commit d58201d
Show file tree
Hide file tree
Showing 24 changed files with 1,084 additions and 266 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
within ThermofluidStream.Processes.Compressors.SimpleCompressors;
model FlowControlledSimpleCompressor "Ideally controlled compressor (mass flow rate, volume flow rate) with fixed isentropic efficiency suitable for compressible media (real gas)"
within ThermofluidStream.Processes.Compressors.AllMediaBasedOnEntropy;
model FlowSource
"Ideal flow source (fixed mass flow rate or volume flow rate) with fixed isentropic efficiency suitable as both pump (incompressible media) or compressor/blower/fan (compressible media)"

extends ThermofluidStream.Processes.Compressors.BaseClasses.PartialFlowControlledSimpleCompressor;
extends ThermofluidStream.Processes.Compressors.BaseClasses.PartialFlowSource;

import SetpointMode = ThermofluidStream.Processes.Compressors.Internal.Types.CompressorSetpointModeFlow;

Expand Down Expand Up @@ -104,5 +105,60 @@ equation
Text(
extent={{-30,-20},{30,20}},
textColor={28,108,200},
textString=setpointModeString)}));
end FlowControlledSimpleCompressor;
textString=setpointModeString)}), Documentation(info="<html>
<p>
Ideal flow source usable as both pump (incompressible media) or compressor/blower/fan (compressible media) with fixed isentropic efficiency <code>eta_is<code>. The outlet enthalpy <code>h_out</code> is thereby calculated based on the medium entropy function:

Check warning on line 110 in ThermofluidStream/Processes/Compressors/AllMediaBasedOnEntropy/FlowSource.mo

View workflow job for this annotation

GitHub Actions / html_documentation_checks

<code> is probably intended as </code>
</p>
<p>
<code>
h_out = h_in + w_t;<br>
w_t = w_t_is/eta_is;<br>
w_t_is = h_out_is - h_in;<br>
h_out_is = Medium.specificEnthalpy_psX(p_out, s_out = s_in, Xi_out = Xi_in);
</code>
</p>
<p>
with:
</p>
<ul>
<li> inlet specific enthalpy <code>h_in</code></li>
<li> specific technical work <code>w_t</code></li>
<li>fixed isentropic efficiency <code>eta_is</code></li>
<li>specific technical work of the isentropic process <code>w_t_is</code></li>
<li>outlet specific enthalpy of the isentropic process <code>h_out_is</code></li>
<li>outlet pressure <code>p_out</code></li>
<li>specific entropy <code>s</code></li>
<li>mass fractions <code>Xi</code></li>
</ul>
<p>
For incompressible fluid, e.g. <a href=\"modelica://ThermofluidStream.Media.myMedia.Incompressible.Examples.Essotherm650\">Essotherm650</a>, <code>s_out = s_in</code> is equivalent with <code>T_out = T_in</code>.<br>
For ideal gas with constant isentropic exponent <code>kappa</code>, e.g. <a href=\"modelica://ThermofluidStream.Media.myMedia.IdealGases.SingleGases.Ar\">Argon</a>, <code>s_out = s_in</code> is equivalent with <code>T_out = T_in*(p_out/p_in)^((kappa-1)/kappa)</code>.
</p>
<p>
<strong>Assumptions:</strong>
</p>
<ul>
<li> stationary, i.e. <code>dEsys/dt = 0, dmsys/dt = 0</code></li>
<li> no heat transfer, i.e. <code>q=0</code></li>
<li> losses are considered by isentropic efficiency <code>eta_is = wt_is/wt</code>, with specific technical work <code>wt = h_out - h_in</code> and specific isentropic technical work <code>wt_is = h_out_is - h_in</code>, where <code>h_out_is = h(s_out=s_in,p_out,X_out)</code> is the specific enthalpy of the isentropic process</li>
<li> no external Force or Momentum accelerating the Compressor as a ridig body, i.e. <code>Wdot_external = 0</code></li>
<li> ridig boundary, i.e. <code>Wdot_v = 0</code> (no work due to change of volume)</li>
<li> difference of kinetic and potential energy of the fluid is negleted, i.e. <code>g*z_2 + 1/2*c_2^2 = g*z_1 + 1/2*c_1^2</code></li>
<li> no change in mass fractions X_in = X_out </li>
</ul>
<p>
The flow source is comparable to <a href=\"modelica://Modelica.Electrical.Analog.Sources.SignalCurrent\">CurrentSource</a> for <a href=\"modelica://Modelica.Electrical\">Modelica.Electrical</a>. One may either set as parameter or as time varying input signal:
</p>
<ul>
<li>mass flow rate <code>m_flow</code></li>
<li>volume flow rate <code>V_flow = m_flow/rho_in</code></li>
</ul>
</html>"));
end FlowSource;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
within ThermofluidStream.Processes.Compressors.SimpleCompressors;
model PressureControlledSimpleCompressor "Ideally controlled compressor (outlet pressure or pressure difference) with fixed isentropic efficiency suitable for compressible media (real gas)"

extends ThermofluidStream.Processes.Compressors.BaseClasses.PartialSimpleCompressor(final clip_p_out=if setpoint == SetpointMode.dp then true else false);
within ThermofluidStream.Processes.Compressors.AllMediaBasedOnEntropy;
model PressureSource "Ideal pressure source (fixed pressure difference, pressure ratio or outlet pressure) with fixed isentropic efficiency suitable as both pump (incompressible media) or compressor/blower/fan (compressible media)"
extends ThermofluidStream.Processes.Compressors.BaseClasses.PartialPressureSource( final clip_p_out=if setpoint == SetpointMode.dp then true else false);

import SetpointMode = ThermofluidStream.Processes.Compressors.Internal.Types.CompressorSetpointModePressure;

Expand Down Expand Up @@ -74,7 +73,6 @@ model PressureControlledSimpleCompressor "Ideally controlled compressor (outlet
rotation=90,
origin={0,-80})));
protected
Real pr = p_out/p_in "Pressure ratio p_out/p_in";
Modelica.Blocks.Interfaces.RealInput dp_internal(unit = "Pa") "Internal connector for pressure difference [Pa]";
Modelica.Blocks.Interfaces.RealInput pr_internal(unit = "1") "Internal connector for pressure ratio [1]";
Modelica.Blocks.Interfaces.RealInput p_out_internal(unit = "Pa") "Internal connector for outlet pressure [Pa]";
Expand Down Expand Up @@ -123,5 +121,61 @@ equation
Text(
extent={{-30,-20},{30,20}},
textColor={28,108,200},
textString=setpointModeString)}));
end PressureControlledSimpleCompressor;
textString=setpointModeString)}), Documentation(info="<html>
<p>
Ideal pressure source usable as both pump (incompressible media) or compressor/blower/fan (compressible media) with fixed isentropic efficiency <code>eta_is<code>. The outlet enthalpy <code>h_out</code> is thereby calculated based on the medium entropy function:

Check warning on line 126 in ThermofluidStream/Processes/Compressors/AllMediaBasedOnEntropy/PressureSource.mo

View workflow job for this annotation

GitHub Actions / html_documentation_checks

<code> is probably intended as </code>
</p>
<p>
<code>
h_out = h_in + w_t;<br>
w_t = w_t_is/eta_is;<br>
w_t_is = h_out_is - h_in;<br>
h_out_is = Medium.specificEnthalpy_psX(p_out, s_out = s_in, Xi_out = Xi_in);
</code>
</p>
<p>
with:
</p>
<ul>
<li> inlet specific enthalpy <code>h_in</code></li>
<li> specific technical work <code>w_t</code></li>
<li>fixed isentropic efficiency <code>eta_is</code></li>
<li>specific technical work of the isentropic process <code>w_t_is</code></li>
<li>outlet specific enthalpy of the isentropic process <code>h_out_is</code></li>
<li>outlet pressure <code>p_out</code></li>
<li>specific entropy <code>s</code></li>
<li>mass fractions <code>Xi</code></li>
</ul>
<p>
For incompressible fluid, e.g. <a href=\"modelica://ThermofluidStream.Media.myMedia.Incompressible.Examples.Essotherm650\">Essotherm650</a>, <code>s_out = s_in</code> is equivalent with <code>T_out = T_in</code>.<br>
For ideal gas with constant isentropic exponent <code>kappa</code>, e.g. <a href=\"modelica://ThermofluidStream.Media.myMedia.IdealGases.SingleGases.Ar\">Argon</a>, <code>s_out = s_in</code> is equivalent with <code>T_out = T_in*(p_out/p_in)^((kappa-1)/kappa)</code>.
</p>
<p>
<strong>Assumptions:</strong>
</p>
<ul>
<li> stationary, i.e. <code>dEsys/dt = 0, dmsys/dt = 0</code></li>
<li> no heat transfer, i.e. <code>q=0</code></li>
<li> losses are considered by isentropic efficiency <code>eta_is = wt_is/wt</code>, with specific technical work <code>wt = h_out - h_in</code> and specific isentropic technical work <code>wt_is = h_out_is - h_in</code>, where <code>h_out_is = h(s_out=s_in,p_out,X_out)</code> is the specific enthalpy of the isentropic process</li>
<li> no external Force or Momentum accelerating the Compressor as a ridig body, i.e. <code>Wdot_external = 0</code></li>
<li> ridig boundary, i.e. <code>Wdot_v = 0</code> (no work due to change of volume)</li>
<li> difference of kinetic and potential energy of the fluid is negleted, i.e. <code>g*z_2 + 1/2*c_2^2 = g*z_1 + 1/2*c_1^2</code></li>
<li> no change in mass fractions X_in = X_out </li>
</ul>
<p>
The pressure source is comparable to <a href=\"modelica://Modelica.Electrical.Analog.Sources.SignalVoltage\">VoltageSource</a> for <a href=\"modelica://Modelica.Electrical\">Modelica.Electrical</a>. One may either set as parameter or as time varying input signal:
</p>
<ul>
<li>pressure difference <code>dp = p_out - p_in</code></li>
<li>pressure ratio <code>pr = p_out/p_in</code></li>
<li>outlet pressure <code>p_out</code></li>
</ul>
</html>"));
end PressureSource;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
within ThermofluidStream.Processes.Compressors;
package AllMediaBasedOnEntropy
extends Modelica.Icons.Package;

annotation (Icon(graphics={
Ellipse(
extent={{-56,54},{64,-66}},
lineColor={28,108,200},
lineThickness=0.5,
fillColor={215,215,215},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Line(
points={{-100,0},{100,0}},
color={28,108,200},
thickness=0.5),
Ellipse(
extent={{-60,60},{60,-60}},
lineColor={28,108,200},
lineThickness=0.5,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(
points={{-30,52},{56,20}},
color={28,108,200},
thickness=0.5),
Line(
points={{-30,-52},{56,-20}},
color={28,108,200},
thickness=0.5)}));
end AllMediaBasedOnEntropy;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PressureSource
FlowSource
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
within ThermofluidStream.Processes.Compressors.BaseClasses;
partial model PartialFlowControlledSimpleCompressor "Base model of flow controlled simple compressor"
partial model PartialFlowSource "Base model of a pressure source with fixed isentropic efficiency suitable as both pump (incompressible media) or compressor/blower/fan (compressible media)"

extends ThermofluidStream.Processes.Compressors.BaseClasses.SISOFlow_v2;

Expand Down Expand Up @@ -55,5 +55,7 @@ equation
Line(
points={{-30,-52},{56,-20}},
color={28,108,200},
thickness=0.5)}));
end PartialFlowControlledSimpleCompressor;
thickness=0.5)}), Documentation(info="<html>
See <a href=\"modelica://ThermofluidStream.Processes.Compressors.AllMediaBasedOnEntropy.FlowSource\">FlowSource</a> for its usage and for further information.
</html>"));
end PartialFlowSource;
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
within ThermofluidStream.Processes.Compressors.BaseClasses;
partial model PartialFlowSourceIdealGas
"Base model of a flow source with fixed isentropic efficiency assuming ideal gas with constant isentropic exponent suitable as simple compressor/blower/fan"

extends ThermofluidStream.Processes.Compressors.BaseClasses.SISOFlow_v2;

parameter Real eta_is(min=0,max=1) = 1 "Fixed isentropic efficiency";
parameter Boolean kappaFromMedia = true "=true, if isentropic coefficient is calculated using the media model"
annotation(Dialog(group = "Isentropic exponent", enable=true));
parameter Real kappa_par(unit="1") = 1.4 "Fixed isentropic coefficient"
annotation(Dialog(group = "Isentropic exponent", enable = not kappaFromMedia));
public
SI.IsentropicExponent kappa = if kappaFromMedia then Medium.isentropicExponent(inlet.state) else kappa_par;
SI.SpecificEnthalpy w_t_is "Specific isentropic technical work";
SI.SpecificEnthalpy w_t "Specific technical work";
SI.Power P "Power (technichal work flow rate)";
protected
SI.Density rho_in = Medium.density(inlet.state) "Inlet density";
public
SI.Density rho = rho_in "Density";
SI.VolumeFlowRate V_flow = m_flow/rho "Volume flow rate";
protected
SI.Temperature T_in = Medium.temperature(inlet.state) "Inlet temperature";
SI.Temperature T_out_is "Outlet temperature for isentropic state change";
SI.SpecificEnthalpy h_out_is "Outlet specific enthalpy for isentropic state change";
equation
T_out_is/T_in = (p_out/p_in)^((kappa-1)/kappa);
h_out_is = Medium.specificEnthalpy_pTX(p_out,T_out_is,Xi_out);
w_t_is = h_out_is - h_in;
w_t = w_t_is/eta_is;
h_out = h_in + w_t;
P = m_flow*w_t;
Xi_out = Xi_in;
annotation (Icon(graphics={
Text(visible=displayInstanceName,
extent={{-150,120},{150,80}},
textString="%name",
textColor=dropOfCommons.instanceNameColor),
Ellipse(
extent={{-56,54},{64,-66}},
lineColor={28,108,200},
lineThickness=0.5,
fillColor={215,215,215},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Line(
points={{-100,0},{100,0}},
color={28,108,200},
thickness=0.5),
Ellipse(
extent={{-60,60},{60,-60}},
lineColor={28,108,200},
lineThickness=0.5,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(
points={{-30,52},{56,20}},
color={28,108,200},
thickness=0.5),
Line(
points={{-30,-52},{56,-20}},
color={28,108,200},
thickness=0.5)}), Documentation(info="<html>
See <a href=\"modelica://ThermofluidStream.Processes.Compressors.IdealGasConstantKappa.FlowSourceIdealGas\">FlowSourceIdealGas</a> for its usage and for further information.
</html>"));
end PartialFlowSourceIdealGas;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
within ThermofluidStream.Processes.Compressors.BaseClasses;
partial model PartialSimpleCompressor "Base model of a simple compressor"
partial model PartialPressureSource
"Base model of a pressure source with fixed isentropic efficiency suitable as both pump (incompressible media) or compressor/blower/fan (compressible media)"

extends ThermofluidStream.Interfaces.SISOFlow;

Expand All @@ -10,6 +11,7 @@ public
SI.SpecificEnthalpy w_t "Specific technical work";
SI.Power P "Power (technichal work flow rate)";
protected
Real pr = p_out/p_in "Pressure ratio";
SI.SpecificEntropy s_in = Medium.specificEntropy(inlet.state);
SI.SpecificEnthalpy h_out_is = Medium.specificEnthalpy_psX(
p_out,
Expand Down Expand Up @@ -50,5 +52,7 @@ equation
Line(
points={{-30,-52},{56,-20}},
color={28,108,200},
thickness=0.5)}));
end PartialSimpleCompressor;
thickness=0.5)}), Documentation(info="<html>
See <a href=\"modelica://ThermofluidStream.Processes.Compressors.AllMediaBasedOnEntropy.PressureSource\">PressureSource</a> for its usage and for further information.
</html>"));
end PartialPressureSource;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
within ThermofluidStream.Processes.Compressors.BaseClasses;
partial model PartialPressureSourceIdealGas
"Base model of a pressure source with fixed isentropic efficiency assuming ideal gas with constant isentropic exponent suitable as simple compressor/blower/fan"

extends ThermofluidStream.Interfaces.SISOFlow;

parameter Real eta_is(min=0,max=1) = 1 "Fixed isentropic efficiency";
parameter Boolean kappaFromMedia = true "=true, if isentropic coefficient is calculated using the media model"
annotation(Dialog(group = "Isentropic exponent", enable=true));
parameter Real kappa_par(unit="1") = 1.4 "Fixed isentropic coefficient"
annotation(Dialog(group = "Isentropic exponent", enable = not kappaFromMedia));
public
SI.IsentropicExponent kappa = if kappaFromMedia then Medium.isentropicExponent(inlet.state) else kappa_par;
SI.SpecificEnthalpy w_t_is "Specific isentropic technical work";
SI.SpecificEnthalpy w_t "Specific technical work";
SI.Power P "Power (technichal work flow rate)";
protected
Real pr = p_out/p_in "Pressure ratio";
SI.Temperature T_in = Medium.temperature(inlet.state) "Inlet temperature";
SI.Temperature T_out_is "Outlet temperature for isentropic state change";
SI.SpecificEnthalpy h_out_is "Outlet specific enthalpy for isentropic state change";
equation
T_out_is/T_in = (p_out/p_in)^((kappa-1)/kappa);
h_out_is = Medium.specificEnthalpy_pTX(p_out,T_out_is,Xi_out);
w_t_is = h_out_is - h_in;
w_t = w_t_is/eta_is;
h_out = h_in + w_t;
P = m_flow*w_t;
Xi_out = Xi_in;
annotation (Icon(graphics={
Text(visible=displayInstanceName,
extent={{-150,120},{150,80}},
textString="%name",
textColor=dropOfCommons.instanceNameColor),
Ellipse(
extent={{-56,54},{64,-66}},
lineColor={28,108,200},
lineThickness=0.5,
fillColor={215,215,215},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Line(
points={{-100,0},{100,0}},
color={28,108,200},
thickness=0.5),
Ellipse(
extent={{-60,60},{60,-60}},
lineColor={28,108,200},
lineThickness=0.5,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(
points={{-30,52},{56,20}},
color={28,108,200},
thickness=0.5),
Line(
points={{-30,-52},{56,-20}},
color={28,108,200},
thickness=0.5)}), Documentation(info="<html>
See <a href=\"modelica://ThermofluidStream.Processes.Compressors.IdealGasConstantKappa.PressureSourceIdealGas\">PressureSourceIdealGas</a> for its usage and for further information.
</html>"));
end PartialPressureSourceIdealGas;
18 changes: 13 additions & 5 deletions ThermofluidStream/Processes/Compressors/BaseClasses/SISOFlow_v2.mo
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ equation
outlet.state = Medium.setState_phX(p_out, h_out, Xi_out);

annotation (Documentation(info="<html>
<p>Interface class for all components with an Inlet and an Outlet and a massflow without a mass storage between.</p>
<p>This class already implements the equations that are common for such components, namly the conservation of mass, the intertance equation, as well as the clipping of p_out to p_min. </p>
<p>If p_out should be lower the p_min, the remaining pressure drop is added on the difference in inertial pressure r, basically accelerating or decelerating the massflow. </p>
<p>The component offers different initialization methods for the massflow, as well as several parameters used in the equations above. </p>
<p>The clipping of the massflow can be turned off (this should be done by the modeler as a final modificator while extending to hide this option from the enduser).</p>
<p>Version of <a href=\"modelica://ThermofluidStream.Interfaces.SISOFlow\">SISOFlow</a> where the mass flow rate <code>m_flow</code> may be set avoiding nonlinear equation systems.
Therefor the pressure difference is adapted based on the inertial pressure <code>r</code> using a <strong>non physical</strong> time constant <code>TC</code>:
</p>
<p>
<code>TC * der(dp) = outlet.r - inlet.r;

Check warning on line 73 in ThermofluidStream/Processes/Compressors/BaseClasses/SISOFlow_v2.mo

View workflow job for this annotation

GitHub Actions / html_documentation_checks

missing </code> before </p>
</p>
<p>
This approach is also used in <a href=\"modelica://ThermofluidStream.Boundaries.TerminalSource\">TerminalSource</a>.

Check warning on line 79 in ThermofluidStream/Processes/Compressors/BaseClasses/SISOFlow_v2.mo

View workflow job for this annotation

GitHub Actions / html_documentation_checks

inserting implicit <code>
</p>
</html>"));
end SISOFlow_v2;
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SISOFlow_v2
PartialSimpleCompressor
PartialFlowControlledSimpleCompressor
PartialPressureSource
PartialFlowSource
PartialPressureSourceIdealGas
PartialFlowSourceIdealGas
Loading

0 comments on commit d58201d

Please sign in to comment.