Buildings.Fluid.BaseClasses

Package with base classes for fluid models

Information


This package contains base classes that are used to construct the models in 
Buildings.Fluid.

Extends from Modelica.Fluid.Icons.BaseClassLibrary (Icon for library).

Package Content

NameDescription
Buildings.Fluid.BaseClasses.FlowModels FlowModels Flow models for pressure drop calculations
Buildings.Fluid.BaseClasses.PartialResistance PartialResistance Partial model for a hydraulic resistance
Buildings.Fluid.BaseClasses.PartialThreeWayResistance PartialThreeWayResistance Flow splitter with partial resistance model at each port


Buildings.Fluid.BaseClasses.PartialResistance Buildings.Fluid.BaseClasses.PartialResistance

Partial model for a hydraulic resistance

Buildings.Fluid.BaseClasses.PartialResistance

Information


Partial model for a flow resistance, possible with variable flow coefficient. The pressure drop is computed by an instance of Buildings.Fluid.BaseClasses.FlowModels.BasicFlowModel, i.e., using a regularized implementation of the equation

  m_flow = sign(dp) * k * sqrt(|dp|).

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

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp_nominal Pressure drop at nominal mass flow rate [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*m_flow_nominalSmall mass flow rate for regularization of zero flow [kg/s]
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
Booleanlinearizedfalse= true, use linear relation between m_flow and dp for any flow rate
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)

Modelica definition

partial model PartialResistance 
  "Partial model for a hydraulic resistance"
    extends Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface(
     show_T=false, show_V_flow=false);

  parameter Boolean from_dp = false 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";
  parameter Medium.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate";
  parameter Modelica.SIunits.Pressure dp_nominal(min=0, displayUnit="Pa") 
    "Pressure drop at nominal mass flow rate";
  parameter Boolean linearized = false 
    "= true, use linear relation between m_flow and dp for any flow rate";

  Real k(unit="") "Flow coefficient, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)";
  Medium.MassFlowRate m_flow_turbulent 
    "Turbulent flow if |m_flow| >= m_flow_turbulent, not a parameter because k can be a function of time";

//  Modelica.SIunits.Pressure dp_turbulent
//    "Turbulent flow if |dp| >= dp_small, not a parameter because k can be a function of time";

protected 
  parameter Medium.ThermodynamicState sta0=
     Medium.setState_pTX(T=Medium.T_default, p=Medium.p_default, X=Medium.X_default);
  parameter Modelica.SIunits.DynamicViscosity eta_nominal=Medium.dynamicViscosity(sta0) 
    "Dynamic viscosity, used to compute transition to turbulent flow regime";
  parameter Modelica.SIunits.SpecificEnthalpy h0=Medium.h_default 
    "Initial value for solver for specific enthalpy";           //specificEnthalpy(sta0)
 constant Real conv(unit="m.s2/kg") = 1 "Factor, needed to satisfy unit check";
 constant Real conv2 = sqrt(conv) "Factor, needed to satisfy unit check";
 final parameter Boolean computeFlowResistance=(dp_nominal > Modelica.Constants.eps) 
    "Flag to enable/disable computation of flow resistance";
equation 
  // Pressure drop calculation
  if computeFlowResistance then
    if from_dp then
      m_flow=FlowModels.basicFlowFunction_dp(dp=dp, k=k, m_flow_turbulent=m_flow_turbulent, linearized=linearized);
    else
      dp=FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k, m_flow_turbulent=m_flow_turbulent, linearized=linearized);
    end if;
  else
    dp = 0;
  end if;
  // Isenthalpic state transformation (no storage and no loss of energy)
  port_a.h_outflow = inStream(port_b.h_outflow);
  port_b.h_outflow = inStream(port_a.h_outflow);

  // Mass balance (no storage)
  port_a.m_flow + port_b.m_flow = 0;

  // Transport of substances
  port_a.Xi_outflow = inStream(port_b.Xi_outflow);
  port_b.Xi_outflow = inStream(port_a.Xi_outflow);

  port_a.C_outflow = inStream(port_b.C_outflow);
  port_b.C_outflow = inStream(port_a.C_outflow);

end PartialResistance;

Buildings.Fluid.BaseClasses.PartialThreeWayResistance Buildings.Fluid.BaseClasses.PartialThreeWayResistance

Flow splitter with partial resistance model at each port

Buildings.Fluid.BaseClasses.PartialThreeWayResistance

Information


Partial model for flow resistances with three ports such as a flow mixer/splitter or a three way valve.

If dynamicBalance=true, then at the junction of the three flows, a mixing volume will be present. This will introduce a dynamic energy and momentum balance, which often breaks algebraic loops. The time constant of the mixing volume is determined by the parameter tau.

Parameters

TypeNameDefaultDescription
PartialStaticTwoPortInterfaceres1redeclare Buildings.Fluid.In...Partial model, to be replaced with a fluid component
PartialStaticTwoPortInterfaceres2redeclare Buildings.Fluid.In...Partial model, to be replaced with a fluid component
PartialStaticTwoPortInterfaceres3redeclare Buildings.Fluid.In...Partial model, to be replaced with a fluid component
Advanced
Booleanfrom_dptrue= true, use m_flow = f(dp) else dp = f(m_flow)
Assumptions
Dynamics
BooleandynamicBalancetrueSet to true to use a dynamic balance, which often leads to smaller systems of equations
Timetau10Time constant at nominal flow for dynamic energy and momentum balance [s]
MassFlowRatemDyn_flow_nominal Nominal mass flow rate for dynamic momentum and energy balance [kg/s]
DynamicsenergyDynamicssystem.energyDynamicsFormulation of energy balance
DynamicsmassDynamicssystem.massDynamicsFormulation of mass balance
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
Booleanuse_T_starttrue= true, use T_start, otherwise h_start
TemperatureT_startif use_T_start then Medium.T...Start value of temperature [K]
SpecificEnthalpyh_startif use_T_start then Medium.s...Start value of specific enthalpy [J/kg]
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

Connectors

TypeNameDescription
FluidPort_aport_1 
FluidPort_bport_2 
FluidPort_aport_3 

Modelica definition

partial model PartialThreeWayResistance 
  "Flow splitter with partial resistance model at each port"
  outer Modelica.Fluid.System system "System properties";

  replaceable package Medium = Modelica.Media.Interfaces.PartialMedium 
    "Fluid medium model";

  Modelica.Fluid.Interfaces.FluidPort_a port_1(redeclare package Medium =
        Medium, m_flow(min=if (portFlowDirection_1 == Modelica.Fluid.Types.PortFlowDirection.Entering) then 
                0.0 else -Modelica.Constants.inf, max=if (portFlowDirection_1
           == Modelica.Fluid.Types.PortFlowDirection.Leaving) then 0.0 else Modelica.Constants.inf));
  Modelica.Fluid.Interfaces.FluidPort_b port_2(redeclare package Medium =
        Medium, m_flow(min=if (portFlowDirection_2 == Modelica.Fluid.Types.PortFlowDirection.Entering) then 
                0.0 else -Modelica.Constants.inf, max=if (portFlowDirection_2
           == Modelica.Fluid.Types.PortFlowDirection.Leaving) then 0.0 else Modelica.Constants.inf));
  Modelica.Fluid.Interfaces.FluidPort_a port_3(
    redeclare package Medium=Medium,
    m_flow(min=if (portFlowDirection_3==Modelica.Fluid.Types.PortFlowDirection.Entering) then 0.0 else -Modelica.Constants.inf,
    max=if (portFlowDirection_3==Modelica.Fluid.Types.PortFlowDirection.Leaving) then 0.0 else Modelica.Constants.inf));

 parameter Boolean from_dp = true 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";
  replaceable Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface res1(redeclare 
      package Medium = Medium, allowFlowReversal=true) 
    "Partial model, to be replaced with a fluid component";
  replaceable Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface res2(redeclare 
      package Medium = Medium, allowFlowReversal=true) 
    "Partial model, to be replaced with a fluid component";
  replaceable Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface res3(redeclare 
      package Medium = Medium, allowFlowReversal=true) 
    "Partial model, to be replaced with a fluid component";

protected 
  parameter Modelica.Fluid.Types.PortFlowDirection portFlowDirection_1=Modelica.Fluid.Types.PortFlowDirection.Bidirectional 
    "Flow direction for port_1";
  parameter Modelica.Fluid.Types.PortFlowDirection portFlowDirection_2=Modelica.Fluid.Types.PortFlowDirection.Bidirectional 
    "Flow direction for port_2";
  parameter Modelica.Fluid.Types.PortFlowDirection portFlowDirection_3=Modelica.Fluid.Types.PortFlowDirection.Bidirectional 
    "Flow direction for port_3";

public 
  Delays.DelayFirstOrder vol(
    redeclare package Medium = Medium,
    nPorts=3,
    use_HeatTransfer=false,
    tau=tau,
    m_flow_nominal=mDyn_flow_nominal,
    energyDynamics=energyDynamics,
    massDynamics=massDynamics,
    p_start=p_start,
    use_T_start=use_T_start,
    T_start=T_start,
    h_start=h_start,
    X_start=X_start,
    C_start=C_start) if 
       dynamicBalance "Fluid volume to break algebraic loop";
  parameter Boolean dynamicBalance = true 
    "Set to true to use a dynamic balance, which often leads to smaller systems of equations";

  parameter Modelica.SIunits.Time tau=10 
    "Time constant at nominal flow for dynamic energy and momentum balance";
  parameter Modelica.SIunits.MassFlowRate mDyn_flow_nominal 
    "Nominal mass flow rate for dynamic momentum and energy balance";
  parameter Modelica.Fluid.Types.Dynamics energyDynamics=system.energyDynamics 
    "Formulation of energy balance";
  parameter Modelica.Fluid.Types.Dynamics massDynamics=system.massDynamics 
    "Formulation of mass balance";
  parameter Modelica.Media.Interfaces.PartialMedium.AbsolutePressure p_start=
      Medium.p_default "Start value of pressure";
  parameter Boolean use_T_start=true "= true, use T_start, otherwise h_start";
  parameter Modelica.Media.Interfaces.PartialMedium.Temperature T_start=if 
      use_T_start then Medium.T_default else Medium.temperature_phX(
      p_start,
      h_start,
      X_start) "Start value of temperature";
  parameter Modelica.Media.Interfaces.PartialMedium.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";
  parameter Modelica.Media.Interfaces.PartialMedium.MassFraction X_start[Medium.nX]=
     Medium.X_default "Start value of mass fractions m_i/m";
  parameter Modelica.Media.Interfaces.PartialMedium.ExtraProperty C_start[
    Medium.nC]=fill(0, Medium.nC) "Start value of trace substances";
equation 
  connect(port_1, res1.port_a);
  connect(res2.port_a, port_2);
  connect(res3.port_a, port_3);
  connect(res1.port_b,vol. ports[1]);
  connect(res2.port_b,vol. ports[2]);
  connect(res3.port_b,vol. ports[3]);
  if not dynamicBalance then
    connect(res1.port_b, res3.port_b);
    connect(res1.port_b, res2.port_b);
  end if;
end PartialThreeWayResistance;

HTML-documentation generated by Dymola Mon Jun 14 14:28:50 2010.