Skip to content

Commit

Permalink
Merge pull request RWTH-EBC#1378 from RWTH-EBC/openModelicaProject
Browse files Browse the repository at this point in the history
Open Modelica PR
  • Loading branch information
FWuellhorst committed Feb 9, 2023
2 parents 4280d7c + fae8e8d commit 5783775
Show file tree
Hide file tree
Showing 65 changed files with 536 additions and 638 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public
extent={{10,10},{-10,-10}},
rotation=180,
origin={-90,50})));
Modelica.Blocks.Math.Gain gain(k=cp_default)
Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)"))
annotation (Placement(transformation(extent={{-32,40},{-12,60}})));
Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public
extent={{10,10},{-10,-10}},
rotation=180,
origin={-90,46})));
Modelica.Blocks.Math.Gain gain(k=cp_default)
Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)"))
annotation (Placement(transformation(extent={{-26,54},{-6,74}})));
Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public
extent={{10,10},{-10,-10}},
rotation=180,
origin={-90,46})));
Modelica.Blocks.Math.Gain gain(k=cp_default)
Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)"))
annotation (Placement(transformation(extent={{-26,54},{-6,74}})));
Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=0,
origin={80,0})));
Modelica.Blocks.Math.Gain gain(k=cp_default)
Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)"))
annotation (Placement(transformation(extent={{-40,104},{-20,124}})));
Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
Expand Down
12 changes: 5 additions & 7 deletions AixLib/Fluid/DistrictHeatingCooling/Pipes/DHCPipe.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
within AixLib.Fluid.DistrictHeatingCooling.Pipes;
model DHCPipe "Generic pipe model for DHC applications"
extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true);
extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true);

parameter Boolean use_zeta=false
"= true HydraulicResistance is implemented, zeta value has to be given next"
Expand Down Expand Up @@ -177,11 +177,11 @@ model DHCPipe "Generic pipe model for DHC applications"
// See also AixLib.Fluid.FixedResistances.Validation.PlugFlowPipes.TransportWaterAir
// for why mSenFac is 10 and not 1000, as this gives more reasonable
// temperature step response
Fluid.MixingVolumes.MixingVolume vol(
AixLib.Fluid.MixingVolumes.MixingVolume vol(
redeclare final package Medium = Medium,
final m_flow_nominal=m_flow_nominal,
final V=if rho_default > 500 then VEqu else VEqu/1000,
final nPorts=nPorts + 1,
final nPorts=2,
final T_start=T_start_out,
final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
final mSenFac = if rho_default > 500 then 1 else 10)
Expand Down Expand Up @@ -284,11 +284,9 @@ equation
der(Q_los) = min(0, pipCor.heatPort.Q_flow);
der(Q_gai) = max(0, pipCor.heatPort.Q_flow);

for i in 1:nPorts loop
connect(vol.ports[i + 1], ports_b[i])
annotation (Line(points={{70,20},{72,20},{72,6},{72,0},{100,0}},
connect(vol.ports[2], port_b)
annotation (Line(points={{71,20},{72,20},{72,6},{72,0},{100,0}},
color={0,127,255}));
end for;

connect(pipCor.port_b, vol.ports[1])
annotation (Line(points={{10,0},{70,0},{70,20}}, color={0,127,255}));
Expand Down
20 changes: 8 additions & 12 deletions AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/DHCPipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ model DHCPipe "Simple example of DHCPipe and its four different modes"
nPorts=1,
p(displayUnit="Pa") = 101325) "Pressure boundary condition"
annotation (Placement(transformation(extent={{72,40},{52,60}})));
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip(
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip(
redeclare package Medium = Medium,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
redeclare BaseClassesStatic.StaticCore pipCor "Static core",
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -66,11 +65,10 @@ model DHCPipe "Simple example of DHCPipe and its four different modes"
nPorts=1,
p(displayUnit="Pa") = 101325) "Pressure boundary condition"
annotation (Placement(transformation(extent={{72,0},{52,20}})));
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip1(
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip1(
redeclare package Medium = Medium,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core",
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -113,12 +111,11 @@ model DHCPipe "Simple example of DHCPipe and its four different modes"
nPorts=1,
p(displayUnit="Pa") = 101325) "Pressure boundary condition"
annotation (Placement(transformation(extent={{72,-42},{52,-22}})));
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip2(
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip2(
redeclare package Medium = Medium,
use_soil=true,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core",
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -161,12 +158,11 @@ model DHCPipe "Simple example of DHCPipe and its four different modes"
nPorts=1,
p(displayUnit="Pa") = 101325) "Pressure boundary condition"
annotation (Placement(transformation(extent={{72,-80},{52,-60}})));
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip3(
AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip3(
redeclare package Medium = Medium,
sum_zetas=2.5,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core",
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -203,7 +199,7 @@ equation
connect(Tin.y, sou.T_in)
annotation (Line(points={{-79,54},{-72,54}},
color={0,0,127}));
connect(pip.ports_b[1], senTemOut.port_a)
connect(pip.port_b, senTemOut.port_a)
annotation (Line(points={{10,50},{20,50}},
color={0,127,255}));
connect(senTemOut.port_b, sin.ports[1])
Expand All @@ -219,7 +215,7 @@ equation
annotation (Line(points={{-80,90},{0,90},{0,20}}, color={191,0,0}));
connect(Tin1.y, sou1.T_in)
annotation (Line(points={{-79,14},{-72,14}}, color={0,0,127}));
connect(pip1.ports_b[1], senTemOut1.port_a)
connect(pip1.port_b, senTemOut1.port_a)
annotation (Line(points={{10,10},{20,10}}, color={0,127,255}));
connect(senTemOut1.port_b, sin1.ports[1])
annotation (Line(points={{40,10},{52,10}}, color={0,127,255}));
Expand All @@ -231,7 +227,7 @@ equation
annotation (Line(points={{-80,90},{0,90},{0,-22}}, color={191,0,0}));
connect(Tin2.y, sou2.T_in)
annotation (Line(points={{-79,-28},{-72,-28}}, color={0,0,127}));
connect(pip2.ports_b[1], senTemOut2.port_a)
connect(pip2.port_b, senTemOut2.port_a)
annotation (Line(points={{10,-32},{20,-32}}, color={0,127,255}));
connect(senTemOut2.port_b, sin2.ports[1])
annotation (Line(points={{40,-32},{52,-32}}, color={0,127,255}));
Expand All @@ -243,7 +239,7 @@ equation
annotation (Line(points={{-80,90},{0,90},{0,-60}}, color={191,0,0}));
connect(Tin3.y, sou3.T_in)
annotation (Line(points={{-79,-66},{-72,-66}}, color={0,0,127}));
connect(pip3.ports_b[1], senTemOut3.port_a)
connect(pip3.port_b, senTemOut3.port_a)
annotation (Line(points={{10,-70},{20,-70}}, color={0,127,255}));
connect(senTemOut3.port_b, sin3.ports[1])
annotation (Line(points={{40,-70},{52,-70}}, color={0,127,255}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ model PlugFlowPipeEmbedded "Simple example of PlugFlowPipeEmbedded"
pip(
redeclare package Medium = Medium,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyStateInitial,
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -60,7 +59,7 @@ equation
color={191,0,0}));
connect(Tin.y, sou.T_in)
annotation (Line(points={{-71,4},{-62,4}}, color={0,0,127}));
connect(pip.ports_b[1], senTemOut.port_a)
connect(pip.port_b, senTemOut.port_a)
annotation (Line(points={{20,0},{30,0}}, color={0,127,255}));
connect(senTemOut.port_b, sin.ports[1])
annotation (Line(points={{50,0},{62,0}}, color={0,127,255}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ model PlugFlowPipeZeta "Simple example of PlugFlowPipe"
annotation (Placement(transformation(extent={{82,-10},{62,10}})));
AixLib.Fluid.DistrictHeatingCooling.Pipes.PlugFlowPipeZeta pip(
redeclare package Medium = Medium,
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -57,7 +56,7 @@ equation
annotation (Line(points={{-20,70},{10,70},{10,10}}, color={191,0,0}));
connect(Tin.y, sou.T_in)
annotation (Line(points={{-71,4},{-62,4}}, color={0,0,127}));
connect(pip.ports_b[1], senTemOut.port_a)
connect(pip.port_b, senTemOut.port_a)
annotation (Line(points={{20,0},{30,0}}, color={0,127,255}));
connect(senTemOut.port_b, sin.ports[1])
annotation (Line(points={{50,0},{62,0}}, color={0,127,255}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ model StaticPipe "Simple example of StaticPipe"
annotation (Placement(transformation(extent={{82,-10},{62,10}})));
AixLib.Fluid.DistrictHeatingCooling.Pipes.StaticPipe pip(
redeclare package Medium = Medium,
nPorts=1,
dh=0.1,
length=100,
dIns=0.05,
Expand Down Expand Up @@ -57,7 +56,7 @@ equation
annotation (Line(points={{-20,70},{10,70},{10,10}}, color={191,0,0}));
connect(Tin.y, sou.T_in)
annotation (Line(points={{-71,4},{-62,4}}, color={0,0,127}));
connect(pip.ports_b[1], senTemOut.port_a)
connect(pip.port_b, senTemOut.port_a)
annotation (Line(points={{20,0},{30,0}}, color={0,127,255}));
connect(senTemOut.port_b, sin.ports[1])
annotation (Line(points={{50,0},{62,0}}, color={0,127,255}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model PlugFlowPipeEmbedded
"Embedded pipe model using spatialDistribution for temperature delay"

extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true);
extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true);

parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial
"Type of energy balance: dynamic (3 initialization options) or steady state"
Expand Down Expand Up @@ -61,11 +61,11 @@ model PlugFlowPipeEmbedded
parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness"
annotation (Dialog(group="Material"));

parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default) =
parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)=
Medium.T_default "Initialization temperature at pipe inlet"
annotation (Dialog(tab="Initialization"));
parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)
= T_start_in "Initialization temperature at pipe outlet"
parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)=
T_start_in "Initialization temperature at pipe outlet"
annotation (Dialog(tab="Initialization"));
parameter Boolean initDelay(start=false) = false
"Initialize delay for a constant mass flow rate if true, otherwise start from 0"
Expand Down Expand Up @@ -135,7 +135,6 @@ model PlugFlowPipeEmbedded
final R=R,
final fac=fac,
final sum_zetas=sum_zetas,
nPorts=nPorts,
final use_zeta=true)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));

Expand Down Expand Up @@ -215,7 +214,7 @@ equation
annotation (Line(points={{0,90.8},{0,104}}, color={191,0,0}));
connect(port_a, plugFlowPipeZeta.port_a)
annotation (Line(points={{-100,0},{-10,0}}, color={0,127,255}));
connect(plugFlowPipeZeta.ports_b, ports_b) annotation (Line(points={{10,0},{56,
connect(plugFlowPipeZeta.port_b, port_b) annotation (Line(points={{10,0},{56,
0},{56,0},{100,0}}, color={0,127,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Rectangle(
Expand Down
18 changes: 8 additions & 10 deletions AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeZeta.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
within AixLib.Fluid.DistrictHeatingCooling.Pipes;
model PlugFlowPipeZeta
"Pipe model using spatialDistribution for temperature delay and conditional HydraulicResistance"
extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true);
extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true);

parameter Boolean use_zeta=false
"= true HydraulicResistance is implemented, zeta value has to be given next"
Expand Down Expand Up @@ -56,11 +56,11 @@ model PlugFlowPipeZeta
parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness"
annotation (Dialog(group="Material"));

parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default) =
parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)=
Medium.T_default "Initialization temperature at pipe inlet"
annotation (Dialog(tab="Initialization"));
parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)
= T_start_in "Initialization temperature at pipe outlet"
parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)=
T_start_in "Initialization temperature at pipe outlet"
annotation (Dialog(tab="Initialization"));
parameter Boolean initDelay(start=false) = false
"Initialize delay for a constant mass flow rate if true, otherwise start from 0"
Expand Down Expand Up @@ -128,7 +128,7 @@ model PlugFlowPipeZeta
redeclare final package Medium = Medium,
final m_flow_nominal=m_flow_nominal,
final V=if rho_default > 500 then VEqu else VEqu/1000,
final nPorts=nPorts + 1,
final nPorts=2,
final T_start=T_start_out,
final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
final mSenFac = if rho_default > 500 then 1 else 10)
Expand Down Expand Up @@ -178,16 +178,14 @@ equation
//calculation of the flow velocity of medium in the pipes
v_med = (4 * port_a.m_flow) / (Modelica.Constants.pi * rho_default * dh * dh);

for i in 1:nPorts loop
connect(vol.ports[i + 1], ports_b[i])
annotation (Line(points={{70,20},{72,20},{72,6},{72,0},{100,0}},
connect(vol.ports[2], port_b)
annotation (Line(points={{71,20},{72,20},{72,6},{72,0},{100,0}},
color={0,127,255}));
end for;
connect(plugFlowCore.heatPort, heatPort)
annotation (Line(points={{0,10},{0,10},{0,100}}, color={191,0,0}));

connect(plugFlowCore.port_b, vol.ports[1])
annotation (Line(points={{10,0},{70,0},{70,20}}, color={0,127,255}));
annotation (Line(points={{10,0},{69,0},{69,20}}, color={0,127,255}));
if use_zeta then
connect(hydraulicResistance.port_b, plugFlowCore.port_a)
annotation (Line(points={{-40,20},{-20,20},{-20,0},{-10,0}},
Expand Down
18 changes: 8 additions & 10 deletions AixLib/Fluid/DistrictHeatingCooling/Pipes/StaticPipe.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
within AixLib.Fluid.DistrictHeatingCooling.Pipes;
model StaticPipe
"Static Pipe model using conditional HydraulicResistance"
extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true);
extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true);

parameter Boolean use_zeta=false
"= true HydraulicResistance is implemented, zeta value has to be given next"
Expand Down Expand Up @@ -56,11 +56,11 @@ model StaticPipe
parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness"
annotation (Dialog(group="Material"));

parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default) =
parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)=
Medium.T_default "Initialization temperature at pipe inlet"
annotation (Dialog(tab="Initialization"));
parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)
= T_start_in "Initialization temperature at pipe outlet"
parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)=
T_start_in "Initialization temperature at pipe outlet"
annotation (Dialog(tab="Initialization"));
parameter Boolean initDelay(start=false) = false
"Initialize delay for a constant mass flow rate if true, otherwise start from 0"
Expand Down Expand Up @@ -129,7 +129,7 @@ model StaticPipe
redeclare final package Medium = Medium,
final m_flow_nominal=m_flow_nominal,
final V=if rho_default > 500 then VEqu else VEqu/1000,
final nPorts=nPorts + 1,
final nPorts=2,
final T_start=T_start_out,
final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
final mSenFac = if rho_default > 500 then 1 else 10)
Expand Down Expand Up @@ -179,16 +179,14 @@ equation
//calculation of the flow velocity of medium in the pipes
v_med = (4 * port_a.m_flow) / (Modelica.Constants.pi * rho_default * dh * dh);

for i in 1:nPorts loop
connect(vol.ports[i + 1], ports_b[i])
annotation (Line(points={{70,20},{72,20},{72,6},{72,0},{100,0}},
connect(vol.ports[2], port_b)
annotation (Line(points={{71,20},{72,20},{72,6},{72,0},{100,0}},
color={0,127,255}));
end for;
connect(staticCore.heatPort, heatPort)
annotation (Line(points={{0,10},{0,10},{0,100}}, color={191,0,0}));

connect(staticCore.port_b, vol.ports[1])
annotation (Line(points={{10,0},{70,0},{70,20}}, color={0,127,255}));
annotation (Line(points={{10,0},{69,0},{69,20}}, color={0,127,255}));
//Connect hydraulicResistance
if use_zeta then
connect(hydraulicResistance.port_b, staticCore.port_a)
Expand Down
6 changes: 5 additions & 1 deletion AixLib/Fluid/HeatExchangers/Examples/HeatingRod.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ model HeatingRod "Example for the usage of the heating rod model"
extends Modelica.Icons.Example;
extends AixLib.Fluid.HeatExchangers.Examples.BaseClasses.Heater(
redeclare package Medium = AixLib.Media.Water,
m_flow_nominal=V*heatingRod.rho_default/3600,
m_flow_nominal=V*rhoWat/3600,
Q_flow_nominal=100,
conPI(k=10),
vol(V=V/1000),
Expand All @@ -23,6 +23,10 @@ model HeatingRod "Example for the usage of the heating rod model"
Modelica.Blocks.Interfaces.RealOutput Pel
"Electrical power used to provide current heat flow"
annotation (Placement(transformation(extent={{120,-70},{140,-50}})));

protected
parameter Modelica.Units.SI.Density rhoWat=1000 "Density of water";

equation
connect(mov.port_b, heatingRod.port_a)
annotation (Line(points={{-50,-40},{-30,-40}}, color={0,127,255}));
Expand Down
Loading

0 comments on commit 5783775

Please sign in to comment.