Skip to content

Commit

Permalink
Refactor SI units path in storage models #1171
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraMaier committed Jul 14, 2022
1 parent 9a26a02 commit 2000641
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
10 changes: 5 additions & 5 deletions AixLib/DataBase/Storage/StorageDetailedBaseDataDefinition.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ record StorageDetailedBaseDataDefinition
"Base data definition for Buffer storage records"
extends Modelica.Icons.Record;
///////////input parameters////////////
import SI = Modelica.SIunits;
import Modelica.Units.SI;
parameter SI.Height hTank "Height of storage";
parameter SI.Height hLowerPortDemand "Height of lower demand port";
parameter SI.Height hUpperPortDemand "Height of upper demand port";
Expand All @@ -17,9 +17,9 @@ record StorageDetailedBaseDataDefinition
parameter SI.Diameter dTank "Inner diameter of storage";
parameter SI.Length sWall "Thickness of storage Wall";
parameter SI.Length sIns "Thickness of storage insulation";
parameter Modelica.SIunits.ThermalConductivity lambdaWall
parameter SI.ThermalConductivity lambdaWall
"thermal conductivity of storage wall";
parameter Modelica.SIunits.ThermalConductivity lambdaIns
parameter SI.ThermalConductivity lambdaIns
"thermal conductivity of storage insulation";
//parameter SI.CoefficientOfHeatTransfer alpha
//"Coefficient of heat transfer air <-> insulation of tank";
Expand All @@ -38,8 +38,8 @@ record StorageDetailedBaseDataDefinition
parameter DataBase.Pipes.PipeBaseDataDefinition pipeHC2
"Type of Pipe for HR2";

parameter Modelica.SIunits.Length lengthHC1 "Length of Pipe for HR1";
parameter Modelica.SIunits.Length lengthHC2 "Length of Pipe for HR2";
parameter SI.Length lengthHC1 "Length of Pipe for HR1";
parameter SI.Length lengthHC2 "Length of Pipe for HR2";

annotation (Icon(graphics), Documentation(info="<html><h4>
<span style=\"color:#008000\">Overview</span>
Expand Down
18 changes: 9 additions & 9 deletions AixLib/Fluid/Storage/StorageDetailed.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
within AixLib.Fluid.Storage;
model StorageDetailed
"Buffer Storage Model with support for heating rod and two heating coils"
import SI = Modelica.SIunits;
import Modelica.Units.SI;

extends AixLib.Fluid.Interfaces.LumpedVolumeDeclarations(final T_start = TStart);

Expand All @@ -16,17 +16,17 @@ model StorageDetailed
replaceable package MediumHC2 =
Modelica.Media.Interfaces.PartialMedium "Medium model for HC2"
annotation (choicesAllMatching = true, Dialog(group="Medium"));
parameter Modelica.SIunits.MassFlowRate m1_flow_nominal(min=0)
parameter SI.MassFlowRate m1_flow_nominal(min=0)
"Nominal mass flow rate of fluid 1 ports"
annotation(Dialog(group = "Nominal condition"));
parameter Modelica.SIunits.MassFlowRate m2_flow_nominal(min=0)
parameter SI.MassFlowRate m2_flow_nominal(min=0)
"Nominal mass flow rate of fluid 2 ports"
annotation(Dialog(group = "Nominal condition"));

parameter Modelica.SIunits.MassFlowRate mHC1_flow_nominal(min=0) if useHeatingCoil1
parameter SI.MassFlowRate mHC1_flow_nominal(min=0) if useHeatingCoil1
"Nominal mass flow rate of fluid 1 ports"
annotation(Dialog(tab="Heating Coils and Rod", group = "Nominal condition", enable=useHeatingCoil1));
parameter Modelica.SIunits.MassFlowRate mHC2_flow_nominal(min=0) if useHeatingCoil2
parameter SI.MassFlowRate mHC2_flow_nominal(min=0) if useHeatingCoil2
"Nominal mass flow rate of fluid 1 ports"
annotation(Dialog(tab="Heating Coils and Rod", group = "Nominal condition", enable=useHeatingCoil2));

Expand Down Expand Up @@ -61,9 +61,9 @@ model StorageDetailed
"Heating Coil 2 orientation from up to down?"
annotation(Dialog(enable = useHeatingCoil2,tab="Heating Coils and Rod"));

parameter Modelica.SIunits.Temperature TStartWall=293.15
parameter SI.Temperature TStartWall=293.15
"Starting Temperature of wall in K" annotation(Dialog(tab="Initialization", group="Storage specific"));
parameter Modelica.SIunits.Temperature TStartIns=293.15
parameter SI.Temperature TStartIns=293.15
"Starting Temperature of insulation in K" annotation(Dialog(tab="Initialization", group="Storage specific"));

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -235,8 +235,8 @@ model StorageDetailed
/////HEATING ROD ////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatingRod if
useHeatingRod annotation (
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatingRod
if useHeatingRod annotation (
Placement(transformation(extent={{-86,-6},{-74,6}}, rotation=0)));

//////////////////////////////////////////////////////////////////////////////////////////
Expand Down
46 changes: 23 additions & 23 deletions AixLib/Fluid/Storage/StorageSimple.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ model StorageSimple
constrainedby Modelica.Media.Interfaces.PartialMedium;

parameter Integer n(min = 3) "number of layers";
parameter Modelica.SIunits.Length d "storage diameter";
parameter Modelica.SIunits.Length h "storage height";
parameter Modelica.SIunits.ThermalConductivity lambda_ins
parameter Modelica.Units.SI.Length d "storage diameter";
parameter Modelica.Units.SI.Length h "storage height";
parameter Modelica.Units.SI.ThermalConductivity lambda_ins
"thermal conductivity of insulation" annotation(Dialog(group = "Heat losses"));
parameter Modelica.SIunits.Length s_ins "thickness of insulation" annotation(Dialog(group = "Heat losses"));
parameter Modelica.SIunits.CoefficientOfHeatTransfer hConIn "Iinternal heat transfer coefficient" annotation(Dialog(group="Heat losses"));
parameter Modelica.SIunits.CoefficientOfHeatTransfer hConOut "External heat transfer coefficient" annotation(Dialog(group="Heat losses"));
parameter Modelica.SIunits.Volume V_HE "heat exchanger volume" annotation(Dialog(group = "Heat exchanger"));
parameter Modelica.SIunits.CoefficientOfHeatTransfer k_HE
parameter Modelica.Units.SI.Length s_ins "thickness of insulation" annotation(Dialog(group = "Heat losses"));
parameter Modelica.Units.SI.CoefficientOfHeatTransfer hConIn "Iinternal heat transfer coefficient" annotation(Dialog(group="Heat losses"));
parameter Modelica.Units.SI.CoefficientOfHeatTransfer hConOut "External heat transfer coefficient" annotation(Dialog(group="Heat losses"));
parameter Modelica.Units.SI.Volume V_HE "heat exchanger volume" annotation(Dialog(group = "Heat exchanger"));
parameter Modelica.Units.SI.CoefficientOfHeatTransfer k_HE
"heat exchanger heat transfer coefficient" annotation(Dialog(group = "Heat exchanger"));
parameter Modelica.SIunits.Area A_HE "heat exchanger area" annotation(Dialog(group = "Heat exchanger"));
parameter Modelica.SIunits.RelativePressureCoefficient beta = 350e-6 annotation(Dialog(group = "Bouyancy"));
parameter Modelica.Units.SI.Area A_HE "heat exchanger area" annotation(Dialog(group = "Heat exchanger"));
parameter Modelica.Units.SI.RelativePressureCoefficient beta = 350e-6 annotation(Dialog(group = "Bouyancy"));
parameter Real kappa = 0.4 annotation(Dialog(group = "Bouyancy"));
Modelica.Fluid.Interfaces.FluidPort_a
port_a_consumer(redeclare final package Medium = Medium)
Expand Down Expand Up @@ -76,9 +76,9 @@ model StorageSimple
each final dx=dx,
each final kappa=kappa) annotation (Placement(transformation(extent={{-10,-10},{
10,10}}, origin={-28,0})));
parameter Modelica.SIunits.MassFlowRate m_flow_nominal_layer
parameter Modelica.Units.SI.MassFlowRate m_flow_nominal_layer
"Nominal mass flow rate in layers";
parameter Modelica.SIunits.MassFlowRate m_flow_nominal_HE
parameter Modelica.Units.SI.MassFlowRate m_flow_nominal_HE
"Nominal mass flow rate of heat exchanger layers";

parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial
Expand All @@ -91,9 +91,9 @@ model StorageSimple
"Start value of pressure" annotation(Dialog(tab="Initialization"));

//Mass flow rates to regulate zero flow
parameter Modelica.SIunits.MassFlowRate m_flow_small_layer=1E-4*abs(m_flow_nominal_layer)
parameter Modelica.Units.SI.MassFlowRate m_flow_small_layer=1E-4*abs(m_flow_nominal_layer)
"Small mass flow rate for regularization of zero flow" annotation(Dialog(tab="Advanced"));
parameter Modelica.SIunits.MassFlowRate m_flow_small_layer_HE=1E-4*abs(m_flow_nominal_HE)
parameter Modelica.Units.SI.MassFlowRate m_flow_small_layer_HE=1E-4*abs(m_flow_nominal_HE)
"Small mass flow rate for regularization of zero flow" annotation(Dialog(tab="Advanced"));

Modelica.Blocks.Interfaces.RealOutput TTopLayer(
Expand Down Expand Up @@ -145,19 +145,19 @@ model StorageSimple
rotation=0,
origin={102,-80})));
protected
parameter Modelica.SIunits.Volume V = A * h;
parameter Modelica.SIunits.Area A = Modelica.Constants.pi * d ^ 2 / 4;
parameter Modelica.SIunits.Length dx = V / A / n;
parameter Modelica.SIunits.ThermalConductance G_middle=2*Modelica.Constants.pi*h/n/(1/(hConIn*d/2) + 1/lambda_ins*log((d/2 + s_ins)/(d/2))
parameter Modelica.Units.SI.Volume V = A * h;
parameter Modelica.Units.SI.Area A = Modelica.Constants.pi * d ^ 2 / 4;
parameter Modelica.Units.SI.Length dx = V / A / n;
parameter Modelica.Units.SI.ThermalConductance G_middle=2*Modelica.Constants.pi*h/n/(1/(hConIn*d/2) + 1/lambda_ins*log((d/2 + s_ins)/(d/2))
+ 1/(hConOut*(d/2 + s_ins)));
parameter Modelica.SIunits.ThermalConductance G_top_bottom = G_middle + lambda_ins / s_ins * A;
parameter Modelica.Units.SI.ThermalConductance G_top_bottom = G_middle + lambda_ins / s_ins * A;
equation
//Connect layers to the upper and lower ports
connect(port_a_consumer, layer[1].ports[1]) annotation (Line(
points={{0,-98},{0,-34},{20,-34},{20,-2},{10,-2}},
points={{0,-98},{0,-34},{20,-34},{20,-1},{10,-1}},
color={0,127,255}));
connect(layer[n].ports[2], port_b_consumer) annotation (Line(
points={{10,2},{16,2},{20,2},{20,40},{0,40},{0,92}},
points={{10,1},{16,1},{20,1},{20,40},{0,40},{0,92}},
color={0,127,255}));

//Connect layers
Expand All @@ -171,10 +171,10 @@ equation
end for;
//Connect layers of Heat Exchanger
connect(port_a_heatGenerator, layer_HE[n].ports[2]) annotation (Line(
points={{84,88},{84,36},{96,22},{94,2}},
points={{84,88},{94,36},{94,22},{94,1}},
color={0,127,255}));
connect(port_b_heatGenerator, layer_HE[1].ports[1]) annotation (Line(
points={{84,-88},{84,-26},{96,-16},{94,-2}},
points={{84,-88},{84,-26},{94,-26},{94,-1}},
color={0,127,255}));
for k in 1:n - 1 loop
connect(layer_HE[k].ports[2], layer_HE[k + 1].ports[1]);
Expand Down

0 comments on commit 2000641

Please sign in to comment.