Buildings.Fluid.MixingVolumes

Package with mixing volumes

Package Content

NameDescription
Buildings.Fluid.MixingVolumes.MixingVolume MixingVolume Mixing volume with inlet and outlet ports (flow reversal is allowed)
Buildings.Fluid.MixingVolumes.MixingVolumeDryAir MixingVolumeDryAir Mixing volume with heat port for latent heat exchange, to be used with dry air
Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir MixingVolumeMoistAir Mixing volume with heat port for latent heat exchange, to be used with media that contain water
Buildings.Fluid.MixingVolumes.Examples Examples Collection of models that illustrate model use and test models
Buildings.Fluid.MixingVolumes.BaseClasses BaseClasses Package with base classes for mixing volumes


Buildings.Fluid.MixingVolumes.MixingVolume Buildings.Fluid.MixingVolumes.MixingVolume

Mixing volume with inlet and outlet ports (flow reversal is allowed)

Buildings.Fluid.MixingVolumes.MixingVolume

Information


This model represents an instantaneously mixed volume. 
Potential and kinetic energy at the port are neglected,
and there is no pressure drop at the ports.
The volume can be parameterized to allow heat exchange
through a heatPort.

Extends from Buildings.Fluid.Interfaces.PartialLumpedVolume (Lumped volume with mass and energy balance), Buildings.BaseClasses.BaseIcon (Base icon).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
VolumefluidVolumeVVolume [m3]
VolumeV Volume [m3]
Assumptions
Dynamics
DynamicsenergyDynamicssystem.energyDynamicsFormulation of energy balance
DynamicsmassDynamicssystem.massDynamicsFormulation of mass balance
DynamicssubstanceDynamicsenergyDynamicsFormulation of substance balance
DynamicstraceDynamicsenergyDynamicsFormulation of trace substance balance
Heat transfer
Booleanuse_HeatTransferfalse= true to use the HeatTransfer model
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 system.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
VesselFluidPorts_bports[nPorts]Fluid inlets and outlets
HeatPort_aheatPort 

Modelica definition

model MixingVolume 
  "Mixing volume with inlet and outlet ports (flow reversal is allowed)"
  extends Buildings.Fluid.Interfaces.PartialLumpedVolume(
      m(start=V*rho_nominal, fixed=false),
      final fluidVolume = V);
  extends Buildings.BaseClasses.BaseIcon;
    import Modelica.Constants.pi;

  // 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";

//  parameter Modelica.SIunits.MassFlowRate m_flow_small(min=0)=system.m_flow_small
//    "Regularization range at zero mass flow rate"
//    annotation(Dialog(tab="Advanced", group="Port properties", enable=stiffCharacteristicForEmptyPort));
  Medium.EnthalpyFlowRate ports_H_flow[nPorts];
  Medium.MassFlowRate ports_mXi_flow[nPorts,Medium.nXi];
  Medium.MassFlowRate[Medium.nXi] sum_ports_mXi_flow 
    "Substance mass flows through ports";
  Medium.ExtraPropertyFlowRate ports_mC_flow[nPorts,Medium.nC];
  Medium.ExtraPropertyFlowRate[Medium.nC] sum_ports_mC_flow 
    "Trace substance mass flows through ports";

  // Heat transfer through boundary
  parameter Boolean use_HeatTransfer = false 
    "= true to use the HeatTransfer model";
  replaceable model HeatTransfer =
      Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer
    constrainedby 
    Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.PartialVesselHeatTransfer 
    "Wall heat transfer";
  HeatTransfer heatTransfer(
    redeclare final package Medium = Medium,
    surfaceAreas={4*pi*(3/4*V/pi)^(2/3)},
    final n=1,
    final states = {medium.state},
    final use_k = use_HeatTransfer);
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort if use_HeatTransfer;

  parameter Modelica.SIunits.Volume V "Volume";

protected 
   parameter Medium.ThermodynamicState sta0 = Medium.setState_pTX(T=T_start,
         p=p_start, X=X_start[1:Medium.nXi]);
   parameter Modelica.SIunits.Density rho_nominal=Medium.density(sta0) 
    "Density, used to compute fluid mass";

equation 
// Only one connection allowed to a port to avoid unwanted ideal mixing
  for i in 1:nPorts loop
    assert(cardinality(ports[i]) <= 1,"
each ports[i] of volume can at most be connected to one component.
If two or more connections are present, ideal mixing takes
place with these connections, which is usually not the intention
of the modeller. Increase nPorts to add an additional port.
");
  end for;

  // actual definition of port variables
  for i in 1:nPorts loop
    // fluid flow through ports
      // regular operation: fluidLevel is above ports[i]
      // Note: >= covers default values of zero as well
    ports[i].p          = medium.p;
    ports[i].h_outflow  = medium.h;
    ports[i].Xi_outflow = medium.Xi;
    ports[i].C_outflow  = C;

    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
    sum_ports_mXi_flow[i] = sum(ports_mXi_flow[:,i]);
  end for;

  for i in 1:Medium.nC loop
    sum_ports_mC_flow[i]  = sum(ports_mC_flow[:,i]);
  end for;
  mb_flow = sum(ports.m_flow);
  mbXi_flow = sum_ports_mXi_flow;
  mbC_flow  = sum_ports_mC_flow;
  Hb_flow = sum(ports_H_flow);
  Qb_flow = heatTransfer.Q_flows[1];

  connect(heatPort, heatTransfer.heatPorts[1]);

end MixingVolume;

Buildings.Fluid.MixingVolumes.MixingVolumeDryAir Buildings.Fluid.MixingVolumes.MixingVolumeDryAir

Mixing volume with heat port for latent heat exchange, to be used with dry air

Buildings.Fluid.MixingVolumes.MixingVolumeDryAir

Information


Model for an ideally mixed fluid volume and the ability 
to store mass and energy. The volume is fixed, 
and sensible heat can be exchanged.

This model has the same ports as Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir. However, there is no mass exchange with the medium other than through the port ports.

For media that do provide water as a species, use the model Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir.

Extends from BaseClasses.PartialMixingVolumeWaterPort (Partial mixing volume that allows adding or subtracting water vapor).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
VolumeV Volume [m3]
Assumptions
Dynamics
DynamicsenergyDynamicssystem.energyDynamicsFormulation of energy balance
DynamicsmassDynamicssystem.massDynamicsFormulation of mass balance
DynamicssubstanceDynamicsenergyDynamicsFormulation of substance balance
DynamicstraceDynamicsenergyDynamicsFormulation of trace substance balance
Heat transfer
Booleanuse_HeatTransferfalse= true to use the HeatTransfer model
replaceable model HeatTransferModelica.Fluid.Vessels.BaseC...Wall heat transfer
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 system.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
FluidPorts_bports[nPorts]Fluid outlets
HeatPort_aheatPort 
input RealInputmWat_flowWater flow rate added into the medium [kg/s]
input RealInputTWatTemperature of liquid that is drained from or injected into volume [K]
output RealOutputX_wSpecies composition of medium

Modelica definition

model MixingVolumeDryAir 
  "Mixing volume with heat port for latent heat exchange, to be used with dry air"
  extends BaseClasses.PartialMixingVolumeWaterPort;

equation 
  if cardinality(mWat_flow) == 0 then
    mWat_flow = 0;
  end if;
  if cardinality(TWat) == 0 then
    TWat = Medium.T_default;
  end if;
  HWat_flow = 0;
  mXi_flow  = zeros(Medium.nXi);
// Assign output port
  X_w = 0;
end MixingVolumeDryAir;

Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir

Mixing volume with heat port for latent heat exchange, to be used with media that contain water

Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir

Information


Model for an ideally mixed fluid volume and the ability 
to store mass and energy. The volume is fixed, 
and latent and sensible heat can be exchanged.

This model represents the same physics as Buildings.Fluid.MixingVolumes.MixingVolume, but in addition, it allows adding (or subtracting) water in liquid phase, which causes a change in enthalpy and species concentration. The water flow rate is assumed to be added or extracted at the temperature of the input port TWat, or if this port is not connected, at the medium default temperature as defined by Medium.T_default.

Note that this model can only be used with medium models that include water as a substance. In particular, the medium model needs to implement the function enthalpyOfLiquid(T) and the integer variable Water that contains the index to the water substance. For medium that do not provide this functionality, use Buildings.Fluid.MixingVolumes.MixingVolumeDryAir.

Extends from BaseClasses.PartialMixingVolumeWaterPort (Partial mixing volume that allows adding or subtracting water vapor).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
VolumeV Volume [m3]
Assumptions
Dynamics
DynamicsenergyDynamicssystem.energyDynamicsFormulation of energy balance
DynamicsmassDynamicssystem.massDynamicsFormulation of mass balance
DynamicssubstanceDynamicsenergyDynamicsFormulation of substance balance
DynamicstraceDynamicsenergyDynamicsFormulation of trace substance balance
Heat transfer
Booleanuse_HeatTransferfalse= true to use the HeatTransfer model
replaceable model HeatTransferModelica.Fluid.Vessels.BaseC...Wall heat transfer
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 system.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
FluidPorts_bports[nPorts]Fluid outlets
HeatPort_aheatPort 
input RealInputmWat_flowWater flow rate added into the medium [kg/s]
input RealInputTWatTemperature of liquid that is drained from or injected into volume [K]
output RealOutputX_wSpecies composition of medium

Modelica definition

model MixingVolumeMoistAir 
  "Mixing volume with heat port for latent heat exchange, to be used with media that contain water"
  extends BaseClasses.PartialMixingVolumeWaterPort;
  // redeclare Medium with a more restricting base class. This improves the error
  // message if a user selects a medium that does not contain the function
  // enthalpyOfLiquid(.)
  replaceable package Medium = Modelica.Media.Interfaces.PartialCondensingGases;

protected 
  parameter Integer i_w(min=1, fixed=false) "Index for water substance";
  parameter Real s[Medium.nXi](fixed=false) 
    "Vector with zero everywhere except where species is";
initial algorithm 
  i_w:= -1;
  if cardinality(mWat_flow) > 0 then
  for i in 1:Medium.nXi loop
    if ( Modelica.Utilities.Strings.isEqual(Medium.substanceNames[i], "water")) then
      i_w := i;
      s[i] :=1;
    else
      s[i] :=0;
    end if;
   end for;
    assert(i_w > 0, "Substance 'water' is not present in medium '"
         + Medium.mediumName + "'.\n"
         + "Check medium model.");
    end if;

equation 
  if cardinality(mWat_flow) == 0 then
    mWat_flow = 0;
    HWat_flow = 0;
    mXi_flow  = zeros(Medium.nXi);
  else
    if cardinality(TWat) == 0 then
       HWat_flow = mWat_flow * Medium.enthalpyOfLiquid(Medium.T_default);
    else
       HWat_flow = mWat_flow * Medium.enthalpyOfLiquid(TWat);
    end if;
  // We obtain the substance concentration with a vector multiplication
  // because Dymola 7.4 cannot find the derivative in the model
  // Buildings.Fluid.HeatExchangers.Examples.WetCoilDiscretizedPControl
  // if we set mXi_flow[i] = if ( i == i_w) then mWat_flow else 0;
    mXi_flow = mWat_flow * s;
  end if;
// Medium species concentration
  X_w = s*medium.Xi;
end MixingVolumeMoistAir;

Buildings.Fluid.MixingVolumes.MixingVolume.HeatTransfer Buildings.Fluid.MixingVolumes.MixingVolume.HeatTransfer

Wall heat transfer

Buildings.Fluid.MixingVolumes.MixingVolume.HeatTransfer

Parameters

TypeNameDefaultDescription
Ambient
CoefficientOfHeatTransferk0Heat transfer coefficient to ambient [W/(m2.K)]
TemperatureT_ambientsystem.T_ambientAmbient temperature [K]
Internal Interface
replaceable package MediumPartialMediumMedium in the component
Integern1Number of heat transfer segments
Booleanuse_kfalse= true to use k value for thermal isolation

Connectors

TypeNameDescription
HeatPorts_aheatPorts[n]Heat port to component boundary

Modelica definition

replaceable model HeatTransfer =
    Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer
  constrainedby 
  Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.PartialVesselHeatTransfer 
  "Wall heat transfer";

HTML-documentation generated by Dymola Thu Jun 24 16:54:48 2010.