Skip to content

Commit

Permalink
Revised heat balance configuration for 2 port models, updated documen…
Browse files Browse the repository at this point in the history
…tation

This is for #237
  • Loading branch information
mwetter committed May 6, 2015
1 parent fb984bd commit c85b7a1
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 28 deletions.
10 changes: 9 additions & 1 deletion Annex60/Fluid/HeatExchangers/HeaterCooler_u.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
within Annex60.Fluid.HeatExchangers;
model HeaterCooler_u "Heater or cooler with prescribed heat flow rate"
extends Annex60.Fluid.Interfaces.TwoPortHeatMassExchanger(
redeclare final Annex60.Fluid.MixingVolumes.MixingVolume vol,
redeclare final Annex60.Fluid.MixingVolumes.MixingVolume vol(
prescribedHeatFlowRate=true),
final showDesignFlowDirection=false);

parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal
Expand Down Expand Up @@ -104,6 +105,13 @@ Annex60.Fluid.HeatExchangers.Validation.HeaterCooler_u</a>.
revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Set <code>prescribedHeatFlowRate=true</code>.
This is for issue
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/412\">
#412</a>.
</li>
<li>
May 1, 2015, by Marcus Fuchs:<br/>
Corrected typo in documentation.
</li>
Expand Down
6 changes: 5 additions & 1 deletion Annex60/Fluid/Interfaces/ConservationEquation.mo
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ model ConservationEquation "Lumped volume with mass and energy balance"
// Outputs that are needed in models that extend this model
Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg",
start=hStart)
"Leaving enthalpy of the component"
"Leaving specific enthalpy of the component"
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=90,
origin={-50,110})));
Expand Down Expand Up @@ -275,6 +275,10 @@ Annex60.Fluid.MixingVolumes.MixingVolume</a>.
</html>", revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Corrected documentation.
</li>
<li>
February 16, 2015, by Filip Jorissen:<br/>
Fixed SteadyState massDynamics implementation for compressible media.
Mass <code>m</code> is now constant.
Expand Down
10 changes: 10 additions & 0 deletions Annex60/Fluid/Interfaces/FourPortHeatMassExchanger.mo
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ model FourPortHeatMassExchanger
redeclare final package Medium = Medium1,
nPorts = 2,
V=m1_flow_nominal*tau1/rho1_nominal,
final allowFlowReversal=allowFlowReversal1,
final m_flow_nominal=m1_flow_nominal,
energyDynamics=if tau1 > Modelica.Constants.eps
then energyDynamics else
Expand All @@ -88,6 +89,7 @@ model FourPortHeatMassExchanger
redeclare final package Medium = Medium2,
nPorts = 2,
V=m2_flow_nominal*tau2/rho2_nominal,
final allowFlowReversal=allowFlowReversal2,
final mSenFac=1,
final m_flow_nominal = m2_flow_nominal,
energyDynamics=if tau2 > Modelica.Constants.eps
Expand Down Expand Up @@ -184,6 +186,7 @@ initial algorithm
"The parameter tau2, or the volume of the model from which tau may be derived, is unreasonably small.
You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state.
Received tau2 = " + String(tau2) + "\n");

equation
connect(vol1.ports[2], port_b1) annotation (Line(
points={{2,70},{20,70},{20,60},{100,60}},
Expand Down Expand Up @@ -236,6 +239,13 @@ Modelica.Fluid.HeatExchangers.BasicHX</a>.
</html>", revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Added missing propagation of <code>allowFlowReversal</code> to
instances <code>vol1</code> and <code>vol2</code>.
This is for issue
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/412\">#412</a>.
</li>
<li>
October 6, 2014, by Michael Wetter:<br/>
Changed medium declaration in pressure drop elements to be final.
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ model StaticTwoPortConservationEquation
p=Medium.p_default,
T=Medium.T_default,
X=Medium.X_default))
"Leaving temperature of the component"
"Leaving specific enthalpy of the component"
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=90,
origin={-50,110}), iconTransformation(
Expand Down Expand Up @@ -175,6 +175,10 @@ or instantiates this model sets <code>mWat_flow = 0</code>.
revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Corrected documentation.
</li>
<li>
February 11, 2014 by Michael Wetter:<br/>
Improved documentation for <code>Q_flow</code> input.
</li>
Expand Down
8 changes: 8 additions & 0 deletions Annex60/Fluid/Interfaces/TwoPortHeatMassExchanger.mo
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ model TwoPortHeatMassExchanger
redeclare final package Medium = Medium,
nPorts = 2,
V=m_flow_nominal*tau/rho_default,
final allowFlowReversal=allowFlowReversal,
final mSenFac=1,
final m_flow_nominal = m_flow_nominal,
final energyDynamics=energyDynamics,
Expand Down Expand Up @@ -143,6 +144,13 @@ Modelica.Fluid.Examples.HeatExchanger.BaseClasses.BasicHX
</html>", revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Added missing propagation of <code>allowFlowReversal</code> to
instance <code>vol</code>.
This is for issue
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/412\">#412</a>.
</li>
<li>
May 1, 2015, by Marcus Fuchs:<br/>
Fixed links in documentation.
</li>
Expand Down
13 changes: 11 additions & 2 deletions Annex60/Fluid/MassExchangers/Humidifier_u.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ within Annex60.Fluid.MassExchangers;
model Humidifier_u
"Ideal humidifier or dehumidifier with prescribed water mass flow rate addition or subtraction"
extends Annex60.Fluid.Interfaces.TwoPortHeatMassExchanger(
redeclare replaceable package Medium = Modelica.Media.Interfaces.PartialCondensingGases,
redeclare final Annex60.Fluid.MixingVolumes.MixingVolumeMoistAir vol);
redeclare replaceable package Medium =
Modelica.Media.Interfaces.PartialCondensingGases,
redeclare final Annex60.Fluid.MixingVolumes.MixingVolumeMoistAir vol(
prescribedHeatFlowRate=true));

parameter Boolean use_T_in= false
"Get the temperature from the input connector"
Expand Down Expand Up @@ -121,6 +123,13 @@ in the species vector.
revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Set <code>prescribedHeatFlowRate=true</code>.
This is for issue
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/412\">
#412</a>.
</li>
<li>
May 29, 2014, by Michael Wetter:<br/>
Removed undesirable annotation <code>Evaluate=true</code>.
</li>
Expand Down
107 changes: 97 additions & 10 deletions Annex60/Fluid/MixingVolumes/BaseClasses/PartialMixingVolume.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ partial model PartialMixingVolume
annotation(Dialog(tab="Assumptions"), Evaluate=true);
parameter Modelica.SIunits.Volume V "Volume";
parameter Boolean prescribedHeatFlowRate=false
"Set to true if the model has a prescribed heat flow at its heatPort"
annotation(Evaluate=true, Dialog(tab="Assumptions",
enable=use_HeatTransfer,
"Set to true if the model has a prescribed heat flow at its heatPort. If the heat flow rate at the heatPort is only based on temperature difference, then set to false."
annotation(Evaluate=true,
Dialog(tab="Assumptions",
group="Heat transfer"));
Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b ports[nPorts](
redeclare each package Medium = Medium) "Fluid inlets and outlets"
Expand Down Expand Up @@ -81,8 +81,9 @@ protected
T=T_start,
p=p_start,
X=X_start[1:Medium.nXi]) "Medium state at start values";
// See info section for why prescribedHeatFlowRate is used here.
final parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and
prescribedHeatFlowRate and (
(prescribedHeatFlowRate or (not allowFlowReversal)) and (
energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and (
massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and (
substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and (
Expand Down Expand Up @@ -123,7 +124,7 @@ equation
smooth=Smooth.None));

connect(steBal.port_b, ports[2]) annotation (Line(
points={{5.55112e-16,10},{8,10},{8,10},{8,-88},{0,-88},{0,-100}},
points={{5.55112e-16,10},{8,10},{8,-88},{0,-88},{0,-100}},
color={0,127,255},
smooth=Smooth.None));

Expand Down Expand Up @@ -157,13 +158,76 @@ It is used as the base class for all fluid volumes of the package
<a href=\"modelica://Annex60.Fluid.MixingVolumes\">
Annex60.Fluid.MixingVolumes</a>.
</p>
<p>
To increase the numerical robustness of the model, the parameter
<code>prescribedHeatFlowRate</code> can be set by the user.
This parameter only has an effect if the model has exactly two fluid ports connected,
and if it is used as a steady-state model.
Use the following settings:
</p>
<ul>
<li>Set <code>prescribedHeatFlowRate=true</code> if there is a model connected to <code>heatPort</code>
that computes the heat flow rate <i>not</i> as a function of the temperature difference
between the medium and an ambient temperature. Examples include an ideal electrical heater,
a pump that rejects heat into the fluid stream, or a chiller that removes heat based on a performance curve.
</li>
<li>Set <code>prescribedHeatFlowRate=true</code> if the only means of heat flow at the <code>heatPort</code>
is computed as <i>K * (T-heatPort.T)</i>, for some temperature <i>T</i> and some conductance <i>K</i>,
which may itself be a function of temperature or mass flow rate.
</li>
</ul>
<h4>Implementation</h4>
<p>
If the model is operated in steady-state and has two fluid ports connected,
then the same energy and mass balance implementation is used as in
steady-state component models, i.e., the use of <code>actualStream</code>
is not used for the properties at the port.
If the model is (i) operated in steady-state,
(ii) has two fluid ports connected, and
(iii) <code>prescribedHeatFlowRate=true</code>, then
the model uses
<a href=\"modelica://Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation\">
Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation</a>
in order to use
the same energy and mass balance implementation as is used as in
steady-state component models.
In this situation, the functions <code>inStream</code> are used for the two
flow directions rather than the function
<code>actualStream</code>, which is less efficient.
However, the use of <code>inStream</code> has the disadvantage
that <code>hOut</code> has to be computed, in
<a href=\"modelica://Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation\">
Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation</a>,
using
</p>
<pre>
if allowFlowReversal then
hOut = Annex60.Utilities.Math.Functions.spliceFunction(pos=port_b.h_outflow,
neg=port_a.h_outflow,
x=port_a.m_flow,
deltax=m_flow_small/1E3);
else
hOut = port_b.h_outflow;
end if;
</pre>
<p>
Hence, for <code>allowFlowReversal=true</code>, if <code>hOut</code>
were to be used to compute the temperature that
drives heat transfer such as by conduction,
then the heat transfer would depend on upstream and the <i>downstream</i>
temperatures for small mass flow rates.
This can give wrong results. Consider for example a mass flow rate that is positive
but very close to zero. Suppose the upstream temperature is <i>20</i>&circ;C,
the downstream temperature is <i>10</i>&circ;C, and the heat port is
connected through a heat conductor to a boundary condition of <i>20</i>&circ;C.
Then, <code>hOut = (port_b.h_outflow + port_a.h_outflow)/2</code> and hence
the temperature <code>heatPort.T</code>
is <i>15</i>&circ;C. Therefore, heat is added to the component.
As the mass flow rate is by assumption very small, the fluid that leaves the component
will have a very high temperature, violating the 2nd law.
To avoid this situation, if
<code>prescribedHeatFlowRate=false</code>, then the model
<a href=\"modelica://Annex60.Fluid.Interfaces.ConservationEquation\">
Annex60.Fluid.Interfaces.ConservationEquation</a>
is used instead of
<a href=\"modelica://Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation\">
Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation</a>.
</p>
<p>
For simple models that uses this model, see
Expand All @@ -173,6 +237,29 @@ Annex60.Fluid.MixingVolumes</a>.
</html>", revisions="<html>
<ul>
<li>
May 6, 2015, by Michael Wetter:<br/>
Improved documentation and changed the test
<pre>
final parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and
prescribedHeatFlowRate and ...
</pre>
to
<pre>
final parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and
(prescribedHeatFlowRate or (not allowFlowReversal)) and ...
</pre>
The reason is that if there is no flow reversal, then
<a href=\"modelica://Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation\">
Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation</a>
computes <code>hOut = port_b.h_outflow;</code>, and hence
it is correct to use <code>hOut</code> to compute
temperature-driven heat flow, such as by conduction or convection.
See also the model documentation.<br/>
This is for issue
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/412\">
#412</a>.
</li>
<li>
February 5, 2015, by Michael Wetter:<br/>
Changed <code>initalize_p</code> from a <code>parameter</code> to a
<code>constant</code>. This is only required in finite volume models
Expand Down
18 changes: 11 additions & 7 deletions Annex60/Fluid/MixingVolumes/MixingVolume.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ equation
color={0,0,127},
smooth=Smooth.None));
connect(QSen_flow.y, steBal.Q_flow) annotation (Line(
points={{-59,88},{-30,88},{-30,18},{-22,18}},
points={{-39,88},{-30,88},{-30,18},{-22,18}},
color={0,0,127},
smooth=Smooth.None));
connect(QSen_flow.y, dynBal.Q_flow) annotation (Line(
points={{-59,88},{28,88},{28,16},{38,16}},
points={{-39,88},{28,88},{28,16},{38,16}},
color={0,0,127},
smooth=Smooth.None));
annotation (
Expand Down Expand Up @@ -54,17 +54,16 @@ which may itself be a function of temperature or mass flow rate.
</li>
</ul>
<h4>Options</h4>
<ul>
<li>Parameter <code>mSenFac</code> can be used to increase the thermal mass of this model
<p>
The parameter <code>mSenFac</code> can be used to increase the thermal mass of this model
without increasing its volume. This way, species concentrations are still calculated
correctly even though the thermal mass increases. The additional thermal mass is calculated
based on the density and the value of the function <code>HeatCapacityCp</code>
of the medium state <code>state_default</code>. <br/>
This parameter can for instance be useful in a pipe model when the developer wants to
lump the pipe thermal mass to the fluid volume. By default <code>mSenFac = 1</code>, hence
the mass is unchanged. For higher values of <code>mSenFac</code>, the mass will be scaled proportionally.
</li>
</ul>
</p>
<h4>Implementation</h4>
<p>
If the model is operated in steady-state and has two fluid ports connected,
Expand All @@ -89,7 +88,12 @@ where <code>m_flowInv</code> approximates the expression <code>1/m_flow</code>.
The variable <code>mXi_flow</code> is used to add a species mass flow rate to the fluid.
</li>
</ul>
<p>
For the rationale of selecting different energy and mass balances, and for the
use of <code>prescribedHeatFlowRate</code>, see the documentation of
<a href=\"modelica://Annex60.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume\">
Annex60.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume</a>.
</p>
<p>
For simple models that uses this model, see
<a href=\"modelica://Annex60.Fluid.HeatExchangers.HeaterCoolerPrescribed\">
Expand Down
20 changes: 19 additions & 1 deletion Annex60/Fluid/MixingVolumes/MixingVolumeMoistAir.mo
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,25 @@ functionality, use
<a href=\"modelica://Annex60.Fluid.MixingVolumes.MixingVolume\">
Annex60.Fluid.MixingVolumes.MixingVolume</a>.
</p>
</html>", revisions="<html>
<p>
To increase the numerical robustness of the model, the parameter
<code>prescribedHeatFlowRate</code> can be set by the user.
This parameter only has an effect if the model has exactly two fluid ports connected,
and if it is used as a steady-state model.
Use the following settings:
</p>
<ul>
<li>Set <code>prescribedHeatFlowRate=true</code> if there is a model connected to <code>heatPort</code>
that computes the heat flow rate <i>not</i> as a function of the temperature difference
between the medium and an ambient temperature. Examples include an ideal electrical heater,
a pump that rejects heat into the fluid stream, or a chiller that removes heat based on a performance curve.
</li>
<li>Set <code>prescribedHeatFlowRate=true</code> if the only means of heat flow at the <code>heatPort</code>
is computed as <i>K * (T-heatPort.T)</i>, for some temperature <i>T</i> and some conductance <i>K</i>,
which may itself be a function of temperature or mass flow rate.
</li>
</ul></html>",
revisions="<html>
<ul>
<li>
February 11, 2014 by Michael Wetter:<br/>
Expand Down
Loading

0 comments on commit c85b7a1

Please sign in to comment.