Skip to content

Commit

Permalink
flow variable working now, solved by dummy variable #790
Browse files Browse the repository at this point in the history
  • Loading branch information
DaJansenGit committed Oct 24, 2019
1 parent d58ab26 commit 2cad670
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 54 deletions.
26 changes: 19 additions & 7 deletions AixLib/FastHVAC/BaseClasses/EnergyBalance.mo
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
within AixLib.FastHVAC.BaseClasses;
model EnergyBalance "Base class depicts energy and mass balances"
parameter AixLib.Media.FastHvac.BaseClasses.MediumSimple medium=
AixLib.Media.FastHvac.WaterSimple()
"Mediums charastics (heat capacity, density, thermal conductivity)";
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"
Expand All @@ -10,24 +13,33 @@ model EnergyBalance "Base class depicts energy and mass balances"
annotation (Placement(transformation(extent={{40,-20},{100,40}}),
iconTransformation(extent={{60,-20},{100,20}})));
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort_a
"Heat port includes the parameter temperature and heat flow"
annotation (Placement(
"Heat port includes the parameter temperature and heat flow" annotation (Placement(
transformation(extent={{-20,60},{20,100}}), iconTransformation(extent={{
-20,60},{20,100}})));
Modelica.SIunits.EnthalpyFlowRate H_a "Enthalpy flow rate at port a";
Modelica.SIunits.EnthalpyFlowRate H_b "Enthalpy flow rate at port b";
protected
parameter Modelica.SIunits.SpecificHeatCapacity cp = medium.c
"medium's specific heat capacity";

equation
// Mass and energy balances
m_flow = enthalpyPort_a.m_flow;
enthalpyPort_a.m_flow + enthalpyPort_b.m_flow = 0;
// H_a = port_a.m_flow * actualStream(port_a.h_outflow);
// H_b = port_b.m_flow * actualStream(port_b.h_outflow);
// H_a + H_b = heatPort_a.Q_flow

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;
enthalpyPort_b.h_outflow = cp * heatPort_a.T;
enthalpyPort_a.h_outflow = cp * heatPort_a.T;

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

enthalpyPort_a.p = 1000;
enthalpyPort_b.p = 1000;
enthalpyPort_a.dummy_potential = 1;
enthalpyPort_b.dummy_potential = 1;

heatPort_a.Q_flow = - m_flow * (actualStream(enthalpyPort_a.h_outflow) - actualStream(enthalpyPort_b.h_outflow))
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
Expand Down
9 changes: 6 additions & 3 deletions AixLib/FastHVAC/Interfaces/EnthalpyPort.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ within AixLib.FastHVAC.Interfaces;
partial connector EnthalpyPort "Enthalpy port for 1-dim. enthalpy transfer"
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";
stream Modelica.SIunits.SpecificEnthalpy h_outflow
"Specific enthalpy of fluid";
protected
Real dummy_potential "dummy potential variable";
// 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
10 changes: 4 additions & 6 deletions AixLib/FastHVAC/Pipes/DynamicPipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ public
parameter Boolean withInsulation = true
"Option to add insulation of the pipe";
parameter AixLib.DataBase.Pipes.InsulationBaseDataDefinition
parameterIso=
AixLib.DataBase.Pipes.Insulation.Iso100pc() "Type of Insulation"
annotation (choicesAllMatching=true, Dialog( enable = withInsulation));
parameterIso=AixLib.DataBase.Pipes.Insulation.Iso100pc()
"Type of Insulation" annotation (choicesAllMatching=true, Dialog( enable = withInsulation));
parameter Boolean withConvection = false
"= true to internally simulate heat loss to ambient by convection ";

parameter Boolean withRadiation=false
parameter Boolean withRadiation=false
"= true to internally simulate heat loss to ambient by radiation (only works with convection = true)" annotation (Dialog( enable = withConvection));

final parameter Boolean withRadiationParam=if not withConvection then false else withRadiation
final parameter Boolean withRadiationParam=if not withConvection then false else withRadiation
"= true to internally simulate heat loss to ambient by radiation (only works with convection = true)" annotation (Dialog( enable = false));
parameter Modelica.SIunits.CoefficientOfHeatTransfer hConOut=8 "Heat transfer coefficient to ambient"
annotation (Dialog( enable=withConvection));
Expand Down
5 changes: 2 additions & 3 deletions AixLib/FastHVAC/Pipes/DynamicPipeAggregated.mo
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ final parameter Boolean withRadiationParam=if not withConvection then f
annotation (Dialog( enable=withConvection));
parameter Modelica.SIunits.Emissivity eps = 0.8 "Emissivity"
annotation (Dialog( enable = withRadiation));
parameter Boolean calcHCon=true "Use calculated value for inside heat coefficient";
parameter Boolean calcHCon = true "Use calculated value for inside heat coefficient";
parameter Modelica.SIunits.CoefficientOfHeatTransfer hConIn_const=30 "Fix value for heat transfer coeffiecient inside pipe" annotation(Dialog(enable=not
calcHCon));
final parameter Modelica.SIunits.Area AOutside = if not withInsulation then Modelica.Constants.pi*outerDiameter*length else Modelica.Constants.pi*(outerDiameter*parameterIso.factor*2 + outerDiameter)*length;
Expand Down Expand Up @@ -198,15 +198,14 @@ equation
connect(pipeWall.port_b,insulation.port_a);
connect(insulation.port_b, twoStar_RadEx.Therm);
connect(insulation.port_b,heatPorts);

end if;

//radiation, insulation and convection
if (withRadiationParam and withInsulation and withConvection) then
connect(pipeWall.port_b,insulation.port_a);
connect(insulation.port_b, heatConv.port_b);
connect(heatConv.port_a, heatPorts);
connect(insulation.port_b, twoStar_RadEx.Therm);

end if;

connect(pipeBase.enthalpyPort_b1, enthalpyPort_b1) annotation (Line(
Expand Down
14 changes: 9 additions & 5 deletions AixLib/FastHVAC/Pumps/Examples/FluidSource.mo
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@ model FluidSource
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)
Modelica.Blocks.Sources.Constant T_source1(k=310.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}})));
Sensors.TemperatureSensor temperature
annotation (Placement(transformation(extent={{0,-36},{20,-16}})));
equation
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={{-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}));
connect(temperature.enthalpyPort_b, vessel.enthalpyPort_a) annotation (Line(
points={{19,-26.1},{23.5,-26.1},{23.5,-24},{25,-24}}, color={176,0,0}));
connect(fluidSource1.enthalpyPort_b, temperature.enthalpyPort_a) annotation (
Line(points={{-21,-84},{-10,-84},{-10,-26.1},{1.2,-26.1}}, color={176,0,0}));
connect(fluidSource.enthalpyPort_b, temperature.enthalpyPort_a) annotation (
Line(points={{-17,-22},{-8,-22},{-8,-26.1},{1.2,-26.1}}, color={176,0,0}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={
Rectangle(
Expand Down
30 changes: 10 additions & 20 deletions AixLib/FastHVAC/Pumps/FluidSource.mo
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
within AixLib.FastHVAC.Pumps;
model FluidSource " Ideal fluid source "


/* *******************************************************************
Medium
******************************************************************* */
parameter Media.FastHvac.BaseClasses.MediumSimple medium=
Media.FastHvac.WaterSimple()
parameter AixLib.Media.FastHvac.BaseClasses.MediumSimple medium=
AixLib.Media.FastHvac.WaterSimple()
"Standard charastics for water (heat capacity, density, thermal conductivity)"
annotation (choicesAllMatching);
protected
parameter Modelica.SIunits.SpecificHeatCapacity cp=medium.c
"medium's specific heat capacity";
/* *******************************************************************
Components
******************************************************************* */

public
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}})));
Expand All @@ -25,15 +12,18 @@ public
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}})));
protected
parameter Modelica.SIunits.SpecificHeatCapacity cp = medium.c
"medium's specific heat capacity";



equation
// balances
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.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",
choicesAllMatching, Documentation(info="<html><h4>
Expand Down
13 changes: 8 additions & 5 deletions AixLib/FastHVAC/Pumps/Pump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ model Pump " Ideal pump "
Medium
******************************************************************* */

parameter Media.FastHvac.BaseClasses.MediumSimple medium=
Media.FastHvac.WaterSimple()
parameter AixLib.Media.FastHvac.BaseClasses.MediumSimple medium=
AixLib.Media.FastHvac.WaterSimple()
"Standard charastics for water (heat capacity, density, thermal conductivity)"
annotation (choicesAllMatching);
protected
Expand Down Expand Up @@ -37,12 +37,15 @@ public
equation
// balances
enthalpyPort_b.m_flow = dotm_setValue " set value of outlet port ";
enthalpyPort_b.c = cp " set value of outlet port ";
// enthalpyPort_b.c_outflow = cp " set value of outlet port ";

// constant values
enthalpyPort_a.T = enthalpyPort_b.T;
enthalpyPort_a.h = enthalpyPort_b.h;

enthalpyPort_b.T_outflow = inStream(enthalpyPort_a.T_outflow);
enthalpyPort_b.h_outflow = inStream(enthalpyPort_a.h_outflow);
enthalpyPort_a.h_outflow = 0;
enthalpyPort_a.T_outflow = 273.15;
enthalpyPort_b.dummy_potential = 1;
annotation (
defaultComponentName="pump",
choicesAllMatching, Documentation(info="<html><h4>
Expand Down
9 changes: 7 additions & 2 deletions AixLib/FastHVAC/Sensors/TemperatureSensor.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
within AixLib.FastHVAC.Sensors;
model TemperatureSensor " Temperature sensor"

parameter AixLib.Media.FastHvac.BaseClasses.MediumSimple medium=
AixLib.Media.FastHvac.WaterSimple()
"Mediums charastics (heat capacity, density, thermal conductivity)";
Modelica.Blocks.Interfaces.RealOutput T( final quantity="ThermodynamicTemperature",
final unit = "K", displayUnit = "degC", min=0)
"Output value which contains the measured temperature of the fluid"
Expand All @@ -18,8 +20,11 @@ model TemperatureSensor " Temperature sensor"
FastHVAC.Interfaces.EnthalpyPort_b enthalpyPort_b "Output connector"
annotation (Placement(transformation(extent={{80,-12},{102,10}}),
iconTransformation(extent={{78,-12},{102,10}})));
protected
parameter Modelica.SIunits.SpecificHeatCapacity cp = medium.c
"medium's specific heat capacity";
equation
T = enthalpyPort_a.T;
T =inStream(enthalpyPort_a.h_outflow) / cp;

connect(enthalpyPort_a, enthalpyPort_b) annotation (Line(
points={{-89,-1},{91,-1}},
Expand Down
8 changes: 5 additions & 3 deletions AixLib/FastHVAC/Sinks/Vessel.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ model Vessel "Vessel model"
transformation(extent={{-88,-18},{-52,18}}), iconTransformation(extent={
{-88,-18},{-52,18}})));


equation
enthalpyPort_a.p = 1000;
enthalpyPort_a.dummy_potential = 1;
enthalpyPort_a.h_outflow = 0;
enthalpyPort_a.T_outflow = 0;
enthalpyPort_a.c_outflow = 0;
// enthalpyPort_a.T_outflow = 273.15;

// enthalpyPort_a.c_outflow = 0;
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}})), Icon(coordinateSystem(preserveAspectRatio=
false, extent={{-100,-100},{100,100}}), graphics={Rectangle(
Expand Down

0 comments on commit 2cad670

Please sign in to comment.