LBL logo

Buildings.Fluid.BaseClasses

Package with base classes for Buildings.Fluid

Information

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

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

NameDescription
Buildings.Fluid.BaseClasses.FlowModels FlowModels Flow models for pressure drop calculations
IndexMassFraction Computes the index of a substance in the mass fraction vector Xi
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.IndexMassFraction

Computes the index of a substance in the mass fraction vector Xi

Information

This block computes the index that the subtance with name substanceName has in the mass fraction vector X. If the medium model has no component called substanceName, then the block writes an error message and terminates the simulation.

This block is used for example to obtain the index of the subtance 'water' to obtain the water vapor concentration, or to measure any other mass fraction.

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium model
StringsubstanceName Name of species substance

Connectors

TypeNameDescription
replaceable package MediumMedium model

Modelica definition

block IndexMassFraction 
  "Computes the index of a substance in the mass fraction vector Xi"
  replaceable package Medium =
      Modelica.Media.Interfaces.PartialCondensingGases "Medium model";
  parameter String substanceName "Name of species substance";

protected 
  parameter Integer i_x(fixed=false) "Index of substance";
initial algorithm 
  // Compute index of species vector that carries the substance name
  i_x :=-1;
    for i in 1:Medium.nXi loop
      if Modelica.Utilities.Strings.isEqual(string1=Medium.substanceNames[i],
                                            string2=substanceName,
                                            caseSensitive=false) then
        i_x :=i;
      end if;
    end for;
  assert(i_x > 0, "Substance '" + substanceName + "' is not present in medium '"
                  + Medium.mediumName + "'.\n"
                  + "Change medium model to one that has '" + substanceName + "' as a substance.");

end IndexMassFraction;

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. Models that extend this class need to implement an equation that relates m_flow and dp, and they need to assign the parameter m_flow_turbulent.

See for example Buildings.Fluid.FixedResistances.FixedResistanceDpM for a model that extends this base class.

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
MassFlowRatem_flow_turbulent Turbulent flow if |m_flow| >= m_flow_turbulent [kg/s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp_nominal Pressure drop at nominal mass flow rate [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
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_Tfalse= true, if actual temperature at port is computed

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.PartialTwoPortInterface(
     show_T=false,
     m_flow(start=0, nominal=m_flow_nominal_pos),
     dp(start=0, nominal=dp_nominal_pos),
     final m_flow_small = 1E-4*abs(m_flow_nominal));

  parameter Boolean from_dp = false 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";

  parameter Modelica.SIunits.Pressure dp_nominal(displayUnit="Pa") 
    "Pressure drop at nominal mass flow rate";
  parameter Boolean homotopyInitialization = true "= true, use homotopy method";
  parameter Boolean linearized = false 
    "= true, use linear relation between m_flow and dp for any flow rate";

  parameter Modelica.SIunits.MassFlowRate m_flow_turbulent(min=0) 
    "Turbulent flow if |m_flow| >= m_flow_turbulent";

protected 
  parameter Medium.ThermodynamicState sta_default=
     Medium.setState_pTX(T=Medium.T_default, p=Medium.p_default, X=Medium.X_default);
  parameter Modelica.SIunits.DynamicViscosity eta_default=Medium.dynamicViscosity(sta_default) 
    "Dynamic viscosity, used to compute transition to turbulent flow regime";
protected 
  final parameter Modelica.SIunits.MassFlowRate m_flow_nominal_pos = abs(m_flow_nominal) 
    "Absolute value of nominal flow rate";
  final parameter Modelica.SIunits.Pressure dp_nominal_pos = abs(dp_nominal) 
    "Absolute value of nominal pressure";
equation 
  // 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.

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

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
PartialTwoPortInterfaceres1redeclare Buildings.Fluid.In...Partial model, to be replaced with a fluid component
PartialTwoPortInterfaceres2redeclare Buildings.Fluid.In...Partial model, to be replaced with a fluid component
PartialTwoPortInterfaceres3redeclare Buildings.Fluid.In...Partial model, to be replaced with a fluid component
Dynamics
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Formulation of energy balance
DynamicsmassDynamicsenergyDynamicsFormulation of mass balance
BooleandynamicBalancetrueSet to true to use a dynamic balance, which often leads to smaller systems of equations
MassFlowRatemDyn_flow_nominal Nominal mass flow rate for dynamic momentum and energy balance [kg/s]
Nominal condition
Timetau10Time constant at nominal flow for dynamic energy and momentum balance [s]
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.)
Advanced
Booleanfrom_dptrue= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanhomotopyInitializationtrue= true, use homotopy method

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"
  extends Buildings.Fluid.Interfaces.LumpedVolumeDeclarations;
  outer Modelica.Fluid.System system "System properties";

  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)";
  parameter Boolean homotopyInitialization = true "= true, use homotopy method";

  replaceable Buildings.Fluid.Interfaces.PartialTwoPortInterface res1(redeclare 
      package Medium = Medium, allowFlowReversal=true, homotopyInitialization=homotopyInitialization) 
    "Partial model, to be replaced with a fluid component";
  replaceable Buildings.Fluid.Interfaces.PartialTwoPortInterface res2(redeclare 
      package Medium = Medium, allowFlowReversal=true, homotopyInitialization=homotopyInitialization) 
    "Partial model, to be replaced with a fluid component";
  replaceable Buildings.Fluid.Interfaces.PartialTwoPortInterface res3(redeclare 
      package Medium = Medium, allowFlowReversal=true, homotopyInitialization=homotopyInitialization) 
    "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 
  Buildings.Fluid.Delays.DelayFirstOrder vol(
    redeclare final package Medium = Medium,
    final nPorts=3,
    final tau=tau,
    final m_flow_nominal=mDyn_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,
    final allowFlowReversal=true,
    final prescribedHeatFlowRate=false) 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";

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;

Automatically generated Thu Oct 24 15:10:04 2013.