Buildings.Fluids.BaseClasses

Package with base classes for fluid models

Information


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

Extends from Modelica_Fluid.Icons.BaseClassLibrary (Icon for library).

Package Content

NameDescription
Buildings.Fluids.BaseClasses.PartialResistance PartialResistance Partial model for a hydraulic resistance
Buildings.Fluids.BaseClasses.PartialThreeWayResistance PartialThreeWayResistance Flow splitter with partial resistance model at each port
Buildings.Fluids.BaseClasses.polynomial polynomial Polynomial function
Buildings.Fluids.BaseClasses.quadraticLinear quadraticLinear Function that is quadratic in first argument and linear in second argument


Buildings.Fluids.BaseClasses.PartialResistance Buildings.Fluids.BaseClasses.PartialResistance

Partial model for a hydraulic resistance

Buildings.Fluids.BaseClasses.PartialResistance

Information


Partial model for a flow resistance, possible with variable flow coefficient.


Extends from Modelica_Fluid.Interfaces.PartialTwoPortTransport (Partial element transporting fluid between two ports without storage of mass or energy).

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
Nominal condition
MassFlowRatem0_flow Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)
Advanced
AbsolutePressuredp_start0.01*system.p_startGuess value of dp = port_a.p - port_b.p [Pa]
MassFlowRatem_flow_startsystem.m_flow_startGuess value of m_flow = port_a.m_flow [kg/s]
MassFlowRatem_flow_small1E-4*m0_flowSmall mass flow rate for regularization of zero flow [kg/s]
Booleanfrom_dptrue= 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_Ttrue= true, if temperatures at port_a and port_b are computed
Booleanshow_V_flowtrue= true, if volume flow rate at inflowing 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 Modelica_Fluid.Interfaces.PartialTwoPortTransport(m_flow_small = 1E-4*m0_flow);


  parameter Boolean from_dp = true 
    "= true, use m_flow = f(dp) else dp = f(m_flow)";
  parameter Medium.MassFlowRate m0_flow(min=0) "Nominal mass flow rate";

  parameter Boolean linearized = false 
    "= true, use linear relation between m_flow and dp for any flow rate";
  parameter Medium.AbsolutePressure dp_start = 0.01*system.p_start 
    "Guess value of dp = port_a.p - port_b.p";
  Modelica.SIunits.Pressure dp(start=dp_start) 
    "Pressure difference between port_a and port_b (= port_a.p - port_b.p)";
protected 
  Real k(start=1) "Flow coefficient, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)";
  Real kInv(unit="1/(kg.m)", start=1) 
    "Flow coefficient for inverse flow computation, kInv=dp/m_flow^2";

  Modelica.SIunits.AbsolutePressure dp_laminar 
    "Turbulent flow if |dp| >= dp_small, not a parameter because k can be a function of time";
  Medium.MassFlowRate m_flow_laminar 
    "Turbulent flow if |m_flow| >= m_flow_laminar, not a parameter because k can be a function of time";

  parameter Medium.ThermodynamicState sta0=
     Medium.setState_pTX(T=Medium.T_default, p=Medium.p_default, X=Medium.X_default);
  parameter Modelica.SIunits.DynamicViscosity eta0=Medium.dynamicViscosity(sta0) 
    "Dynamic viscosity, used to compute laminar/turbulent transition";
  parameter Modelica.SIunits.SpecificEnthalpy h0=Medium.h_default 
    "Initial value for solver for specific enthalpy";           //specificEnthalpy(sta0)

equation 
  1=k*k*kInv;
  dp_laminar = kInv * m_flow_laminar^2;
  if linearized then
     m_flow = k * dp;
  else
    if from_dp then
       m_flow = Buildings.Fluids.Utilities.massFlowRate_dp(dp=dp, dp_small=dp_laminar, k=k);
    else
       dp = Buildings.Fluids.Utilities.pressureLoss_m_flow(m_flow=m_flow,m_small_flow=m_flow_laminar,k=kInv);
    end if;
  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);

end PartialResistance;

Buildings.Fluids.BaseClasses.PartialThreeWayResistance Buildings.Fluids.BaseClasses.PartialThreeWayResistance

Flow splitter with partial resistance model at each port

Buildings.Fluids.BaseClasses.PartialThreeWayResistance

Information


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


Extends from Buildings.BaseClasses.BaseIcon (Base icon).

Parameters

TypeNameDefaultDescription
PartialTwoPortTransportres1redeclare Modelica_Fluid.Int...Partial model, to be replaced with a fluid component
PartialTwoPortTransportres2redeclare Modelica_Fluid.Int...Partial model, to be replaced with a fluid component
PartialTwoPortTransportres3redeclare Modelica_Fluid.Int...Partial model, to be replaced with a fluid component
Advanced
Booleanfrom_dptrue= true, use m_flow = f(dp) else dp = f(m_flow)

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.BaseClasses.BaseIcon;
  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 Modelica_Fluid.Interfaces.PartialTwoPortTransport res1(redeclare 
      package Medium = Medium) 
    "Partial model, to be replaced with a fluid component";
  replaceable Modelica_Fluid.Interfaces.PartialTwoPortTransport res2(redeclare 
      package Medium = Medium) 
    "Partial model, to be replaced with a fluid component";
  replaceable Modelica_Fluid.Interfaces.PartialTwoPortTransport res3(redeclare 
      package Medium = Medium) 
    "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";

protected 
  Modelica_Fluid.Interfaces.FluidPort_b port_m(redeclare package Medium = 
        Medium) "Mixing port";
equation 
  connect(port_1, res1.port_a);
  connect(res2.port_b, port_2);
  connect(res3.port_a, port_3);
  connect(res1.port_b, port_m);
  connect(res2.port_a, port_m);
  connect(res3.port_b, port_m);
end PartialThreeWayResistance;

Buildings.Fluids.BaseClasses.polynomial

Polynomial function

Information


This function computes a polynomial of arbitrary order.


Inputs

TypeNameDefaultDescription
Reala[:] Coefficients
Realx Independent variable

Outputs

TypeNameDescription
RealyResult

Modelica definition

function polynomial "Polynomial function"
 input Real a[:] "Coefficients";
 input Real x "Independent variable";
 output Real y "Result";
protected 
 parameter Integer n = size(a, 1)-1;
 Real xp[n+1] "Powers of x";
algorithm 
  xp[1] :=1;
  for i in 1:n loop
     xp[i+1] :=xp[i]*x;
  end for;
  y :=a*xp;
end polynomial;

Buildings.Fluids.BaseClasses.quadraticLinear

Function that is quadratic in first argument and linear in second argument

Information


This function computes
  y =   a1 + a2 * x1 + a3 *x1^2 
     + (a4 + a5 * x1 + a6 *x1^2) * x2


Inputs

TypeNameDefaultDescription
Reala[6] Coefficients
Realx1 Independent variable for quadratic part
Realx2 Independent variable for linear part

Outputs

TypeNameDescription
RealyResult

Modelica definition

function quadraticLinear 
  "Function that is quadratic in first argument and linear in second argument"
 input Real a[6] "Coefficients";
 input Real x1 "Independent variable for quadratic part";
 input Real x2 "Independent variable for linear part";
 output Real y "Result";
protected 
 Real x1Sq;
algorithm 
  x1Sq :=x1*x1;
  y :=a[1] + a[2]*x1 + a[3]*x1Sq + (a[4] + a[5]*x1 + a[6]*x1Sq)*x2;

end quadraticLinear;

HTML-documentation generated by Dymola Thu Feb 19 16:51:00 2009.