text
stringlengths
1
4.74k
code
stringlengths
69
637k
Test model for Carnot_TEva with limited heating capacity. This example extends from <a href=\"modelica://AixLib.Fluid.Chillers.Examples.Carnot_TEva\"> AixLib.Fluid.Chillers.Examples.Carnot_TEva</a> but limits the cooling capacity.
within AixLib.Fluid.Chillers.Validation; model Carnot_TEva_LimitedCapacity "Test model for Carnot_TEva with limited heating capacity" extends Examples.Carnot_TEva( chi(QEva_flow_min=-100000)); end Carnot_TEva_LimitedCapacity;
Test model for chiller based on Carnot efficiency and evaporator outlet temperature control signal
within AixLib.Fluid.Chillers.Validation; model Carnot_TEva_reverseFlow "Test model for chiller based on Carnot efficiency and evaporator outlet temperature control signal" extends Modelica.Icons.Example; package Medium1 = AixLib.Media.Water "Medium model"; package Medium2 = AixLib.Media.Water "Medium model"; parameter Modelica.Units.SI.TemperatureDifference dTEva_nominal=-10 "Temperature difference evaporator inlet-outlet"; parameter Modelica.Units.SI.TemperatureDifference dTCon_nominal=10 "Temperature difference condenser outlet-inlet"; parameter Real COPc_nominal = 3 "Chiller COP"; parameter Modelica.Units.SI.HeatFlowRate QEva_flow_nominal=-100E3 "Evaporator heat flow rate"; parameter Modelica.Units.SI.MassFlowRate m2_flow_nominal=QEva_flow_nominal/ dTEva_nominal/4200 "Nominal mass flow rate at chilled water side"; parameter Modelica.Units.SI.MassFlowRate m1_flow_nominal=m2_flow_nominal*( COPc_nominal + 1)/COPc_nominal "Nominal mass flow rate at condenser water wide"; AixLib.Fluid.Chillers.Carnot_TEva chi( redeclare package Medium1 = Medium1, redeclare package Medium2 = Medium2, dTEva_nominal=dTEva_nominal, dTCon_nominal=dTCon_nominal, use_eta_Carnot_nominal=true, m1_flow_nominal=m1_flow_nominal, m2_flow_nominal=m2_flow_nominal, show_T=true, QEva_flow_nominal=QEva_flow_nominal, allowFlowReversal1=true, allowFlowReversal2=true, dp1_nominal=6000, dp2_nominal=6000) "Chiller model" AixLib.Fluid.Sources.MassFlowSource_T sou1(nPorts=1, redeclare package Medium = Medium1, m_flow=m1_flow_nominal, use_T_in=false, use_m_flow_in=true, T=298.15) AixLib.Fluid.Sources.MassFlowSource_T sou2(nPorts=1, redeclare package Medium = Medium2, m_flow=m2_flow_nominal, use_T_in=false, use_m_flow_in=true, T=295.15) AixLib.Fluid.Sources.Boundary_pT sin1( redeclare package Medium = Medium1, nPorts=1) AixLib.Fluid.Sources.Boundary_pT sin2(nPorts=1, redeclare package Medium = Medium2) Modelica.Blocks.Sources.Constant TEvaLvg(k=273.15 + 10) "Control signal for evaporator leaving temperature" Modelica.Blocks.Math.Gain mCon_flow(k=-1/cp1_default/dTEva_nominal) "Condenser mass flow rate" Modelica.Blocks.Math.Add QCon_flow(k2=-1) "Condenser heat flow rate" final parameter Modelica.Units.SI.SpecificHeatCapacity cp1_default= Medium1.specificHeatCapacityCp(Medium1.setState_pTX( Medium1.p_default, Medium1.T_default, Medium1.X_default)) "Specific heat capacity of medium 1 at default medium state"; Modelica.Blocks.Sources.Ramp mEva_flow( duration=60, startTime=1800, height=-2*m2_flow_nominal, offset=m2_flow_nominal) "Mass flow rate for evaporator" equation connect(sou1.ports[1], chi.port_a1) connect(sou2.ports[1], chi.port_a2) connect(sin2.ports[1], chi.port_b2) connect(TEvaLvg.y, chi.TSet) connect(chi.P, QCon_flow.u1) connect(chi.QEva_flow, QCon_flow.u2) connect(QCon_flow.y, mCon_flow.u) connect(mCon_flow.y, sou1.m_flow_in) connect(chi.port_b1, sin1.ports[1]) connect(mEva_flow.y, sou2.m_flow_in) end Carnot_TEva_reverseFlow;
Test model for the part load efficiency curve with compressor speed as input signal. This example extends from <a href=\"modelica://AixLib.Fluid.Chillers.Examples.Carnot_y\"> AixLib.Fluid.Chillers.Examples.Carnot_y</a> but uses a part load efficiency curve that is different from <i>1</i>.
within AixLib.Fluid.Chillers.Validation; model Carnot_y_etaPL "Test model for the part load efficiency curve with compressor speed as input signal" extends Examples.Carnot_y(chi(a={0.7,0.3})); end Carnot_y_etaPL;
Collection of models that validate the chiller models
within AixLib.Fluid.Chillers; package Validation "Collection of models that validate the chiller models" extends Modelica.Icons.ExamplesPackage; end Validation;
Delay element, approximated by a first order differential equation. This model approximates a transport delay using first order differential equations.
within AixLib.Fluid.Delays; model DelayFirstOrder "Delay element, approximated by a first order differential equation" extends AixLib.Fluid.MixingVolumes.MixingVolume( final V=V_nominal, final massDynamics=energyDynamics, final mSenFac=1); parameter Modelica.Units.SI.Time tau=60 "Time constant at nominal flow" protected parameter Modelica.Units.SI.Volume V_nominal=m_flow_nominal*tau/rho_default "Volume of delay element"; end DelayFirstOrder;
Package with delay models
within AixLib.Fluid; package Delays "Package with delay models" extends Modelica.Icons.VariantsPackage; end Delays;
Fluid volume that is a first order approximation of the transport delay
within AixLib.Fluid.Delays.Examples; model Delay extends Modelica.Icons.Example; // We set X_default to a small enough value to avoid saturation at the medium temperature // that is used in this model. package Medium = AixLib.Media.Air(X_default={0.001, 0.999}); Modelica.Blocks.Sources.Constant PAtm(k=101325) Modelica.Blocks.Sources.Ramp P( duration=1, height=20, offset=101315) AixLib.Fluid.FixedResistances.PressureDrop res1( from_dp=true, m_flow_nominal=5, dp_nominal=5, redeclare package Medium = Medium) AixLib.Fluid.Sources.Boundary_pT sou( T=293.15, redeclare package Medium = Medium, use_p_in=true, nPorts=1) AixLib.Fluid.Sources.Boundary_pT sin( T=283.15, redeclare package Medium = Medium, use_p_in=true, nPorts=1) AixLib.Fluid.FixedResistances.PressureDrop res2( from_dp=true, m_flow_nominal=5, dp_nominal=5, redeclare package Medium = Medium) AixLib.Fluid.Delays.DelayFirstOrder del( m_flow_nominal=5, redeclare package Medium = Medium, nPorts=2, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, T_start=283.15) "Fluid volume that is a first order approximation of the transport delay" equation connect(P.y, sou.p_in) connect(PAtm.y, sin.p_in) connect(sou.ports[1], res1.port_a) connect(sin.ports[1], res2.port_b) connect(res1.port_b, del.ports[1]) connect(res2.port_a, del.ports[2]) end Delay;
Collection of models that illustrate model use and test models
within AixLib.Fluid.Delays; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Models for District Heating and Cooling networks
within AixLib.Fluid; package DistrictHeatingCooling "Models for District Heating and Cooling networks" end DistrictHeatingCooling;
Users' Guide for the District Heating and Cooling package
within AixLib.Fluid.DistrictHeatingCooling; model UsersGuide "Users' Guide for the District Heating and Cooling package" extends Modelica.Icons.Information; end UsersGuide;
Base classes for modular DHC system assembly
within AixLib.Fluid.DistrictHeatingCooling; package BaseClasses "Base classes for modular DHC system assembly" extends Modelica.Icons.BasesPackage; end BaseClasses;
Base classes for supply node models
within AixLib.Fluid.DistrictHeatingCooling.BaseClasses; package Supplies "Base classes for supply node models" extends Modelica.Icons.BasesPackage; end Supplies;
Base classes for open loop design supply models
within AixLib.Fluid.DistrictHeatingCooling.BaseClasses.Supplies; package OpenLoop "Base classes for open loop design supply models" extends Modelica.Icons.BasesPackage; end OpenLoop;
Base class for modeling supply nodes in DHC systems without return lines
within AixLib.Fluid.DistrictHeatingCooling.BaseClasses.Supplies.OpenLoop; partial model PartialSupply "Base class for modeling supply nodes in DHC systems without return lines" extends AixLib.Fluid.Interfaces.PartialTwoPort; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model" AixLib.Fluid.Sensors.TemperatureTwoPort senT_supply(redeclare package Medium = Medium, m_flow_nominal=1, tau=0) "Supply flow temperature sensor" AixLib.Fluid.Sensors.MassFlowRate senMasFlo(redeclare package Medium = Medium) "Mass flow rate sensor" Modelica.Blocks.Interfaces.RealInput TIn(unit="K") "Prescribed supply temperature" Modelica.Blocks.Interfaces.RealInput dpIn(unit="Pa") "Prescribed pressure rise" Sensors.TemperatureTwoPort senT_return(redeclare package Medium = Medium, m_flow_nominal=1, tau=0) "Return temperature sensor" equation connect(senMasFlo.port_a, senT_supply.port_b) connect(senMasFlo.port_b, port_b) connect(port_a, senT_return.port_b) end PartialSupply;
Demand nodes for DHC system models
within AixLib.Fluid.DistrictHeatingCooling; package Demands "Demand nodes for DHC system models" end Demands;
Substation model for bidirctional low-temperature networks for buildings with heat pump and chiller
within AixLib.Fluid.DistrictHeatingCooling.Demands.ClosedLoop; model DHCSubstationHeatPumpChiller "Substation model for bidirctional low-temperature networks for buildings with heat pump and chiller" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model for water" parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Nominal pressure drop"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=max(max((heaDem_max/( cp_default*deltaT_heaSecSet)), -cooDem_max/(cp_default*deltaT_cooSecSet)), 0.0001) "Nominal mass flow rate based on max. demand and set temperature difference"; parameter Modelica.Units.SI.HeatFlowRate heaDem_max "Maximum heat demand for scaling of heatpump in Watt" parameter Modelica.Units.SI.HeatFlowRate cooDem_max "Maximum cooling demand for scaling of chiller in Watt (negative values)" parameter Modelica.Units.SI.Temperature T_heaSecSet=273.15 + 55 "Set supply temperature for space heating on secondary side (building system)" parameter Modelica.Units.SI.TemperatureDifference deltaT_heaSecSet "Set temperature difference for heating on secondary site (building system)" parameter Modelica.Units.SI.Temperature T_cooSecSet=273.15 + 12 "Set supply temperature for cooling on secondary side (building system)" parameter Modelica.Units.SI.Temperature deltaT_cooSecSet "Set temperature difference for cooling on secondary site (building system)" parameter Modelica.Units.SI.Temperature deltaT_heaPriSet "Set temperature difference for heating on primary site (grid)" parameter Modelica.Units.SI.Temperature deltaT_cooPriSet "Set temperature difference for cooling on primary site (grid)" AixLib.Fluid.Delays.DelayFirstOrder vol( nPorts=2, redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) AixLib.Fluid.Delays.DelayFirstOrder vol1( nPorts=2, redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) AixLib.Fluid.Movers.FlowControlled_m_flow pumHea( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, addPowerToMedium=false, use_inputFilter=false, m_flow_nominal=m_flow_nominal) "decentral distribution pump for heating on primary side" AixLib.Fluid.Sources.MassFlowSource_T souHeaSec( use_m_flow_in=true, use_T_in=true, redeclare package Medium = Medium, nPorts=1) Modelica.Blocks.Sources.Constant T_heaPumInSec(k=T_heaSecSet - deltaT_heaSecSet) "Inlet temperatur of heat pump on secondary side" Sources.Boundary_pT sinHeaSec(redeclare package Medium = Medium, nPorts=1) Modelica.Blocks.Sources.Constant const(k=(cp_default*deltaT_heaSecSet)) Modelica.Blocks.Math.Division division public Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium) "Fluid connector for connecting the substation to the warm line of the network" Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium) "Fluid connector for connecting the substation to the cold line of the network" AixLib.Fluid.HeatPumps.Carnot_TCon heaPum(redeclare package Medium1 = Medium, redeclare package Medium2 = Medium, allowFlowReversal1=false, allowFlowReversal2=false, dp1_nominal=dp_nominal, dp2_nominal=dp_nominal, use_eta_Carnot_nominal=true, show_T=true, etaCarnot_nominal=0.5, QCon_flow_max=heaDem_max, QCon_flow_nominal=heaDem_max) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Interfaces.RealInput heaDem(unit="W") "Input for heat demand profile of substation" Modelica.Blocks.Math.Add add1(k2=-1) AixLib.Fluid.FixedResistances.Junction jun( redeclare package Medium = Medium, tau=60, dp_nominal={0,dp_nominal,dp_nominal}, portFlowDirection_1=Modelica.Fluid.Types.PortFlowDirection.Bidirectional, portFlowDirection_2=Modelica.Fluid.Types.PortFlowDirection.Bidirectional, portFlowDirection_3=Modelica.Fluid.Types.PortFlowDirection.Entering, m_flow_nominal=max(m_flow_nominal, 1)*{1,1,1}) AixLib.Fluid.FixedResistances.Junction jun1( redeclare package Medium = Medium, tau=60, dp_nominal={0,dp_nominal,dp_nominal}, portFlowDirection_3=Modelica.Fluid.Types.PortFlowDirection.Entering, m_flow_nominal=max(m_flow_nominal, 1)*{1,1,1}) AixLib.Fluid.Chillers.Carnot_TEva chi( redeclare package Medium1 = Medium, redeclare package Medium2 = Medium, allowFlowReversal1=false, allowFlowReversal2=false, use_eta_Carnot_nominal=true, dp1_nominal=dp_nominal, dp2_nominal=dp_nominal, etaCarnot_nominal=0.4, QEva_flow_min=cooDem_max, QEva_flow_nominal=cooDem_max) AixLib.Fluid.Movers.FlowControlled_m_flow pumCoo( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, addPowerToMedium=false, use_inputFilter=false, m_flow_nominal=m_flow_nominal) "decentral distribution pump for cooling on primary side" Modelica.Blocks.Interfaces.RealInput cooDem(unit="W") "Input for cooling demand profile of substation" AixLib.Fluid.Sources.MassFlowSource_T souCoo( use_m_flow_in=true, use_T_in=true, redeclare package Medium = Medium, nPorts=1) Sources.Boundary_pT sinCoo(redeclare package Medium = Medium, nPorts=1) Modelica.Blocks.Math.Add add2(k2=+1) Modelica.Blocks.Math.Division division2 Modelica.Blocks.Math.Division division3 Modelica.Blocks.Sources.Constant const2(k=cp_default*deltaT_cooSecSet) Modelica.Blocks.Interfaces.RealOutput P_el_heaPum(unit="W") "Power demand of heat pump" Modelica.Blocks.Interfaces.RealOutput P_el_chi(unit="W") "Power demand of chiller" Modelica.Blocks.Interfaces.RealOutput P_el_subSta(unit="W") "Power demand of substation for heat pump, chiller and distribution pumps on primary side (grid)" Modelica.Blocks.Math.Sum sum1(nin=4) Modelica.Blocks.Sources.Constant T_heaPumSet(k=T_heaSecSet) Modelica.Blocks.Sources.RealExpression realExpression2(y=heaPum.P) Modelica.Blocks.Sources.RealExpression realExpression1(y=heaDem) Modelica.Blocks.Sources.RealExpression realExpression(y=cp_default* deltaT_heaPriSet) Modelica.Blocks.Sources.RealExpression realExpression3(y=heaPum.P) Modelica.Blocks.Sources.RealExpression realExpression4(y=chi.P) Modelica.Blocks.Sources.RealExpression realExpression5(y=chi.P) Modelica.Blocks.Sources.Constant const3(k=cp_default*deltaT_cooPriSet) Modelica.Blocks.Sources.Constant T_chiSet(k=T_cooSecSet) Modelica.Blocks.Sources.RealExpression realExpression6(y=T_cooSecSet + deltaT_cooSecSet) protected final parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default properties"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid"; equation connect(port_a,vol. ports[1]) connect(port_b,vol1. ports[1]) connect(chi.port_b1, jun.port_3) connect(heaPum.port_b2, jun1.port_3) connect(pumHea.port_b, heaPum.port_a2) connect(chi.port_a1, pumCoo.port_b) connect(heaDem, add1.u1) connect(add1.y, division1.u1) connect(division1.y, pumHea.m_flow_in) connect(souHeaSec.ports[1], heaPum.port_a1) connect(sinHeaSec.ports[1], heaPum.port_b1) connect(division.u2, const.y) connect(division.y, souHeaSec.m_flow_in) connect(souCoo.ports[1], chi.port_a2) connect(chi.port_b2, sinCoo.ports[1]) connect(division2.u1, add2.y) connect(division2.y, pumCoo.m_flow_in) connect(const2.y, division3.u2) connect(division3.y, souCoo.m_flow_in) connect(port_a, port_a) connect(sum1.y, P_el_subSta) //Power Consumptin Calculation connect(chi.P, sum1.u[1]); connect(heaPum.P, sum1.u[2]); connect(pumCoo.P, sum1.u[3]); connect(pumHea.P, sum1.u[4]); connect(vol.ports[2], jun.port_1) connect(jun.port_2, pumHea.port_a) connect(jun1.port_2, pumCoo.port_a) connect(vol1.ports[2], jun1.port_1) connect(souHeaSec.T_in, T_heaPumInSec.y) connect(heaPum.TSet, T_heaPumSet.y) connect(realExpression2.y, add1.u2) connect(division.u1, realExpression1.y) connect(realExpression.y, division1.u2) connect(P_el_heaPum, realExpression3.y) connect(P_el_chi, realExpression4.y) connect(add2.u1, cooDem) connect(add2.u2, realExpression5.y) connect(division2.u2, const3.y) connect(division3.u1, cooDem) connect(chi.TSet, T_chiSet.y) connect(realExpression6.y, souCoo.T_in) end DHCSubstationHeatPumpChiller;
Substation model for bidirctional low-temperature networks for buildings with heat pump and direct cooling.
within AixLib.Fluid.DistrictHeatingCooling.Demands.ClosedLoop; model DHCSubstationHeatPumpDirectCooling "Substation model for bidirctional low-temperature networks for buildings with heat pump and direct cooling." replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model for water" parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Nominal pressure drop"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=m_flow_nominal "Nominal mass flow rate" parameter Modelica.Units.SI.HeatFlowRate heaDem_max "Maximum heat demand for scaling of heat pump" parameter Modelica.Units.SI.Temperature deltaT_heaSecSet=10 "Set temperature difference for heating on secondary site (building system)" parameter Modelica.Units.SI.Temperature T_heaSecSet=273.15 + 55 "Set supply temperature for space heating on secondary side (building)" parameter Modelica.Units.SI.Temperature T_heaPriSet=273.15 + 22 "Set temperature of primary side (warm line of grid)" parameter Modelica.Units.SI.Temperature T_cooPriSet=273.15 + 12 "Set temperature of primary side (cold line of grid)" Delays.DelayFirstOrder vol( nPorts=2, redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, tau=60) Delays.DelayFirstOrder vol1( nPorts=2, redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, tau=60) Movers.FlowControlled_m_flow pumHeaPri( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, addPowerToMedium=false, use_inputFilter=false, m_flow_nominal=m_flow_nominal) "decentral distribution pump for heating on primary side" Sources.MassFlowSource_T souHeaSec( use_m_flow_in=true, use_T_in=true, redeclare package Medium = Medium, nPorts=1) Modelica.Blocks.Sources.Constant T_heaPumInSec(k=T_heaSecSet - deltaT_heaSecSet) "Inlet temperatur of heat pump on secondary side" Sources.Boundary_pT sinHeaSec(redeclare package Medium = Medium, nPorts=1) Modelica.Blocks.Sources.Constant const(k=(cp_default*deltaT_heaSecSet)) Modelica.Blocks.Math.Division m_flow_heaSec "Mass flow rate on secondary side" HeatPumps.Carnot_TCon heaPum( redeclare package Medium1 = Medium, redeclare package Medium2 = Medium, dp1_nominal=dp_nominal, dp2_nominal=dp_nominal, use_eta_Carnot_nominal=true, show_T=true, etaCarnot_nominal=0.5, QCon_flow_nominal=heaDem_max) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression(y=(cp_default*( senT_heaPumInPri.T - T_cooPriSet))) Modelica.Blocks.Math.Add add1(k2=-1) FixedResistances.Junction jun( redeclare package Medium = Medium, dp_nominal={0,dp_nominal,dp_nominal}, portFlowDirection_1=Modelica.Fluid.Types.PortFlowDirection.Bidirectional, portFlowDirection_2=Modelica.Fluid.Types.PortFlowDirection.Bidirectional, portFlowDirection_3=Modelica.Fluid.Types.PortFlowDirection.Entering, m_flow_nominal=m_flow_nominal*{1,1,1}) FixedResistances.Junction jun1( redeclare package Medium = Medium, dp_nominal={0,dp_nominal,dp_nominal}, portFlowDirection_3=Modelica.Fluid.Types.PortFlowDirection.Entering, m_flow_nominal=m_flow_nominal*{1,1,1}) Delays.DelayFirstOrder dirCoo( nPorts=2, redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Ideal heat exchanger for direct cooling" Movers.FlowControlled_m_flow pumCoo( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, addPowerToMedium=false, use_inputFilter=false, m_flow_nominal=m_flow_nominal) "decentral distribution pump for cooling on primary side" Modelica.Blocks.Math.Division division2 Modelica.Blocks.Sources.RealExpression realExpression1(y=(cp_default*( T_heaPriSet - senT_dirCooInPri.T))) Modelica.Blocks.Sources.Constant T_heaPumSet(k=T_heaSecSet) Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow Sensors.TemperatureTwoPort senT_heaPumOutPri(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) Sensors.TemperatureTwoPort senT_heaPumInPri(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) Sensors.TemperatureTwoPort senT_heaPumOutSec(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Outlet temperature of heat pump on secondary side" Sensors.TemperatureTwoPort senT_heaPumInSec(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Inlet temperatur of heat pump on secondary side" Sensors.TemperatureTwoPort senT_dirCooInPri(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Inlet temperature of ideal heat exchanger for direct cooling on primary side" Sensors.TemperatureTwoPort senT_dirCooOutPri(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Outlet temperature of ideal heat exchanger for direct cooling on primary side" Modelica.Blocks.Sources.RealExpression realExpression2(y=heaPum.P) Modelica.Blocks.Sources.RealExpression realExpression3(y=heaPum.P) Modelica.Blocks.Sources.RealExpression realExpression4(y=heaDem) public Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium) "Fluid connector for connecting the substation to the warm line of the network" Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium) "Fluid connector for connecting the substation to the cold line of the network" Modelica.Blocks.Interfaces.RealInput heaDem(unit="W") "Input for heat demand profile of substation" Modelica.Blocks.Interfaces.RealInput cooDem(unit="W") "Input for cooling demand profile of substation" Modelica.Blocks.Interfaces.RealOutput P_el_heaPum(unit="W") "Electrical power consumed by heat pump" protected final parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default properties"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid"; equation connect(port_a,vol. ports[1]) connect(port_b,vol1. ports[1]) connect(heaDem, add1.u1) connect(add1.y,division1. u1) connect(realExpression.y,division1. u2) connect(m_flow_heaSec.u2, const.y) connect(m_flow_heaSec.y, souHeaSec.m_flow_in) connect(division2.u2,realExpression1. y) connect(port_a,port_a) connect(T_heaPumSet.y, heaPum.TSet) connect(dirCoo.ports[1], pumCoo.port_b) connect(cooDem, division2.u1) connect(prescribedHeatFlow.port, dirCoo.heatPort) connect(prescribedHeatFlow.Q_flow, cooDem) connect(pumHeaPri.port_b, senT_heaPumInPri.port_a) connect(senT_heaPumInPri.port_b, heaPum.port_a2) connect(heaPum.port_b2, senT_heaPumOutPri.port_a) connect(senT_heaPumOutPri.port_b, jun1.port_3) connect(senT_heaPumOutSec.port_a, heaPum.port_b1) connect(senT_heaPumOutSec.port_b, sinHeaSec.ports[1]) connect(senT_dirCooInPri.port_b, jun1.port_2) connect(division2.y, pumCoo.m_flow_in) connect(division1.y, pumHeaPri.m_flow_in) connect(senT_dirCooOutPri.port_b, dirCoo.ports[2]) connect(jun.port_3, senT_dirCooOutPri.port_a) connect(souHeaSec.T_in, T_heaPumInSec.y) connect(realExpression2.y,add1. u2) connect(senT_heaPumInSec.port_b, heaPum.port_a1) connect(senT_heaPumInSec.port_a, souHeaSec.ports[1]) connect(realExpression3.y, P_el_heaPum) connect(m_flow_heaSec.u1, realExpression4.y) connect(vol.ports[2], jun.port_1) connect(jun.port_2, pumHeaPri.port_a) connect(pumCoo.port_a, senT_dirCooInPri.port_a) connect(jun1.port_1, vol1.ports[2]) end DHCSubstationHeatPumpDirectCooling;
Substation with closed loop design
within AixLib.Fluid.DistrictHeatingCooling.Demands; package ClosedLoop "Substation with closed loop design" end ClosedLoop;
Fluid in the pipes
within AixLib.Fluid.DistrictHeatingCooling.Demands.Examples; model DHCSubstationHeatPumpChiller import AixLib; extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Fluid in the pipes"; AixLib.Fluid.Sources.Boundary_pT warmLine( redeclare package Medium = Medium, use_T_in=true, nPorts=1) "Warm Line of network" AixLib.Fluid.Sources.Boundary_pT coldLine( redeclare package Medium = Medium, use_T_in=true, nPorts=1) "Cold line of network" Modelica.Blocks.Sources.Constant T_coldLine(k=12 + 273.15) AixLib.Fluid.Sensors.TemperatureTwoPort senTem(redeclare package Medium = Medium, m_flow_nominal=2) AixLib.Fluid.Sensors.TemperatureTwoPort senTem1(redeclare package Medium = Medium, m_flow_nominal=2) Modelica.Blocks.Sources.Constant T_warmLine(k=22 + 273.15) Modelica.Blocks.Sources.TimeTable coolingDemand(table=[0,0; 3600,0; 3600,1500; 7200,1500; 7200,2000; 10800,1000; 14400,0; 18000,0; 18000,2000]) Modelica.Blocks.Sources.TimeTable heatDemand(table=[0,2000; 3600,2000; 3600,0; 7200,0; 7200,3000; 10800,4000; 14400,4000; 14400,2500; 18000,2500]) AixLib.Fluid.DistrictHeatingCooling.Demands.ClosedLoop.DHCSubstationHeatPumpChiller DHCsubstationHeatingDirectCooling( redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, m_flow_nominal=2, heaDem_max=4000, cooDem_max=-2500, deltaT_heaSecSet(displayUnit="K") = 10, T_heaSecSet=328.15, T_cooSecSet=285.15, deltaT_cooSecSet=279.15, deltaT_heaPriSet(displayUnit="K") = 5, deltaT_cooPriSet(displayUnit="K") = 5) equation connect(T_warmLine.y, warmLine.T_in) connect(senTem1.port_b, coldLine.ports[1]) connect(warmLine.ports[1], senTem.port_a) connect(T_coldLine.y, coldLine.T_in) connect(DHCsubstationHeatingDirectCooling.port_b, senTem1.port_a) connect(senTem.port_b, DHCsubstationHeatingDirectCooling.port_a) connect(coolingDemand.y, DHCsubstationHeatingDirectCooling.cooDem) connect(DHCsubstationHeatingDirectCooling.heaDem, heatDemand.y) end DHCSubstationHeatPumpChiller;
Fluid in the pipes
within AixLib.Fluid.DistrictHeatingCooling.Demands.Examples; model DHCSubstationHeatPumpDirectCooling import AixLib; extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Fluid in the pipes"; AixLib.Fluid.Sources.Boundary_pT warmLine( redeclare package Medium = Medium, use_T_in=true, nPorts=1) "Warm Line of network" AixLib.Fluid.Sources.Boundary_pT coldLine( redeclare package Medium = Medium, use_T_in=true, nPorts=1) "Cold line of network" Modelica.Blocks.Sources.Constant T_coldLine(k=12 + 273.15) AixLib.Fluid.Sensors.TemperatureTwoPort senTem(redeclare package Medium = Medium, m_flow_nominal=2) AixLib.Fluid.Sensors.TemperatureTwoPort senTem1(redeclare package Medium = Medium, m_flow_nominal=2) Modelica.Blocks.Sources.Constant T_warmLine(k=22 + 273.15) Modelica.Blocks.Sources.TimeTable coolingDemand(table=[0,0; 3600,0; 3600,1500; 7200,1500; 7200,2000; 10800,1000; 14400,0; 18000,0; 18000,2000]) Modelica.Blocks.Sources.TimeTable heatDemand(table=[0,2000; 3600,2000; 3600,0; 7200,0; 7200,3000; 10800,4000; 14400,4000; 14400,2500; 18000,2500]) AixLib.Fluid.DistrictHeatingCooling.Demands.ClosedLoop.DHCSubstationHeatPumpDirectCooling DHCsubstationHeatingDirectCooling( redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, m_flow_nominal=2, heaDem_max=4000, deltaT_heaSecSet=283.15, T_heaSecSet=328.15, T_heaPriSet=295.15, T_cooPriSet=285.15) equation connect(T_warmLine.y, warmLine.T_in) connect(senTem1.port_b, coldLine.ports[1]) connect(warmLine.ports[1], senTem.port_a) connect(T_coldLine.y, coldLine.T_in) connect(DHCsubstationHeatingDirectCooling.port_b, senTem1.port_a) connect(senTem.port_b, DHCsubstationHeatingDirectCooling.port_a) connect(coolingDemand.y, DHCsubstationHeatingDirectCooling.cooDem) connect(DHCsubstationHeatingDirectCooling.heaDem, heatDemand.y) end DHCSubstationHeatPumpDirectCooling;
A small open loop example with a heat pump in the substation
within AixLib.Fluid.DistrictHeatingCooling.Demands.Examples; model OpenLoopHeatPumpCarnot "A small open loop example with a heat pump in the substation" extends Modelica.Icons.Example; parameter Modelica.Units.SI.Temperature T_amb=283.15 "Ambient temperature around pipes"; package Medium = AixLib.Media.Specialized.Water.ConstantProperties_pT ( T_nominal=273.15+15, p_nominal=600000.0, T_default=273.15+15); Supplies.OpenLoop.SourceIdeal sourceIdeal( redeclare package Medium = Medium, TReturn=273.15 + 10, pReturn=200000) "Simple suppy model" .AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop.HeatPumpCarnot demand( redeclare package Medium = Medium, dp_nominal=50000, redeclare package MediumBuilding = Medium, dTBuilding=10, Q_flow_nominal=78239.1, dTDesign=10, TReturn=283.15, TSupplyBuilding=313.15) "Simple demand model" FixedResistances.PlugFlowPipe pipeSupply( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Supply pipe" FixedResistances.PlugFlowPipe pipeReturn( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Return pipe" Modelica.Blocks.Sources.Constant TSet(k=20 + 273.15) "Set supply temperature" Modelica.Blocks.Sources.Constant dpSet(k=1.4e5) "Set pressure difference for substation" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TGround "Ground temperature" Modelica.Blocks.Sources.Constant TGroundSet(k=10 + 273.15) "Set ground temperature" Modelica.Blocks.Sources.Sine sine( amplitude=12000, f=1/10000, offset=24000) "A sine wave for varying heat demands" Modelica.Blocks.Continuous.LimPID pControl(controllerType=Modelica.Blocks.Types.SimpleController.PI, yMax=6e5) "Pressure controller" equation connect(sourceIdeal.port_b, pipeSupply.port_a) connect(pipeSupply.port_b, demand.port_a) connect(demand.port_b, pipeReturn.port_a) connect(pipeReturn.port_b, sourceIdeal.port_a) connect(TSet.y, sourceIdeal.TIn) connect(TGroundSet.y, TGround.T) connect(TGround.port, pipeReturn.heatPort) connect(TGround.port, pipeSupply.heatPort) connect(demand.Q_flow_input, sine.y) connect(dpSet.y, pControl.u_s) connect(demand.dpOut, pControl.u_m) connect(pControl.y, sourceIdeal.dpIn) end OpenLoopHeatPumpCarnot;
A small open loop example with a Substation with variable dT for fixed return temperature
within AixLib.Fluid.DistrictHeatingCooling.Demands.Examples; model OpenLoopVarTSupplyDp "A small open loop example with a Substation with variable dT for fixed return temperature" extends Modelica.Icons.Example; parameter Modelica.Units.SI.Temperature T_amb=283.15 "Ambient temperature around pipes"; package Medium = AixLib.Media.Specialized.Water.ConstantProperties_pT ( T_nominal=273.15+60, p_nominal=600000.0, T_default=273.15+60); Supplies.OpenLoop.SourceIdeal sourceIdeal( redeclare package Medium = Medium, TReturn=273.15 + 60, pReturn=200000) "Simple suppy model" AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop.VarTSupplyDp demand( redeclare package Medium = Medium, dp_nominal=50000, Q_flow_nominal=78239.1, dTDesign=15, TReturn=333.15) "Simple demand model" FixedResistances.PlugFlowPipe pipeSupply( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Supply pipe" FixedResistances.PlugFlowPipe pipeReturn( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Return pipe" Modelica.Blocks.Sources.Constant TSet(k=75 + 273.15) "Set supply temperature" Modelica.Blocks.Sources.Constant dpSet(k=1.4e5) "Set pressure difference for substation" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TGround "Ground temperature" Modelica.Blocks.Sources.Constant TGroundSet(k=10 + 273.15) "Set ground temperature" Modelica.Blocks.Sources.Sine sine( amplitude=12000, f=1/10000, offset=24000) "A sine wave for varying heat demands" Modelica.Blocks.Continuous.LimPID pControl(controllerType=Modelica.Blocks.Types.SimpleController.PI, yMax=6e5) "Pressure controller" equation connect(sourceIdeal.port_b, pipeSupply.port_a) connect(pipeSupply.port_b, demand.port_a) connect(demand.port_b, pipeReturn.port_a) connect(pipeReturn.port_b, sourceIdeal.port_a) connect(TSet.y, sourceIdeal.TIn) connect(TGroundSet.y, TGround.T) connect(TGround.port, pipeReturn.heatPort) connect(TGround.port, pipeSupply.heatPort) connect(demand.Q_flow_input, sine.y) connect(dpSet.y, pControl.u_s) connect(demand.dpOut, pControl.u_m) connect(pControl.y, sourceIdeal.dpIn) end OpenLoopVarTSupplyDp;
A small open loop example with a Substation with variable dT for fixed return temperature
within AixLib.Fluid.DistrictHeatingCooling.Demands.Examples; model OpenLoopVarTSupplyDpBypass "A small open loop example with a Substation with variable dT for fixed return temperature" extends Modelica.Icons.Example; parameter Modelica.Units.SI.Temperature T_amb=283.15 "Ambient temperature around pipes"; package Medium = AixLib.Media.Specialized.Water.ConstantProperties_pT ( T_nominal=273.15+60, p_nominal=600000.0, T_default=273.15+60); Supplies.OpenLoop.SourceIdeal sourceIdeal( redeclare package Medium = Medium, TReturn=273.15 + 60, pReturn=200000) "Simple suppy model" AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop.VarTSupplyDpBypass demand( redeclare package Medium = Medium, dp_nominal=50000, Q_flow_nominal=78239.1, dTDesign=15, TReturn=283.15, m_flo_bypass=0.00) "Simple demand model" FixedResistances.PlugFlowPipe pipeSupply( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Supply pipe" FixedResistances.PlugFlowPipe pipeReturn( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Return pipe" Modelica.Blocks.Sources.Constant TSet(k=75 + 273.15) "Set supply temperature" Modelica.Blocks.Sources.Constant dpSet(k=1.4e5) "Set pressure difference for substation" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TGround "Ground temperature" Modelica.Blocks.Sources.Constant TGroundSet(k=10 + 273.15) "Set ground temperature" Modelica.Blocks.Sources.Sine sine( amplitude=12000, f=1/10000, offset=24000) "A sine wave for varying heat demands" Modelica.Blocks.Continuous.LimPID pControl(controllerType=Modelica.Blocks.Types.SimpleController.PI, yMax=6e5) "Pressure controller" equation connect(sourceIdeal.port_b, pipeSupply.port_a) connect(pipeSupply.port_b, demand.port_a) connect(demand.port_b, pipeReturn.port_a) connect(pipeReturn.port_b, sourceIdeal.port_a) connect(TSet.y, sourceIdeal.TIn) connect(TGroundSet.y, TGround.T) connect(TGround.port, pipeReturn.heatPort) connect(TGround.port, pipeSupply.heatPort) connect(demand.Q_flow_input, sine.y) connect(dpSet.y, pControl.u_s) connect(demand.dpOut, pControl.u_m) connect(pControl.y, sourceIdeal.dpIn) end OpenLoopVarTSupplyDpBypass;
A small open loop example with a Substation with variable supply temperature and fixed dT
within AixLib.Fluid.DistrictHeatingCooling.Demands.Examples; model OpenLoopVarTSupplyDpFixedTempDifferenceBypass "A small open loop example with a Substation with variable supply temperature and fixed dT" extends Modelica.Icons.Example; parameter Modelica.Units.SI.Temperature T_amb=283.15 "Ambient temperature around pipes"; package Medium = AixLib.Media.Specialized.Water.ConstantProperties_pT ( T_nominal=273.15+60, p_nominal=600000.0, T_default=273.15+60); Supplies.OpenLoop.SourceIdeal sourceIdeal( redeclare package Medium = Medium, TReturn=273.15 + 60, pReturn=200000) "Simple suppy model" AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop.VarTSupplyDpFixedTempDifferenceBypass demand( redeclare package Medium = Medium, dp_nominal=50000, Q_flow_nominal=78239.1, dTDesign=15, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, m_flo_bypass=0.003) "Simple demand model" FixedResistances.PlugFlowPipe pipeSupply( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Supply pipe" FixedResistances.PlugFlowPipe pipeReturn( redeclare package Medium = Medium, dh=0.05, length=50, m_flow_nominal=1, dIns=0.03, kIns=0.027) "Return pipe" Modelica.Blocks.Sources.Constant TSet(k=75 + 273.15) "Set supply temperature" Modelica.Blocks.Sources.Constant dpSet(k=1.4e5) "Set pressure difference for substation" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TGround "Ground temperature" Modelica.Blocks.Sources.Constant TGroundSet(k=10 + 273.15) "Set ground temperature" Modelica.Blocks.Sources.Sine sine( amplitude=12000, f=1/10000, offset=24000) "A sine wave for varying heat demands" Modelica.Blocks.Continuous.LimPID pControl(controllerType=Modelica.Blocks.Types.SimpleController.PI, yMax=6e5) "Pressure controller" equation connect(sourceIdeal.port_b, pipeSupply.port_a) connect(pipeSupply.port_b, demand.port_a) connect(demand.port_b, pipeReturn.port_a) connect(pipeReturn.port_b, sourceIdeal.port_a) connect(TSet.y, sourceIdeal.TIn) connect(TGroundSet.y, TGround.T) connect(TGround.port, pipeReturn.heatPort) connect(TGround.port, pipeSupply.heatPort) connect(demand.Q_flow_input, sine.y) connect(dpSet.y, pControl.u_s) connect(demand.dpOut, pControl.u_m) connect(pControl.y, sourceIdeal.dpIn) end OpenLoopVarTSupplyDpFixedTempDifferenceBypass;
<html><p> This package contains examples for the use of models that can be found in <a href= \
within AixLib.Fluid.DistrictHeatingCooling.Demands; package Examples extends Modelica.Icons.ExamplesPackage; end Examples;
Substation with a heat pump carnot model
within AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop; model HeatPumpCarnot "Substation with a heat pump carnot model" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface( final m_flow(start=0), final dp(start=0), final allowFlowReversal=false, final m_flow_nominal = Q_flow_nominal/cp_default/dTDesign); replaceable package MediumBuilding = Modelica.Media.Interfaces.PartialMedium "Medium in the building heating system" parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal "Nominal heat flow rate added to medium"; parameter Modelica.Units.SI.TemperatureDifference dTDesign(displayUnit="K") "Design temperature difference for the heat pump on its district heating side"; parameter Modelica.Units.SI.Temperature TReturn "Fixed return temperature"; parameter Modelica.Units.SI.TemperatureDifference dTBuilding(displayUnit="K") "Design temperature difference for the building's heating system"; parameter Modelica.Units.SI.Temperature TSupplyBuilding "Fixed supply temperature for the building heating system"; parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Pressure difference at nominal flow rate" parameter Real deltaM=0.1 "Fraction of nominal flow rate where flow transitions to laminar" parameter Modelica.Units.SI.Time tau=30 "Time constant at nominal flow (if energyDynamics <> SteadyState)" parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState "Type of energy balance: dynamic (3 initialization options) or steady state" parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state" protected final parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default properties"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid in the district heating system"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default_building= MediumBuilding.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid in the building heating system"; public Modelica.Blocks.Interfaces.RealInput Q_flow_input "Prescribed heat flow" Sensors.TemperatureTwoPort senT_supply(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Supply flow temperature sensor" Sensors.TemperatureTwoPort senT_return(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Return flow temperature sensor" Modelica.Blocks.Math.Add deltaT(k2=-1) "Differernce of flow and return line temperature in K" Modelica.Blocks.Sources.Constant dTheaPum(k=dTDesign) "Temperature drop over heat pump in K" Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) Modelica.Blocks.Math.Division hea2MasFlo Sources.MassFlowSource_T sink( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1) "Sink extracting prescribed flow from the network" Modelica.Blocks.Math.Gain changeSign(k=-1) "Changes sign of prescribed flow for extraction from network" Sources.MassFlowSource_T source( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1, T=TReturn, use_T_in=true) "Source sending prescribed flow back to the network" Modelica.Blocks.Interfaces.RealOutput dpOut "Output signal of pressure difference" HeatPumps.Carnot_TCon heaPum( redeclare package Medium1 = MediumBuilding, dp1_nominal=dp_nominal, dp2_nominal=dp_nominal, use_eta_Carnot_nominal=true, etaCarnot_nominal=0.3, show_T=true, redeclare package Medium2 = Medium, QCon_flow_nominal=Q_flow_nominal) Modelica.Blocks.Math.Add Q_con(k2=-1) "Differernce of heat demand and electric power of heat pump" Sources.MassFlowSource_T sourceHeating( use_m_flow_in=true, redeclare package Medium = MediumBuilding, use_T_in=true, nPorts=1) Sources.Boundary_pT sinkHeating( redeclare package Medium = MediumBuilding, nPorts=1) Modelica.Blocks.Math.Gain masFloBuilding(k=1/(cp_default_building*dTBuilding)) "Changes sign of prescribed flow for extraction from network" Modelica.Blocks.Sources.Constant temperatureSupplyBuilding(k=TSupplyBuilding) "Temperature of supply line" Modelica.Blocks.Sources.Constant deltaTBuilding(k=dTBuilding) "Temperature difference in building heating system" Modelica.Blocks.Math.Add temperatureReturnBuilding(k2=-1) "Temperature returning from building heating system" Modelica.Blocks.Math.Gain gainInput(k=1) "Optional gain on the input" Modelica.Blocks.Sources.Constant minT_return(k=273.15 + 10) "Minimal return Temperature" Modelica.Blocks.Math.Max max equation dpOut = dp; connect(port_a, senT_supply.port_a) connect(port_b, senT_return.port_b) connect(gain.y, hea2MasFlo.u2) connect(source.ports[1], senT_return.port_a) connect(hea2MasFlo.y, changeSign.u) connect(changeSign.y, sink.m_flow_in) connect(hea2MasFlo.y, source.m_flow_in) connect(senT_supply.port_b, heaPum.port_a2) connect(sink.ports[1], heaPum.port_b2) connect(Q_con.y, hea2MasFlo.u1) connect(heaPum.P, Q_con.u2) connect(masFloBuilding.y, sourceHeating.m_flow_in) connect(temperatureSupplyBuilding.y, heaPum.TSet) connect(sourceHeating.T_in, temperatureReturnBuilding.y) connect(temperatureSupplyBuilding.y, temperatureReturnBuilding.u1) connect(deltaTBuilding.y, temperatureReturnBuilding.u2) connect(sinkHeating.ports[1], heaPum.port_b1) connect(heaPum.port_a1, sourceHeating.ports[1]) connect(dTheaPum.y, gain.u) connect(senT_supply.T, deltaT.u1) connect(dTheaPum.y, deltaT.u2) connect(Q_flow_input, gainInput.u) connect(Q_con.u1, gainInput.y) connect(gainInput.y,masFloBuilding. u) connect(deltaT.y, max.u2) connect(minT_return.y, max.u1) connect(max.y, source.T_in) end HeatPumpCarnot;
Substation with an open loop design
within AixLib.Fluid.DistrictHeatingCooling.Demands; package OpenLoop "Substation with an open loop design" end OpenLoop;
Substation with variable dT for fixed return temperature
within AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop; model VarTSupplyDp "Substation with variable dT for fixed return temperature" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface( final m_flow(start=0), final dp(start=0), final allowFlowReversal=false, final m_flow_nominal = Q_flow_nominal/cp_default/dTDesign); parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal "Nominal heat flow rate added to medium"; parameter Modelica.Units.SI.TemperatureDifference dTDesign(displayUnit="K") "Design temperature difference for the substation's heat exchanger"; parameter Modelica.Units.SI.Temperature TReturn "Fixed return temperature"; parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Pressure difference at nominal flow rate" parameter Real deltaM=0.1 "Fraction of nominal flow rate where flow transitions to laminar" parameter Modelica.Units.SI.Time tau=30 "Time constant at nominal flow (if energyDynamics <> SteadyState)" parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState "Type of energy balance: dynamic (3 initialization options) or steady state" parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state" protected final parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default properties"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid"; public Modelica.Blocks.Interfaces.RealInput Q_flow_input "Prescribed heat flow" Sensors.TemperatureTwoPort senT_supply(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Supply flow temperature sensor" Sensors.TemperatureTwoPort senT_return(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Return flow temperature sensor" Modelica.Blocks.Math.Add deltaT(k1=+1, k2=-1) "Differernce of flow and return line temperature in K" Modelica.Blocks.Sources.Constant temRet(k=TReturn) "Temperature of return line in °C" Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) Modelica.Blocks.Math.Division hea2MasFlo Sources.MassFlowSource_T sink( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1) "Sink extracting prescribed flow from the network" Modelica.Blocks.Math.Gain changeSign(k=-1) "Changes sign of prescribed flow for extraction from network" Sources.MassFlowSource_T source( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1, T=TReturn, use_T_in=true) "Source sending prescribed flow back to the network" Modelica.Blocks.Interfaces.RealOutput dpOut "Output signal of pressure difference" Modelica.Blocks.Sources.Constant mindeltaT(k=20) "Temperature of return line in °C" Modelica.Blocks.Math.Max max Modelica.Blocks.Math.Min min Modelica.Blocks.Sources.Constant temRet_nominal(k=TReturn) "Temperature of return line in °C" Modelica.Blocks.Math.Add deltaT1(k1=+1, k2=-1) "Differernce of flow and return line temperature in K" equation dpOut = dp; connect(port_a, senT_supply.port_a) connect(port_b, senT_return.port_b) connect(temRet.y, deltaT.u2) connect(gain.y, hea2MasFlo.u2) connect(Q_flow_input, hea2MasFlo.u1) connect(source.ports[1], senT_return.port_a) connect(hea2MasFlo.y, changeSign.u) connect(changeSign.y, sink.m_flow_in) connect(hea2MasFlo.y, source.m_flow_in) connect(senT_supply.port_b, sink.ports[1]) connect(senT_supply.T, deltaT.u1) connect(max.y, gain.u) connect(deltaT.y, max.u1) connect(mindeltaT.y, max.u2) connect(min.y, source.T_in) connect(temRet_nominal.y, min.u1) connect(deltaT1.y, min.u2) connect(senT_supply.T, deltaT1.u1) connect(mindeltaT.y, deltaT1.u2) end VarTSupplyDp;
Substation with variable dT for fixed return temperature
within AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop; model VarTSupplyDpBypass "Substation with variable dT for fixed return temperature" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface( final m_flow(start=0), final dp(start=0), final allowFlowReversal=false, final m_flow_nominal = Q_flow_nominal/cp_default/dTDesign); parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal "Nominal heat flow rate added to medium"; parameter Modelica.Units.SI.TemperatureDifference dTDesign(displayUnit="K") "Design temperature difference for the substation's heat exchanger"; parameter Modelica.Units.SI.Temperature TReturn "Fixed return temperature"; parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Pressure difference at nominal flow rate" parameter Real deltaM=0.1 "Fraction of nominal flow rate where flow transitions to laminar" parameter Modelica.Units.SI.Time tau=30 "Time constant at nominal flow (if energyDynamics <> SteadyState)" parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState "Type of energy balance: dynamic (3 initialization options) or steady state" parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state" parameter Modelica.Units.SI.MassFlowRate m_flo_bypass "Minimum bypass flow through substation"; protected final parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default properties"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid"; public Modelica.Blocks.Interfaces.RealInput Q_flow_input "Prescribed heat flow" Sensors.TemperatureTwoPort senT_supply(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Supply flow temperature sensor" Sensors.TemperatureTwoPort senT_return(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Return flow temperature sensor" Modelica.Blocks.Math.Add deltaT(k1=+1, k2=-1) "Differernce of flow and return line temperature in K" Modelica.Blocks.Sources.Constant temRet(k=TReturn) "Temperature of return line in °C" Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) Modelica.Blocks.Math.Division hea2MasFlo Sources.MassFlowSource_T sink( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1) "Sink extracting prescribed flow from the network" Modelica.Blocks.Math.Gain changeSign(k=-1) "Changes sign of prescribed flow for extraction from network" Sources.MassFlowSource_T source( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1, T=TReturn, use_T_in=true) "Source sending prescribed flow back to the network" Modelica.Blocks.Interfaces.RealOutput dpOut "Output signal of pressure difference" Modelica.Blocks.Sources.Constant mindeltaT(k=20) "Temperature of return line in °C" Modelica.Blocks.Math.Max max Modelica.Blocks.Math.Min min Modelica.Blocks.Sources.Constant temRet_nominal(k=TReturn) "Temperature of return line in °C" Modelica.Blocks.Math.Add deltaT1(k1=+1, k2=-1) "Differernce of flow and return line temperature in K" Modelica.Blocks.Sources.RealExpression m_flo_min(y=m_flo_bypass) Utilities.Math.SmoothMax smoothMax(deltaX=0.001) Modelica.Blocks.Logical.LessEqualThreshold lessEqualThreshold(threshold= m_flo_bypass) Utilities.Logical.SmoothSwitch switch1 equation dpOut = dp; connect(port_a, senT_supply.port_a) connect(port_b, senT_return.port_b) connect(temRet.y, deltaT.u2) connect(gain.y, hea2MasFlo.u2) connect(Q_flow_input, hea2MasFlo.u1) connect(source.ports[1], senT_return.port_a) connect(changeSign.y, sink.m_flow_in) connect(senT_supply.port_b, sink.ports[1]) connect(senT_supply.T, deltaT.u1) connect(max.y, gain.u) connect(deltaT.y, max.u1) connect(mindeltaT.y, max.u2) connect(temRet_nominal.y, min.u1) connect(deltaT1.y, min.u2) connect(senT_supply.T, deltaT1.u1) connect(mindeltaT.y, deltaT1.u2) connect(smoothMax.y, changeSign.u) connect(hea2MasFlo.y, smoothMax.u2) connect(m_flo_min.y, smoothMax.u1) connect(smoothMax.y, lessEqualThreshold.u) connect(lessEqualThreshold.y, switch1.u2) connect(min.y, switch1.u3) connect(senT_supply.T, switch1.u1) connect(switch1.y, source.T_in) connect(changeSign.y, source.m_flow_in) end VarTSupplyDpBypass;
Substation with variable supply temperature and fixed dT
within AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop; model VarTSupplyDpFixedTempDifferenceBypass "Substation with variable supply temperature and fixed dT" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface( final m_flow(start=0), final dp(start=0), final allowFlowReversal=false, final m_flow_nominal = Q_flow_nominal/cp_default/dTDesign); parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal "Nominal heat flow rate added to medium"; parameter Modelica.Units.SI.TemperatureDifference dTDesign(displayUnit="K") "Constant temperature difference for the substation's heat exchanger"; parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Pressure difference at nominal flow rate" parameter Real deltaM=0.1 "Fraction of nominal flow rate where flow transitions to laminar" parameter Modelica.Units.SI.Time tau=30 "Time constant at nominal flow (if energyDynamics <> SteadyState)" parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState "Type of energy balance: dynamic (3 initialization options) or steady state" parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state" parameter Modelica.Units.SI.MassFlowRate m_flo_bypass "Minimum bypass flow through substation"; protected final parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default properties"; final parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(sta_default) "Specific heat capacity of the fluid"; public Modelica.Blocks.Interfaces.RealInput Q_flow_input "Prescribed heat flow" Sensors.TemperatureTwoPort senT_supply(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Supply flow temperature sensor" Sensors.TemperatureTwoPort senT_return(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Return flow temperature sensor" Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) Modelica.Blocks.Math.Division hea2MasFlo Sources.MassFlowSource_T sink( redeclare package Medium = Medium, use_m_flow_in=true, nPorts=1) "Sink extracting prescribed flow from the network" Modelica.Blocks.Math.Gain changeSign(k=-1) "Changes sign of prescribed flow for extraction from network" Sources.MassFlowSource_T source( redeclare package Medium = Medium, use_m_flow_in=true, use_T_in=true, nPorts=1) "Source sending prescribed flow back to the network" Modelica.Blocks.Interfaces.RealOutput dpOut "Output signal of pressure difference" Modelica.Blocks.Sources.Constant deltaT(k=dTDesign) "Fixed temperature difference between supply and return" Modelica.Blocks.Math.Add temRet(k1=-1, k2=+1) Utilities.Math.SmoothMax smoothMax(deltaX=0.001) Modelica.Blocks.Sources.RealExpression m_flo_min(y=m_flo_bypass) Utilities.Logical.SmoothSwitch switch1 Modelica.Blocks.Logical.LessEqualThreshold lessEqualThreshold(threshold= m_flo_bypass) MixingVolumes.MixingVolume vol( energyDynamics=energyDynamics, nPorts=2, redeclare package Medium = Medium, m_flow_nominal=1, V=m_flow_nominal*30/995.58) equation dpOut = dp; connect(port_a, senT_supply.port_a) connect(port_b, senT_return.port_b) connect(Q_flow_input, hea2MasFlo.u1) connect(changeSign.y, sink.m_flow_in) connect(senT_supply.port_b, sink.ports[1]) connect(deltaT.y, gain.u) connect(deltaT.y, temRet.u1) connect(senT_supply.T, temRet.u2) connect(gain.y, hea2MasFlo.u2) connect(smoothMax.y, changeSign.u) connect(smoothMax.y, source.m_flow_in) connect(smoothMax.u1, hea2MasFlo.y) connect(m_flo_min.y, smoothMax.u2) connect(lessEqualThreshold.y, switch1.u2) connect(smoothMax.y, lessEqualThreshold.u) connect(senT_supply.T, switch1.u1) connect(temRet.y, switch1.u3) connect(switch1.y, source.T_in) connect(source.ports[1], vol.ports[1]) connect(vol.ports[2], senT_return.port_a) end VarTSupplyDpFixedTempDifferenceBypass;
Generic pipe model for DHC applications
within AixLib.Fluid.DistrictHeatingCooling.Pipes; model DHCPipe "Generic pipe model for DHC applications" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" parameter Boolean use_soil=false "= true 3 cylindric heat transfers are implemented, representing the soil around the pipe, otherwise direct heat throughzeta value has to be given next" parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)" parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/ v_nominal/Modelica.Constants.pi) "Hydraulic diameter (assuming a round cross section area)" parameter Modelica.Units.SI.Velocity v_nominal=1.5 "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)" parameter Modelica.Units.SI.Length length "Pipe length" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate" parameter Modelica.Units.SI.MassFlowRate m_flow_small=1E-4*abs(m_flow_nominal) "Small mass flow rate for regularization of zero flow" parameter Modelica.Units.SI.Length dIns "Thickness of pipe insulation, used to compute R" parameter Modelica.Units.SI.ThermalConductivity kIns "Heat conductivity of pipe insulation, used to compute R" parameter Modelica.Units.SI.SpecificHeatCapacity cPip=2300 "Specific heat of pipe wall material. 2300 for PE, 500 for steel" parameter Modelica.Units.SI.Density rhoPip(displayUnit="kg/m3") = 930 "Density of pipe wall material. 930 for PE, 8000 for steel" parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= T_start_in "Initialization temperature at pipe outlet" parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 "Initial value of mass flow rate through pipe" parameter Real R(unit="(m.K)/W")=1/(kIns*2*Modelica.Constants.pi/ Modelica.Math.log((dh/2 + dIns)/(dh/2))) "Thermal resistance per unit length from fluid to boundary temperature" parameter Real fac= 1.0 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal" parameter Real sum_zetas=0 "Sum of all zeta values. Takes into account additional pressure drops due to bends/valves/etc. if use_zeta" constant Boolean homotopyInitialization = true "= true, use homotopy method" parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate" //Ground/Soil: values for sandy soil with clay content based on "SIMULATIONSMODELL //"ERDWÄRMEKOLLEKTOR" zur wärmetechnischen Beurteilung von Wärmequellen, //Wärmesenken und Wärme-/Kältespeichern" by Bernd Glück --> move to docu parameter Modelica.Units.SI.Density rho_soi=1630 "Density of material/soil" parameter Modelica.Units.SI.SpecificHeatCapacity c=1046 "Specific heat capacity of material/soil" parameter Modelica.Units.SI.Length thickness_soi=0.6 "thickness of soil layer for heat loss calulcation" parameter Modelica.Units.SI.ThermalConductivity lambda=1.5 "Heat conductivity of material/soil" final parameter Modelica.Units.SI.Length d_in=dh + 2*thickness "Inner diameter of pipe" final parameter Modelica.Units.SI.Temperature T0=289.15 "Initial temperature" parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state" Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat transfer to or from surroundings (heat loss from pipe results in a positive heat flow)" replaceable AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowCore pipCor( redeclare final package Medium = Medium, final dh=dh, final v_nominal=v_nominal, final length=length, final C=C, final R=R, final m_flow_small=m_flow_small, final m_flow_nominal=m_flow_nominal, final T_start_in=T_start_in, final T_start_out=T_start_out, final m_flow_start=m_flow_start, final initDelay=initDelay, final from_dp=from_dp, final fac=if not use_zeta then fac else 1.0, final ReC=ReC, final thickness=thickness, final roughness=roughness, final allowFlowReversal=allowFlowReversal, final homotopyInitialization=homotopyInitialization, final linearized=linearized) constrainedby Interfaces.PartialTwoPort( redeclare package Medium = Medium, dh=dh, v_nominal=v_nominal, length=length, C=C, R=R, m_flow_small=m_flow_small, m_flow_nominal=m_flow_nominal, T_start_in=T_start_in, T_start_out=T_start_out, m_flow_start=m_flow_start, initDelay=initDelay, from_dp=from_dp, fac=if not use_zeta then fac else 1.0, ReC=ReC, thickness=thickness, roughness=roughness, allowFlowReversal=allowFlowReversal, homotopyInitialization=homotopyInitialization, linearized=linearized) "Describing the pipe behavior" // In the volume, below, we scale down V and use // mSenFac. Otherwise, for air, we would get very large volumes // which affect the delay of water vapor and contaminants. // See also AixLib.Fluid.FixedResistances.Validation.PlugFlowPipes.TransportWaterAir // for why mSenFac is 10 and not 1000, as this gives more reasonable // temperature step response 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=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac = if rho_default > 500 then 1 else 10) "Control volume connected to ports_b. Represents equivalent pipe wall thermal capacity." AixLib.Utilities.HeatTransfer.CylindricHeatTransfer cylHeaTra1( final energyDynamics=energyDynamics, final rho=rho_soi, final c=c, final d_in=dh + 2*thickness, final d_out=d_in + thickness_soi/3, final length=length, final lambda=lambda, T0=283.15) if use_soil AixLib.Utilities.HeatTransfer.CylindricHeatTransfer cylHeaTra2( final energyDynamics=energyDynamics, final rho=rho_soi, final c=c, final d_in=dh + 2*thickness + thickness_soi/3, final d_out=d_in + 2*thickness_soi/3, final length=length, final lambda=lambda, T0=283.15) if use_soil AixLib.Utilities.HeatTransfer.CylindricHeatTransfer cylHeaTra3( final energyDynamics=energyDynamics, final rho=rho_soi, final c=c, final d_in=dh + 2*thickness + 2*thickness_soi/3, final d_out=d_in + thickness_soi, final length=length, final lambda=lambda, T0=283.15) if use_soil protected parameter Modelica.Units.SI.HeatCapacity CPip=length*((dh + 2*thickness)^2 - dh^2)*Modelica.Constants.pi/4*cPip*rhoPip "Heat capacity of pipe wall"; final parameter Modelica.Units.SI.Volume VEqu=CPip/(rho_default*cp_default) "Equivalent water volume to represent pipe wall thermal inertia"; parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default) "Default medium state"; parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=sta_default) "Heat capacity of medium"; parameter Real C(unit="J/(K.m)")= rho_default*Modelica.Constants.pi*(dh/2)^2*cp_default "Thermal capacity per unit length of water in pipe"; parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)" Modelica.Units.SI.Velocity v_med "Velocity of the medium in the pipe"; Modelica.Units.SI.Heat Q_los(start=0.0, fixed=true) "Integrated heat loss of the pipe"; Modelica.Units.SI.Heat Q_gai(start=0.0, fixed=true) "Integrated heat gain of the pipe"; public FixedResistances.HydraulicResistance hydRes( diameter=dh, m_flow_nominal=m_flow_nominal, redeclare package Medium = Medium, zeta=sum_zetas, allowFlowReversal=allowFlowReversal, from_dp=from_dp, homotopyInitialization=homotopyInitialization, linearized=linearized, m_flow_start=m_flow_start) if use_zeta Modelica.Thermal.HeatTransfer.Components.ThermalCollector thePasThr(final m=1) if not use_soil "Thermal pass through if there is no soil activated" Interfaces.PassThroughMedium pasThrMed(redeclare package Medium = Medium) if not use_zeta equation //calculation of the flow velocity of water in the pipes v_med = (4 * port_a.m_flow) / (Modelica.Constants.pi * rho_default * dh * dh); //calculation of heat losses and heat gains of pipe der(Q_los) = min(0, pipCor.heatPort.Q_flow); der(Q_gai) = max(0, pipCor.heatPort.Q_flow); connect(vol.ports[2], port_b) connect(pipCor.port_b, vol.ports[1]) connect(pipCor.heatPort, cylHeaTra1.port_a) connect(cylHeaTra1.port_b, cylHeaTra2.port_a) connect(cylHeaTra2.port_b, cylHeaTra3.port_a) connect(cylHeaTra3.port_b, heatPort) connect(pipCor.heatPort, thePasThr.port_a[1]) connect(thePasThr.port_b, heatPort) connect(port_a, hydRes.port_a) connect(hydRes.port_b, pipCor.port_a) connect(port_a, port_a) connect(port_a, pasThrMed.port_a) connect(pasThrMed.port_b, pipCor.port_a) end DHCPipe;
Models for DHC systems' pipe networks
within AixLib.Fluid.DistrictHeatingCooling; package Pipes "Models for DHC systems' pipe networks" end Pipes;
Embedded pipe model using spatialDistribution for temperature delay
within AixLib.Fluid.DistrictHeatingCooling.Pipes; model PlugFlowPipeEmbedded "Embedded pipe model using spatialDistribution for temperature delay" 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" parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)" parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/ v_nominal/Modelica.Constants.pi) "Hydraulic diameter (assuming a round cross section area)" parameter Modelica.Units.SI.Velocity v_nominal=1.5 "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)" parameter Modelica.Units.SI.Length length "Pipe length" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate" parameter Modelica.Units.SI.MassFlowRate m_flow_small=1E-4*abs(m_flow_nominal) "Small mass flow rate for regularization of zero flow" parameter Modelica.Units.SI.Length dIns "Thickness of pipe insulation, used to compute R" parameter Modelica.Units.SI.ThermalConductivity kIns "Heat conductivity of pipe insulation, used to compute R" parameter Modelica.Units.SI.SpecificHeatCapacity cPip=2300 "Specific heat of pipe wall material. 2300 for PE, 500 for steel" parameter Modelica.Units.SI.Density rhoPip(displayUnit="kg/m3") = 930 "Density of pipe wall material. 930 for PE, 8000 for steel" parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= T_start_in "Initialization temperature at pipe outlet" parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 "Initial value of mass flow rate through pipe" parameter Real R(unit="(m.K)/W")=1/(kIns*2*Modelica.Constants.pi/ Modelica.Math.log((dh/2 + dIns)/(dh/2))) "Thermal resistance per unit length from fluid to boundary temperature" parameter Real fac=1 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal" parameter Real sum_zetas=0 "Sum of all zeta values. Takes into account additional pressure drops due to bends/valves/etc." constant Boolean homotopyInitialization = true "= true, use homotopy method" parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate" //Ground/Soil: values for sandy soil with clay content based on "SIMULATIONSMODELL //"ERDWÄRMEKOLLEKTOR" zur wärmetechnischen Beurteilung von Wärmequellen, //Wärmesenken und Wärme-/Kältespeichern" by Bernd Glück parameter Modelica.Units.SI.Density rho_soi=1630 "Density of material/soil" parameter Modelica.Units.SI.SpecificHeatCapacity c=1046 "Specific heat capacity of material/soil" parameter Modelica.Units.SI.Length thickness_soi=0.6 "thickness of soil layer for heat loss calulcation" parameter Modelica.Units.SI.ThermalConductivity lambda=1.5 "Heat conductivity of material/soil" final parameter Modelica.Units.SI.Length d_in=dh + 2*thickness "Inner diameter of pipe" final parameter Integer nParallel = 1 "Number of identical parallel pipes" final parameter Modelica.Units.SI.Temperature T0=289.15 "Initial temperature" Modelica.Units.SI.Velocity v_med "Velocity of the medium in the pipe"; AixLib.Fluid.DistrictHeatingCooling.Pipes.PlugFlowPipeZeta plugFlowPipeZeta( redeclare final package Medium = Medium, final dh=dh, final v_nominal=v_nominal, final ReC=ReC, final roughness=roughness, final length=length, final m_flow_nominal=m_flow_nominal, final dIns=dIns, final kIns=kIns, final cPip=cPip, final rhoPip=rhoPip, final thickness=thickness, final R=R, final fac=fac, final sum_zetas=sum_zetas, final use_zeta=true) Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat transfer to or from surroundings (heat loss from pipe results in a positive heat flow)" AixLib.Utilities.HeatTransfer.CylindricHeatTransfer cylindricHeatTransfer_1( final energyDynamics=energyDynamics, final rho=rho_soi, final c=c, final d_in=dh + 2*thickness, final d_out=d_in + thickness_soi/3, final length=length, final lambda=lambda, T0=283.15) AixLib.Utilities.HeatTransfer.CylindricHeatTransfer cylindricHeatTransfer_2( final energyDynamics=energyDynamics, final rho=rho_soi, final c=c, final d_in=dh + 2*thickness + thickness_soi/3, final d_out=d_in + 2*thickness_soi/3, final length=length, final lambda=lambda, T0=283.15) AixLib.Utilities.HeatTransfer.CylindricHeatTransfer cylindricHeatTransfer_3( final energyDynamics=energyDynamics, final rho=rho_soi, final c=c, final d_in=dh + 2*thickness + 2*thickness_soi/3, final d_out=d_in + thickness_soi, final length=length, final lambda=lambda, T0=283.15) protected parameter Modelica.Units.SI.HeatCapacity CPip=length*((dh + 2*thickness)^2 - dh^2)*Modelica.Constants.pi/4*cPip*rhoPip "Heat capacity of pipe wall"; final parameter Modelica.Units.SI.Volume VEqu=CPip/(rho_default*cp_default) "Equivalent medium volume to represent pipe wall thermal inertia"; parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default) "Default medium state"; parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=sta_default) "Heat capacity of medium"; parameter Real C(unit="J/(K.m)")= rho_default*Modelica.Constants.pi*(dh/2)^2*cp_default "Thermal capacity per unit length of medium in pipe"; parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)" 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); connect(plugFlowPipeZeta.heatPort, cylindricHeatTransfer_1.port_a) connect(cylindricHeatTransfer_1.port_b, cylindricHeatTransfer_2.port_a) connect(cylindricHeatTransfer_2.port_b,cylindricHeatTransfer_3. port_a) connect(cylindricHeatTransfer_3.port_b, heatPort) connect(port_a, plugFlowPipeZeta.port_a) connect(plugFlowPipeZeta.port_b, port_b) end PlugFlowPipeEmbedded;
Pipe model using spatialDistribution for temperature delay and conditional HydraulicResistance
within AixLib.Fluid.DistrictHeatingCooling.Pipes; model PlugFlowPipeZeta "Pipe model using spatialDistribution for temperature delay and conditional HydraulicResistance" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)" parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/ v_nominal/Modelica.Constants.pi) "Hydraulic diameter (assuming a round cross section area)" parameter Modelica.Units.SI.Velocity v_nominal=1.5 "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)" parameter Modelica.Units.SI.Length length "Pipe length" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate" parameter Modelica.Units.SI.MassFlowRate m_flow_small=1E-4*abs(m_flow_nominal) "Small mass flow rate for regularization of zero flow" parameter Modelica.Units.SI.Length dIns "Thickness of pipe insulation, used to compute R" parameter Modelica.Units.SI.ThermalConductivity kIns "Heat conductivity of pipe insulation, used to compute R" parameter Modelica.Units.SI.SpecificHeatCapacity cPip=2300 "Specific heat of pipe wall material. 2300 for PE, 500 for steel" parameter Modelica.Units.SI.Density rhoPip(displayUnit="kg/m3") = 930 "Density of pipe wall material. 930 for PE, 8000 for steel" parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= T_start_in "Initialization temperature at pipe outlet" parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 "Initial value of mass flow rate through pipe" parameter Real R(unit="(m.K)/W")=1/(kIns*2*Modelica.Constants.pi/ Modelica.Math.log((dh/2 + dIns)/(dh/2))) "Thermal resistance per unit length from fluid to boundary temperature" parameter Real fac= 1.0 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal" parameter Real sum_zetas=0 "Sum of all zeta values. Takes into account additional pressure drops due to bends/valves/etc." constant Boolean homotopyInitialization = true "= true, use homotopy method" parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate" Modelica.Units.SI.Velocity v_med "Velocity of the medium in the pipe"; Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat transfer to or from surroundings (heat loss from pipe results in a positive heat flow)" AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowCore plugFlowCore( redeclare final package Medium = Medium, final dh=dh, final v_nominal=v_nominal, final length=length, final C=C, final R=R, final m_flow_small=m_flow_small, final m_flow_nominal=m_flow_nominal, final T_start_in=T_start_in, final T_start_out=T_start_out, final m_flow_start=m_flow_start, final initDelay=initDelay, final from_dp=from_dp, final fac=if not use_zeta then fac else 1.0, final ReC=ReC, final thickness=thickness, final roughness=roughness, final allowFlowReversal=allowFlowReversal, final homotopyInitialization=homotopyInitialization, final linearized=linearized) "Describing the pipe behavior" // In the volume, below, we scale down V and use // mSenFac. Otherwise, for air, we would get very large volumes // which affect the delay of water vapor and contaminants. // 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( 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=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac = if rho_default > 500 then 1 else 10) "Control volume connected to ports_b. Represents equivalent pipe wall thermal capacity." protected parameter Modelica.Units.SI.HeatCapacity CPip=length*((dh + 2*thickness)^2 - dh^2)*Modelica.Constants.pi/4*cPip*rhoPip "Heat capacity of pipe wall"; final parameter Modelica.Units.SI.Volume VEqu=CPip/(rho_default*cp_default) "Equivalent medium volume to represent pipe wall thermal inertia"; parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default) "Default medium state"; parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=sta_default) "Heat capacity of medium"; parameter Real C(unit="J/(K.m)")= rho_default*Modelica.Constants.pi*(dh/2)^2*cp_default "Thermal capacity per unit length of medium in pipe"; parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)" public FixedResistances.HydraulicResistance hydraulicResistance( diameter=dh, m_flow_nominal=m_flow_nominal, redeclare package Medium = Medium, zeta=sum_zetas, allowFlowReversal=allowFlowReversal, from_dp=from_dp, homotopyInitialization=homotopyInitialization, linearized=linearized, m_flow_start=m_flow_start) if use_zeta 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); connect(vol.ports[2], port_b) connect(plugFlowCore.heatPort, heatPort) connect(plugFlowCore.port_b, vol.ports[1]) if use_zeta then connect(hydraulicResistance.port_b, plugFlowCore.port_a) connect(hydraulicResistance.port_a, port_a) else connect(port_a, plugFlowCore.port_a) end if; end PlugFlowPipeZeta;
Static Pipe model using conditional HydraulicResistance
within AixLib.Fluid.DistrictHeatingCooling.Pipes; model StaticPipe "Static Pipe model using conditional HydraulicResistance" extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)" parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/ v_nominal/Modelica.Constants.pi) "Hydraulic diameter (assuming a round cross section area)" parameter Modelica.Units.SI.Velocity v_nominal=1.5 "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)" parameter Modelica.Units.SI.Length length "Pipe length" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate" parameter Modelica.Units.SI.MassFlowRate m_flow_small=1E-4*abs(m_flow_nominal) "Small mass flow rate for regularization of zero flow" parameter Modelica.Units.SI.Length dIns "Thickness of pipe insulation, used to compute R" parameter Modelica.Units.SI.ThermalConductivity kIns "Heat conductivity of pipe insulation, used to compute R" parameter Modelica.Units.SI.SpecificHeatCapacity cPip=2300 "Specific heat of pipe wall material. 2300 for PE, 500 for steel" parameter Modelica.Units.SI.Density rhoPip(displayUnit="kg/m3") = 930 "Density of pipe wall material. 930 for PE, 8000 for steel" parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= T_start_in "Initialization temperature at pipe outlet" parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 "Initial value of mass flow rate through pipe" parameter Real R(unit="(m.K)/W")=1/(kIns*2*Modelica.Constants.pi/ Modelica.Math.log((dh/2 + dIns)/(dh/2))) "Thermal resistance per unit length from fluid to boundary temperature" parameter Real fac=1 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal" parameter Real sum_zetas=0 "Sum of all zeta values. Takes into account additional pressure drops due to bends/valves/etc." constant Boolean homotopyInitialization = true "= true, use homotopy method" parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate" Modelica.Units.SI.Velocity v_med "Velocity of the medium in the pipe"; Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat transfer to or from surroundings (heat loss from pipe results in a positive heat flow)" AixLib.Fluid.DistrictHeatingCooling.Pipes.BaseClassesStatic.StaticCore staticCore( redeclare final package Medium = Medium, final dh=dh, final v_nominal=v_nominal, final length=length, final C=C, final R=R, final m_flow_small=m_flow_small, final m_flow_nominal=m_flow_nominal, final T_start_in=T_start_in, final T_start_out=T_start_out, final m_flow_start=m_flow_start, final initDelay=initDelay, final from_dp=from_dp, final fac=fac, final ReC=ReC, final thickness=thickness, final roughness=roughness, final allowFlowReversal=allowFlowReversal, final homotopyInitialization=homotopyInitialization, final linearized=linearized) "Describing the pipe behavior" // In the volume, below, we scale down V and use // mSenFac. Otherwise, for air, we would get very large volumes // which affect the delay of water vapor and contaminants. // 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( 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=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac = if rho_default > 500 then 1 else 10) "Control volume connected to ports_b. Represents equivalent pipe wall thermal capacity." protected parameter Modelica.Units.SI.HeatCapacity CPip=length*((dh + 2*thickness)^2 - dh^2)*Modelica.Constants.pi/4*cPip*rhoPip "Heat capacity of pipe wall"; final parameter Modelica.Units.SI.Volume VEqu=CPip/(rho_default*cp_default) "Equivalent medium volume to represent pipe wall thermal inertia"; parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default) "Default medium state"; parameter Modelica.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=sta_default) "Heat capacity of medium"; parameter Real C(unit="J/(K.m)")= rho_default*Modelica.Constants.pi*(dh/2)^2*cp_default "Thermal capacity per unit length of medium in pipe"; parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)" public FixedResistances.HydraulicResistance hydraulicResistance( diameter=dh, m_flow_nominal=m_flow_nominal, redeclare package Medium = Medium, zeta=sum_zetas, allowFlowReversal=allowFlowReversal, from_dp=from_dp, homotopyInitialization=homotopyInitialization, linearized=linearized, m_flow_start=m_flow_start) if use_zeta 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); connect(vol.ports[2], port_b) connect(staticCore.heatPort, heatPort) connect(staticCore.port_b, vol.ports[1]) //Connect hydraulicResistance if use_zeta then connect(hydraulicResistance.port_b, staticCore.port_a) connect(hydraulicResistance.port_a, port_a) else connect(port_a, staticCore.port_a) end if; end StaticPipe;
Base classes for static pipe
within AixLib.Fluid.DistrictHeatingCooling.Pipes; package BaseClassesStatic "Base classes for static pipe" extends Modelica.Icons.BasesPackage; end BaseClassesStatic;
Pipe model using static conditions
within AixLib.Fluid.DistrictHeatingCooling.Pipes.BaseClassesStatic; model StaticCore "Pipe model using static conditions" extends AixLib.Fluid.Interfaces.PartialTwoPort; parameter Modelica.Units.SI.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.Units.SI.Velocity v_nominal "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" parameter Modelica.Units.SI.Length length(min=0) "Pipe length"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate" parameter Modelica.Units.SI.MassFlowRate m_flow_small(min=0) = 1E-4*abs( m_flow_nominal) "Small mass flow rate for regularization of zero flow" parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)" parameter Real R(unit="(m.K)/W") "Thermal resistance per unit length from fluid to boundary temperature"; parameter Real C(unit="J/(K.m)") "Thermal capacity per unit length of pipe"; parameter Real fac=1 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal"; parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)" parameter Modelica.Units.SI.Length thickness(min=0) "Pipe wall thickness"; parameter Modelica.Units.SI.Temperature T_start_in=Medium.T_default "Initialization temperature at pipe inlet" parameter Modelica.Units.SI.Temperature T_start_out=Medium.T_default "Initialization temperature at pipe outlet" parameter Boolean initDelay=false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; constant Boolean homotopyInitialization = true "= true, use homotopy method" parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate" AixLib.Fluid.FixedResistances.HydraulicDiameter res( redeclare final package Medium = Medium, final dh=dh, final m_flow_nominal=m_flow_nominal, final from_dp=from_dp, final length=length, final roughness=roughness, final fac=fac, final ReC=ReC, final v_nominal=v_nominal, final allowFlowReversal=allowFlowReversal, final show_T=false, final homotopyInitialization=homotopyInitialization, final linearized=linearized, dp(nominal=fac*200*length)) "Pressure drop calculation for this pipe" AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss heaLos_a( redeclare final package Medium = Medium, final C=C, final R=R, final m_flow_small=m_flow_small, final T_start=T_start_in, final m_flow_nominal=m_flow_nominal, final m_flow_start=m_flow_start, final show_T=false, final show_V_flow=false) "Heat loss for flow from port_b to port_a" AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss heaLos_b( redeclare final package Medium = Medium, final C=C, final R=R, final m_flow_small=m_flow_small, final T_start=T_start_out, final m_flow_nominal=m_flow_nominal, final m_flow_start=m_flow_start, final show_T=false, final show_V_flow=false) "Heat loss for flow from port_a to port_b" AixLib.Fluid.Sensors.MassFlowRate senMasFlo( redeclare final package Medium = Medium) "Mass flow sensor" StaticTransportDelay timDel( final length=length, final dh=dh, final rho=rho_default, final initDelay=initDelay, final m_flow_nominal=m_flow_nominal, final m_flow_start=m_flow_start) "Time delay" Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat port to connect environment (positive heat flow for heat loss to surroundings)" protected parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)" equation connect(senMasFlo.m_flow, timDel.m_flow) connect(heaLos_a.heatPort, heatPort) connect(heaLos_b.heatPort, heatPort) connect(timDel.tauRev, heaLos_a.tau) connect(timDel.tau, heaLos_b.tau) connect(port_a, heaLos_a.port_b) connect(heaLos_a.port_a, senMasFlo.port_a) connect(heaLos_b.port_b, port_b) connect(senMasFlo.port_b, res.port_a) connect(res.port_b, heaLos_b.port_a) end StaticCore;
Delay time for given current velocity. This is a copy of the PlugFlowTransportDelay modified to react directly on the current velocity. This gives a static behavior similar to quasi-static DHC models for comparison. Note that this is only included for some legacy testing.
within AixLib.Fluid.DistrictHeatingCooling.Pipes.BaseClassesStatic; model StaticTransportDelay "Delay time for given current velocity" parameter Modelica.Units.SI.Length length "Pipe length"; parameter Modelica.Units.SI.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.Units.SI.Density rho "Standard density of fluid"; parameter Boolean initDelay=false "Initialize delay for a constant m_flow_start if true, otherwise start from 0" parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 "Initialization of mass flow rate to calculate initial time delay" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate" final parameter Modelica.Units.SI.Time t_in_start=if initDelay and (abs( m_flow_start) > 1E-10*m_flow_nominal) then min(length/m_flow_start*(rho* dh^2/4*Modelica.Constants.pi), 0) else 0 "Initial value of input time at inlet"; final parameter Modelica.Units.SI.Time t_out_start=if initDelay and (abs( m_flow_start) > 1E-10*m_flow_nominal) then min(-length/m_flow_start*(rho* dh^2/4*Modelica.Constants.pi), 0) else 0 "Initial value of input time at outlet"; Modelica.Units.SI.Velocity velocity "Flow velocity within pipe"; Modelica.Blocks.Interfaces.RealInput m_flow "Mass flow of fluid" Modelica.Blocks.Interfaces.RealOutput tau "Time delay for design flow direction" Modelica.Blocks.Interfaces.RealOutput tauRev "Time delay for reverse flow" equation velocity = abs(m_flow)/(rho*(dh^2)/4*Modelica.Constants.pi); tau = length*( AixLib.Utilities.Math.Functions.inverseXRegularized( x=velocity, delta=0.0001)); tauRev = tau; end StaticTransportDelay;
Simple example of DHCPipe and its four different modes
within AixLib.Fluid.DistrictHeatingCooling.Pipes.Examples; model DHCPipe "Simple example of DHCPipe and its four different modes" extends Modelica.Icons.Example; replaceable package Medium = AixLib.Media.Water "Medium in the pipe" Modelica.Blocks.Sources.Pulse Tin( amplitude=20, period=20, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, redeclare BaseClassesStatic.StaticCore pipCor "Static core", dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=false, T_start_in=323.15, T_start_out=323.15) "Pipe" Modelica.Thermal.HeatTransfer.Sources.FixedTemperature bou(T=283.15) "Boundary temperature" AixLib.Fluid.Sources.MassFlowSource_T sou( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=1) "Flow source" AixLib.Fluid.Sensors.TemperatureTwoPort senTemOut( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" AixLib.Fluid.Sensors.TemperatureTwoPort senTemIn( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" Modelica.Blocks.Sources.Pulse Tin1( amplitude=20, period=20, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin1( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip1( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core", dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=false, T_start_in=323.15, T_start_out=323.15) "Pipe" Sources.MassFlowSource_T sou1( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=1) "Flow source" Sensors.TemperatureTwoPort senTemOut1( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" Sensors.TemperatureTwoPort senTemIn1( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" Modelica.Blocks.Sources.Pulse Tin2( amplitude=20, period=20, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin2( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" 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", dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=false, T_start_in=323.15, T_start_out=323.15) "Pipe" Sources.MassFlowSource_T sou2( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=1) "Flow source" Sensors.TemperatureTwoPort senTemOut2( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" Sensors.TemperatureTwoPort senTemIn2( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" Modelica.Blocks.Sources.Pulse Tin3( amplitude=20, period=20, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin3( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" 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", dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=true, T_start_in=323.15, T_start_out=323.15) "Pipe" Sources.MassFlowSource_T sou3( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=1) "Flow source" Sensors.TemperatureTwoPort senTemOut3( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" Sensors.TemperatureTwoPort senTemIn3( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" equation connect(bou.port, pip.heatPort) connect(Tin.y, sou.T_in) connect(pip.port_b, senTemOut.port_a) connect(senTemOut.port_b, sin.ports[1]) connect(sou.ports[1], senTemIn.port_a) connect(senTemIn.port_b, pip.port_a) connect(bou.port, pip1.heatPort) connect(Tin1.y, sou1.T_in) connect(pip1.port_b, senTemOut1.port_a) connect(senTemOut1.port_b, sin1.ports[1]) connect(sou1.ports[1], senTemIn1.port_a) connect(senTemIn1.port_b, pip1.port_a) connect(bou.port, pip2.heatPort) connect(Tin2.y, sou2.T_in) connect(pip2.port_b, senTemOut2.port_a) connect(senTemOut2.port_b, sin2.ports[1]) connect(sou2.ports[1], senTemIn2.port_a) connect(senTemIn2.port_b, pip2.port_a) connect(bou.port, pip3.heatPort) connect(Tin3.y, sou3.T_in) connect(pip3.port_b, senTemOut3.port_a) connect(senTemOut3.port_b, sin3.ports[1]) connect(sou3.ports[1], senTemIn3.port_a) connect(senTemIn3.port_b, pip3.port_a) end DHCPipe;
Collection of models that illustrate model use and test models
within AixLib.Fluid.DistrictHeatingCooling.Pipes; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Simple example of PlugFlowPipeEmbedded
within AixLib.Fluid.DistrictHeatingCooling.Pipes.Examples; model PlugFlowPipeEmbedded "Simple example of PlugFlowPipeEmbedded" extends Modelica.Icons.Example; replaceable package Medium = AixLib.Media.Water "Medium in the pipe" Modelica.Blocks.Sources.Ramp Tin( height=20, duration=0, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" AixLib.Fluid.DistrictHeatingCooling.Pipes.PlugFlowPipeEmbedded pip( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyStateInitial, dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=true, T_start_in=323.15, T_start_out=323.15) "Pipe" Modelica.Thermal.HeatTransfer.Sources.FixedTemperature bou(T=283.15) "Boundary temperature" AixLib.Fluid.Sources.MassFlowSource_T sou( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=3) "Flow source" AixLib.Fluid.Sensors.TemperatureTwoPort senTemOut( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" AixLib.Fluid.Sensors.TemperatureTwoPort senTemIn( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" equation connect(bou.port, pip.heatPort) connect(Tin.y, sou.T_in) connect(pip.port_b, senTemOut.port_a) connect(senTemOut.port_b, sin.ports[1]) connect(sou.ports[1], senTemIn.port_a) connect(senTemIn.port_b, pip.port_a) end PlugFlowPipeEmbedded;
Simple example of PlugFlowPipe
within AixLib.Fluid.DistrictHeatingCooling.Pipes.Examples; model PlugFlowPipeZeta "Simple example of PlugFlowPipe" extends Modelica.Icons.Example; replaceable package Medium = AixLib.Media.Water "Medium in the pipe" Modelica.Blocks.Sources.Ramp Tin( height=20, duration=0, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" AixLib.Fluid.DistrictHeatingCooling.Pipes.PlugFlowPipeZeta pip( redeclare package Medium = Medium, dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=true, T_start_in=323.15, T_start_out=323.15) "Pipe" Modelica.Thermal.HeatTransfer.Sources.FixedTemperature bou(T=283.15) "Boundary temperature" AixLib.Fluid.Sources.MassFlowSource_T sou( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=3) "Flow source" AixLib.Fluid.Sensors.TemperatureTwoPort senTemOut( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" AixLib.Fluid.Sensors.TemperatureTwoPort senTemIn( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" equation connect(bou.port, pip.heatPort) connect(Tin.y, sou.T_in) connect(pip.port_b, senTemOut.port_a) connect(senTemOut.port_b, sin.ports[1]) connect(sou.ports[1], senTemIn.port_a) connect(senTemIn.port_b, pip.port_a) end PlugFlowPipeZeta;
Simple example of StaticPipe
within AixLib.Fluid.DistrictHeatingCooling.Pipes.Examples; model StaticPipe "Simple example of StaticPipe" extends Modelica.Icons.Example; replaceable package Medium = AixLib.Media.Water "Medium in the pipe" Modelica.Blocks.Sources.Ramp Tin( height=20, duration=0, offset=273.15 + 50, startTime=100) "Ramp pressure signal" Sources.Boundary_pT sin( redeclare package Medium = Medium, T=273.15 + 10, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" AixLib.Fluid.DistrictHeatingCooling.Pipes.StaticPipe pip( redeclare package Medium = Medium, dh=0.1, length=100, dIns=0.05, kIns=0.028, m_flow_nominal=1, cPip=500, thickness=0.0032, initDelay=true, m_flow_start=1, rhoPip=8000, use_zeta=true, T_start_in=323.15, T_start_out=323.15) "Pipe" Modelica.Thermal.HeatTransfer.Sources.FixedTemperature bou(T=283.15) "Boundary temperature" AixLib.Fluid.Sources.MassFlowSource_T sou( nPorts=1, redeclare package Medium = Medium, use_T_in=true, m_flow=3) "Flow source" AixLib.Fluid.Sensors.TemperatureTwoPort senTemOut( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" AixLib.Fluid.Sensors.TemperatureTwoPort senTemIn( redeclare package Medium = Medium, m_flow_nominal=1, T_start=323.15) "Temperature sensor" equation connect(bou.port, pip.heatPort) connect(Tin.y, sou.T_in) connect(pip.port_b, senTemOut.port_a) connect(senTemOut.port_b, sin.ports[1]) connect(sou.ports[1], senTemIn.port_a) connect(senTemIn.port_b, pip.port_a) end StaticPipe;
Supply node models
within AixLib.Fluid.DistrictHeatingCooling; package Supplies "Supply node models" end Supplies;
Supply node model with ideal heater and cooler and storage tank without heat losses for heat and cold supply of bidirectional networks
within AixLib.Fluid.DistrictHeatingCooling.Supplies.ClosedLoop; model DHCSupplyHeaterCoolerStorage "Supply node model with ideal heater and cooler and storage tank without heat losses for heat and cold supply of bidirectional networks" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model for water" parameter Modelica.Units.SI.Pressure dp_nominal(displayUnit="Pa") = 30000 "Nominal pressure drop"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=m_flow_nominal "Nominal mass flow rate"; parameter Modelica.Units.SI.Volume V_Tank "Volume of thermal storage tank"; Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium) "Fluid connector for connecting the ideal plant with storage to the cold line of the network" Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium) "Fluid connector for connecting the ideal plant with storage to the warm line of the network" AixLib.Fluid.HeatExchangers.PrescribedOutlet coo( redeclare package Medium = Medium, use_X_wSet=false, dp_nominal=dp_nominal, use_TSet=true, m_flow_nominal=m_flow_nominal) "Ideal cooler (only in operation if mass flow direction is from port_b to port_a)" AixLib.Fluid.HeatExchangers.PrescribedOutlet hea( redeclare package Medium = Medium, use_X_wSet=false, dp_nominal=dp_nominal, m_flow_nominal=m_flow_nominal) "Ideal heater (only in operation if mass flow direction is from port_a to port_b)" AixLib.Fluid.Sensors.TemperatureTwoPort senT_cooOut(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Outlet temperature of ideal cooler if mass flow direcetion is from port_b to port_a" Modelica.Blocks.Interfaces.RealInput T_cooSet(unit="K") "Maximum supply temperature of the cold line of the bidirectional low-temperature network" Modelica.Blocks.Interfaces.RealInput T_heaSet(unit="K") "Minimum supply temperature of the hot line of the bidirectional low-temperature network" AixLib.Fluid.Storage.Stratified tan( allowFlowReversal=true, hTan=4, dIns=0.1, energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, nSeg=3, VTan=V_Tank) AixLib.Fluid.Sensors.TemperatureTwoPort senT_heaOut(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) "Outlet temperature of ideal heater if mass flow direcetion is from port_a to port_b" AixLib.Fluid.Sensors.TemperatureTwoPort senT_stoHea(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) AixLib.Fluid.Sensors.TemperatureTwoPort senT_stoCoo(redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal) Modelica.Blocks.Math.Min min "Set temperature of ideal heater" Modelica.Blocks.Math.Max max "Set temperature of ideal cooler" Sources.Boundary_pT bou(nPorts=1, redeclare package Medium = Medium) equation connect(port_b, senT_heaOut.port_a) connect(hea.port_b, senT_heaOut.port_b) connect(senT_stoHea.port_a, hea.port_a) connect(tan.port_a, senT_stoHea.port_b) connect(senT_stoCoo.T, min.u2) connect(max.y, hea.TSet) connect(senT_stoHea.T, max.u2) connect(tan.port_b, senT_stoCoo.port_a) connect(senT_stoCoo.port_b, coo.port_a) connect(port_a, senT_cooOut.port_b) connect(senT_cooOut.port_a, coo.port_b) connect(coo.TSet, min.y) connect(T_cooSet, min.u1) connect(T_heaSet, max.u1) connect(bou.ports[1], coo.port_a) end DHCSupplyHeaterCoolerStorage;
Supply with closed loop design
within AixLib.Fluid.DistrictHeatingCooling.Supplies; package ClosedLoop "Supply with closed loop design" end ClosedLoop;
Fluid in the pipes
within AixLib.Fluid.DistrictHeatingCooling.Supplies.Examples; model DHCSupplyHeaterCoolerStorage extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Fluid in the pipes"; ClosedLoop.DHCSupplyHeaterCoolerStorage DHCSupplyHeaterCoolerStorage( redeclare package Medium = Medium, m_flow_nominal=5, V_Tank=500) Demands.ClosedLoop.DHCSubstationHeatPumpDirectCooling substation1( redeclare package Medium = Medium, m_flow_nominal=5, heaDem_max=10000, deltaT_heaSecSet=278.15, T_heaSecSet=328.15, T_heaPriSet=295.15, T_cooPriSet=289.15) Demands.ClosedLoop.DHCSubstationHeatPumpDirectCooling substation2( redeclare package Medium = Medium, m_flow_nominal=5, heaDem_max=10000, deltaT_heaSecSet=278.15, T_heaSecSet=328.15, T_heaPriSet=295.15, T_cooPriSet=289.15) AixLib.Fluid.FixedResistances.PlugFlowPipe plugFlowPipe( dh=0.2, length=5, m_flow_nominal=5, dIns=0.001, kIns=0.04, redeclare package Medium = Medium) AixLib.Fluid.FixedResistances.PlugFlowPipe plugFlowPipe1( dh=0.2, length=5, m_flow_nominal=5, dIns=0.001, kIns=0.04, redeclare package Medium = Medium) AixLib.Fluid.FixedResistances.PlugFlowPipe plugFlowPipe2( dh=0.2, length=5, m_flow_nominal=5, dIns=0.001, kIns=0.04, redeclare package Medium = Medium) AixLib.Fluid.FixedResistances.PlugFlowPipe plugFlowPipe3( dh=0.2, length=5, m_flow_nominal=5, dIns=0.001, kIns=0.04, redeclare package Medium = Medium) Modelica.Blocks.Sources.Constant T_HotLineSet(k=16 + 273.15) Modelica.Blocks.Sources.Constant T_ColdLineSet(k=22 + 273.15) Modelica.Blocks.Sources.Constant heaDem(k=10000) Modelica.Blocks.Sources.Step colDem( height=10000, offset=5000, startTime=86400) equation connect(heaDem.y, substation1.heaDem); connect(heaDem.y, substation2.heaDem); connect(colDem.y, substation1.cooDem); connect(colDem.y, substation2.cooDem); connect(DHCSupplyHeaterCoolerStorage.port_b, plugFlowPipe.port_a) connect(T_ColdLineSet.y, DHCSupplyHeaterCoolerStorage.T_heaSet) connect(T_HotLineSet.y, DHCSupplyHeaterCoolerStorage.T_cooSet) connect(plugFlowPipe1.port_b, substation2.port_a) connect(plugFlowPipe2.port_a, substation2.port_b) connect(plugFlowPipe.port_b, plugFlowPipe1.port_a) connect(plugFlowPipe.port_b, substation1.port_a) connect(plugFlowPipe3.port_a, plugFlowPipe2.port_b) connect(substation1.port_b, plugFlowPipe3.port_a) connect(DHCSupplyHeaterCoolerStorage.port_a, plugFlowPipe3.port_b) end DHCSupplyHeaterCoolerStorage;
<html><p> This package contains examples for the use of models that can be found in <a href= \
within AixLib.Fluid.DistrictHeatingCooling.Supplies; package Examples extends Modelica.Icons.ExamplesPackage; end Examples;
Supplies for open loop model designs
within AixLib.Fluid.DistrictHeatingCooling.Supplies; package OpenLoop "Supplies for open loop model designs" end OpenLoop;
Simple supply node model with ideal flow source and return port
within AixLib.Fluid.DistrictHeatingCooling.Supplies.OpenLoop; model SourceIdeal "Simple supply node model with ideal flow source and return port" extends BaseClasses.Supplies.OpenLoop.PartialSupply(senT_return( allowFlowReversal=true)); parameter Modelica.Units.SI.AbsolutePressure pReturn "Fixed return pressure"; parameter Modelica.Units.SI.Temperature TReturn "Fixed return temperature"; AixLib.Fluid.Sources.Boundary_pT source( redeclare package Medium = Medium, nPorts=1, use_T_in=true, use_p_in=true) "Ideal fluid source with prescribed temperature and pressure" Sources.Boundary_pT sink(redeclare package Medium = Medium, p=pReturn, nPorts=1) "Ideal sink for return from the network" Modelica.Blocks.Interfaces.RealOutput Q_flow equation Q_flow = (senT_supply.T - senT_return.T) * 4180 * senMasFlo.m_flow; connect(source.ports[1], senT_supply.port_a) connect(TIn, source.T_in) connect(dpIn, source.p_in) connect(senT_return.port_a, sink.ports[1]) end SourceIdeal;
Example models integrating multiple components
within AixLib.Fluid; package Examples "Example models integrating multiple components" extends Modelica.Icons.ExamplesPackage; end Examples;
System demonstrating impact of allowFlowReversal on number/size of non-linear systems
within AixLib.Fluid.Examples; model ResistanceVolumeFlowReversal "System demonstrating impact of allowFlowReversal on number/size of non-linear systems" extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; parameter Real m_flow_nominal=0.1 "Gain value multiplied with input signal"; AixLib.Fluid.Sources.Boundary_pT bou( redeclare package Medium = Medium, nPorts=1) "Boundary for pressure boundary condition" Movers.FlowControlled_m_flow pump( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, use_inputFilter=false, allowFlowReversal=allowFlowReversal.k, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, nominalValuesDefineDefaultPressureCurve=true) "Pump model with unidirectional flow" AixLib.Fluid.HeatExchangers.Heater_T hea( redeclare package Medium = Medium, dp_nominal=1000, QMax_flow=1000, m_flow_nominal=m_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=allowFlowReversal.k) "Heater" Modelica.Blocks.Sources.Pulse pulse(period=1000) "Pulse input" Modelica.Blocks.Math.Gain gain(k=m_flow_nominal) "Gain for m_flow_nominal" AixLib.Fluid.Actuators.Valves.ThreeWayLinear val( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dpValve_nominal=1000, l={0.002,0.002}, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Three way valve with constant input" Modelica.Blocks.Sources.Constant const(k=0.5) "Constant valve set point" Modelica.Blocks.Sources.BooleanConstant allowFlowReversal(k=false) "Block for setting allowFlowReversal in components" AixLib.Fluid.FixedResistances.PressureDrop[nRes.k] res( redeclare package Medium = Medium, each allowFlowReversal=allowFlowReversal.k, each m_flow_nominal=m_flow_nominal/nRes.k, each dp_nominal=1000) "Fluid resistance for splitting flow" Modelica.Blocks.Sources.IntegerConstant nRes(k=10) "Number of parallel branches" Delays.DelayFirstOrder[nRes.k] vol( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal/nRes.k, each nPorts=2, each energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, each allowFlowReversal=true) "Mixing volumes for enthalpy circuit" equation connect(bou.ports[1],hea. port_a) connect(pulse.y,hea. TSet) connect(pump.m_flow_in, gain.y) connect(gain.u,pulse. y) connect(hea.port_b,val. port_1) connect(val.port_2, pump.port_a) connect(const.y,val. y) connect(val.port_3,hea. port_a) for i in 1:nRes.k loop connect(pump.port_b, res[i].port_a) connect(res[i].port_b, vol[i].ports[1]) connect(vol[i].ports[2], val.port_3) end for; end ResistanceVolumeFlowReversal;
Example implementation of flow system
within AixLib.Fluid.Examples.FlowSystem; model Basic "Example implementation of flow system" extends Modelica.Icons.Example; package Medium = AixLib.Media.Water "Medium model"; AixLib.Fluid.Movers.FlowControlled_dp pmpSouth( redeclare package Medium = Medium, redeclare replaceable AixLib.Fluid.Movers.Data.Pumps.Wilo.Stratos80slash1to12 per, dp_nominal=12*9810, m_flow_nominal=27570/3600, inputType=AixLib.Fluid.Types.InputType.Stages, heads=pmpSouth.dp_nominal*{0,1}, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Pump to south of building" AixLib.Fluid.FixedResistances.PressureDrop pipSouth1( redeclare package Medium = Medium, dp_nominal=50000, m_flow_nominal=4) "Pipe 1 to south of building" AixLib.Fluid.FixedResistances.PressureDrop pipSouth2( redeclare package Medium = Medium, dp_nominal=50000, m_flow_nominal=3) "Pipe 2 to south of building" AixLib.Fluid.Movers.FlowControlled_dp pmpNorth( redeclare package Medium = Medium, redeclare replaceable AixLib.Fluid.Movers.Data.Pumps.Wilo.Stratos80slash1to12 per, dp_nominal=12*9810, m_flow_nominal=24660/3600, inputType=AixLib.Fluid.Types.InputType.Stages, heads=pmpNorth.dp_nominal*{0,1}, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Pump to north of building" AixLib.Fluid.FixedResistances.PressureDrop pipNorth2( redeclare package Medium = Medium, dp_nominal=50000, m_flow_nominal=5) "Pipe 2 to north of building" AixLib.Fluid.FixedResistances.PressureDrop pipNorth1( redeclare package Medium = Medium, dp_nominal=50000, m_flow_nominal=3) "Pipe 1 to north of building" AixLib.Fluid.Actuators.Valves.TwoWayLinear[4] valSouth1( each dpFixed_nominal=0, each CvData=AixLib.Fluid.Types.CvTypes.OpPoint, each dpValve_nominal=8e4, redeclare each package Medium = Medium, each m_flow_nominal=1) "Valves on souther tabs section 1" AixLib.Fluid.Actuators.Valves.TwoWayLinear[8] valSouth2( each dpFixed_nominal=0, each CvData=AixLib.Fluid.Types.CvTypes.OpPoint, each dpValve_nominal=8e4, redeclare each package Medium = Medium, each m_flow_nominal=1) "Valves on souther tabs section 2" AixLib.Fluid.Actuators.Valves.TwoWayLinear[4] valNorth1( each dpFixed_nominal=0, each CvData=AixLib.Fluid.Types.CvTypes.OpPoint, each dpValve_nominal=8e4, redeclare each package Medium = Medium, each m_flow_nominal=1) "Valves on northern tabs section 1" AixLib.Fluid.Actuators.Valves.TwoWayLinear[8] valNorth2( each dpFixed_nominal=0, each CvData=AixLib.Fluid.Types.CvTypes.OpPoint, each dpValve_nominal=8e4, redeclare each package Medium = Medium, each m_flow_nominal=1) "Valves on northern tabs section 2" Modelica.Blocks.Math.BooleanToInteger booleanToInteger(integerTrue=2, integerFalse=1) "Boolean to integer conversion block" Modelica.Blocks.Sources.BooleanPulse stepPump(startTime=5, period=1000) "Step control" Modelica.Blocks.Sources.Sine sine( amplitude=0.5, offset=0.5, f=0.001) "Valve control signal" AixLib.Fluid.Actuators.Valves.ThreeWayLinear valSouth( redeclare package Medium = Medium, m_flow_nominal=5, dpFixed_nominal={20000,0}, from_dp=true, dpValve_nominal=10000, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Three way valve for controlling supply temperature to south of building" AixLib.Fluid.Actuators.Valves.ThreeWayLinear valNorth( redeclare package Medium = Medium, m_flow_nominal=5, dpFixed_nominal={20000,0}, from_dp=true, dpValve_nominal=10000, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Three way valve for controlling supply temperature to north of building" AixLib.Fluid.HeatExchangers.PrescribedOutlet heater( m_flow_nominal=10, dp_nominal=100, redeclare package Medium = Medium, use_X_wSet=false) "Heating device" AixLib.Fluid.Sources.Boundary_pT bou(nPorts=1, redeclare package Medium = Medium) "Boundary for setting absolute temperature" AixLib.Fluid.FixedResistances.Junction spl( m_flow_nominal={10,10,10}, dp_nominal={1000,10,10}, redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Splitter" AixLib.Fluid.FixedResistances.Junction spl1( m_flow_nominal={10,10,10}, dp_nominal={10,10,10}, redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Splitter" AixLib.Fluid.Movers.FlowControlled_m_flow pumpHea( m_flow_nominal=10, redeclare AixLib.Fluid.Movers.Data.Pumps.Wilo.VeroLine80slash115dash2comma2slash2 per, redeclare package Medium = Medium, inputType=AixLib.Fluid.Types.InputType.Stages, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Pump for circulating hot water" Modelica.Blocks.Sources.Constant Thot(k=273.15 + 50) "Hot water temperature" AixLib.Fluid.Actuators.Valves.TwoWayLinear valHea( dpFixed_nominal=0, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, redeclare package Medium = Medium, m_flow_nominal=10, dpValve_nominal=1e4) "Valve for allowing water to be drawn from hot water circuit" Modelica.Blocks.Sources.Pulse stepValve(startTime=10, period=500) "Set point for valves" AixLib.Fluid.Actuators.Valves.TwoWayLinear valCoo( dpFixed_nominal=0, CvData=AixLib.Fluid.Types.CvTypes.OpPoint, redeclare package Medium = Medium, m_flow_nominal=10, dpValve_nominal=1e4) "Valve for allowing water to be drawn from cold water circuit" Modelica.Blocks.Sources.RealExpression valCooExp(y=1 - stepValve.y) "Cooling valve opens when heating valve is closed" AixLib.Fluid.FixedResistances.Junction spl2( m_flow_nominal={10,10,10}, dp_nominal={1000,10,10}, redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Splitter" AixLib.Fluid.FixedResistances.Junction spl3( m_flow_nominal={10,10,10}, dp_nominal={10,10,10}, redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Splitter" AixLib.Fluid.Movers.FlowControlled_m_flow pumpCoo( m_flow_nominal=10, redeclare AixLib.Fluid.Movers.Data.Pumps.Wilo.VeroLine80slash115dash2comma2slash2 per, redeclare package Medium = Medium, inputType=AixLib.Fluid.Types.InputType.Stages, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Pump for circulating cold water" AixLib.Fluid.MixingVolumes.MixingVolume vol( nPorts=2, redeclare package Medium = Medium, m_flow_nominal=10, V=1) "Simplified model of cold water source" Modelica.Thermal.HeatTransfer.Sources.FixedTemperature Tcold(T=273.15 + 10) "Cold water temperature" AixLib.Fluid.FixedResistances.PressureDrop tabsSouth1[4]( redeclare each package Medium = Medium, each dp_nominal=50000, m_flow_nominal=valSouth1.m_flow_nominal) "Pressure drop of southern tabs sections on collector 1" AixLib.Fluid.FixedResistances.PressureDrop tabsSouth2[8]( redeclare each package Medium = Medium, each dp_nominal=50000, m_flow_nominal=valSouth2.m_flow_nominal) "Pressure drop of southern tabs sections on collector 2" AixLib.Fluid.FixedResistances.PressureDrop tabsNorth1[4]( redeclare each package Medium = Medium, each dp_nominal=50000, m_flow_nominal=valNorth1.m_flow_nominal) "Pressure drop of northern tabs sections on collector 1" AixLib.Fluid.FixedResistances.PressureDrop tabsNorth2[8]( redeclare each package Medium = Medium, each dp_nominal=50000, m_flow_nominal=valNorth2.m_flow_nominal) "Pressure drop of northern tabs sections on collector 2" equation connect(pipSouth2.port_a, pmpSouth.port_b) connect(pmpSouth.port_b, pipSouth1.port_a) connect(pipNorth1.port_a, pmpNorth.port_b) connect(pmpNorth.port_b, pipNorth2.port_a) for i in 1:4 loop connect(tabsNorth1[i].port_b,valNorth. port_3) connect(tabsSouth1[i].port_b, valSouth.port_3) connect(valSouth1[i].y, sine.y) connect(pipSouth1.port_b, valSouth1[i].port_a) connect(pipNorth1.port_b, valNorth1[i].port_a) end for; for i in 1:8 loop connect(tabsNorth2[i].port_b,valNorth. port_3) connect(tabsSouth2[i].port_b, valSouth.port_3) connect(valSouth2[i].y, sine.y) connect(pipSouth2.port_b, valSouth2[i].port_a) connect(pipNorth2.port_b, valNorth2[i].port_a) end for; connect(pmpSouth.stage, pmpNorth.stage) connect(booleanToInteger.y, pmpSouth.stage) connect(stepPump.y, booleanToInteger.u) connect(valSouth1.y, valNorth1.y) connect(valSouth2.y,valNorth2. y) connect(valSouth.port_2, pmpSouth.port_a) connect(valNorth.port_2, pmpNorth.port_a) connect(valNorth.y, valSouth.y) connect(bou.ports[1], heater.port_a) connect(spl1.port_3, spl.port_3) connect(heater.port_b, spl.port_1) connect(pumpHea.port_a, spl1.port_2) connect(pumpHea.port_b, heater.port_a) connect(Thot.y, heater.TSet) connect(spl1.port_1, valSouth.port_3) connect(spl.port_2, valHea.port_a) connect(valHea.port_b, valSouth.port_1) connect(stepValve.y, valSouth.y) connect(stepValve.y, valHea.y) connect(valCooExp.y, valCoo.y) connect(valCoo.port_b, valSouth.port_1) connect(valCoo.port_b,valNorth. port_1) connect(spl2.port_2, valCoo.port_a) connect(spl3.port_1, spl1.port_1) connect(spl3.port_3, spl2.port_3) connect(spl3.port_2, pumpCoo.port_a) connect(vol.ports[1], pumpCoo.port_b) connect(vol.ports[2], spl2.port_1) connect(Tcold.port, vol.heatPort) connect(pumpHea.stage, pumpCoo.stage) connect(pumpHea.stage, booleanToInteger.y) connect(valNorth.port_3, spl3.port_1) connect(valSouth1.port_b, tabsSouth1.port_a) connect(valSouth2.port_b, tabsSouth2.port_a) connect(valNorth1.port_b, tabsNorth1.port_a) connect(valNorth2.port_b, tabsNorth2.port_a) end Basic;
<html> <p> This package contains fluid flow models that demonstrate how such models can be simplified to reduce the dimension of systems of nonlinear equations in order to reduce computing time. </p> </html>
within AixLib.Fluid.Examples; package FlowSystem extends Modelica.Icons.ExamplesPackage; end FlowSystem;
Aggregated pressure drops. The model is simplified: series pressure drop components are aggregated into the valve model.
within AixLib.Fluid.Examples.FlowSystem; model Simplified1 "Aggregated pressure drops" extends Basic( tabsSouth1(each dp_nominal=0), tabsSouth2(each dp_nominal=0), tabsNorth1(each dp_nominal=0), tabsNorth2(each dp_nominal=0), valSouth1(each dpFixed_nominal=50000), valSouth2(each dpFixed_nominal=50000), valNorth1(each dpFixed_nominal=50000), valNorth2(each dpFixed_nominal=50000)); end Simplified1;
Using from_dp. The model is simplified: using <code>from_dp</code> to find more efficient tearing variables.
within AixLib.Fluid.Examples.FlowSystem; model Simplified2 "Using from_dp" extends Simplified1( valSouth1(each from_dp=true), valSouth2(each from_dp=true), valNorth1(each from_dp=true), valNorth2(each from_dp=true)); end Simplified2;
Neglecting pressure drop in splitters. The model is further simplified by removing some small pressure drops in the bypass. This allows the solver to identify sub-circuits.
within AixLib.Fluid.Examples.FlowSystem; model Simplified3 "Neglecting pressure drop in splitters" extends Simplified2( spl(dp_nominal={1000,0,0}), spl1(dp_nominal={0,0,0}), spl3(dp_nominal={0,0,0}), spl2(dp_nominal={1000,0,0})); end Simplified3;
Removed valve dynamics. The model is further simplified by removing the valve and pump control dynamics.
within AixLib.Fluid.Examples.FlowSystem; model Simplified4 "Removed valve dynamics" extends Simplified3( valNorth(use_inputFilter=false), valSouth(use_inputFilter=false), pmpNorth( energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, use_inputFilter=false), pmpSouth( energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, use_inputFilter=false), valSouth1(each use_inputFilter=false), valSouth2(each use_inputFilter=false), valNorth1(each use_inputFilter=false), valNorth2(each use_inputFilter=false), pumpHea(use_inputFilter=false), pumpCoo(use_inputFilter=false), valCoo(use_inputFilter=false), valHea(use_inputFilter=false)); end Simplified4;
Removed most mass/energy dynamics. The model is further simplified by setting the mass dynamics and energy dynamics of most models to be steady state. Note that by default, the mass dynamics is set to the same configuration as the energy dynamics.
within AixLib.Fluid.Examples.FlowSystem; model Simplified5 "Removed most mass/energy dynamics" extends Simplified4( spl1(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState), spl(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState), spl2(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState), spl3(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState), pumpCoo(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState), pumpHea(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState), heater(energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)); end Simplified5;
Set allowFlowReversal=false. The model is further simplified by setting <code>allowFlowReversal=false</code>.
within AixLib.Fluid.Examples.FlowSystem; model Simplified6 "Set allowFlowReversal=false" extends Simplified5( pmpNorth(allowFlowReversal=false), pmpSouth(allowFlowReversal=false), tabsSouth1(each allowFlowReversal=false), tabsSouth2(each allowFlowReversal=false), pipSouth1(allowFlowReversal=false), pipSouth2(allowFlowReversal=false), valSouth2(each allowFlowReversal=false), valSouth1(each allowFlowReversal=false), tabsNorth1(each allowFlowReversal=false), valNorth1(each allowFlowReversal=false), pipNorth1(allowFlowReversal=false), pipNorth2(allowFlowReversal=false), valNorth2(each allowFlowReversal=false), tabsNorth2(each allowFlowReversal=false), pumpHea(allowFlowReversal=false), vol(allowFlowReversal=false), heater(allowFlowReversal=false), valCoo(allowFlowReversal=false), valHea(allowFlowReversal=false)); end Simplified6;
Example of a geothermal heat pump system
within AixLib.Fluid.Examples.GeothermalHeatPump; model GeothermalHeatPump "Example of a geothermal heat pump system" extends Modelica.Icons.Example; extends AixLib.Fluid.Examples.GeothermalHeatPump.BaseClasses.GeothermalHeatPumpControlledBase( redeclare model PeakLoadDeviceModel = AixLib.Fluid.Examples.GeothermalHeatPump.Components.BoilerStandAlone ( redeclare package Medium = Medium, energyDynamics=energyDynamics)); Sources.Boundary_pT coldConsumerFlow(redeclare package Medium = Medium, nPorts=1) Sources.Boundary_pT heatConsumerFlow(redeclare package Medium = Medium, nPorts=1) "Sink representing heat consumer" Sources.Boundary_pT heatConsumerReturn(redeclare package Medium = Medium, nPorts=1, T=303.15) "Source representing heat consumer" Sources.Boundary_pT coldConsumerReturn(redeclare package Medium = Medium, nPorts=1, T=287.15) "Source representing cold consumer" Modelica.Blocks.Sources.Constant pressureDifference(k=60000) "Pressure difference used for all pumps" Controls.HeatPump.TwoPointControlledHP twoPointControlledHP( use_secHeaGen=false, use_heaLim=false, T_heaLim=293.15, movAveTime=300, bandwidth=2) "Controls the temperature in the heat storage by switching the heat pump on or off" Modelica.Blocks.Sources.Constant TStorageSet(k=273.15 + 45) "Set point of upper heat storage temperature" Control.geothermalFieldController geothermalFieldControllerCold( temperature_low=273.15 + 8, temperature_high=273.15 + 10) "Controls the heat exchange with the geothermal field and the heat storage" Control.geothermalFieldController geothermalFieldControllerHeat( temperature_low=308.15, temperature_high=313.15) "Controls the heat exchange with the geothermal field and the heat storage" Modelica.Blocks.Sources.BooleanConstant mode "Dummy signal for unit mode, true: heat pump, false: chiller" equation connect(resistanceColdConsumerFlow.port_b,coldConsumerFlow. ports[1]) connect(pressureDifference.y, pumpColdConsumer.dp_in) connect(pressureDifference.y, pumpHeatConsumer.dp_in) connect(resistanceColdConsumerReturn.port_a,coldConsumerReturn. ports[1]) connect(resistanceHeatConsumerReturn.port_a,heatConsumerReturn. ports[1]) connect(pressureDifference.y, pumpEvaporator.dp_in) connect(pressureDifference.y, pumpCondenser.dp_in) connect(pumpGeothermalSource.dp_in,pressureDifference. y) connect(peaLoaDev.port_b,heatConsumerFlow. ports[1]) connect(peaLoaDev.chemicalEnergyFlowRate, chemicalEnergyFlowRate) connect(getTStorageLower.y,geothermalFieldControllerCold. temperature) connect(geothermalFieldControllerCold.valveOpening1, valveColdStorage.y) connect(geothermalFieldControllerCold.valveOpening2, valveHeatSource.y) connect(getTStorageUpper.y,geothermalFieldControllerHeat. temperature) connect(valveHeatSink.y, geothermalFieldControllerHeat.valveOpening1) connect(geothermalFieldControllerHeat.valveOpening2, valveHeatStorage.y) connect(valveHeatStorage.port_b, heatPump.port_a1) connect(TStorageSet.y, twoPointControlledHP.TSet) connect(twoPointControlledHP.sigBusHP, heatPumpControlBus) connect(getTStorageUpper.y,twoPointControlledHP.TMea) connect(mode.y, heatPumpControlBus.hea) connect(heatPump.P, heatPumpPower) connect(twoPointControlledHP.nOut, heatPumpControlBus.ySet) connect(twoPointControlledHP.nOut, heatPumpControlBus.yMea) end GeothermalHeatPump;
Contains examples of hydraulic systems based on geothermal heat pumps
within AixLib.Fluid.Examples; package GeothermalHeatPump "Contains examples of hydraulic systems based on geothermal heat pumps" extends Modelica.Icons.ExamplesPackage; end GeothermalHeatPump;
Base class of the geothermal heat pump system
within AixLib.Fluid.Examples.GeothermalHeatPump.BaseClasses; partial model GeothermalHeatPumpBase "Base class of the geothermal heat pump system" replaceable package Medium = AixLib.Media.Water "Medium model used for hydronic components"; parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial "Type of energy balance: dynamic (3 initialization options) or steady state" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal_layer=0.5 "Nominal mass flow rate in layers of storages"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal_HE=0.5 "Nominal mass flow rate of heat exchanger layers of storages"; parameter Modelica.Units.SI.Temperature T_start_cold=300 "Initial temperature of cold components"; parameter Modelica.Units.SI.Temperature T_start_hot=300 "Initial temperature of warm components"; replaceable model PeakLoadDeviceModel = AixLib.Fluid.Interfaces.PartialTwoPortTransport constrainedby AixLib.Fluid.Interfaces.PartialTwoPortTransport(redeclare package Medium=Medium) PeakLoadDeviceModel peaLoaDev Storage.StorageDetailed coldStorage( redeclare package Medium = Medium, energyDynamics=energyDynamics, redeclare package MediumHC1 = Medium, redeclare package MediumHC2 = Medium, m1_flow_nominal=m_flow_nominal_layer, m2_flow_nominal=m_flow_nominal_layer, mHC1_flow_nominal=m_flow_nominal_HE, useHeatingCoil2=false, useHeatingRod=false, redeclare DataBase.Storage.Generic_New_2000l data( hTank=1.5, hUpperPortDemand=1.45, hUpperPortSupply=1.45, hHC1Up=1.45, dTank=1, sIns=0.2, lambdaIns=0.075, hTS2=1.45), n=5, hConIn=100, hConOut=10, hConHC1=500, upToDownHC1=false) "Storage tank for buffering cold demand" FixedResistances.PressureDrop resistanceColdStorage( redeclare package Medium = Medium, m_flow_nominal=0.5, dp_nominal=15000) "Resistance in evaporator circuit" AixLib.Fluid.Sources.Boundary_pT geothFieldSource( redeclare package Medium = Medium, nPorts=1, T=284.15) "Source representing geothermal field" FixedResistances.PressureDrop resistanceGeothermalSource( redeclare package Medium = Medium, m_flow_nominal=0.5, dp_nominal=15000) "Resistance in geothermal field circuit" FixedResistances.PressureDrop resistanceColdConsumerFlow( redeclare package Medium = Medium, m_flow_nominal=0.2, dp_nominal=10000) "Resistance in cold consumer flow line" Actuators.Valves.TwoWayQuickOpening valveHeatSink( redeclare package Medium = Medium, m_flow_nominal=0.5, dpValve_nominal=5000) "Valve connecting geothermal field to the condenser of the heat pump" Actuators.Valves.TwoWayQuickOpening valveHeatSource(redeclare package Medium = Medium, m_flow_nominal=0.5, dpValve_nominal=5000) "Valve connecting geothermal field to the evaporator of the heat pump" AixLib.Fluid.Storage.StorageDetailed heatStorage( redeclare package Medium = Medium, energyDynamics=energyDynamics, redeclare package MediumHC1 = Medium, redeclare package MediumHC2 = Medium, m1_flow_nominal=m_flow_nominal_layer, m2_flow_nominal=m_flow_nominal_layer, mHC1_flow_nominal=m_flow_nominal_HE, useHeatingCoil2=false, useHeatingRod=false, redeclare DataBase.Storage.Generic_New_2000l data( hTank=1.5, hUpperPortDemand=1.45, hUpperPortSupply=1.45, hHC1Up=1.45, dTank=1, sIns=0.2, lambdaIns=0.075, hTS2=1.45), n=5, hConIn=100, hConOut=10, hConHC1=500) "Storage tank for buffering heat demand" AixLib.Fluid.FixedResistances.PressureDrop resistanceHeatStorage( redeclare package Medium = Medium, m_flow_nominal=0.5, dp_nominal=15000) "Resistance in condenser circuit" AixLib.Fluid.Sources.Boundary_pT geothField_sink1(redeclare package Medium = Medium, nPorts=2) "One of two sinks representing geothermal field" AixLib.Fluid.FixedResistances.PressureDrop resistanceHeatConsumerFlow( redeclare package Medium = Medium, m_flow_nominal=0.2, dp_nominal=10000) "Resistance in heat consumer flow line" AixLib.Fluid.Actuators.Valves.TwoWayQuickOpening valveColdStorage( redeclare package Medium = Medium, m_flow_nominal=0.5, dpValve_nominal=5000) "Valve connecting cold storage to the evaporator of the heat pump" AixLib.Fluid.Actuators.Valves.TwoWayQuickOpening valveHeatStorage( redeclare package Medium = Medium, m_flow_nominal=0.5, dpValve_nominal=5000) "Valve connecting heat storage to the condenser of the heat pump" AixLib.Fluid.Movers.FlowControlled_dp pumpColdConsumer( energyDynamics=energyDynamics, m_flow_nominal=0.05, redeclare package Medium = Medium, addPowerToMedium=false, T_start=T_start_cold) "Pump moving fluid from storage tank to cold consumers" AixLib.Fluid.Movers.FlowControlled_dp pumpHeatConsumer( energyDynamics=energyDynamics, m_flow_nominal=0.05, redeclare package Medium = Medium, addPowerToMedium=false, T_start=T_start_hot) "Pump moving fluid from storage tank to heat consumers" AixLib.Fluid.FixedResistances.PressureDrop resistanceColdConsumerReturn( redeclare package Medium = Medium, m_flow_nominal=0.2, dp_nominal=10000) "Resistance in cold consumer return line" AixLib.Fluid.FixedResistances.PressureDrop resistanceHeatConsumerReturn( redeclare package Medium = Medium, m_flow_nominal=0.2, dp_nominal=10000) "Resistance in heat consumer return line" AixLib.Fluid.Movers.FlowControlled_dp pumpCondenser( energyDynamics=energyDynamics, m_flow_nominal=0.05, redeclare package Medium = Medium, addPowerToMedium=false, T_start=T_start_cold) "Pump moving fluid from storage tank to condenser of heat pump" AixLib.Fluid.Movers.FlowControlled_dp pumpEvaporator( energyDynamics=energyDynamics, m_flow_nominal=0.05, redeclare package Medium = Medium, addPowerToMedium=false, T_start=T_start_cold) "Pump moving fluid from storage tank to evaporator of heat pump" AixLib.Fluid.Movers.FlowControlled_dp pumpGeothermalSource( energyDynamics=energyDynamics, m_flow_nominal=0.05, redeclare package Medium = Medium, addPowerToMedium=false, T_start=T_start_cold) "Pump moving fluid from geothermal source into system" HeatPumps.ModularReversible.BaseClasses.RefrigerantMachineControlBus heatPumpControlBus AixLib.Fluid.HeatPumps.ModularReversible.Modular heatPump( redeclare package MediumCon = Medium, redeclare package MediumEva = Medium, use_rev=false, tauCon=0.005*heatPump.rhoCon/heatPump.mCon_flow_nominal, dTCon_nominal=0, tauEva=0.005*heatPump.rhoEva/heatPump.mEva_flow_nominal, dpCon_nominal=0, use_conCap=false, CCon=0, GConOut=0, GConIns=0, dTEva_nominal=0, dpEva_nominal=0, use_evaCap=false, CEva=0, GEvaOut=0, GEvaIns=0, use_intSafCtr=false, energyDynamics=energyDynamics, QHea_flow_nominal=12740, redeclare model RefrigerantCycleHeatPumpHeating = AixLib.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.TableData2D ( redeclare AixLib.Fluid.HeatPumps.ModularReversible.Data.TableData2D.EN255.Vitocal350BWH110 datTab), redeclare model RefrigerantCycleHeatPumpCooling = AixLib.Fluid.Chillers.ModularReversible.RefrigerantCycle.BaseClasses.NoCooling, mCon_flow_nominal=0.5, mEva_flow_nominal=0.5, TConHea_nominal=318.15, TEvaHea_nominal=273.15, TConCoo_nominal=273.15, TEvaCoo_nominal=273.15, use_busConOnl=true) equation connect(resistanceGeothermalSource.port_b, valveHeatSink.port_a) connect(valveHeatSource.port_a, valveHeatSink.port_a) connect(resistanceColdStorage.port_b, valveColdStorage.port_a) connect(resistanceHeatStorage.port_b, valveHeatStorage.port_a) connect(pumpColdConsumer.port_b, resistanceColdConsumerFlow.port_a) connect(pumpHeatConsumer.port_b, resistanceHeatConsumerFlow.port_a) connect(pumpEvaporator.port_b, resistanceColdStorage.port_a) connect(pumpCondenser.port_b, resistanceHeatStorage.port_a) connect(pumpGeothermalSource.port_b, resistanceGeothermalSource.port_a) connect(pumpGeothermalSource.port_a, geothFieldSource.ports[1]) connect(resistanceHeatConsumerFlow.port_b, peaLoaDev.port_a) connect(heatPump.port_b1, geothField_sink1.ports[1]) connect(valveHeatStorage.port_b, heatPump.port_a1) connect(heatPump.port_b2, geothField_sink1.ports[2]) connect(heatPump.port_a2, valveHeatSource.port_b) connect(heatPump.port_a2, valveColdStorage.port_b) connect(valveHeatSink.port_b, heatPump.port_a1) connect(heatPumpControlBus, heatPump.sigBus) connect(coldStorage.fluidportBottom1, pumpColdConsumer.port_a) connect(coldStorage.fluidportTop1, resistanceColdConsumerReturn.port_b) connect(pumpCondenser.port_a, heatStorage.portHC1Out) connect(heatPump.port_b1, heatStorage.portHC1In) connect(heatStorage.fluidportTop2, pumpHeatConsumer.port_a) connect(resistanceHeatConsumerReturn.port_b, heatStorage.fluidportBottom2) connect(pumpEvaporator.port_a, coldStorage.portHC1Out) connect(heatPump.port_b2, coldStorage.portHC1In) end GeothermalHeatPumpBase;
Example of a geothermal heat pump system with controllers. Base class of an example demonstrating the use of a heat pump connected to two storages and a geothermal source. A replaceable model is connected in the flow line of the heating circuit. A peak load device can be added here. This model also includes basic controllers.
within AixLib.Fluid.Examples.GeothermalHeatPump.BaseClasses; partial model GeothermalHeatPumpControlledBase "Example of a geothermal heat pump system with controllers" extends BaseClasses.GeothermalHeatPumpBase; Modelica.Blocks.Sources.RealExpression getTStorageUpper(y=heatStorage.layer[ heatStorage.n].T) "Gets the temperature of upper heat storage layer" Modelica.Blocks.Sources.RealExpression getTStorageLower(y=coldStorage.layer[1].T) "Gets the temperature of lower cold storage layer" Modelica.Blocks.Interfaces.RealOutput coldStorageTemperature( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="degC", min=0, start=T_start_cold) "Temperature in the cold storage" Modelica.Blocks.Interfaces.RealOutput heatStorageTemperature( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="degC", min=0, start=T_start_hot) "Temperature in the heat storage" Modelica.Blocks.Interfaces.RealOutput chemicalEnergyFlowRate(final unit="W") "Flow of primary (chemical) energy into boiler " Modelica.Blocks.Interfaces.RealOutput heatPumpPower(final unit="W") "Electrical power of the heat pump" inner Modelica.Fluid.System system equation connect(getTStorageLower.y, coldStorageTemperature) connect(getTStorageUpper.y, heatStorageTemperature) connect(heatPump.P, heatPumpPower) end GeothermalHeatPumpControlledBase;
Contains base classes required for the examples of geothermal heat pump systems
within AixLib.Fluid.Examples.GeothermalHeatPump; package BaseClasses "Contains base classes required for the examples of geothermal heat pump systems" extends Modelica.Icons.BasesPackage; end BaseClasses;
Model containing the simple boiler model and the bus connector for external control. Model containing the simple boiler model <a href= \"modelica://AixLib.Fluid.BoilerCHP.Boiler\">AixLib.Fluid.BoilerCHP.Boiler</a> and interfaces for external control.
within AixLib.Fluid.Examples.GeothermalHeatPump.Components; model BoilerExternalControl "Model containing the simple boiler model and the bus connector for external control" extends BaseClasses.BoilerBase; Controls.Interfaces.BoilerControlBus boilerControlBus equation connect(boiler.TAmbient, boilerControlBus.TAmbient) connect(boiler.switchToNightMode, boilerControlBus.switchToNightMode) connect(boiler.isOn, boilerControlBus.isOn) connect(chemicalEnergyFlowRateSource.y, boilerControlBus.chemicalEnergyFlowRate) end BoilerExternalControl;
Model containing the simple boiler model and all required inputs as dummies. Model containing the simple boiler model <a href= \"modelica://AixLib.Fluid.BoilerCHP.Boiler\">AixLib.Fluid.BoilerCHP.Boiler</a> and dummy inputs.
within AixLib.Fluid.Examples.GeothermalHeatPump.Components; model BoilerStandAlone "Model containing the simple boiler model and all required inputs as dummies" extends BaseClasses.BoilerBase; Modelica.Blocks.Sources.BooleanConstant falseSource(k=false) "Outputs a false signal" Modelica.Blocks.Sources.Constant ambientTemperature(k=273.15 + 10) "Dummy for ambient temperature" Modelica.Blocks.Sources.BooleanConstant trueSource "Outputs a true signal" Modelica.Blocks.Interfaces.RealOutput chemicalEnergyFlowRate(final unit="W") "Flow of primary (chemical) energy into boiler " equation connect(ambientTemperature.y, boiler.TAmbient) connect(falseSource.y, boiler.switchToNightMode) connect(trueSource.y, boiler.isOn) connect(chemicalEnergyFlowRateSource.y,chemicalEnergyFlowRate) end BoilerStandAlone;
Contains variants of the example with connectors to be used in system models.
within AixLib.Fluid.Examples.GeothermalHeatPump; package Components "Contains variants of the example with connectors to be used in system models." extends Modelica.Icons.VariantsPackage; end Components;
Base class containing the simple boiler model as peak load device
within AixLib.Fluid.Examples.GeothermalHeatPump.Components.BaseClasses; partial model BoilerBase "Base class containing the simple boiler model as peak load device" extends Interfaces.PartialTwoPort; parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state" BoilerCHP.Boiler boiler( redeclare final package Medium = Medium, m_flow_nominal=0.5, paramHC=AixLib.DataBase.Boiler.DayNightMode.HeatingCurves_Vitotronic_Day23_Night10(), paramBoiler=AixLib.DataBase.Boiler.General.Boiler_Vitogas200F_11kW(), energyDynamics=energyDynamics) "Peak load energy conversion unit" Modelica.Blocks.Sources.RealExpression chemicalEnergyFlowRateSource( y=boiler.internalControl.ControlerHeater.y) "Outputs the chemical energy flow rate of the boiler" equation connect(port_a, boiler.port_a) connect(boiler.port_b, port_b) end BoilerBase;
Contains base classes of the component models in this example
within AixLib.Fluid.Examples.GeothermalHeatPump.Components; package BaseClasses "Contains base classes of the component models in this example" extends Modelica.Icons.BasesPackage; end BaseClasses;
Controls the heat exchange with a heat or cold source by setting two valves. This is a model of a controller, which manipulates the opening of two valves. If the measured temperature drops below the lower thrshold, the first valve is fully closed and the second valve is fully opened. The opposite constellation applies if the temperature exceeds the higher threshold. To avoid zero mass flow rates, the opening is only close 0. Additionally, a delay can be set so that the valves do not react simultaneously (opened valve is closed first). It can be used in <a href= \"modelica://AixLib.Fluid.Examples.GeothermalHeatPump.Components.GeothermalHeatPump\"> AixLib.Fluid.Examples.GeothermalHeatPump.Components.GeothermalHeatPump</a>.
within AixLib.Fluid.Examples.GeothermalHeatPump.Control; model geothermalFieldController "Controls the heat exchange with a heat or cold source by setting two valves" parameter Modelica.Units.SI.Temperature temperature_low=273.15 + 40 "Lower temperature threshold for hysteresis"; parameter Modelica.Units.SI.Temperature temperature_high=273.15 + 45 "Upper temperature threshold for hysteresis"; parameter Boolean warmSide=true "true = hysteresis with negation = for warm side"; parameter Modelica.Units.SI.Time delayTime=10 "Time delay between opening of valve 1 and 2"; Modelica.Blocks.Logical.Switch switch "Switches between fully opened and fully closed" Modelica.Blocks.Nonlinear.FixedDelay fixedDelay(delayTime=delayTime) "Delay that prevents that both valves react simultaneously" Modelica.Blocks.Math.Add add(k1=-1) "If one valve is fully openend, the other one must be fully closed" Modelica.Blocks.Logical.Hysteresis hysteresis(uLow=temperature_low, uHigh= temperature_high) "Checks if the temperature is too high or too low" Modelica.Blocks.Sources.Constant approxFullyClosed(k=0.00001) "Used for closing a valve almost fully" Modelica.Blocks.Sources.Constant approxFullyOpened(k=0.99999) "Used for opening a valve almost fully" Modelica.Blocks.Interfaces.RealInput temperature( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="degC", min=0) "Temperature of the controlled flow" Modelica.Blocks.Interfaces.RealOutput valveOpening1(min=0, max=1) "Actuator position (0: closed, 1: open)" Modelica.Blocks.Interfaces.RealOutput valveOpening2(min=0, max=1) "Actuator position (0: closed, 1: open)" Modelica.Blocks.Logical.Switch switch1 "Switches between delayed and direct opening" Modelica.Blocks.Logical.Switch switch2 "Switches between delayed and direct opening" Modelica.Blocks.Nonlinear.FixedDelay fixedDelay1( delayTime=delayTime) "Delay that prevents that both valves react simultaneously" Modelica.Blocks.Sources.Constant fullOpening(k=1) "Used for opening a valve fully" equation connect(approxFullyOpened.y, switch.u1) connect(switch.y, add.u1) connect(hysteresis.y, switch.u2) connect(temperature, hysteresis.u) connect(switch1.y, valveOpening1) connect(approxFullyClosed.y, switch.u3) connect(switch2.y, valveOpening2) connect(add.y, fixedDelay.u) connect(hysteresis.y, switch1.u2) connect(hysteresis.y, switch2.u2) connect(fixedDelay.y, switch2.u3) connect(add.y, switch2.u1) connect(switch1.u1, fixedDelay1.y) connect(fixedDelay1.u, switch.y) connect(switch1.u3, switch.y) connect(fullOpening.y, add.u2) end geothermalFieldController;
Contains controllers that are specific for this example
within AixLib.Fluid.Examples.GeothermalHeatPump; package Control "Contains controllers that are specific for this example" end Control;
Example 1 model without mixing volume. This model demonstrates the impact of the <code>allowFlowReversal</code> and <code>from_dp</code> parameters on the sizes of nonlinear algebraic loops. The user can change the parameter value in the respective <code>BooleanConstant</code> blocks and rerun the simulation to compare the performance. The results are also demonstrated below for <code>nRes.k = 20</code>, the number of parallel branches, which contain one pressure drop element each.
within AixLib.Fluid.Examples.Performance; model Example1v1 "Example 1 model without mixing volume" extends AixLib.Fluid.Examples.Performance.BaseClasses.Example1( allowFlowReversal(k=false), from_dp(k=true)); equation for i in 1:nRes.k loop connect(res[i].port_b, val.port_3) end for;<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example1v2(from_dp.k=true, allowFlowReversal.k=true)\", stopTime=10000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example1v2\");<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example1v1(allowFlowReversal.k=false, from_dp.k=false)\", stopTime=10000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example1v1\");<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example1v1(allowFlowReversal.k=false, from_dp.k=true)\", stopTime=10000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example1v1\");<br/> createPlot(id=1, position={15, 10, 592, 421}, range={0.0, 10000.0, -0.01, 0.35}, autoscale=false, grid=true);<br/> plotExpression(apply(Example1v1[end-2].CPUtime), false, \"Default case\", 1);<br/> plotExpression(apply(Example1v2[end].CPUtime), false, \"Adding dummy states\", 1);<br/> plotExpression(apply(Example1v1[end-1].CPUtime), false, \"allowFlowReversal=false\", 1);<br/> plotExpression(apply(Example1v1[end].CPUtime), false, \"allowFlowReversal=false, from_dp=true\", 1);<br/> OutputCPUtime=cpuOld;<br/> Evaluate=evaluateOld;</code> </p> <p> See Jorissen et al. (2015) for a discussion. </p> <h4>References</h4> <ul> <li> Filip Jorissen, Michael Wetter and Lieve Helsen.<br/> Simulation speed analysis and improvements of Modelica models for building energy simulation.<br/> Submitted: 11th Modelica Conference. Paris, France. Sep. 2015. </li> </ul> </html>", revisions="<html> <ul> <li> July 14, 2015, by Michael Wetter:<br/> Revised documentation. </li> <li> April 17, 2015, by Filip Jorissen:<br/> First implementation. </li> </ul> </html>"), __Dymola_Commands(file="modelica://AixLib/Resources/Scripts/Dymola/Fluid/Examples/Performance/Example1v1.mos" "Simulate and plot"), __Dymola_LockedEditing="Model from IBPSA"); end Example1v1;
Example 1 model with mixing volume
within AixLib.Fluid.Examples.Performance; model Example1v2 "Example 1 model with mixing volume" extends AixLib.Fluid.Examples.Performance.BaseClasses.Example1; parameter Modelica.Units.SI.Time tau=10 "Time constant at nominal flow"; Fluid.Delays.DelayFirstOrder[nRes.k] vol( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=allowFlowReversal.k, each nPorts=2, each tau=tau, each energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Mixing volumes for adding states in enthalpy circuit" equation for i in 1:nRes.k loop connect(vol[i].ports[1], res[i].port_b) connect(vol[i].ports[2], val.port_3) end for; end Example1v2;
Example 2 model with series pressure components
within AixLib.Fluid.Examples.Performance; model Example2 "Example 2 model with series pressure components" extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; Fluid.Movers.FlowControlled_dp pump_dp( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, use_inputFilter=false, allowFlowReversal=false, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, nominalValuesDefineDefaultPressureCurve=true) "Pump model with unidirectional flow" Fluid.Sources.Boundary_pT bou(redeclare package Medium = Medium, nPorts=1) "Boundary for absolute pressure boundary condition" Modelica.Blocks.Sources.Pulse pulse(period=1) "Pulse input" FixedResistances.PressureDrop[nRes.k] res( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each from_dp=from_dp.k, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes.k}) Modelica.Blocks.Sources.BooleanConstant from_dp(k=true) "Block for easily changing parameter from_dp.k" Modelica.Blocks.Sources.IntegerConstant nRes(k=6) "Number of parallel branches" equation connect(pump_dp.port_a, bou.ports[1]) connect(pump_dp.dp_in, pulse.y) connect(res[1].port_a, pump_dp.port_b) for i in 1:nRes.k-1 loop connect(res[i].port_b, res[i+1].port_a) end for; connect(res[nRes.k].port_b, pump_dp.port_a)<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example2(from_dp.k=true)\", stopTime=10000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example2\");<br/> createPlot(id=1, position={15, 10, 592, 421}, range={0.0, 10000.0, -0.01, 25}, autoscale=false, grid=true);<br/> plotExpression(apply(Example2[end-1].CPUtime), false, \"from_dp=false\", 1);<br/> plotExpression(apply(Example2[end].CPUtime), false, \"from_dp=true\", 1);<br/> OutputCPUtime=cpuOld;<br/> Evaluate=evaluateOld;<br/> </code> </p> <p> See Jorissen et al. (2015) for a discussion. </p> <h4>References</h4> <ul> <li> Filip Jorissen, Michael Wetter and Lieve Helsen.<br/> Simulation speed analysis and improvements of Modelica models for building energy simulation.<br/> Submitted: 11th Modelica Conference. Paris, France. Sep. 2015. </li> </ul> </html>", revisions="<html> <ul> <li> January 22, 2016, by Michael Wetter:<br/> Corrected type declaration of pressure difference. This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/404\">#404</a>. </li> <li> July 14, 2015, by Michael Wetter:<br/> Revised documentation. </li> <li> May 20, 2015, by Filip Jorissen:<br/> First implementation. </li> </ul> </html>"), __Dymola_Commands(file="modelica://AixLib/Resources/Scripts/Dymola/Fluid/Examples/Performance/Example2.mos" "Simulate and plot"), __Dymola_LockedEditing="Model from IBPSA"); end Example2;
Example 3 model with mixed series/parallel pressure drop components
within AixLib.Fluid.Examples.Performance; model Example3 "Example 3 model with mixed series/parallel pressure drop components" extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; Fluid.Movers.FlowControlled_m_flow pump( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, use_inputFilter=false, allowFlowReversal=false, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, nominalValuesDefineDefaultPressureCurve=true) "Pump model with unidirectional flow" Fluid.Sources.Boundary_pT bou(redeclare package Medium = Medium, nPorts=1) "Boundary for absolute pressure boundary condition" Modelica.Blocks.Sources.Pulse pulse(period=1) "Pulse input" FixedResistances.PressureDrop[nRes.k] res( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each from_dp=from_dp.k, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) + (if mergeDp.k then 0 else dp_nominal) for i in 1:nRes.k}) "First pressure drop component" Modelica.Blocks.Sources.BooleanConstant mergeDp(k=true) "Block for easily changing parameter mergeDp.k" Modelica.Blocks.Sources.BooleanConstant from_dp(k=true) "Block for easily changing parameter from_dp.k" FixedResistances.PressureDrop[nRes.k] res1( redeclare package Medium = Medium, each m_flow_nominal=m_flow_nominal, each from_dp=from_dp.k, each allowFlowReversal=false, each dp_nominal=if mergeDp.k then 0 else dp_nominal) "Second pressure drop component" Modelica.Blocks.Sources.IntegerConstant nRes(k=6) "Block for easily changing parameter nRes.k" equation connect(pump.port_a, bou.ports[1]) connect(pulse.y, pump.m_flow_in) connect(res.port_b, res1.port_a) for i in 1:nRes.k loop connect(res[i].port_a, pump.port_b) connect(res1[i].port_b, pump.port_a) end for;<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example3(from_dp.k=false, mergeDp.k=true, nRes.k=10)\", stopTime=1000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example3\");<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example3(from_dp.k=true, mergeDp.k=false, nRes.k=10)\", stopTime=1000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example3\");<br/> simulateModel(\"AixLib.Fluid.Examples.Performance.Example3(from_dp.k=true, mergeDp.k=true, nRes.k=10)\", stopTime=1000, numberOfIntervals=10, method=\"dassl\", resultFile=\"Example3\");<br/> createPlot(id=1, position={15, 10, 592, 421}, range={0.0, 1000.0, -0.01, 8}, autoscale=false, grid=true);<br/> plotExpression(apply(Example3[end-3].CPUtime), false, \"from_dp=false, mergeDp=false\", 1);<br/> plotExpression(apply(Example3[end-2].CPUtime), false, \"from_dp=false, mergeDp=true\", 1);<br/> plotExpression(apply(Example3[end-1].CPUtime), false, \"from_dp=true, mergeDp=false\", 1);<br/> plotExpression(apply(Example3[end].CPUtime), false, \"from_dp=true, mergeDp=true\", 1);<br/> OutputCPUtime=cpuOld;<br/> Evaluate=evaluateOld;</code> </p> <p> See Jorissen et al. (2015) for a discussion. </p> <h4>References</h4> <ul> <li> Filip Jorissen, Michael Wetter and Lieve Helsen.<br/> Simulation speed analysis and improvements of Modelica models for building energy simulation.<br/> Submitted: 11th Modelica Conference. Paris, France. Sep. 2015. </li> </ul> </html>"), __Dymola_Commands(file="modelica://AixLib/Resources/Scripts/Dymola/Fluid/Examples/Performance/Example3.mos" "Simulate and plot"), __Dymola_LockedEditing="Model from IBPSA"); end Example3;
Example 4 model of simple condensing heat exchanger
within AixLib.Fluid.Examples.Performance; model Example4 "Example 4 model of simple condensing heat exchanger" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Boolean allowFlowReversal=false "= false to simplify equations, assuming, but not enforcing, no flow reversal"; Modelica.Units.SI.MassFlowRate m_condens=min(0, -vol.ports[1].m_flow*(bou.X[1] - xSat.X[1])) "Water vapor mass flow rate"; Fluid.MixingVolumes.MixingVolumeMoistAir vol( nPorts=2, ports(m_flow(min={0,-Modelica.Constants.inf})), redeclare package Medium = Medium, m_flow_nominal=1, V=1, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, prescribedHeatFlowRate=true) "Mixing volume for extracting moisture" Fluid.HeatExchangers.ConstantEffectiveness hex( redeclare package Medium1 = Medium, redeclare package Medium2 = Medium, m1_flow_nominal=1, m2_flow_nominal=1, dp1_nominal=0, dp2_nominal=0, allowFlowReversal1=allowFlowReversal, allowFlowReversal2=allowFlowReversal) "Heat exchanger" Fluid.Sources.Boundary_pT bou( redeclare package Medium = Medium, p=Medium.p_default + 1000, use_p_in=false, use_T_in=true, X={0.02,0.98}, nPorts=2) "Sink and source" Fluid.Sources.MassFlowSource_T sou( redeclare package Medium = Medium, m_flow=1, T=273.15, nPorts=1) "Air source" Fluid.Sources.Boundary_pT sin(redeclare package Medium = Medium, nPorts=1) "Air sink" Modelica.Blocks.Sources.RealExpression mCond(y=m_condens) AixLib.Utilities.Psychrometrics.X_pTphi xSat(use_p_in=false) "Block for converting relative humidity into absolute humidity" Modelica.Blocks.Sources.Constant phiSat(k=1) "Humidity of 100%" Modelica.Blocks.Sources.Ramp Tin( duration=1, height=20, offset=293.15) "Inlet temperature ramp" FixedResistances.PressureDrop res( redeclare package Medium = Medium, m_flow_nominal=1, dp_nominal=100, allowFlowReversal=allowFlowReversal, from_dp=true) "Pressure drop component" Fluid.Sensors.TemperatureTwoPort senTem( redeclare package Medium = Medium, allowFlowReversal=false, m_flow_nominal=1, tau=0) "Temperature sensor" equation connect(phiSat.y, xSat.phi) connect(mCond.y, vol.mWat_flow) connect(Tin.y, bou.T_in) connect(res.port_b, sin.ports[1]) connect(senTem.port_b, vol.ports[1]) connect(senTem.T, xSat.T) connect(vol.ports[2], res.port_a) connect(hex.port_a1, sou.ports[1]) connect(hex.port_a2, bou.ports[1]) connect(hex.port_b1, bou.ports[2]) connect(hex.port_b2, senTem.port_a) end Example4;
Example 5 model of Modelica code that is inefficiently compiled into C-code. This example illustrates the impact of Modelica code formulations on the C-code.
within AixLib.Fluid.Examples.Performance; model Example5 "Example 5 model of Modelica code that is inefficiently compiled into C-code" extends Modelica.Icons.Example; parameter Boolean efficient = false parameter Real[3] a = 1:3; parameter Real b=sum(a); Real c; protected constant Real k(final unit="1/s") = 1 "Unit conversion to satisfy unit check"; initial equation c=0; equation der(c) = sin(k*time)*(if efficient then b else sum(a)); F_[0] = helpvar[0]*(IF DP_[0] THEN W_[0] ELSE DP_[1]+DP_[2]+DP_[3]); </pre> <h4>Efficient = false and Evaluate = true</h4> <pre> helpvar[0] = sin(Time); F_[0] = helpvar[0]*(DP_[0]+DP_[1]+DP_[2]); </pre> <h4>Efficient = true and Evaluate = true</h4> <pre> helpvar[0] = sin(Time); F_[0] = helpvar[0]*W_[1]; </pre> <p> The last option requires much less operations to be performed and is therefore more efficient. </p> <p> See Jorissen et al. (2015) for a discussion. </p> <h4>References</h4> <ul> <li> Filip Jorissen, Michael Wetter and Lieve Helsen.<br/> Simulation speed analysis and improvements of Modelica models for building energy simulation.<br/> Submitted: 11th Modelica Conference. Paris, France. Sep. 2015. </li> </ul> </html>"), __Dymola_Commands(file="modelica://AixLib/Resources/Scripts/Dymola/Fluid/Examples/Performance/Example5.mos" "Simulate and plot"), __Dymola_LockedEditing="Model from IBPSA"); end Example5;
Example 6 model of Modelica code that is inefficiently compiled into C-code. This example, together with <a href=\"modelica://AixLib.Fluid.Examples.Performance.Example7\"> AixLib.Fluid.Examples.Performance.Example7</a>, illustrates the overhead generated by divisions by parameters. See Jorissen et al. (2015) for a complementary discussion.
within AixLib.Fluid.Examples.Performance; model Example6 "Example 6 model of Modelica code that is inefficiently compiled into C-code" extends Modelica.Icons.Example; parameter Integer nCapacitors = 500; parameter Real R = 0.001; // parameter Real C = 1000; // Real[nCapacitors] T; Real[nCapacitors+1] Q_flow; protected constant Real k(final unit="1/s") = 1 "Unit conversion to satisfy unit check"; initial equation T = fill(273.15,nCapacitors); equation Q_flow[1]=((273.15+sin(k*time))-T[1])/R; der(T[1])=(Q_flow[1]-Q_flow[2])/C; for i in 2:nCapacitors loop Q_flow[i] = (T[i-1] - T[i])/R; der(T[i])=(Q_flow[i]-Q_flow[i+1])/C; end for; Q_flow[nCapacitors+1]=0; //adiabatic simulateModel(\"AixLib.Fluid.Examples.PerformanceExamples.Example7\", stopTime=100, numberOfIntervals=1, method=\"Rkfix4\", fixedstepsize=0.001, resultFile=\"Example7\"); </pre> <p> Comparing the CPU times indicates a speed improvement of <i>56%</i>. This difference almost disappears when adding <code> F_[0] = divmacro(W_[1]-W_[2],\"Q_flow[1]-Q_flow[2]\",DP_[1],\"C\"); </pre> <p> This suggests that the parameter division needs to be handled during each function evaluation, probably causing the increased overhead. </p> <p> The following command allows comparing the CPU times objectively. </p> <p> <code> simulateModel(\"AixLib.Fluid.Examples.Performance.Example6\", stopTime=100, numberOfIntervals=1, method=\"Euler\", fixedstepsize=0.001, resultFile=\"Example6\"); </code> </p> <p> See Jorissen et al. (2015) for a discussion. </p> <h4>References</h4> <ul> <li> Filip Jorissen, Michael Wetter and Lieve Helsen.<br/> Simulation speed analysis and improvements of Modelica models for building energy simulation.<br/> Submitted: 11th Modelica Conference. Paris, France. Sep. 2015. </li> </ul> </html>"), __Dymola_Commands(file="modelica://AixLib/Resources/Scripts/Dymola/Fluid/Examples/Performance/Example6.mos" "Simulate and plot"), __Dymola_LockedEditing="Model from IBPSA"); end Example6;
Example 7 model of Modelica code that is more efficiently compiled into C-code. See <a href=\"modelica://AixLib.Fluid.Examples.Performance.Example6\"> AixLib.Fluid.Examples.Performance.Example6</a> for the documentation.
within AixLib.Fluid.Examples.Performance; model Example7 "Example 7 model of Modelica code that is more efficiently compiled into C-code" extends Modelica.Icons.Example; parameter Integer nTem = 500; parameter Real R = 0.001; parameter Real C = 1000; parameter Real tauInv = 1/(R*C); Real[nTem] T; protected constant Real k(final unit="1/s") = 1 "Unit conversion to satisfy unit check"; initial equation T = fill(273.15, nTem); equation der(T[1])= ((273.15+sin(k*time))-2*T[1] + T[2])*tauInv; for i in 2:nTem-1 loop der(T[i])=(T[i+1]+T[i-1]-2*T[i])*tauInv; end for; der(T[nTem])= (T[nTem-1]-T[nTem])*tauInv; end Example7;
Common subexpression elimination example. This is a very simple example demonstrating common subexpression elimination. The Dymola generated <code>C-code</code> of this model is:
within AixLib.Fluid.Examples.Performance; model Example8 "Common subexpression elimination example" extends Modelica.Icons.Example; Real a = sin(k*time+1); Real b = sin(k*time+1); protected constant Real k(final unit="1/s") = 1 "Unit conversion to satisfy unit check"; W_[1] = W_[0]; </pre> <p> Hence, the sine and addition are evaluated once only, which is more efficient. </p> </html>"), __Dymola_Commands(file="modelica://AixLib/Resources/Scripts/Dymola/Fluid/Examples/Performance/Example8.mos" "Simulate and plot"), __Dymola_LockedEditing="Model from IBPSA"); end Example8;
Package of examples that demonstrate computation speed performance
within AixLib.Fluid.Examples; package Performance "Package of examples that demonstrate computation speed performance" extends Modelica.Icons.ExamplesPackage; end Performance;
Example 1 partial model
within AixLib.Fluid.Examples.Performance.BaseClasses; partial model Example1 "Example 1 partial model" extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; parameter Real m_flow_nominal=0.1 "Gain value multiplied with input signal"; AixLib.Fluid.Sources.Boundary_pT bou( redeclare package Medium = Medium, nPorts=1) "Boundary for pressure boundary condition" Fluid.Movers.FlowControlled_m_flow pump( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, use_inputFilter=false, allowFlowReversal=allowFlowReversal.k, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, nominalValuesDefineDefaultPressureCurve=true) "Pump model with unidirectional flow" AixLib.Fluid.HeatExchangers.Heater_T hea( redeclare package Medium = Medium, dp_nominal=1000, QMax_flow=1000, m_flow_nominal=m_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=allowFlowReversal.k) "Heater" Modelica.Blocks.Sources.Pulse pulse(period=1000) "Pulse input" Modelica.Blocks.Math.Gain gain(k=m_flow_nominal) "Gain for m_flow_nominal" AixLib.Fluid.Actuators.Valves.ThreeWayLinear val( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dpValve_nominal=1000, l={0.002,0.002}, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, use_inputFilter=false, portFlowDirection_1=if allowFlowReversal.k then Modelica.Fluid.Types.PortFlowDirection.Bidirectional else Modelica.Fluid.Types.PortFlowDirection.Entering, portFlowDirection_2=if allowFlowReversal.k then Modelica.Fluid.Types.PortFlowDirection.Bidirectional else Modelica.Fluid.Types.PortFlowDirection.Leaving, portFlowDirection_3=if allowFlowReversal.k then Modelica.Fluid.Types.PortFlowDirection.Bidirectional else Modelica.Fluid.Types.PortFlowDirection.Entering) "Three way valve with constant input" Modelica.Blocks.Sources.Constant const(k=0.5) "Constant valve set point" Modelica.Blocks.Sources.BooleanConstant allowFlowReversal(k=true) "Block for setting allowFlowReversal in components" AixLib.Fluid.FixedResistances.PressureDrop[nRes.k] res( redeclare package Medium = Medium, each allowFlowReversal=allowFlowReversal.k, each m_flow_nominal=m_flow_nominal, each dp_nominal=1000, each from_dp=from_dp.k) "Fluid resistance for splitting flow" Modelica.Blocks.Sources.IntegerConstant nRes(k=20) "Number of parallel branches" Modelica.Blocks.Sources.BooleanConstant from_dp(k=false) "Block for setting from_dp in res" equation connect(bou.ports[1],hea. port_a) connect(pulse.y,hea. TSet) connect(pump.m_flow_in, gain.y) connect(gain.u,pulse. y) connect(hea.port_b,val. port_1) connect(val.port_2, pump.port_a) connect(const.y,val. y) connect(val.port_3,hea. port_a) for i in 1:nRes.k loop connect(pump.port_b, res[i].port_a) end for; end Example1;
Package with various configurations of pressure drop models to analyze symbolic processing
within AixLib.Fluid.Examples.Performance; package PressureDrop "Package with various configurations of pressure drop models to analyze symbolic processing" extends Modelica.Icons.ExamplesPackage; end PressureDrop;
Parallel connection with prescribed pressure difference and non-optimised parameters
within AixLib.Fluid.Examples.Performance.PressureDrop; model ParallelDp "Parallel connection with prescribed pressure difference and non-optimised parameters" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Integer nRes(min=2) = 10 "Number of resistances"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=1, use_p_in=true) "Pressure boundary condition" Modelica.Blocks.Sources.Pulse pulse_p( period=1, offset=Medium.p_default, amplitude=dp_nominal) "Pulse input for pressure" FixedResistances.PressureDrop[nRes] resParallel( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes}, each from_dp=false) "Parallel pressure drop components" Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=1) "Pressure boundary condition" equation connect(pulse_p.y,sou. p_in) for i in 1:nRes-1 loop connect(resParallel[i].port_a, resParallel[i + 1].port_a) connect(resParallel[i].port_b, resParallel[i + 1].port_b) end for; connect(resParallel[nRes].port_b, sin.ports[1]) connect(resParallel[1].port_a, sou.ports[1]) end ParallelDp;
Parallel connection with prescribed pressure difference and optimised parameters. Example model that demonstrates how translation statistics depend on the type of boundary conditions, the parallel or series configuration of the components and the value of parameter <code>from_dp</code>.
within AixLib.Fluid.Examples.Performance.PressureDrop; model ParallelDpOptimised "Parallel connection with prescribed pressure difference and optimised parameters" extends ParallelDp(resParallel(each from_dp=true)); end ParallelDpOptimised;
Parallel connection with prescribed flow rate and non-optimised parameters
within AixLib.Fluid.Examples.Performance.PressureDrop; model ParallelFlow "Parallel connection with prescribed flow rate and non-optimised parameters" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Integer nRes(min=2) = 10 "Number of resistances"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; Sources.MassFlowSource_T sou( redeclare package Medium = Medium, nPorts=1, use_m_flow_in=true) "Flow rate boundary condition" Modelica.Blocks.Sources.Pulse pulse_m_flow( amplitude=1, period=1, offset=0) "Pulse input for flow rate" FixedResistances.PressureDrop[nRes] resParallel( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes}, each from_dp=false) "Parallel pressure drop components" Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=1) "Pressure boundary condition" equation for i in 1:nRes-1 loop connect(resParallel[i].port_a, resParallel[i + 1].port_a) connect(resParallel[i].port_b, resParallel[i + 1].port_b) end for; connect(resParallel[nRes].port_b, sin.ports[1]) connect(resParallel[1].port_a, sou.ports[1]) connect(pulse_m_flow.y, sou.m_flow_in) end ParallelFlow;
Parallel connection with prescribed flow rate and optimised parameters. Example model that demonstrates how translation statistics depend on the type of boundary conditions, the parallel or series configuration of the components and the value of parameter <code>from_dp</code>.
within AixLib.Fluid.Examples.Performance.PressureDrop; model ParallelFlowOptimised "Parallel connection with prescribed flow rate and optimised parameters" extends ParallelFlow( resParallel(each from_dp=true)); end ParallelFlowOptimised;
Series connection with prescribed pressure difference and non-optimised parameters
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesDp "Series connection with prescribed pressure difference and non-optimised parameters" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Integer nRes(min=2) = 10 "Number of resistances"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=1, use_p_in=true) "Pressure boundary condition" Modelica.Blocks.Sources.Pulse pulse_p( period=1, offset=Medium.p_default, amplitude=dp_nominal) "Pulse input for pressure" FixedResistances.PressureDrop[nRes] resSeries( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes}, each from_dp=true) "Series pressure drop components" Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=1) "Pressure boundary condition" equation connect(pulse_p.y,sou. p_in) for i in 1:nRes-1 loop connect(resSeries[i].port_b, resSeries[i + 1].port_a) end for; connect(resSeries[nRes].port_b, sin.ports[1]) connect(resSeries[1].port_a, sou.ports[1]) end SeriesDp;
Series connection with prescribed pressure difference and optimised parameters. Example model that demonstrates how translation statistics depend on the type of boundary conditions, the parallel or series configuration of the components and the value of parameter <code>from_dp</code>.
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesDpOptimised "Series connection with prescribed pressure difference and optimised parameters" extends SeriesDp( resSeries(each from_dp=false)); end SeriesDpOptimised;
Series connection with prescribed flow rate and non-optimised parameters
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesFlow "Series connection with prescribed flow rate and non-optimised parameters" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Integer nRes(min=2) = 10 "Number of resistances"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; Sources.MassFlowSource_T sou( redeclare package Medium = Medium, nPorts=1, use_m_flow_in=true) "Flow rate boundary condition" Modelica.Blocks.Sources.Pulse pulse_p( amplitude=1, period=1, offset=0) "Pulse input for flow rate" FixedResistances.PressureDrop[nRes] resSeries( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes}, each from_dp=true) "Series pressure drop components" Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=1) "Pressure boundary condition" equation for i in 1:nRes-1 loop connect(resSeries[i].port_b, resSeries[i + 1].port_a) end for; connect(resSeries[nRes].port_b, sin.ports[1]) connect(resSeries[1].port_a, sou.ports[1]) connect(sou.m_flow_in, pulse_p.y) end SeriesFlow;
Series connection with prescribed flow and optimised parameters. Example model that demonstrates how translation statistics depend on the type of boundary conditions, the parallel or series configuration of the components and the value of parameter <code>from_dp</code>.
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesFlowOptimised "Series connection with prescribed flow and optimised parameters" extends SeriesFlow(resSeries(each from_dp=false)); end SeriesFlowOptimised;
Combined series and parallel connection with prescribed pressure difference and non-optimised parameters
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesParallelDp "Combined series and parallel connection with prescribed pressure difference and non-optimised parameters" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Integer nRes(min=2) = 10 "Number of resistances"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; Sources.Boundary_pT sou( redeclare package Medium = Medium, nPorts=1, use_p_in=true) "Pressure boundary condition" Modelica.Blocks.Sources.Pulse pulse_m_flow( period=1, offset=Medium.p_default, amplitude=dp_nominal) "Pulse input for flow rate" FixedResistances.PressureDrop[nRes] resParallel( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes}, each from_dp=false) "Parallel pressure drop components" Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=1) "Pressure boundary condition" FixedResistances.PressureDrop res2( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, from_dp=false) "Series pressure drop component" equation for i in 1:nRes-1 loop connect(resParallel[i].port_a, resParallel[i + 1].port_a) connect(resParallel[i].port_b, resParallel[i + 1].port_b) end for; connect(resParallel[1].port_a, sou.ports[1]) connect(resParallel[nRes].port_b, res2.port_a) connect(res2.port_b, sin.ports[1]) connect(pulse_m_flow.y, sou.p_in) end SeriesParallelDp;
Combined series and parallel connection with prescribed pressure difference and non-optimised parameters. Example model that demonstrates how translation statistics depend on the type of boundary conditions, the parallel or series configuration of the components and the value of parameter <code>from_dp</code>.
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesParallelDpOptimised "Combined series and parallel connection with prescribed pressure difference and non-optimised parameters" extends SeriesParallelDp( res2(from_dp=true), resParallel(each from_dp=true)); end SeriesParallelDpOptimised;
Combined series and parallel connection with prescribed flow rate and non-optimised parameters
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesParallelFlow "Combined series and parallel connection with prescribed flow rate and non-optimised parameters" extends Modelica.Icons.Example; package Medium = AixLib.Media.Air; parameter Integer nRes(min=2) = 10 "Number of resistances"; parameter Modelica.Units.SI.PressureDifference dp_nominal=1 "Pressure drop at nominal mass flow rate"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=1 "Nominal mass flow rate"; Sources.MassFlowSource_T sou( redeclare package Medium = Medium, nPorts=1, use_m_flow_in=true) "Flow rate boundary condition" Modelica.Blocks.Sources.Pulse pulse_m_flow( amplitude=1, period=1, offset=0) "Pulse input for flow rate" FixedResistances.PressureDrop[nRes] resParallel( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each allowFlowReversal=false, dp_nominal={dp_nominal*(1 + mod(i, 3)) for i in 1:nRes}, each from_dp=false) "Parallel pressure drop components" Sources.Boundary_pT sin( redeclare package Medium = Medium, nPorts=1) "Pressure boundary condition" FixedResistances.PressureDrop res2( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, from_dp=true) "Series pressure drop component" equation for i in 1:nRes-1 loop connect(resParallel[i].port_a, resParallel[i + 1].port_a) connect(resParallel[i].port_b, resParallel[i + 1].port_b) end for; connect(resParallel[1].port_a, sou.ports[1]) connect(pulse_m_flow.y, sou.m_flow_in) connect(resParallel[nRes].port_b, res2.port_a) connect(res2.port_b, sin.ports[1]) end SeriesParallelFlow;
Combined series and parallel connection with prescribed flow rate and non-optimised parameters. Example model that demonstrates how translation statistics depend on the type of boundary conditions, the parallel or series configuration of the components and the value of parameter <code>from_dp</code>.
within AixLib.Fluid.Examples.Performance.PressureDrop; model SeriesParallelFlowOptimised "Combined series and parallel connection with prescribed flow rate and non-optimised parameters" extends SeriesParallelFlow( res2(from_dp=false), resParallel(each from_dp=true)); end SeriesParallelFlowOptimised;
Check valve that avoids flow reversal. Implementation of a hydraulic check valve. Note that the small reverse flows can still occur with this model.
within AixLib.Fluid.FixedResistances; model CheckValve "Check valve that avoids flow reversal" extends AixLib.Fluid.BaseClasses.PartialResistance( dp(nominal=2000), final dp_nominal=dpValve_nominal + dpFixed_nominal, final m_flow_turbulent=deltaM*abs(m_flow_nominal), final from_dp=true, final linearized=false, allowFlowReversal=true); extends AixLib.Fluid.Actuators.BaseClasses.ValveParameters( rhoStd=Medium.density_pTX(101325, 273.15 + 4, Medium.X_default)); parameter Modelica.Units.SI.PressureDifference dpFixed_nominal( displayUnit="Pa", min=0) = 0 "Pressure drop of pipe and other resistances that are in series" parameter Modelica.Units.SI.PressureDifference dpValve_closing= dpValve_nominal/2 "Pressure drop when the check valve starts to close" parameter Real l(min=1e-10, max=1)=0.001 "Valve leakage, l=Kv(y=0)/Kv(y=1)"; parameter Real kFixed(unit="", min=0)= if dpFixed_nominal > Modelica.Constants.eps then m_flow_nominal/sqrt(dpFixed_nominal) else 0 "Flow coefficient of fixed resistance that may be in series with valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)."; Real k(min=Modelica.Constants.small) "Flow coefficient of valve and pipe in series in allowed/forward direction, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)."; protected Real a "Scaled pressure variable"; Real cv "Twice differentiable Heaviside check valve characteristic"; Real kCv "Smoothed restriction characteristic"; initial equation assert(dpFixed_nominal > -Modelica.Constants.eps, "In " + getInstanceName() + ": We require dpFixed_nominal >= 0. Received dpFixed_nominal = " + String(dpFixed_nominal) + " Pa."); assert(l > -Modelica.Constants.eps, "In " + getInstanceName() + ": We require l >= 0. Received l = " + String(l)); equation a = dp/dpValve_closing; cv = smooth(2, max(0, min(1, a^3*(10+a*(-15+6*a))))); kCv = Kv_SI*(cv*(1-l) + l); if (dpFixed_nominal > Modelica.Constants.eps) then k = sqrt(1/(1/kFixed^2 + 1/kCv^2)); else k = kCv; end if; if homotopyInitialization then m_flow = homotopy( actual=AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp = dp, k = k, m_flow_turbulent = m_flow_turbulent), simplified = m_flow_nominal_pos*dp/dp_nominal_pos); else m_flow = AixLib.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp = dp, k = k, m_flow_turbulent = m_flow_turbulent); end if; end CheckValve;
Pipe model that includes several selectable pipe models
within AixLib.Fluid.FixedResistances; model GenericPipe "Pipe model that includes several selectable pipe models" extends AixLib.Fluid.Interfaces.PartialTwoPort; parameter String pipeModel="SimplePipe" parameter AixLib.DataBase.Pipes.PipeBaseDataDefinition parameterPipe= AixLib.DataBase.Pipes.Copper.Copper_6x1() "Pipe type" parameter Modelica.Units.SI.Length length(min=0) "Pipe length"; parameter Boolean withInsulation=true "Pipe with or without insulation" parameter AixLib.DataBase.Pipes.InsulationBaseDataDefinition parameterIso= AixLib.DataBase.Pipes.Insulation.Iso50pc() "Insulation Type" parameter Boolean withConvection=true "convectional heat transfer" parameter Modelica.Units.SI.CoefficientOfHeatTransfer hCon=4 "Convection heat transfer coeffient" parameter Modelica.Units.SI.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate" // Advanced parameter Real fac=1 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal" parameter Real ReC=2300 "Reynolds number where transition to turbulent starts" parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)" parameter Integer nNodes=3 "Spatial segmentation for SimplePipe" // Assumptions parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state" parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state" // Initialization parameter Modelica.Units.SI.Temperature T_start=Medium.T_default "Initialization temperature at pipe inlet" PlugFlowPipe plugFlowPipe( redeclare final package Medium = Medium, final allowFlowReversal=allowFlowReversal, final dh=parameterPipe.d_i, final ReC=ReC, final roughness=roughness, final length=length, final m_flow_nominal=m_flow_nominal, final dIns=(parameterPipe.d_o - parameterPipe.d_i)/2, final kIns=parameterPipe.lambda, final cPip=parameterPipe.c, final rhoPip=parameterPipe.d, final thickness=(parameterPipe.d_o - parameterPipe.d_i)/2, final T_start_in=T_start, final T_start_out=T_start, final fac=fac) if pipeModel == "PlugFlowPipe" SimplePipe simplePipe( redeclare final package Medium = Medium, final allowFlowReversal=allowFlowReversal, final nNodes=nNodes, final dh=parameterPipe.d_i, final withHeattransfer=true, final length=length, final fac=fac, final ReC=ReC, final roughness=roughness, final lambda=parameterPipe.lambda, final c=parameterPipe.c, final rho=parameterPipe.d, final thickness=(parameterPipe.d_o - parameterPipe.d_i)/2, final T_start=T_start, final m_flow_nominal=m_flow_nominal, final energyDynamics=energyDynamics, final massDynamics=massDynamics) if pipeModel == "SimplePipe" Modelica.Thermal.HeatTransfer.Components.ThermalCollector thermalCollector( final m=nNodes) if pipeModel == "SimplePipe" Utilities.HeatTransfer.CylindricHeatTransfer Insulation( final energyDynamics=energyDynamics, final c=parameterIso.c, final d_out=parameterPipe.d_o*parameterIso.factor*2 + parameterPipe.d_o, final d_in=parameterPipe.d_o, final length=length/nNodes, final lambda=parameterIso.lambda, final T0=T_start, final rho=parameterIso.d, final nParallel=1) if withInsulation Utilities.HeatTransfer.HeatConv heatConv( final hCon=hCon, final A=Modelica.Constants.pi*parameterPipe.d_o*length) if withConvection "Convection from insulation" Modelica.Thermal.HeatTransfer.Components.ThermalCollector thermalPassthroughInsulation(final m=1) if not withInsulation Modelica.Thermal.HeatTransfer.Components.ThermalCollector thermalPassthroughConvection(final m=1) if not withConvection Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat port at outside surface of pipe" equation connect(simplePipe.heatPorts, thermalCollector.port_a) connect(thermalCollector.port_b, Insulation.port_a) connect(plugFlowPipe.heatPort, Insulation.port_a) connect(plugFlowPipe.port_a, port_a) connect(plugFlowPipe.port_b, port_b) connect(simplePipe.port_a, port_a) connect(simplePipe.port_b, port_b) connect(heatConv.port_a, heatPort) connect(Insulation.port_b, heatConv.port_b) connect(plugFlowPipe.heatPort, thermalPassthroughInsulation.port_a[1]) connect(thermalCollector.port_b, thermalPassthroughInsulation.port_a[1]) connect(thermalPassthroughInsulation.port_b, thermalPassthroughConvection.port_a[1]) connect(thermalPassthroughConvection.port_b, heatPort) connect(thermalPassthroughInsulation.port_b, heatConv.port_b) connect(Insulation.port_b, thermalPassthroughConvection.port_a[1]) end GenericPipe;
Fixed flow resistance with hydraulic diameter and m_flow as parameter
within AixLib.Fluid.FixedResistances; model HydraulicDiameter "Fixed flow resistance with hydraulic diameter and m_flow as parameter" extends AixLib.Fluid.FixedResistances.PressureDrop( final deltaM = eta_default*dh/4*Modelica.Constants.pi*ReC/m_flow_nominal_pos, final dp_nominal=fac*dpStraightPipe_nominal); parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/ v_nominal/Modelica.Constants.pi) "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.Units.SI.Length length "Length of the pipe"; parameter Real ReC(min=0)=4000 "Reynolds number where transition to turbulence starts"; parameter Modelica.Units.SI.Velocity v_nominal=if rho_default < 500 then 1.5 else 0.15 "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" parameter Modelica.Units.SI.Length roughness(min=0) = 2.5e-5 "Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)"; parameter Real fac(min=1) = 2 "Factor to take into account resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal"; final parameter Modelica.Units.SI.PressureDifference dpStraightPipe_nominal( displayUnit="Pa") = Modelica.Fluid.Pipes.BaseClasses.WallFriction.Detailed.pressureLoss_m_flow( m_flow=m_flow_nominal, rho_a=rho_default, rho_b=rho_default, mu_a=mu_default, mu_b=mu_default, length=length, diameter=dh, roughness=roughness, m_flow_small=m_flow_small) "Pressure loss of a straight pipe at m_flow_nominal"; Modelica.Units.SI.Velocity v=m_flow/(rho_default*ARound) "Flow velocity (assuming a round cross section area)"; protected parameter Modelica.Units.SI.Area ARound=dh^2*Modelica.Constants.pi/4 "Cross sectional area (assuming a round cross section area)"; parameter Medium.ThermodynamicState state_default= Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Default state"; parameter Modelica.Units.SI.Density rho_default=Medium.density(state_default) "Density at nominal condition"; parameter Modelica.Units.SI.DynamicViscosity mu_default= Medium.dynamicViscosity(state_default) "Dynamic viscosity at nominal condition"; end HydraulicDiameter;
Simple model for a hydraulic resistance using a pressure loss factor. <b><span style=\"color: #008000;\">Overview</span></b>
within AixLib.Fluid.FixedResistances; model HydraulicResistance "Simple model for a hydraulic resistance using a pressure loss factor" extends AixLib.Fluid.BaseClasses.PartialResistance( final m_flow(start=m_flow_start), final dp(start=dp_start), final dp_nominal=8*zeta*m_flow_nominal*m_flow_nominal/ (rho_default*Modelica.Constants.pi*Modelica.Constants.pi* diameter*diameter*diameter*diameter), final m_flow_turbulent=100*m_flow_nominal); /* No usage of m_flow_turbulent since zeta approach does not distinguish between laminar and turbulent flow. */ parameter Real zeta(min=0, unit="") "Pressure loss factor for flow of port_a -> port_b"; parameter Modelica.Units.SI.Diameter diameter "Diameter of component"; parameter Modelica.Units.SI.PressureDifference dp_start(displayUnit="Pa") = 0 "Guess value of dp = port_a.p - port_b.p" parameter Medium.MassFlowRate m_flow_start=0 "Guess value of m_flow = port_a.m_flow" protected final parameter Real k(min=0, unit="")= Modelica.Fluid.Fittings.BaseClasses.lossConstant_D_zeta( D=diameter, zeta=zeta) "Calculate loss coefficient based on diameter and zeta"; parameter Modelica.Units.SI.PressureDifference dp_small=1E-4*abs(dp_nominal) "Small pressure difference for regularization of zero pressure difference"; parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default[1:Medium.nXi]) "Density at nominal condition"; Modelica.Units.SI.Density rho_a "Density of the fluid at port_a"; Modelica.Units.SI.Density rho_b "Density of the fluid at port_b"; initial equation assert(m_flow_nominal_pos > 0, "m_flow_nominal_pos must be non-zero. Check parameters."); equation rho_a = Medium.density(Medium.setState_phX( p=port_a.p, h=inStream(port_a.h_outflow), X=inStream(port_a.Xi_outflow))); rho_b = Medium.density(Medium.setState_phX( p=port_b.p, h=inStream(port_b.h_outflow), X=inStream(port_b.Xi_outflow))); // Pressure drop calculation if linearized then m_flow*m_flow_nominal_pos = k*k*dp; else if homotopyInitialization then if from_dp then m_flow = homotopy(actual=Modelica.Fluid.Utilities.regRoot2( dp, dp_small, rho_a/k, rho_b/k), simplified=m_flow_nominal_pos*dp/dp_nominal_pos); else dp = homotopy(actual=Modelica.Fluid.Utilities.regSquare2( m_flow, m_flow_small, k/rho_a, k/rho_b), simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos); end if; // from_dp else // do not use homotopy if from_dp then m_flow = Modelica.Fluid.Utilities.regRoot2( dp, dp_small, rho_a/k, rho_b/k); else dp = Modelica.Fluid.Utilities.regSquare2( m_flow, m_flow_small, k/rho_a, k/rho_b); end if; // from_dp end if; // homotopyInitialization end if; // linearized end HydraulicResistance;