Skip to content

Commit

Permalink
Merge from Annex60:issue95-2_nominal
Browse files Browse the repository at this point in the history
This change primarily avoids warnings about alias sets with different
nominal values in OpenModelica.
It also contains some reformulations that are needed for OpenModelica.
  • Loading branch information
mwetter committed Oct 5, 2014
1 parent fb192cc commit f4dd519
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 28 deletions.
8 changes: 5 additions & 3 deletions Buildings/Fluid/Interfaces/ConservationEquation.mo
Expand Up @@ -17,16 +17,13 @@ model ConservationEquation "Lumped volume with mass and energy balance"
Medium.BaseProperties medium(
preferredMediumStates= not (energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState),
p(start=p_start,
nominal=Medium.p_default,
stateSelect=if not (massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState)
then StateSelect.prefer else StateSelect.default),
h(start=hStart),
T(start=T_start,
nominal=Medium.T_default,
stateSelect=if (not (energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState))
then StateSelect.prefer else StateSelect.default),
Xi(start=X_start[1:Medium.nXi],
nominal=Medium.X_default[1:Medium.nXi],
each stateSelect=if (not (substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState))
then StateSelect.prefer else StateSelect.default),
d(start=rho_nominal)) "Medium properties";
Expand Down Expand Up @@ -256,6 +253,11 @@ Buildings.Fluid.MixingVolumes.MixingVolume</a>.
</html>", revisions="<html>
<ul>
<li>
October 3, 2014, by Michael Wetter:<br/>
Changed assignment of nominal value to avoid in OpenModelica the warning
alias set with different nominal values.
</li>
<li>
July 3, 2014, by Michael Wetter:<br/>
Added parameter <code>initialize_p</code>. This is required
to enable the coil models to initialize the pressure in the first
Expand Down
17 changes: 9 additions & 8 deletions Buildings/Fluid/Interfaces/FourPort.mo
Expand Up @@ -36,33 +36,29 @@ model FourPort "Partial model with four ports"
Modelica.Fluid.Interfaces.FluidPort_a port_a1(
redeclare package Medium = Medium1,
m_flow(min=if allowFlowReversal1 then -Modelica.Constants.inf else 0),
h_outflow(nominal=1E5, start=h_outflow_a1_start),
Xi_outflow(each nominal=0.01))
h_outflow(start=h_outflow_a1_start))
"Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)"
annotation (Placement(transformation(extent={{-110,50},{-90,70}},
rotation=0)));
Modelica.Fluid.Interfaces.FluidPort_b port_b1(
redeclare package Medium = Medium1,
m_flow(max=if allowFlowReversal1 then +Modelica.Constants.inf else 0),
h_outflow(nominal=1E5, start=h_outflow_b1_start),
Xi_outflow(each nominal=0.01))
h_outflow(start=h_outflow_b1_start))
"Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)"
annotation (Placement(transformation(extent={{110,50},{90,70}}, rotation=
0), iconTransformation(extent={{110,50},{90,70}})));

Modelica.Fluid.Interfaces.FluidPort_a port_a2(
redeclare package Medium = Medium2,
m_flow(min=if allowFlowReversal2 then -Modelica.Constants.inf else 0),
h_outflow(nominal=1E5,start=h_outflow_a2_start),
Xi_outflow(each nominal=0.01))
h_outflow(start=h_outflow_a2_start))
"Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)"
annotation (Placement(transformation(extent={{90,-70},{110,-50}},
rotation=0)));
Modelica.Fluid.Interfaces.FluidPort_b port_b2(
redeclare package Medium = Medium2,
m_flow(max=if allowFlowReversal2 then +Modelica.Constants.inf else 0),
h_outflow(nominal=1E5, start=h_outflow_b2_start),
Xi_outflow(each nominal=0.01))
h_outflow(start=h_outflow_b2_start))
"Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)"
annotation (Placement(transformation(extent={{-90,-70},{-110,-50}},
rotation=0),
Expand All @@ -89,6 +85,11 @@ Modelica.Fluid.Interfaces.PartialTwoPort</a>, except that it has four ports.
</html>", revisions="<html>
<ul>
<li>
October 3, 2014, by Michael Wetter:<br/>
Changed assignment of nominal value to avoid in OpenModelica the warning
alias set with different nominal values.
</li>
<li>
November 12, 2013, by Michael Wetter:<br/>
Removed <code>import Modelica.Constants</code> statement.
</li>
Expand Down
11 changes: 7 additions & 4 deletions Buildings/Fluid/Interfaces/PartialTwoPortInterface.mo
Expand Up @@ -2,10 +2,8 @@ within Buildings.Fluid.Interfaces;
partial model PartialTwoPortInterface
"Partial model transporting fluid between two ports without storing mass or energy"
extends Modelica.Fluid.Interfaces.PartialTwoPort(
port_a(p(start=Medium.p_default,
nominal=Medium.p_default)),
port_b(p(start=Medium.p_default,
nominal=Medium.p_default)));
port_a(p(start=Medium.p_default)),
port_b(p(start=Medium.p_default)));

parameter Modelica.SIunits.MassFlowRate m_flow_nominal
"Nominal mass flow rate"
Expand Down Expand Up @@ -65,6 +63,11 @@ Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger</a>.
</html>", revisions="<html>
<ul>
<li>
October 3, 2014, by Michael Wetter:<br/>
Changed assignment of nominal value to avoid in OpenModelica the warning
alias set with different nominal values.
</li>
<li>
November 12, 2013 by Michael Wetter:<br/>
Removed <code>import Modelica.Constants;</code> statement.
</li>
Expand Down
85 changes: 85 additions & 0 deletions Buildings/Fluid/package.mo
Expand Up @@ -25,6 +25,91 @@ which is typically more readily available prior to the detailed
HVAC system design.
</p>

<h4>Port variables</h4>
<p>
Component models of this package have fluid ports, which
are a subclass of
<a href=\"modelica://Modelica.Fluid.Interfaces.FluidPort\">
Modelica.Fluid.Interfaces.FluidPort</a>.
Fluid ports declare the variables listed in the table below.
</p>

<table summary=\"summary\" border=\"1\" cellspacing=0 cellpadding=2 style=\"border-collapse:collapse;\">
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<tr>
<td><code>m_flow</code></td>
<td>Mass flow rate <i>m&#775;</i>.<br/>
The convention is that <code>m_flow &ge; 0</code>
if at this port, mass flows into the component.</td>
</tr>
<tr>
<td><code>p</code></td>
<td>Absolute total pressure <i>p</i>.<br/>
The absolute total pressure is the sum of
the static pressure and the dynamic pressure.
As the total pressure is used in the connector, components
do not need to specify the area of the port or the velocity at the port.
This convention is consistent with the Modelica Standard Library.
Note that component models typically simplify the pressure balance
by not taking into account the static pressure that is caused by
the height of the medium column, i.e., the term
<i>&Delta;p = &Delta;h &rho; g,</i>
where
<i>&Delta;h</i> is the height of the medium column,
<i>&rho;</i> is the mass density and
<i>g = 9.81</i> m/s<sup>2</sup> is the gravity acceleration,
is ignored.</td>
</tr>
<tr>
<td><code>h_outflow</code></td>
<td>Specific enthalpy <i>h</i> of the outflowing fluid, i.e.,
assuming <i>m&#775; &lt; 0.</i><br/>
The specific enthalpy in the fluid port always carries the value
of the enthalpy that the medium would have if it was leaving
the component.
Users who need to access the actual enthalpy for the given flow
direction can do so using the sensor
<a href=\"modelica://Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort\">
Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort</a>.
</tr>
<tr>
<td><code>Xi_outflow[Medium.nXi]</code></td>
<td>Independent mixture mass fractions
<i>m<sub>i</sub>/m</i> close to the connection point, i.e.,
assuming <i>m&#775; &lt; 0.</i><br/>
The independent mixture mass fraction in the fluid port always carries the value
that the medium would have if it was leaving
the component.
Users who need to access the actual value for the given flow
direction can do so using the sensor
<a href=\"modelica://Buildings.Fluid.Sensors.MassFractionTwoPort\">
Buildings.Fluid.Sensors.MassFractionTwoPort</a>.
Note that this variable is only present for fluids that are a mixture
of different substances such as moist air. For water,
this variable is automatically removed when a model is translated.</td>
</tr>
<tr>
<td><code>C_outflow[Medium.nC]</code></td>
<td>Trace substances <i>c<sub>i</sub>/m</i> close to the connection point, i.e.,
assuming <i>m&#775; &lt; 0.</i><br/>
The trace substances in the fluid port always carries the value
that the medium would have if it was leaving
the component.
Users who need to access the actual value for the given flow
direction can do so using the sensor
<a href=\"modelica://Buildings.Fluid.Sensors.TraceSubstancesTwoPort\">
Buildings.Fluid.Sensors.TraceSubstancesTwoPort</a>.
Note that this variable is only present for fluids that declare
a trace substance such as CO<sub>2</sub>.
See for example
<a href=\"modelica://Buildings.Fluid.Sensors.Examples.TraceSubstances\">
Buildings.Fluid.Sensors.Examples.TraceSubstances</a>.</td>
</tr>
</table>

<h4>Computation of flow resistance</h4>
<p>
Most component models compute pressure drop as a function of flow rate.
Expand Down
Expand Up @@ -19,7 +19,8 @@ equation
"Simulate and plot"),
experiment(
StartTime=273.15,
StopTime=473.15),
StopTime=473.15,
Tolerance=1E-8),
Documentation(info="<html>
<p>
This example checks whether the function derivative
Expand All @@ -29,6 +30,11 @@ is not correct, the model will stop with an assert statement.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Added a high tolerance which is needed for OpenModelica to pass the assert
statement.
</li>
<li>
October 29, 2008, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
Expand Up @@ -19,7 +19,8 @@ equation
"Simulate and plot"),
experiment(
StartTime=273.15,
StopTime=323.15),
StopTime=323.15,
Tolerance=1E-8),
Documentation(info="<html>
<p>
This example checks whether the function derivative
Expand All @@ -29,6 +30,11 @@ is not correct, the model will stop with an assert statement.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Added a high tolerance which is needed for OpenModelica to pass the assert
statement.
</li>
<li>
October 29, 2008, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
Expand Up @@ -23,7 +23,8 @@ equation
"Simulate and plot"),
experiment(
StartTime=0,
StopTime=1),
StopTime=1,
Tolerance=1E-10),
Documentation(info="<html>
<p>
This example checks whether the function derivative
Expand All @@ -33,6 +34,11 @@ is not correct, the model will stop with an assert statement.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Added a high tolerance which is needed for OpenModelica to pass the assert
statement.
</li>
<li>
November 20, 2013, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
Expand Up @@ -19,7 +19,8 @@ equation
"Simulate and plot"),
experiment(
StartTime=0,
StopTime=1),
StopTime=1,
Tolerance=10E-8),
Documentation(info="<html>
<p>
This example checks whether the function derivative
Expand All @@ -29,6 +30,11 @@ is not correct, the model will stop with an assert statement.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Added a high tolerance which is needed for OpenModelica to pass the assert
statement.
</li>
<li>
October 29, 2008, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
@@ -1,10 +1,19 @@
within Buildings.Utilities.Psychrometrics.Functions.BaseClasses;
function der_pW_TDewPoi_amb "Derivative of function pW_TDewPoi_amb"
extends
Buildings.Utilities.Psychrometrics.Functions.BaseClasses.pW_TDewPoi_amb;
extends Modelica.Icons.Function;
input Modelica.SIunits.Temperature T "Dew point temperature";
input Real dT;
output Real dp_w "Differential of water vapor partial pressure";
protected
constant Modelica.SIunits.Temperature T1=283.15 "First support point";
constant Modelica.SIunits.Temperature T2=293.15 "Second support point";
constant Modelica.SIunits.Pressure p1=1227.97 "First support point";
constant Modelica.SIunits.Pressure p2=2338.76 "Second support point";

constant Real a1=(Modelica.Math.log(p2) - Modelica.Math.log(p1)*T2/T1)/(1 -
T2/T1);
constant Real a2(unit="1/K")=(Modelica.Math.log(p1) - a1)/T1;

algorithm
dp_w:=a2*Modelica.Math.exp(a1 + a2*T)*dT;

Expand All @@ -16,6 +25,12 @@ Derivative of dew point temperature calculation for moist air.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Removed <code>extends Buildings.Utilities.Psychrometrics.Functions.BaseClasses.pW_TDewPoi_amb</code>
as this gives a compile time error in OpenModelica as the input argument <code>T</code>
cannot be found.
</li>
<li>
May 21, 2010 by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
Expand Up @@ -4,8 +4,9 @@ model X_pSatpphi "Model to test X_pSatpphi function"
package Medium = Buildings.Media.PerfectGases.MoistAir "Medium model"
annotation (choicesAllMatching = true);
parameter Modelica.SIunits.Temperature T = 293.15 "Temperature";
Modelica.SIunits.AbsolutePressure pSat "Saturation pressure";
parameter Modelica.SIunits.Pressure p = 101325 "Pressure of the fluid";

Modelica.SIunits.AbsolutePressure pSat "Saturation pressure";
Real phi(min=0, max=1) "Relative humidity";
Modelica.SIunits.MassFraction X_w(
min=0,
Expand All @@ -14,7 +15,7 @@ model X_pSatpphi "Model to test X_pSatpphi function"

constant Real conv(unit="1/s") = 1 "Conversion factor";
equation
phi = time;
phi = time*conv;
pSat = Medium.saturationPressure(T);
X_w = Buildings.Utilities.Psychrometrics.Functions.X_pSatpphi(pSat=pSat, p=p, phi=phi);

Expand All @@ -31,6 +32,10 @@ and atmospheric pressure.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Added conversion factor to avoid a unit error.
</li>
<li>
August 21, 2012, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
17 changes: 16 additions & 1 deletion Buildings/Utilities/Psychrometrics/Functions/pW_TDewPoi_amb.mo
@@ -1,11 +1,20 @@
within Buildings.Utilities.Psychrometrics.Functions;
function pW_TDewPoi_amb
"Function to compute the water vapor partial pressure for a given dew point temperature of moist air"
extends Buildings.Utilities.Psychrometrics.Functions.BaseClasses.pW_TDewPoi_amb;
extends Modelica.Icons.Function;

input Modelica.SIunits.Temperature T "Dew point temperature";
output Modelica.SIunits.Pressure p_w(displayUnit="Pa", min=100)
"Water vapor partial pressure";
protected
constant Modelica.SIunits.Temperature T1=283.15 "First support point";
constant Modelica.SIunits.Temperature T2=293.15 "Second support point";
constant Modelica.SIunits.Pressure p1=1227.97 "First support point";
constant Modelica.SIunits.Pressure p2=2338.76 "Second support point";

constant Real a1=(Modelica.Math.log(p2) - Modelica.Math.log(p1)*T2/T1)/(1 -
T2/T1);
constant Real a2(unit="1/K")=(Modelica.Math.log(p1) - a1)/T1;

algorithm
p_w := Modelica.Math.exp(a1 + a2*T);
Expand Down Expand Up @@ -33,6 +42,12 @@ whereas the other function requires a numerical solution.
</html>", revisions="<html>
<ul>
<li>
October 4, 2014, by Michael Wetter:<br/>
Removed <code>extends Buildings.Utilities.Psychrometrics.Functions.BaseClasses.pW_TDewPoi_amb</code>
as this gives a compile time error in OpenModelica as the input argument <code>T</code>
cannot be found.
</li>
<li>
March 9, 2012 by Michael Wetter:<br/>
Added <code>smoothOrder=99</code> and <code>displayUnit</code> for pressure.
</li>
Expand Down

0 comments on commit f4dd519

Please sign in to comment.