LBL logo

Buildings.Fluid.Interfaces

Package with interfaces for fluid models

Information

This package contains basic classes that are used to build component models that change the state of the fluid. The classes are not directly usable, but can be extended when building a new model.

Extends from Modelica.Icons.InterfacesPackage (Icon for packages containing interfaces).

Package Content

NameDescription
Buildings.Fluid.Interfaces.UsersGuide UsersGuide User's Guide
Buildings.Fluid.Interfaces.FourPort FourPort Partial model with four ports
Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger TwoPortHeatMassExchanger Partial model transporting one fluid stream with storing mass or energy
Buildings.Fluid.Interfaces.FourPortHeatMassExchanger FourPortHeatMassExchanger Model transporting two fluid streams between four ports with storing mass or energy
Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger StaticTwoPortHeatMassExchanger Partial model transporting fluid between two ports without storing mass or energy
Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger StaticFourPortHeatMassExchanger Partial model transporting two fluid streams between four ports without storing mass or energy
Buildings.Fluid.Interfaces.PartialTwoPortInterface PartialTwoPortInterface Partial model transporting fluid between two ports without storing mass or energy
Buildings.Fluid.Interfaces.PartialFourPortInterface PartialFourPortInterface Partial model transporting fluid between two ports without storing mass or energy
Buildings.Fluid.Interfaces.ConservationEquation ConservationEquation Lumped volume with mass and energy balance
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation StaticTwoPortConservationEquation Partial model for static energy and mass conservation equations
Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters TwoPortFlowResistanceParameters Parameters for flow resistance for models with two ports
Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters FourPortFlowResistanceParameters Parameters for flow resistance for models with four ports
Buildings.Fluid.Interfaces.LumpedVolumeDeclarations LumpedVolumeDeclarations Declarations for lumped volumes
Buildings.Fluid.Interfaces.Examples Examples Collection of models that illustrate model use and test models


Buildings.Fluid.Interfaces.FourPort Buildings.Fluid.Interfaces.FourPort

Partial model with four ports

Buildings.Fluid.Interfaces.FourPort

Information

This model defines an interface for components with four ports. The parameters allowFlowReversal1 and allowFlowReversal2 may be used by models that extend this model to treat flow reversal.

This model is identical to Modelica.Fluid.Interfaces.PartialTwoPort, except that it has four ports.

Parameters

TypeNameDefaultDescription
Assumptions
BooleanallowFlowReversal1system.allowFlowReversal= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2system.allowFlowReversal= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_startMedium1.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_startMedium1.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_startMedium2.h_defaultStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_startMedium2.h_defaultStart value for enthalpy flowing out of port b2 [J/kg]

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

model FourPort "Partial model with four ports"
  import Modelica.Constants;
  outer Modelica.Fluid.System system "System wide properties";

  replaceable package Medium1 =
      Modelica.Media.Interfaces.PartialMedium "Medium 1 in the component";
  replaceable package Medium2 =
      Modelica.Media.Interfaces.PartialMedium "Medium 2 in the component";

  parameter Boolean allowFlowReversal1 = system.allowFlowReversal 
    "= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)";
  parameter Boolean allowFlowReversal2 = system.allowFlowReversal 
    "= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)";

  parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a1_start = Medium1.h_default 
    "Start value for enthalpy flowing out of port a1";

  parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b1_start = Medium1.h_default 
    "Start value for enthalpy flowing out of port b1";

  parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a2_start = Medium2.h_default 
    "Start value for enthalpy flowing out of port a2";

  parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b2_start = Medium2.h_default 
    "Start value for enthalpy flowing out of port b2";

  Modelica.Fluid.Interfaces.FluidPort_a port_a1(
                                redeclare package Medium = Medium1,
                     m_flow(min=if allowFlowReversal1 then -Constants.inf else 0),
                     h_outflow(nominal=1E5, start=h_outflow_a1_start),
                     Xi_outflow(nominal=0.01)) 
    "Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)";
  Modelica.Fluid.Interfaces.FluidPort_b port_b1(
                                redeclare package Medium = Medium1,
                     m_flow(max=if allowFlowReversal1 then +Constants.inf else 0),
                     h_outflow(nominal=1E5, start=h_outflow_b1_start),
                     Xi_outflow(nominal=0.01)) 
    "Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)";

  Modelica.Fluid.Interfaces.FluidPort_a port_a2(
                                redeclare package Medium = Medium2,
                     m_flow(min=if allowFlowReversal2 then -Constants.inf else 0),
                     h_outflow(nominal=1E5,start=h_outflow_a2_start),
                     Xi_outflow(nominal=0.01)) 
    "Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)";
  Modelica.Fluid.Interfaces.FluidPort_b port_b2(
                                redeclare package Medium = Medium2,
                     m_flow(max=if allowFlowReversal2 then +Constants.inf else 0),
                     h_outflow(nominal=1E5, start=h_outflow_b2_start),
                     Xi_outflow(nominal=0.01)) 
    "Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)";

end FourPort;

Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger

Partial model transporting one fluid stream with storing mass or energy

Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger

Information

This component transports one fluid stream. It provides the basic model for implementing dynamic and steady-state models that exchange heat and water vapor with the fluid stream. The model also computes the pressure drop due to the flow resistance. By setting the parameter dp_nominal=0, the computation of the pressure drop can be avoided. The variable vol.heatPort.T always has the value of the temperature of the medium that leaves the component. For the actual temperatures at the port, the variables sta_a.T and sta_b.T can be used. These two variables are provided by the base class Buildings.Fluid.Interfaces.PartialTwoPortInterface.

For models that extend this model, see for example

Implementation

The variable names follow the conventions used in Modelica.Fluid.HeatExchangers.BasicHX.

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
MixingVolumevolredeclare Buildings.Fluid.Mi...Volume for fluid stream
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp_nominal Pressure [Pa]
Initialization
MassFlowRatem_flow.start0Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction) [kg/s]
Pressuredp.start0Pressure difference between port_a and port_b [Pa]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Tfalse= true, if actual temperature at port is computed (may lead to events)
Flow resistance
BooleancomputeFlowResistancetrue=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistancefalse= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM0.1Fraction of nominal flow rate where flow transitions to laminar
Dynamics
Nominal condition
Timetau30Time constant at nominal flow (if energyDynamics <> SteadyState) [s]
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Formulation of energy balance
DynamicsmassDynamicsenergyDynamicsFormulation of mass balance
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC_start[Medium.nC]fill(0, Medium.nC)Start value of trace substances

Modelica definition

model TwoPortHeatMassExchanger 
  "Partial model transporting one fluid stream with storing mass or energy"
  extends Buildings.Fluid.Interfaces.PartialTwoPortInterface(
    port_a(h_outflow(start=h_outflow_start)),
    port_b(h_outflow(start=h_outflow_start)));
  extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters(
    final computeFlowResistance=true);
  import Modelica.Constants;

  replaceable Buildings.Fluid.MixingVolumes.MixingVolume vol
    constrainedby Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume(
    redeclare final package Medium = Medium,
    nPorts = 2,
    V=m_flow_nominal*tau/rho_nominal,
    final m_flow_nominal = m_flow_nominal,
    final energyDynamics=energyDynamics,
    final massDynamics=massDynamics,
    final p_start=p_start,
    final T_start=T_start,
    final X_start=X_start,
    final C_start=C_start) "Volume for fluid stream";

  parameter Modelica.SIunits.Time tau = 30 
    "Time constant at nominal flow (if energyDynamics <> SteadyState)";

  // Advanced
  parameter Boolean homotopyInitialization = true "= true, use homotopy method";

  // Dynamics
  parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial 
    "Formulation of energy balance";
  parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics 
    "Formulation of mass balance";

  // Initialization
  parameter Medium.AbsolutePressure p_start = Medium.p_default 
    "Start value of pressure";
  parameter Medium.Temperature T_start = Medium.T_default 
    "Start value of temperature";
  parameter Medium.MassFraction X_start[Medium.nX] = Medium.X_default 
    "Start value of mass fractions m_i/m";
  parameter Medium.ExtraProperty C_start[Medium.nC](
       quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) 
    "Start value of trace substances";

protected 
  parameter Medium.ThermodynamicState sta_nominal=Medium.setState_pTX(
      T=Medium.T_default, p=Medium.p_default, X=Medium.X_default);
  parameter Modelica.SIunits.Density rho_nominal=Medium.density(sta_nominal) 
    "Density, used to compute fluid volume";
  parameter Medium.ThermodynamicState sta_start=Medium.setState_pTX(
      T=T_start, p=p_start, X=X_start);
  parameter Modelica.SIunits.SpecificEnthalpy h_outflow_start = Medium.specificEnthalpy(sta_start) 
    "Start value for outflowing enthalpy";
public 
  Buildings.Fluid.FixedResistances.FixedResistanceDpM preDro(
    redeclare package Medium = Medium,
    final use_dh=false,
    final m_flow_nominal=m_flow_nominal,
    final deltaM=deltaM,
    final allowFlowReversal=allowFlowReversal,
    final show_T=false,
    final show_V_flow=show_V_flow,
    final from_dp=from_dp,
    final linearized=linearizeFlowResistance,
    final homotopyInitialization=homotopyInitialization,
    final dp_nominal=dp_nominal) "Pressure drop model";
initial algorithm 
  assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or 
          tau > Modelica.Constants.eps,
"The parameter tau, or the volume of the model from which tau may be derived, is unreasonably small.
 Set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state.
 Received tau = " + String(tau) + "\n");
  assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or 
          tau > Modelica.Constants.eps,
"The parameter tau, or the volume of the model from which tau may be derived, is unreasonably small.          
 Set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state.
 Received tau = " + String(tau) + "\n");


equation 
  connect(vol.ports[2], port_b);
  connect(port_a, preDro.port_a);
  connect(preDro.port_b, vol.ports[1]);
end TwoPortHeatMassExchanger;

Buildings.Fluid.Interfaces.FourPortHeatMassExchanger Buildings.Fluid.Interfaces.FourPortHeatMassExchanger

Model transporting two fluid streams between four ports with storing mass or energy

Buildings.Fluid.Interfaces.FourPortHeatMassExchanger

Information

This component transports two fluid streams between four ports. It provides the basic model for implementing a dynamic heat exchanger.

The model can be used as-is, although there will be no heat or mass transfer between the two fluid streams. To add heat transfer, heat flow can be added to the heat port of the two volumes. See for example Buildings.Fluid.Chillers.Carnot. To add moisture input into (or moisture output from) volume vol2, the model can be replaced as shown in Buildings.Fluid.HeatExchangers.BaseClasses.HexElement.

Implementation

The variable names follow the conventions used in

Modelica.Fluid.HeatExchangers.BasicHX.

Extends from Buildings.Fluid.Interfaces.PartialFourPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters (Parameters for flow resistance for models with four ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
MixingVolumevol2redeclare Buildings.Fluid.Mi...Volume for fluid 2
Nominal condition
MassFlowRatem1_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp1_nominal Pressure [Pa]
Pressuredp2_nominal Pressure [Pa]
Initialization
MassFlowRatem1_flow.start0Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction) [kg/s]
Pressuredp1.start0Pressure difference between port_a1 and port_b1 [Pa]
MassFlowRatem2_flow.start0Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction) [kg/s]
Pressuredp2.start0Pressure difference between port_a2 and port_b2 [Pa]
Assumptions
BooleanallowFlowReversal1system.allowFlowReversal= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2system.allowFlowReversal= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_starth1_outflow_startStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_starth1_outflow_startStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_starth2_outflow_startStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_starth2_outflow_startStart value for enthalpy flowing out of port b2 [J/kg]
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Tfalse= true, if actual temperature at port is computed (may lead to events)
Flow resistance
Medium 1
BooleancomputeFlowResistance1true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar
Dynamics
Nominal condition
Timetau130Time constant at nominal flow [s]
Timetau230Time constant at nominal flow [s]
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Formulation of energy balance
DynamicsmassDynamicsenergyDynamicsFormulation of mass balance
Initialization
Medium 1
AbsolutePressurep1_startMedium1.p_defaultStart value of pressure [Pa]
TemperatureT1_startMedium1.T_defaultStart value of temperature [K]
MassFractionX1_start[Medium1.nX]Medium1.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC1_start[Medium1.nC]fill(0, Medium1.nC)Start value of trace substances
ExtraPropertyC1_nominal[Medium1.nC]fill(1E-2, Medium1.nC)Nominal value of trace substances. (Set to typical order of magnitude.)
Medium 2
AbsolutePressurep2_startMedium2.p_defaultStart value of pressure [Pa]
TemperatureT2_startMedium2.T_defaultStart value of temperature [K]
MassFractionX2_start[Medium2.nX]Medium2.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC2_start[Medium2.nC]fill(0, Medium2.nC)Start value of trace substances
ExtraPropertyC2_nominal[Medium2.nC]fill(1E-2, Medium2.nC)Nominal value of trace substances. (Set to typical order of magnitude.)

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

model FourPortHeatMassExchanger 
  "Model transporting two fluid streams between four ports with storing mass or energy"
  extends Buildings.Fluid.Interfaces.PartialFourPortInterface(
    final h_outflow_a1_start = h1_outflow_start,
    final h_outflow_b1_start = h1_outflow_start,
    final h_outflow_a2_start = h2_outflow_start,
    final h_outflow_b2_start = h2_outflow_start);
  extends Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters(
     final computeFlowResistance1=true, final computeFlowResistance2=true);
  import Modelica.Constants;

  Buildings.Fluid.MixingVolumes.MixingVolume vol1(
    redeclare final package Medium = Medium1,
    nPorts = 2,
    V=m1_flow_nominal*tau1/rho1_nominal,
    final m_flow_nominal=m1_flow_nominal,
    energyDynamics=if tau1 > Modelica.Constants.eps
                         then energyDynamics else 
                         Modelica.Fluid.Types.Dynamics.SteadyState,
    massDynamics=if tau1 > Modelica.Constants.eps
                         then massDynamics else 
                         Modelica.Fluid.Types.Dynamics.SteadyState,
    final p_start=p1_start,
    final T_start=T1_start,
    final X_start=X1_start,
    final C_start=C1_start,
    final C_nominal=C1_nominal) "Volume for fluid 1";

  replaceable Buildings.Fluid.MixingVolumes.MixingVolume vol2
    constrainedby Buildings.Fluid.MixingVolumes.MixingVolume(
    redeclare final package Medium = Medium2,
    nPorts = 2,
    V=m2_flow_nominal*tau2/rho2_nominal,
    final m_flow_nominal = m2_flow_nominal,
    energyDynamics=if tau2 > Modelica.Constants.eps
                         then energyDynamics else 
                         Modelica.Fluid.Types.Dynamics.SteadyState,
    massDynamics=if tau2 > Modelica.Constants.eps
                         then massDynamics else 
                         Modelica.Fluid.Types.Dynamics.SteadyState,
    final p_start=p2_start,
    final T_start=T2_start,
    final X_start=X2_start,
    final C_start=C2_start,
    final C_nominal=C2_nominal) "Volume for fluid 2";

  parameter Modelica.SIunits.Time tau1 = 30 "Time constant at nominal flow";
  parameter Modelica.SIunits.Time tau2 = 30 "Time constant at nominal flow";
  Modelica.SIunits.HeatFlowRate Q1_flow= sum(vol1.heatPort.Q_flow) 
    "Heat flow rate into medium 1";
  Modelica.SIunits.HeatFlowRate Q2_flow= sum(vol2.heatPort.Q_flow) 
    "Heat flow rate into medium 2";

  // Advanced
  parameter Boolean homotopyInitialization = true "= true, use homotopy method";

  // Assumptions
  parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial 
    "Formulation of energy balance";
  parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics 
    "Formulation of mass balance";

  // Initialization
  parameter Medium1.AbsolutePressure p1_start = Medium1.p_default 
    "Start value of pressure";
  parameter Medium1.Temperature T1_start = Medium1.T_default 
    "Start value of temperature";
  parameter Medium1.MassFraction X1_start[Medium1.nX] = Medium1.X_default 
    "Start value of mass fractions m_i/m";
  parameter Medium1.ExtraProperty C1_start[Medium1.nC](
       quantity=Medium1.extraPropertiesNames)=fill(0, Medium1.nC) 
    "Start value of trace substances";
  parameter Medium1.ExtraProperty C1_nominal[Medium1.nC](
       quantity=Medium1.extraPropertiesNames) = fill(1E-2, Medium1.nC) 
    "Nominal value of trace substances. (Set to typical order of magnitude.)";

  parameter Medium2.AbsolutePressure p2_start = Medium2.p_default 
    "Start value of pressure";
  parameter Medium2.Temperature T2_start = Medium2.T_default 
    "Start value of temperature";
  parameter Medium2.MassFraction X2_start[Medium2.nX] = Medium2.X_default 
    "Start value of mass fractions m_i/m";
  parameter Medium2.ExtraProperty C2_start[Medium2.nC](
       quantity=Medium2.extraPropertiesNames)=fill(0, Medium2.nC) 
    "Start value of trace substances";
  parameter Medium2.ExtraProperty C2_nominal[Medium2.nC](
       quantity=Medium2.extraPropertiesNames) = fill(1E-2, Medium2.nC) 
    "Nominal value of trace substances. (Set to typical order of magnitude.)";

protected 
  parameter Medium1.ThermodynamicState sta1_nominal=Medium1.setState_pTX(
      T=Medium1.T_default, p=Medium1.p_default, X=Medium1.X_default);
  parameter Modelica.SIunits.Density rho1_nominal=Medium1.density(sta1_nominal) 
    "Density, used to compute fluid volume";
  parameter Medium2.ThermodynamicState sta2_nominal=Medium2.setState_pTX(
      T=Medium2.T_default, p=Medium2.p_default, X=Medium2.X_default);
  parameter Modelica.SIunits.Density rho2_nominal=Medium2.density(sta2_nominal) 
    "Density, used to compute fluid volume";

  parameter Medium1.ThermodynamicState sta1_start=Medium1.setState_pTX(
      T=T1_start, p=p1_start, X=X1_start);
  parameter Modelica.SIunits.SpecificEnthalpy h1_outflow_start = Medium1.specificEnthalpy(sta1_start) 
    "Start value for outflowing enthalpy";
  parameter Medium2.ThermodynamicState sta2_start=Medium2.setState_pTX(
      T=T2_start, p=p2_start, X=X2_start);
  parameter Modelica.SIunits.SpecificEnthalpy h2_outflow_start = Medium2.specificEnthalpy(sta2_start) 
    "Start value for outflowing enthalpy";

public 
  Buildings.Fluid.FixedResistances.FixedResistanceDpM preDro1(
    redeclare package Medium = Medium1,
    final use_dh=false,
    final m_flow_nominal=m1_flow_nominal,
    final deltaM=deltaM1,
    final allowFlowReversal=allowFlowReversal1,
    final show_T=false,
    final show_V_flow=show_V_flow,
    final from_dp=from_dp1,
    final linearized=linearizeFlowResistance1,
    final homotopyInitialization=homotopyInitialization,
    final dp_nominal=dp1_nominal,
    final dh=1,
    final ReC=4000) "Pressure drop model for fluid 1";

  Buildings.Fluid.FixedResistances.FixedResistanceDpM preDro2(
    redeclare package Medium = Medium2,
    final use_dh=false,
    final m_flow_nominal=m2_flow_nominal,
    final deltaM=deltaM2,
    final allowFlowReversal=allowFlowReversal2,
    final show_T=false,
    final show_V_flow=show_V_flow,
    final from_dp=from_dp2,
    final linearized=linearizeFlowResistance2,
    final homotopyInitialization=homotopyInitialization,
    final dp_nominal=dp2_nominal,
    final dh=1,
    final ReC=4000) "Pressure drop model for fluid 2";

equation 
  connect(vol1.ports[2], port_b1);
  connect(vol2.ports[2], port_b2);
  connect(port_a1, preDro1.port_a);
  connect(preDro1.port_b, vol1.ports[1]);
  connect(port_a2, preDro2.port_a);
  connect(preDro2.port_b, vol2.ports[1]);
end FourPortHeatMassExchanger;

Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger

Partial model transporting fluid between two ports without storing mass or energy

Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger

Information

This component transports fluid between its two ports, without storing mass or energy. It is based on Modelica.Fluid.Interfaces.PartialTwoPortTransport but it does use a different implementation for handling reverse flow because in this component, mass flow rate can be added or removed from the medium.

If dp_nominal > Modelica.Constants.eps, this component computes pressure drop due to flow friction. The pressure drop is defined by a quadratic function that goes through the point (m_flow_nominal, dp_nominal). At |m_flow| < deltaM * m_flow_nominal, the pressure drop vs. flow relation is linearized. If the parameter linearizeFlowResistance is set to true, then the whole pressure drop vs. flow resistance curve is linearized.

Implementation

This model uses inputs and constants that need to be set by models that extend or instantiate this model. The following inputs need to be assigned:

Set the constant sensibleOnly=true if the model that extends or instantiates this model sets mXi_flow = zeros(Medium.nXi).

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
BooleansensibleOnly Set to true if sensible exchange only
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp_nominal Pressure [Pa]
Initialization
MassFlowRatem_flow.start0Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction) [kg/s]
Pressuredp.start0Pressure difference between port_a and port_b [Pa]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Ttrue= true, if actual temperature at port is computed (may lead to events)
Flow resistance
BooleancomputeFlowResistance(abs(dp_nominal) > Modelica....=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistancefalse= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM0.1Fraction of nominal flow rate where flow transitions to laminar

Connectors

TypeNameDescription
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)
output RealOutputhOutLeaving temperature of the component [J/kg]
output RealOutputXiOut[Medium.nXi]Leaving species concentration of the component [1]
output RealOutputCOut[Medium.nC]Leaving trace substances of the component [1]

Modelica definition

model StaticTwoPortHeatMassExchanger 
  "Partial model transporting fluid between two ports without storing mass or energy"
  extends Buildings.Fluid.Interfaces.PartialTwoPortInterface(
  showDesignFlowDirection = false,
  final show_T=true);
  extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters(
    final computeFlowResistance=(abs(dp_nominal) > Modelica.Constants.eps));

  // Model inputs
  input Modelica.SIunits.HeatFlowRate Q_flow "Heat transfered into the medium";
  input Medium.MassFlowRate mXi_flow[Medium.nXi] 
    "Mass flow rates of independent substances added to the medium";

  // Models for conservation equations and pressure drop
  Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation vol(
    sensibleOnly = sensibleOnly,
    use_safeDivision = use_safeDivision,
    redeclare final package Medium = Medium,
    final m_flow_nominal = m_flow_nominal,
    final allowFlowReversal=allowFlowReversal,
    final m_flow_small=m_flow_small,
    final homotopyInitialization=homotopyInitialization) 
    "Control volume for steady-state energy and mass balance";
  Buildings.Fluid.FixedResistances.FixedResistanceDpM preDro(
    redeclare final package Medium = Medium,
    final use_dh=false,
    final m_flow_nominal=m_flow_nominal,
    final deltaM=deltaM,
    final allowFlowReversal=allowFlowReversal,
    final show_T=false,
    final show_V_flow=show_V_flow,
    final from_dp=from_dp,
    final linearized=linearizeFlowResistance,
    final homotopyInitialization=homotopyInitialization,
    final dp_nominal=dp_nominal) "Pressure drop model";

  // Outputs that are needed in models that extend this model
  Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg") 
    "Leaving temperature of the component";
  Modelica.Blocks.Interfaces.RealOutput XiOut[Medium.nXi](unit="1") 
    "Leaving species concentration of the component";
  Modelica.Blocks.Interfaces.RealOutput COut[Medium.nC](unit="1") 
    "Leaving trace substances of the component";
  constant Boolean sensibleOnly "Set to true if sensible exchange only";
  constant Boolean use_safeDivision=true 
    "Set to true to improve numerical robustness";
protected 
  Modelica.Blocks.Sources.RealExpression heaInp(y=Q_flow) 
    "Block to set heat input into volume";
  Modelica.Blocks.Sources.RealExpression
    masExc[Medium.nXi](y=mXi_flow) if 
       Medium.nXi > 0 "Block to set mass exchange in volume";
equation 
  connect(vol.hOut, hOut);
  connect(vol.XiOut, XiOut);
  connect(vol.COut, COut);
  connect(port_a,preDro. port_a);
  connect(preDro.port_b, vol.port_a);

  connect(vol.port_b, port_b);

  connect(heaInp.y, vol.Q_flow);
  connect(masExc.y, vol.mXi_flow);
end StaticTwoPortHeatMassExchanger;

Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger

Partial model transporting two fluid streams between four ports without storing mass or energy

Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger

Information

This component transports two fluid streams between four ports, without storing mass or energy. It is similar to Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger, but it has four ports instead of two.

If dpN_nominal > Modelica.Constants.eps, where N denotes the fluid 1 or 2, then the model computes pressure drop due to flow friction in the respective fluid stream. The pressure drop is defined by a quadratic function that goes through the point (mN_flow_nominal, dpN_nominal). At |mN_flow| < deltaMN * mN_flow_nominal, the pressure drop vs. flow relation is linearized. If the parameter linearizeFlowResistanceN is set to true, then the whole pressure drop vs. flow resistance curve is linearized.

Implementation

This model uses inputs and constants that need to be set by models that extend or instantiate this model. The following inputs need to be assigned, where N denotes 1 or 2:

Set the constant sensibleOnlyN=true if the model that extends or instantiates this model sets mXiN_flow = zeros(Medium.nXiN).

Note that the model does not implement 0 = Q1_flow + Q2_flow or 0 = mXi1_flow + mXi2_flow. If there is no heat or mass transfer with the environment, then a model that extends this model needs to provide these equations.

Extends from Buildings.Fluid.Interfaces.PartialFourPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters (Parameters for flow resistance for models with four ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
BooleansensibleOnly1 Set to true if sensible exchange only for medium 1
BooleansensibleOnly2 Set to true if sensible exchange only for medium 2
Nominal condition
MassFlowRatem1_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp1_nominal Pressure [Pa]
Pressuredp2_nominal Pressure [Pa]
Initialization
MassFlowRatem1_flow.start0Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction) [kg/s]
Pressuredp1.start0Pressure difference between port_a1 and port_b1 [Pa]
MassFlowRatem2_flow.start0Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction) [kg/s]
Pressuredp2.start0Pressure difference between port_a2 and port_b2 [Pa]
Assumptions
BooleanallowFlowReversal1system.allowFlowReversal= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2system.allowFlowReversal= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_startMedium1.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_startMedium1.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_startMedium2.h_defaultStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_startMedium2.h_defaultStart value for enthalpy flowing out of port b2 [J/kg]
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Tfalse= true, if actual temperature at port is computed (may lead to events)
Flow resistance
Medium 1
BooleancomputeFlowResistance1(dp1_nominal > Modelica.Cons...=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2(dp2_nominal > Modelica.Cons...=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

model StaticFourPortHeatMassExchanger 
  "Partial model transporting two fluid streams between four ports without storing mass or energy"
  extends Buildings.Fluid.Interfaces.PartialFourPortInterface;
  extends Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters(
   final computeFlowResistance1=(dp1_nominal > Modelica.Constants.eps),
   final computeFlowResistance2=(dp2_nominal > Modelica.Constants.eps));
  import Modelica.Constants;
  input Modelica.SIunits.HeatFlowRate Q1_flow 
    "Heat transfered into the medium 1";
  input Medium1.MassFlowRate mXi1_flow[Medium1.nXi] 
    "Mass flow rates of independent substances added to the medium 1";
  input Modelica.SIunits.HeatFlowRate Q2_flow 
    "Heat transfered into the medium 2";
  input Medium2.MassFlowRate mXi2_flow[Medium2.nXi] 
    "Mass flow rates of independent substances added to the medium 2";
  constant Boolean sensibleOnly1 
    "Set to true if sensible exchange only for medium 1";
  constant Boolean sensibleOnly2 
    "Set to true if sensible exchange only for medium 2";
protected 
  Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger bal1(
    final sensibleOnly = sensibleOnly1,
    redeclare final package Medium=Medium1,
    final m_flow_nominal = m1_flow_nominal,
    final dp_nominal = dp1_nominal,
    final allowFlowReversal = allowFlowReversal1,
    final m_flow_small = m1_flow_small,
    final homotopyInitialization = homotopyInitialization,
    final show_V_flow = false,
    final from_dp = from_dp1,
    final linearizeFlowResistance = linearizeFlowResistance1,
    final deltaM = deltaM1,
    final Q_flow = Q1_flow,
    final mXi_flow = mXi1_flow) 
    "Model for heat, mass, species, trace substance and pressure balance of stream 1";
  Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger bal2(
    final sensibleOnly = sensibleOnly2,
    redeclare final package Medium=Medium2,
    final m_flow_nominal = m2_flow_nominal,
    final dp_nominal = dp2_nominal,
    final allowFlowReversal = allowFlowReversal2,
    final m_flow_small = m2_flow_small,
    final homotopyInitialization = homotopyInitialization,
    final show_V_flow = false,
    final from_dp = from_dp2,
    final linearizeFlowResistance = linearizeFlowResistance2,
    final deltaM = deltaM2,
    final Q_flow = Q2_flow,
    final mXi_flow = mXi2_flow) 
    "Model for heat, mass, species, trace substance and pressure balance of stream 2";
equation 
  connect(bal1.port_a, port_a1);
  connect(bal1.port_b, port_b1);
  connect(bal2.port_a, port_a2);
  connect(bal2.port_b, port_b2);
end StaticFourPortHeatMassExchanger;

Buildings.Fluid.Interfaces.PartialTwoPortInterface Buildings.Fluid.Interfaces.PartialTwoPortInterface

Partial model transporting fluid between two ports without storing mass or energy

Buildings.Fluid.Interfaces.PartialTwoPortInterface

Information

This component defines the interface for models that transports a fluid between two ports. It is similar to Modelica.Fluid.Interfaces.PartialTwoPortTransport, but it does not include the species balance

  port_b.Xi_outflow = inStream(port_a.Xi_outflow);
Thus, it can be used as a base class for a heat and mass transfer component

The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations. See for example Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger.

Extends from Modelica.Fluid.Interfaces.PartialTwoPort (Partial component with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Tfalse= true, if actual temperature at port is computed (may lead to events)

Modelica definition

partial model PartialTwoPortInterface 
  "Partial model transporting fluid between two ports without storing mass or energy"
  import Modelica.Constants;
  extends Modelica.Fluid.Interfaces.PartialTwoPort(
    port_a(p(start=Medium.p_default,
             nominal=Medium.p_default)),
    port_b(p(start=Medium.p_default,
           nominal=Medium.p_default)));

  parameter Medium.MassFlowRate m_flow_nominal "Nominal mass flow rate";
  parameter Medium.MassFlowRate m_flow_small(min=0) = 1E-4*abs(m_flow_nominal) 
    "Small mass flow rate for regularization of zero flow";
  parameter Boolean homotopyInitialization = true "= true, use homotopy method";

  // Diagnostics
   parameter Boolean show_V_flow = false 
    "= true, if volume flow rate at inflowing port is computed";
   parameter Boolean show_T = false 
    "= true, if actual temperature at port is computed (may lead to events)";

  Modelica.SIunits.VolumeFlowRate V_flow=
      m_flow/Medium.density(sta_a) if show_V_flow 
    "Volume flow rate at inflowing port (positive when flow from port_a to port_b)";

  Medium.MassFlowRate m_flow(start=0) = port_a.m_flow 
    "Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction)";
  Modelica.SIunits.Pressure dp(start=0, displayUnit="Pa") = port_a.p - port_b.p 
    "Pressure difference between port_a and port_b";

  Medium.ThermodynamicState sta_a=if homotopyInitialization then 
      Medium.setState_phX(port_a.p,
                          homotopy(actual=actualStream(port_a.h_outflow),
                                   simplified=inStream(port_a.h_outflow)),
                          homotopy(actual=actualStream(port_a.Xi_outflow),
                                   simplified=inStream(port_a.Xi_outflow)))
    else 
      Medium.setState_phX(port_a.p,
                          actualStream(port_a.h_outflow),
                          actualStream(port_a.Xi_outflow)) if 
         show_T "Medium properties in port_a";

  Medium.ThermodynamicState sta_b=if homotopyInitialization then 
      Medium.setState_phX(port_b.p,
                          homotopy(actual=actualStream(port_b.h_outflow),
                                   simplified=port_b.h_outflow),
                          homotopy(actual=actualStream(port_b.Xi_outflow),
                            simplified=port_b.Xi_outflow))
    else 
      Medium.setState_phX(port_b.p,
                          actualStream(port_b.h_outflow),
                          actualStream(port_b.Xi_outflow)) if 
          show_T "Medium properties in port_b";

end PartialTwoPortInterface;

Buildings.Fluid.Interfaces.PartialFourPortInterface Buildings.Fluid.Interfaces.PartialFourPortInterface

Partial model transporting fluid between two ports without storing mass or energy

Buildings.Fluid.Interfaces.PartialFourPortInterface

Information

This component defines the interface for models that transport two fluid streams between four ports. It is similar to Buildings.Fluid.Interfaces.PartialTwoPortInterface, but it has four ports instead of two.

The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations.

Extends from Buildings.Fluid.Interfaces.FourPort (Partial model with four ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
Nominal condition
MassFlowRatem1_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominal Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversal1system.allowFlowReversal= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2system.allowFlowReversal= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_startMedium1.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_startMedium1.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_startMedium2.h_defaultStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_startMedium2.h_defaultStart value for enthalpy flowing out of port b2 [J/kg]
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Tfalse= true, if actual temperature at port is computed (may lead to events)

Modelica definition

partial model PartialFourPortInterface 
  "Partial model transporting fluid between two ports without storing mass or energy"
  import Modelica.Constants;
  extends Buildings.Fluid.Interfaces.FourPort(
    port_a1(
      m_flow(min = if allowFlowReversal1 then -Constants.inf else 0)),
    port_b1(
      m_flow(max = if allowFlowReversal1 then +Constants.inf else 0)),
    port_a2(
      m_flow(min = if allowFlowReversal2 then -Constants.inf else 0)),
    port_b2(
      m_flow(max = if allowFlowReversal2 then +Constants.inf else 0)));
  parameter Modelica.SIunits.MassFlowRate m1_flow_nominal(min=0) 
    "Nominal mass flow rate";
  parameter Modelica.SIunits.MassFlowRate m2_flow_nominal(min=0) 
    "Nominal mass flow rate";
  parameter Medium1.MassFlowRate m1_flow_small(min=0) = 1E-4*abs(m1_flow_nominal) 
    "Small mass flow rate for regularization of zero flow";
  parameter Medium2.MassFlowRate m2_flow_small(min=0) = 1E-4*abs(m2_flow_nominal) 
    "Small mass flow rate for regularization of zero flow";
  parameter Boolean homotopyInitialization = true "= true, use homotopy method";
  // Diagnostics
  parameter Boolean show_V_flow = false 
    "= true, if volume flow rate at inflowing port is computed";
  parameter Boolean show_T = false 
    "= true, if actual temperature at port is computed (may lead to events)";
public 
  Modelica.SIunits.VolumeFlowRate V1_flow=m1_flow/Medium.density(sta_a1) if 
        show_V_flow 
    "Volume flow rate at inflowing port (positive when flow from port_a1 to port_b1)";
  Modelica.SIunits.VolumeFlowRate V2_flow=m2_flow/Medium.density(sta_a2) if 
        show_V_flow 
    "Volume flow rate at inflowing port (positive when flow from port_a2 to port_b2)";
  Medium1.MassFlowRate m1_flow(start=0) = port_a1.m_flow 
    "Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction)";
  Modelica.SIunits.Pressure dp1(start=0, displayUnit="Pa") = port_a1.p - port_b1.p 
    "Pressure difference between port_a1 and port_b1";
  Medium2.MassFlowRate m2_flow(start=0) = port_a2.m_flow 
    "Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction)";
  Modelica.SIunits.Pressure dp2(start=0, displayUnit="Pa") = port_a2.p - port_b2.p 
    "Pressure difference between port_a2 and port_b2";
  Medium1.ThermodynamicState sta_a1=if homotopyInitialization then 
      Medium1.setState_phX(port_a1.p,
         homotopy(actual=actualStream(port_a1.h_outflow),
                  simplified=inStream(port_a1.h_outflow)),
         homotopy(actual=actualStream(port_a1.Xi_outflow),
                  simplified=inStream(port_a1.Xi_outflow)))
    else 
      Medium1.setState_phX(port_a1.p,
                           actualStream(port_a1.h_outflow),
                           actualStream(port_a1.Xi_outflow)) if 
         show_T "Medium properties in port_a1";
  Medium1.ThermodynamicState sta_b1=if homotopyInitialization then 
      Medium1.setState_phX(port_b1.p,
          homotopy(actual=actualStream(port_b1.h_outflow),
                   simplified=port_b1.h_outflow),
          homotopy(actual=actualStream(port_b1.Xi_outflow),
                   simplified=port_b1.Xi_outflow))
    else 
      Medium1.setState_phX(port_b1.p,
                           actualStream(port_b1.h_outflow),
                           actualStream(port_b1.Xi_outflow)) if 
         show_T "Medium properties in port_b1";
  Medium2.ThermodynamicState sta_a2=if homotopyInitialization then 
      Medium2.setState_phX(port_b2.p,
          homotopy(actual=actualStream(port_a2.h_outflow),
                   simplified=inStream(port_a2.h_outflow)),
          homotopy(actual=actualStream(port_a2.Xi_outflow),
                   simplified=inStream(port_a2.Xi_outflow)))
    else 
      Medium2.setState_phX(port_a2.p,
                           actualStream(port_a2.h_outflow),
                           actualStream(port_a2.Xi_outflow)) if 
         show_T "Medium properties in port_a2";
  Medium2.ThermodynamicState sta_b2=if homotopyInitialization then 
      Medium2.setState_phX(port_b2.p,
          homotopy(actual=actualStream(port_b2.h_outflow),
                   simplified=port_b2.h_outflow),
          homotopy(actual=actualStream(port_b2.Xi_outflow),
                   simplified=port_b2.Xi_outflow))
    else 
      Medium2.setState_phX(port_b2.p,
                           actualStream(port_b2.h_outflow),
                           actualStream(port_b2.Xi_outflow)) if 
         show_T "Medium properties in port_b2";
protected 
  Medium1.ThermodynamicState state_a1_inflow=
    Medium1.setState_phX(port_a1.p, inStream(port_a1.h_outflow), inStream(port_a1.Xi_outflow)) 
    "state for medium inflowing through port_a1";
  Medium1.ThermodynamicState state_b1_inflow=
    Medium1.setState_phX(port_b1.p, inStream(port_b1.h_outflow), inStream(port_b1.Xi_outflow)) 
    "state for medium inflowing through port_b1";
  Medium2.ThermodynamicState state_a2_inflow=
    Medium2.setState_phX(port_a2.p, inStream(port_a2.h_outflow), inStream(port_a2.Xi_outflow)) 
    "state for medium inflowing through port_a2";
  Medium2.ThermodynamicState state_b2_inflow=
    Medium2.setState_phX(port_b2.p, inStream(port_b2.h_outflow), inStream(port_b2.Xi_outflow)) 
    "state for medium inflowing through port_b2";
end PartialFourPortInterface;

Buildings.Fluid.Interfaces.ConservationEquation Buildings.Fluid.Interfaces.ConservationEquation

Lumped volume with mass and energy balance

Buildings.Fluid.Interfaces.ConservationEquation

Information

Basic model for an ideally mixed fluid volume with the ability to store mass and energy. It implements a dynamic or a steady-state conservation equation for energy and mass fractions. The model has zero pressure drop between its ports.

Implementation

When extending or instantiating this model, the input fluidVolume, which is the actual volume occupied by the fluid, needs to be assigned. For most components, this can be set to a parameter. However, for components such as expansion vessels, the fluid volume can change in time.

Input connectors of the model are

The model can be used as a dynamic model or as a steady-state model. However, for a steady-state model with exactly two fluid ports connected, the model Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation provides a more efficient implementation.

For models that instantiates this model, see Buildings.Fluid.MixingVolumes.MixingVolume and Buildings.Fluid.Storage.ExpansionVessel.

Extends from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations (Declarations for lumped volumes).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Dynamics
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Formulation of energy balance
DynamicsmassDynamicsenergyDynamicsFormulation of mass balance
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC_start[Medium.nC]fill(0, Medium.nC)Start value of trace substances
ExtraPropertyC_nominal[Medium.nC]fill(1E-2, Medium.nC)Nominal value of trace substances. (Set to typical order of magnitude.)

Connectors

TypeNameDescription
VesselFluidPorts_bports[nPorts]Fluid inlets and outlets
input RealInputQ_flowHeat transfered into the medium [W]
input RealInputmXi_flow[Medium.nXi]Mass flow rates of independent substances added to the medium [kg/s]
output RealOutputhOutLeaving enthalpy of the component [J/kg]
output RealOutputXiOut[Medium.nXi]Leaving species concentration of the component [1]
output RealOutputCOut[Medium.nC]Leaving trace substances of the component [1]

Modelica definition

model ConservationEquation 
  "Lumped volume with mass and energy balance"

//  outer Modelica.Fluid.System system "System properties";
  extends Buildings.Fluid.Interfaces.LumpedVolumeDeclarations;
  // Port definitions
  parameter Integer nPorts=0 "Number of ports";
  Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b ports[nPorts](
      redeclare each package Medium = Medium) "Fluid inlets and outlets";

  // Set nominal attributes where literal values can be used.
  Medium.BaseProperties medium(
    preferredMediumStates= not (energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState),
    p(start=p_start,
      nominal=Medium.p_default,
      stateSelect=if not (massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState)
                     then StateSelect.prefer else StateSelect.default),
    h(start=Medium.specificEnthalpy_pTX(p_start, T_start, X_start)),
    T(start=T_start,
      nominal=Medium.T_default,
      stateSelect=if (not (energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState))
                     then StateSelect.prefer else StateSelect.default),
    Xi(start=X_start[1:Medium.nXi],
       nominal=Medium.X_default[1:Medium.nXi],
       stateSelect=if (not (substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState))
                     then StateSelect.prefer else StateSelect.default),
    d(start=rho_nominal)) "Medium properties";

  Modelica.SIunits.Energy U "Internal energy of fluid";
  Modelica.SIunits.Mass m "Mass of fluid";
  Modelica.SIunits.Mass[Medium.nXi] mXi 
    "Masses of independent components in the fluid";
  Modelica.SIunits.Mass[Medium.nC] mC "Masses of trace substances in the fluid";
  // C need to be added here because unlike for Xi, which has medium.Xi,
  // there is no variable medium.C
  Medium.ExtraProperty C[Medium.nC](nominal=C_nominal) 
    "Trace substance mixture content";

  Modelica.SIunits.MassFlowRate mb_flow "Mass flows across boundaries";
  Modelica.SIunits.MassFlowRate[Medium.nXi] mbXi_flow 
    "Substance mass flows across boundaries";
  Medium.ExtraPropertyFlowRate[Medium.nC] mbC_flow 
    "Trace substance mass flows across boundaries";
  Modelica.SIunits.EnthalpyFlowRate Hb_flow 
    "Enthalpy flow across boundaries or energy source/sink";

  // Inputs that need to be defined by an extending class
  input Modelica.SIunits.Volume fluidVolume "Volume";

  Modelica.Blocks.Interfaces.RealInput Q_flow(unit="W") 
    "Heat transfered into the medium";
  Modelica.Blocks.Interfaces.RealInput mXi_flow[Medium.nXi](unit="kg/s") 
    "Mass flow rates of independent substances added to the medium";

  // Outputs that are needed in models that extend this model
  Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg") 
    "Leaving enthalpy of the component";
  Modelica.Blocks.Interfaces.RealOutput XiOut[Medium.nXi](unit="1") 
    "Leaving species concentration of the component";
  Modelica.Blocks.Interfaces.RealOutput COut[Medium.nC](unit="1") 
    "Leaving trace substances of the component";
protected 
  parameter Boolean initialize_p = not Medium.singleState 
    "= true to set up initial equations for pressure";

  Medium.EnthalpyFlowRate ports_H_flow[nPorts];
  Medium.MassFlowRate ports_mXi_flow[nPorts,Medium.nXi];
  Medium.ExtraPropertyFlowRate ports_mC_flow[nPorts,Medium.nC];

  parameter Modelica.SIunits.Density rho_nominal=Medium.density(
   Medium.setState_pTX(
     T=T_start,
     p=p_start,
     X=X_start[1:Medium.nXi])) "Density, used to compute fluid mass";
equation 
  // Total quantities
  m = fluidVolume*medium.d;
  mXi = m*medium.Xi;
  U = m*medium.u;
  mC = m*C;

  hOut = medium.h;
  XiOut = medium.Xi;
  COut = C;

  for i in 1:nPorts loop
    ports_H_flow[i]     = ports[i].m_flow * actualStream(ports[i].h_outflow) 
      "Enthalpy flow";
    ports_mXi_flow[i,:] = ports[i].m_flow * actualStream(ports[i].Xi_outflow) 
      "Component mass flow";
    ports_mC_flow[i,:]  = ports[i].m_flow * actualStream(ports[i].C_outflow) 
      "Trace substance mass flow";
  end for;

  for i in 1:Medium.nXi loop
    mbXi_flow[i] = sum(ports_mXi_flow[:,i]);
  end for;

  for i in 1:Medium.nC loop
    mbC_flow[i]  = sum(ports_mC_flow[:,i]);
  end for;

  mb_flow = sum(ports.m_flow);
  Hb_flow = sum(ports_H_flow);

  // Energy and mass balances
  if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then
    0 = Hb_flow + Q_flow;
  else
    der(U) = Hb_flow + Q_flow;
  end if;

  if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then
    0 = mb_flow + sum(mXi_flow);
  else
    der(m) = mb_flow + sum(mXi_flow);
  end if;

  if substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then
    zeros(Medium.nXi) = mbXi_flow + mXi_flow;
  else
    der(mXi) = mbXi_flow + mXi_flow;
  end if;

  if traceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then
    zeros(Medium.nC)  = mbC_flow;
  else
    der(mC)  = mbC_flow;
  end if;

  // Properties of outgoing flows
  for i in 1:nPorts loop
      ports[i].p          = medium.p;
      ports[i].h_outflow  = medium.h;
      ports[i].Xi_outflow = medium.Xi;
      ports[i].C_outflow  = C;
  end for;
initial equation 
  // Make sure that if energyDynamics is SteadyState, then
  // massDynamics is also SteadyState.
  // Otherwise, the system of ordinary differential equations may be inconsistent.
  if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then
    assert(massDynamics == energyDynamics, "
         If 'massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState', then it is 
         required that 'energyDynamics==Modelica.Fluid.Types.Dynamics.SteadyState'.
         Otherwise, the system of equations may not be consistent.
         You need to select other parameter values.");
  end if;

  // initialization of balances
  if energyDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then
//    if use_T_start then
      medium.T = T_start;
//    else
//      medium.h = h_start;
//    end if;
  else
    if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then
//      if use_T_start then
        der(medium.T) = 0;
//      else
//        der(medium.h) = 0;
//      end if;
    end if;
  end if;

  if massDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then
    if initialize_p then
      medium.p = p_start;
    end if;
  else
    if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then
      if initialize_p then
        der(medium.p) = 0;
      end if;
    end if;
  end if;

  if substanceDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then
    medium.Xi = X_start[1:Medium.nXi];
  else
    if substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then
      der(medium.Xi) = zeros(Medium.nXi);
    end if;
  end if;

  if traceDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then
    C = C_start[1:Medium.nC];
  else
    if traceDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then
      der(C) = zeros(Medium.nC);
    end if;
  end if;

end ConservationEquation;

Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation

Partial model for static energy and mass conservation equations

Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation

Information

This model transports fluid between its two ports, without storing mass or energy. It implements a steady-state conservation equation for energy and mass fractions. The model has zero pressure drop between its ports.

Implementation

Input connectors of the model are

The model can only be used as a steady-state model with two fluid ports. For a model with a dynamic balance, and more fluid ports, use Buildings.Fluid.Interfaces.ConservationEquation.

Set the constant sensibleOnly=true if the model that extends or instantiates this model sets mXi_flow = zeros(Medium.nXi).

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
BooleansensibleOnly Set to true if sensible exchange only
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Initialization
MassFlowRatem_flow.start0Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction) [kg/s]
Pressuredp.start0Pressure difference between port_a and port_b [Pa]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_V_flowfalse= true, if volume flow rate at inflowing port is computed
Booleanshow_Tfalse= true, if actual temperature at port is computed (may lead to events)

Connectors

TypeNameDescription
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)
input RealInputQ_flowHeat transfered into the medium [W]
input RealInputmXi_flow[Medium.nXi]Mass flow rates of independent substances added to the medium [kg/s]
output RealOutputhOutLeaving temperature of the component [J/kg]
output RealOutputXiOut[Medium.nXi]Leaving species concentration of the component [1]
output RealOutputCOut[Medium.nC]Leaving trace substances of the component [1]

Modelica definition

model StaticTwoPortConservationEquation 
  "Partial model for static energy and mass conservation equations"
  extends Buildings.Fluid.Interfaces.PartialTwoPortInterface(
  showDesignFlowDirection = false);
//  import Modelica.Constants;
  Modelica.Blocks.Interfaces.RealInput Q_flow(unit="W") 
    "Heat transfered into the medium";
  Modelica.Blocks.Interfaces.RealInput mXi_flow[Medium.nXi](unit="kg/s") 
    "Mass flow rates of independent substances added to the medium";
  constant Boolean sensibleOnly "Set to true if sensible exchange only";
  // Outputs that are needed in models that extend this model
  Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg") 
    "Leaving temperature of the component";
  Modelica.Blocks.Interfaces.RealOutput XiOut[Medium.nXi](unit="1") 
    "Leaving species concentration of the component";
  Modelica.Blocks.Interfaces.RealOutput COut[Medium.nC](unit="1") 
    "Leaving trace substances of the component";
  constant Boolean use_safeDivision=true 
    "Set to true to improve numerical robustness";
protected 
  Real m_flowInv(unit="s/kg") "Regularization of 1/m_flow";
equation 
  // Regularization of m_flow around the origin to avoid a division by zero
 if use_safeDivision then
    m_flowInv = Buildings.Utilities.Math.Functions.inverseXRegularized(x=port_a.m_flow, delta=m_flow_small/1E3);
 else
     m_flowInv = 1/port_a.m_flow;
 end if;
 if allowFlowReversal then
// This formulation fails to simulate in Buildings.Fluid.MixingVolumes.Examples.MixingVolumePrescribedHeatFlowRate
// with Dymola 2012. See also Dynasim ticket 13596.
// It works with Dymola 2012 FD01.
   if (port_a.m_flow >= 0) then
     hOut =  port_b.h_outflow;
     XiOut = port_b.Xi_outflow;
     COut =  port_b.C_outflow;
    else
     hOut =  port_a.h_outflow;
     XiOut = port_a.Xi_outflow;
     COut =  port_a.C_outflow;
    end if;
 else
   hOut =  port_b.h_outflow;
   XiOut = port_b.Xi_outflow;
   COut =  port_b.C_outflow;
 end if;
  //////////////////////////////////////////////////////////////////////////////////////////
  // Energy balance and mass balance
  if sensibleOnly then
    // Mass balance
    port_a.m_flow = -port_b.m_flow;
    // Energy balance
    port_b.h_outflow = inStream(port_a.h_outflow) + Q_flow * m_flowInv;
    port_a.h_outflow = inStream(port_b.h_outflow) - Q_flow * m_flowInv;
    // Transport of species
    port_a.Xi_outflow = inStream(port_b.Xi_outflow);
    port_b.Xi_outflow = inStream(port_a.Xi_outflow);
    // Transport of trace substances
    port_a.C_outflow = inStream(port_b.C_outflow);
    port_b.C_outflow = inStream(port_a.C_outflow);
  else
    // Mass balance (no storage)
    port_a.m_flow + port_b.m_flow = -sum(mXi_flow);
    // Energy balance.
    // This equation is approximate since m_flow = port_a.m_flow is used for the mass flow rate
    // at both ports. Since mXi_flow << m_flow, the error is small.
    port_b.h_outflow = inStream(port_a.h_outflow) + Q_flow * m_flowInv;
    port_a.h_outflow = inStream(port_b.h_outflow) - Q_flow * m_flowInv;
    // Transport of species
    for i in 1:Medium.nXi loop
      port_b.Xi_outflow[i] = inStream(port_a.Xi_outflow[i]) + mXi_flow[i] * m_flowInv;
      port_a.Xi_outflow[i] = inStream(port_b.Xi_outflow[i]) - mXi_flow[i] * m_flowInv;
    end for;
    // Transport of trace substances
    for i in 1:Medium.nC loop
      port_a.m_flow*port_a.C_outflow[i] = -port_b.m_flow*inStream(port_b.C_outflow[i]);
      port_b.m_flow*port_b.C_outflow[i] = -port_a.m_flow*inStream(port_a.C_outflow[i]);
    end for;
  end if; // sensibleOnly
  //////////////////////////////////////////////////////////////////////////////////////////
  // No pressure drop in this model
  port_a.p = port_b.p;
end StaticTwoPortConservationEquation;

Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters

Parameters for flow resistance for models with two ports

Information

This class contains parameters that are used to compute the pressure drop in models that have one fluid stream. Note that the nominal mass flow rate is not declared here because the model PartialTwoPortInterface already declares it.

Parameters

TypeNameDefaultDescription
Nominal condition
Pressuredp_nominal Pressure [Pa]
Flow resistance
BooleancomputeFlowResistancetrue=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistancefalse= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM0.1Fraction of nominal flow rate where flow transitions to laminar

Modelica definition

record TwoPortFlowResistanceParameters 
  "Parameters for flow resistance for models with two ports"

  parameter Boolean computeFlowResistance = true 
    "=true, compute flow resistance. Set to false to assume no friction";

  parameter Boolean from_dp = false 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";
  parameter Modelica.SIunits.Pressure dp_nominal(min=0, displayUnit="Pa") 
    "Pressure";
  parameter Boolean linearizeFlowResistance = false 
    "= true, use linear relation between m_flow and dp for any flow rate";
  parameter Real deltaM = 0.1 
    "Fraction of nominal flow rate where flow transitions to laminar";

end TwoPortFlowResistanceParameters;

Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters

Parameters for flow resistance for models with four ports

Information

This class contains parameters that are used to compute the pressure drop in components that have two fluid streams. Note that the nominal mass flow rate is not declared here because the model PartialFourPortInterface already declares it.

Parameters

TypeNameDefaultDescription
Nominal condition
Pressuredp1_nominal Pressure [Pa]
Pressuredp2_nominal Pressure [Pa]
Flow resistance
Medium 1
BooleancomputeFlowResistance1true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar

Modelica definition

record FourPortFlowResistanceParameters 
  "Parameters for flow resistance for models with four ports"

  parameter Boolean computeFlowResistance1 = true 
    "=true, compute flow resistance. Set to false to assume no friction";

  parameter Boolean from_dp1 = false 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";
  parameter Modelica.SIunits.Pressure dp1_nominal(min=0, displayUnit="Pa") 
    "Pressure";
  parameter Boolean linearizeFlowResistance1 = false 
    "= true, use linear relation between m_flow and dp for any flow rate";
  parameter Real deltaM1 = 0.1 
    "Fraction of nominal flow rate where flow transitions to laminar";
  parameter Boolean computeFlowResistance2 = true 
    "=true, compute flow resistance. Set to false to assume no friction";

  parameter Boolean from_dp2 = false 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";
  parameter Modelica.SIunits.Pressure dp2_nominal(min=0, displayUnit="Pa") 
    "Pressure";
  parameter Boolean linearizeFlowResistance2 = false 
    "= true, use linear relation between m_flow and dp for any flow rate";
  parameter Real deltaM2 = 0.1 
    "Fraction of nominal flow rate where flow transitions to laminar";
end FourPortFlowResistanceParameters;

Buildings.Fluid.Interfaces.LumpedVolumeDeclarations

Declarations for lumped volumes

Information

This class contains parameters and medium properties that are used in the lumped volume model, and in models that extend the lumped volume model.

These parameters are used by Buildings.Fluid.Interfaces.ConservationEquation, Buildings.Fluid.MixingVolumes.MixingVolume, Buildings.Rooms.MixedAir, and by Buildings.Rooms.BaseClasses.MixedAir.

Parameters

TypeNameDefaultDescription
Dynamics
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Formulation of energy balance
DynamicsmassDynamicsenergyDynamicsFormulation of mass balance
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC_start[Medium.nC]fill(0, Medium.nC)Start value of trace substances
ExtraPropertyC_nominal[Medium.nC]fill(1E-2, Medium.nC)Nominal value of trace substances. (Set to typical order of magnitude.)

Modelica definition

record LumpedVolumeDeclarations "Declarations for lumped volumes"
  replaceable package Medium =
    Modelica.Media.Interfaces.PartialMedium "Medium in the component";

  // Assumptions
  parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial 
    "Formulation of energy balance";
  parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics 
    "Formulation of mass balance";
  final parameter Modelica.Fluid.Types.Dynamics substanceDynamics=energyDynamics 
    "Formulation of substance balance";
  final parameter Modelica.Fluid.Types.Dynamics traceDynamics=energyDynamics 
    "Formulation of trace substance balance";

  // Initialization
  parameter Medium.AbsolutePressure p_start = Medium.p_default 
    "Start value of pressure";
//  parameter Boolean use_T_start = true "= true, use T_start, otherwise h_start"
 //   annotation(Dialog(tab = "Initialization"), Evaluate=true);
  parameter Medium.Temperature T_start=Medium.T_default 
    "Start value of temperature";
//  parameter Medium.SpecificEnthalpy h_start=
//    if use_T_start then Medium.specificEnthalpy_pTX(p_start, T_start, X_start) else Medium.h_default
//    "Start value of specific enthalpy"
//    annotation(Dialog(tab = "Initialization", enable = not use_T_start));
  parameter Medium.MassFraction X_start[Medium.nX] = Medium.X_default 
    "Start value of mass fractions m_i/m";
  parameter Medium.ExtraProperty C_start[Medium.nC](
       quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) 
    "Start value of trace substances";
  parameter Medium.ExtraProperty C_nominal[Medium.nC](
       quantity=Medium.extraPropertiesNames) = fill(1E-2, Medium.nC) 
    "Nominal value of trace substances. (Set to typical order of magnitude.)";

end LumpedVolumeDeclarations;

Automatically generated Wed Feb 22 15:22:57 2012.