Skip to content

Commit

Permalink
integrate flow variable for m_flow again #790
Browse files Browse the repository at this point in the history
  • Loading branch information
DaJansenGit committed Oct 24, 2019
1 parent b2c0837 commit d58ab26
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 83 deletions.
20 changes: 14 additions & 6 deletions AixLib/FastHVAC/BaseClasses/EnergyBalance.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
within AixLib.FastHVAC.BaseClasses;
model EnergyBalance "Base class depicts energy and mass balances"

Modelica.SIunits.MassFlowRate m_flow "";
AixLib.FastHVAC.Interfaces.EnthalpyPort_a enthalpyPort_a
"Enthalpie input port includes the parameter temperature, specific enthalpy, specific heat capacity and mass flow"
annotation (Placement(transformation(extent={{-100,-20},{-40,38}}),
Expand All @@ -17,12 +17,19 @@ model EnergyBalance "Base class depicts energy and mass balances"

equation
// Mass and energy balances
enthalpyPort_a.m_flow - enthalpyPort_b.m_flow = 0;
enthalpyPort_b.T = heatPort_a.T;
enthalpyPort_b.h = enthalpyPort_a.c*heatPort_a.T;
enthalpyPort_b.c = enthalpyPort_a.c;
heatPort_a.Q_flow = -(enthalpyPort_a.h*enthalpyPort_a.m_flow - enthalpyPort_b.h*enthalpyPort_b.m_flow);
m_flow = enthalpyPort_a.m_flow;
enthalpyPort_a.m_flow + enthalpyPort_b.m_flow = 0;
enthalpyPort_b.T_outflow = heatPort_a.T;
enthalpyPort_a.T_outflow = heatPort_a.T;
enthalpyPort_b.h_outflow = inStream(enthalpyPort_a.c_outflow) * heatPort_a.T;
enthalpyPort_a.h_outflow = inStream(enthalpyPort_b.c_outflow) * heatPort_a.T;

actualStream(enthalpyPort_b.c_outflow) = actualStream(enthalpyPort_a.c_outflow);

enthalpyPort_a.p = 1000;
enthalpyPort_b.p = 1000;

heatPort_a.Q_flow = - m_flow * (actualStream(enthalpyPort_a.h_outflow) - actualStream(enthalpyPort_b.h_outflow))
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={Rectangle(
extent={{-60,60},{60,-60}},
Expand Down Expand Up @@ -57,4 +64,5 @@ equation
</li>
</ul>
</html>"));

end EnergyBalance;
13 changes: 6 additions & 7 deletions AixLib/FastHVAC/Interfaces/EnthalpyPort.mo
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
within AixLib.FastHVAC.Interfaces;
partial connector EnthalpyPort "Enthalpy port for 1-dim. enthalpy transfer"

Modelica.SIunits.Temperature T "Port temperature";
Modelica.SIunits.MassFlowRate m_flow
"Mass flow rate(positive if flowing from outside into the component)";
Modelica.SIunits.SpecificEnthalpy h "Specific enthalpy of fluid";
Modelica.SIunits.SpecificHeatCapacity c "Constant specific heat capacity";

flow Modelica.SIunits.MassFlowRate m_flow
"Mass flow rate(positive if flowing from outside into the component)";
Modelica.SIunits.Pressure p "dummy pressure";
stream Modelica.SIunits.Temperature T_outflow "Port temperature";
stream Modelica.SIunits.SpecificEnthalpy h_outflow "Specific enthalpy of fluid";
stream Modelica.SIunits.SpecificHeatCapacity c_outflow "Constant specific heat capacity";
annotation (Documentation(info="<html>This is an interface model for a 1-dimensional enthalpy port to
consider enthalpy transfer
</html>", revisions="<html>
Expand Down
26 changes: 14 additions & 12 deletions AixLib/FastHVAC/Interfaces/EnthalpyPort_b.mo
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
within AixLib.FastHVAC.Interfaces;
connector EnthalpyPort_b "Outlet enthalpy connector non-Fluid models"
extends AixLib.FastHVAC.Interfaces.EnthalpyPort;
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={Ellipse(
extent={{-100,100},{100,-100}},
lineColor={176,0,0}, thickness={0.5},
fillColor={176,0,0},
fillPattern=FillPattern.Solid), Ellipse(
extent={{-54,50},{52,-52}},
lineColor={255,255,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}), Documentation(info="<html><p>
extends AixLib.FastHVAC.Interfaces.EnthalpyPort;

annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={Ellipse(
extent={{-100,100},{100,-100}},
lineColor={176,0,0}, thickness={0.5},
fillColor={176,0,0},
fillPattern=FillPattern.Solid), Ellipse(
extent={{-54,50},{52,-52}},
lineColor={255,255,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}), Documentation(info="<html><p>
This model defines a inlet enthalpy port used within the FastHVAC
package
</p>
</html>", revisions="<html>
</html>",
revisions="<html>
<ul>
<li>
<i>April 25, 2017</i>, by Michael Mans:<br/>
Expand Down
13 changes: 5 additions & 8 deletions AixLib/FastHVAC/Pipes/DynamicPipe.mo
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
within AixLib.FastHVAC.Pipes;
model DynamicPipe "DynamicPipe with heat loss to ambient"

/* *******************************************************************
Medium
******************************************************************* */
parameter Boolean selectable=true "Pipe record";
parameter Media.FastHvac.BaseClasses.MediumSimple medium=
Media.FastHvac.WaterSimple()
parameter Boolean selectable=true "Pipe record";
parameter AixLib.Media.FastHvac.BaseClasses.MediumSimple medium=
AixLib.Media.FastHvac.WaterSimple()
"Mediums charastics (heat capacity, density, thermal conductivity)"
annotation (choicesAllMatching);

protected
parameter Modelica.SIunits.Volume V_fluid= Modelica.Constants.pi*length*innerDiameter*innerDiameter/4;
parameter Modelica.SIunits.Volume V_fluid = Modelica.Constants.pi * length
* innerDiameter * innerDiameter / 4;
parameter Modelica.SIunits.Diameter innerDiameter=(if selectable then parameterPipe.d_i else diameter)
"Inner diameter of pipe";
parameter Modelica.SIunits.Diameter outerDiameter=(if selectable then parameterPipe.d_o else innerDiameter+2*s_pipeWall)
Expand Down
24 changes: 12 additions & 12 deletions AixLib/FastHVAC/Pipes/Examples/Pipes.mo
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ model Pipes
annotation (Placement(transformation(extent={{-32,-10},{-16,6}})));
Modelica.Blocks.Sources.Constant TFlow3(
k=273.15 + 60)
annotation (Placement(transformation(extent={{-98,62},{-82,76}})));
annotation (Placement(transformation(extent={{-96,62},{-80,76}})));
Modelica.Blocks.Sources.Ramp mFlow3(
height=1, duration=5000)
annotation (Placement(transformation(extent={{-96,38},{-82,52}})));
annotation (Placement(transformation(extent={{-94,38},{-80,52}})));
AixLib.FastHVAC.Pumps.FluidSource fluidSource3
annotation (Placement(transformation(extent={{-74,36},{-54,56}})));
annotation (Placement(transformation(extent={{-72,36},{-52,56}})));
AixLib.FastHVAC.Pipes.DynamicPipe PipeInsulation(
withInsulation=true,
withRadiation=false,
withConvection=false)
annotation (Placement(transformation(extent={{-16,32},{4,52}})));
Modelica.Thermal.HeatTransfer.Sources.FixedTemperature
fixedTemperatureSurroundingAir1(T=288.15)
annotation (Placement(transformation(extent={{-32,54},{-16,70}})));
annotation (Placement(transformation(extent={{-30,54},{-14,70}})));
AixLib.FastHVAC.Sinks.Vessel vessel3
annotation (Placement(transformation(extent={{68,32},{88,52}})));
equation
Expand All @@ -74,28 +74,28 @@ equation
annotation (Line(points={{-16,-2},{-16,-12.8},{-14.8,-12.8}}, color={191,
0,0}));
connect(fluidSource2.enthalpyPort_b, PipeInsulationAndConvection.enthalpyPort_a1)
annotation (Line(points={{-54,-17},{-43,-17},{-43,-18},{-15.8,-18}},
annotation (Line(points={{-55,-16},{-43,-16},{-43,-18},{-15.8,-18}},
color={176,0,0}));
connect(fixedTemperatureSurroundingAir1.port, PipeInsulation.heatPort_outside)
annotation (Line(points={{-16,62},{-16,47.2},{-14.8,47.2}}, color={191,0,
annotation (Line(points={{-14,62},{-14,47.2},{-14.8,47.2}}, color={191,0,
0}));
connect(TFlow3.y, fluidSource3.T_fluid) annotation (Line(points={{-81.2,69},
{-81.2,59.5},{-72,59.5},{-72,50.2}}, color={0,0,127}));
connect(TFlow3.y, fluidSource3.T_fluid) annotation (Line(points={{-79.2,69},{
-79.2,59.5},{-70,59.5},{-70,50.2}}, color={0,0,127}));
connect(fluidSource3.enthalpyPort_b, PipeInsulation.enthalpyPort_a1)
annotation (Line(points={{-54,47},{-36,47},{-36,42},{-15.8,42}}, color={
annotation (Line(points={{-53,48},{-34,48},{-34,42},{-15.8,42}}, color={
176,0,0}));
connect(PipeInsulation.enthalpyPort_b1, vessel3.enthalpyPort_a)
annotation (Line(points={{3.8,42},{71,42}}, color={176,0,0}));
connect(PipeInsulationAndConvection.enthalpyPort_b1, vessel2.enthalpyPort_a)
annotation (Line(points={{3.8,-18},{71,-18}}, color={176,0,0}));
connect(fluidSource1.enthalpyPort_b,
PipeInsulationAndConvectionandRadiation.enthalpyPort_a1) annotation (Line(
points={{-56,-85},{-34,-85},{-34,-86},{-13.8,-86}}, color={176,0,0}));
points={{-57,-84},{-34,-84},{-34,-86},{-13.8,-86}}, color={176,0,0}));
connect(PipeInsulationAndConvectionandRadiation.enthalpyPort_b1, vessel1.enthalpyPort_a)
annotation (Line(points={{5.8,-86},{36,-86},{36,-84},{69,-84}}, color={
176,0,0}));
connect(mFlow3.y, fluidSource3.dotm) annotation (Line(points={{-81.3,45},{
-77.65,45},{-77.65,43.4},{-72,43.4}}, color={0,0,127}));
connect(mFlow3.y, fluidSource3.dotm) annotation (Line(points={{-79.3,45},{
-75.65,45},{-75.65,43.4},{-70,43.4}}, color={0,0,127}));
connect(mFlow2.y, fluidSource2.dotm) annotation (Line(points={{-81.3,-19},{
-77.65,-19},{-77.65,-20.6},{-72,-20.6}}, color={0,0,127}));
connect(mFlow1.y, fluidSource1.dotm) annotation (Line(points={{-83.3,-87},{
Expand Down
36 changes: 21 additions & 15 deletions AixLib/FastHVAC/Pumps/Examples/FluidSource.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@ within AixLib.FastHVAC.Pumps.Examples;
model FluidSource
extends Modelica.Icons.Example;

AixLib.FastHVAC.Pumps.FluidSource fluidSource
annotation (Placement(transformation(extent={{-10,-36},{10,-16}})));
AixLib.FastHVAC.Sinks.Vessel vessel
annotation (Placement(transformation(extent={{60,-36},{82,-14}})));
Modelica.Blocks.Sources.Constant dotm_source(k=2)
annotation (Placement(transformation(extent={{-84,-52},{-64,-32}})));
Modelica.Blocks.Sources.Constant T_source(k=333.15)
annotation (Placement(transformation(extent={{-84,-22},{-64,-2}})));
AixLib.FastHVAC.Pumps.FluidSource fluidSource
annotation (Placement(transformation(extent={{-36,-34},{-16,-14}})));
Sinks.Vessel vessel
annotation (Placement(transformation(extent={{22,-34},{42,-14}})));
AixLib.FastHVAC.Pumps.FluidSource fluidSource1
annotation (Placement(transformation(extent={{-40,-96},{-20,-76}})));
Modelica.Blocks.Sources.Constant T_source1(k=333.15)
annotation (Placement(transformation(extent={{-88,-84},{-68,-64}})));
Modelica.Blocks.Sources.Constant dotm_source1(k=2)
annotation (Placement(transformation(extent={{-88,-114},{-68,-94}})));
equation
connect(T_source.y, fluidSource.T_fluid) annotation (Line(
points={{-63,-12},{-36,-12},{-36,-21.8},{-8,-21.8}},
color={0,0,127},
smooth=Smooth.None));
connect(T_source.y, fluidSource.T_fluid) annotation (Line(points={{-63,-12},{
-48,-12},{-48,-19.8},{-34,-19.8}}, color={0,0,127}));
connect(dotm_source.y, fluidSource.dotm) annotation (Line(points={{-63,-42},{
-50,-42},{-50,-26.6},{-34,-26.6}}, color={0,0,127}));
connect(fluidSource.enthalpyPort_b, vessel.enthalpyPort_a) annotation (Line(
points={{10,-25},{63.3,-25}},
color={176,0,0},
smooth=Smooth.None));
connect(dotm_source.y, fluidSource.dotm) annotation (Line(
points={{-63,-42},{-36,-42},{-36,-28.6},{-8,-28.6}},
color={0,0,127},
smooth=Smooth.None));
points={{-17,-22},{4,-22},{4,-24},{25,-24}}, color={176,0,0}));
connect(dotm_source1.y, fluidSource1.dotm) annotation (Line(points={{-67,-104},
{-54,-104},{-54,-88.6},{-38,-88.6}}, color={0,0,127}));
connect(T_source1.y, fluidSource1.T_fluid) annotation (Line(points={{-67,-74},
{-52,-74},{-52,-81.8},{-38,-81.8}}, color={0,0,127}));
connect(fluidSource1.enthalpyPort_b, vessel.enthalpyPort_a) annotation (Line(
points={{-21,-84},{2,-84},{2,-24},{25,-24}}, color={176,0,0}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={
Rectangle(
Expand Down
18 changes: 9 additions & 9 deletions AixLib/FastHVAC/Pumps/FluidSource.mo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
within AixLib.FastHVAC.Pumps;
model FluidSource " Ideal fluid source "


/* *******************************************************************
Medium
******************************************************************* */

parameter Media.FastHvac.BaseClasses.MediumSimple medium=
Media.FastHvac.WaterSimple()
"Standard charastics for water (heat capacity, density, thermal conductivity)"
Expand All @@ -17,22 +17,22 @@ protected
******************************************************************* */

public
FastHVAC.Interfaces.EnthalpyPort_b enthalpyPort_b
"Thermal port for output values (temperature, mass flow rate, specific enthalpy, constant specific heat capacity)"
annotation (Placement(transformation(extent={{64,-12},{84,8}}),
iconTransformation(extent={{80,-10},{120,30}})));
Modelica.Blocks.Interfaces.RealInput T_fluid( unit="K")
"External real input to set the temperature of the fluid"
annotation (Placement(transformation(extent={{-100,22},{-60,62}})));
Modelica.Blocks.Interfaces.RealInput dotm( unit="kg/s")
"External real input to set the mass flow rate"
annotation (Placement(transformation(extent={{-100,-46},{-60,-6}})));
Interfaces.EnthalpyPort_b enthalpyPort_b annotation (Placement(transformation(
extent={{90,-10},{110,10}}), iconTransformation(extent={{80,10},{100,30}})));
equation
// balances
enthalpyPort_b.m_flow = dotm " set value of outlet port ";
enthalpyPort_b.c = cp " set value of outlet port ";
enthalpyPort_b.T = T_fluid " set value of outlet port ";
enthalpyPort_b.h = cp*T_fluid " set value of outlet port ";
enthalpyPort_b.m_flow = - dotm " set value of outlet port ";
enthalpyPort_b.c_outflow = cp " set value of outlet port ";
enthalpyPort_b.T_outflow = T_fluid " set value of outlet port ";
enthalpyPort_b.h_outflow = cp * T_fluid " set value of outlet port ";



annotation (
defaultComponentName="fluidSource",
Expand Down
13 changes: 6 additions & 7 deletions AixLib/FastHVAC/Sinks/Vessel.mo
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
within AixLib.FastHVAC.Sinks;
model Vessel "Vessel model"

/* *******************************************************************
Components
******************************************************************* */

FastHVAC.Interfaces.EnthalpyPort_a enthalpyPort_a annotation (Placement(
transformation(extent={{-88,-18},{-52,18}}), iconTransformation(extent={
{-88,-18},{-52,18}})));

equation
enthalpyPort_a.p = 1000;
enthalpyPort_a.h_outflow = 0;
enthalpyPort_a.T_outflow = 0;
enthalpyPort_a.c_outflow = 0;
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}),
graphics), Icon(coordinateSystem(preserveAspectRatio=
-100},{100,100}})), Icon(coordinateSystem(preserveAspectRatio=
false, extent={{-100,-100},{100,100}}), graphics={Rectangle(
extent={{-70,68},{94,-60}},
lineColor={127,0,0},
Expand Down
4 changes: 2 additions & 2 deletions AixLib/FastHVAC/Valves/Manifold.mo
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ parameter Integer n(min=1) = 1 "Number of input flows";
annotation (Placement(transformation(extent={{90,-10},{110,10}}))); //n-dimensional imput port // 1-dimensional output port
equation
enthalpyPort_b.m_flow = sum(enthalpyPort_a.m_flow); //mass balance
enthalpyPort_b.m_flow*enthalpyPort_b.h = enthalpyPort_a.m_flow*enthalpyPort_a.h; //enthalpy balance
enthalpyPort_b.m_flow + sum(enthalpyPort_a.m_flow) = 0; //mass balance
enthalpyPort_b.m_flow*enthalpyPort_b.h + enthalpyPort_a.m_flow*enthalpyPort_a.h = 0; //enthalpy balance
enthalpyPort_b.c = enthalpyPort_a[1].c; //cp remains unchanged
enthalpyPort_b.h = enthalpyPort_b.c*enthalpyPort_b.T; //h=c*T
Expand Down
5 changes: 2 additions & 3 deletions AixLib/FastHVAC/Valves/ThreeWayValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ model ThreeWayValve

equation
// mass balance
enthalpyPort_a.m_flow = enthalpyPort_ab.m_flow*opening;
- enthalpyPort_ab.m_flow + enthalpyPort_a.m_flow + enthalpyPort_b.m_flow =
0;
enthalpyPort_a.m_flow = -enthalpyPort_ab.m_flow*opening;
enthalpyPort_ab.m_flow + enthalpyPort_a.m_flow + enthalpyPort_b.m_flow = 0;
// constant values
enthalpyPort_a.T = enthalpyPort_ab.T;
enthalpyPort_ab.T = enthalpyPort_b.T;
Expand Down
4 changes: 2 additions & 2 deletions AixLib/Utilities/HeatTransfer/HeatConvPipeInside.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ model HeatConvPipeInside
parameter Boolean calcHCon=true "Use calculated value for inside heat coefficient";
parameter Modelica.SIunits.CoefficientOfHeatTransfer hConIn_const=30 "Constant convective heat transfer coefficient (Inside)"
annotation(Dialog(enable=not calcHCon));
parameter FastHVAC.Media.BaseClasses.MediumSimple medium=
FastHVAC.Media.WaterSimple();
parameter AixLib.Media.FastHvac.BaseClasses.MediumSimple medium=
AixLib.Media.FastHvac.WaterSimple();
Modelica.SIunits.ReynoldsNumber Re;
Modelica.SIunits.Velocity v;
Modelica.SIunits.NusseltNumber Nu;
Expand Down

0 comments on commit d58ab26

Please sign in to comment.