LBL logo

Buildings.Fluid.MixingVolumes.BaseClasses

Package with base classes for Buildings.Fluid.MixingVolumes

Information

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

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

Package Content

NameDescription
Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume PartialMixingVolume Partial mixing volume with inlet and outlet ports (flow reversal is allowed)
Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolumeWaterPort PartialMixingVolumeWaterPort Partial mixing volume that allows adding or subtracting water vapor


Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume

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

Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume

Information

This is a partial model of an instantaneously mixed volume. It is used as the base class for all fluid volumes of the package Buildings.Fluid.MixingVolumes.

Implementation

If the model is operated in steady-state and has two fluid ports connected, then the same energy and mass balance implementation is used as in steady-state component models, i.e., the use of actualStream is not used for the properties at the port.

For simple models that uses this model, see Buildings.Fluid.MixingVolumes.

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

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
VolumeV Volume [m3]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
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.)
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
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports.
Heat transfer
BooleanprescribedHeatFlowRatefalseSet to true if the model has a prescribed heat flow at its heatPort

Connectors

TypeNameDescription
VesselFluidPorts_bports[nPorts]Fluid inlets and outlets
HeatPort_aheatPortHeat port connected to outflowing medium

Modelica definition

partial model PartialMixingVolume 
  "Partial mixing volume with inlet and outlet ports (flow reversal is allowed)"
  outer Modelica.Fluid.System system "System properties";
  extends Buildings.Fluid.Interfaces.LumpedVolumeDeclarations;
  parameter Modelica.SIunits.MassFlowRate m_flow_nominal(min=0) 
    "Nominal mass flow rate";
  // Port definitions
  parameter Integer nPorts=0 "Number of ports";
  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";
  parameter Boolean allowFlowReversal = system.allowFlowReversal 
    "= true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports.";
  parameter Modelica.SIunits.Volume V "Volume";
  parameter Boolean prescribedHeatFlowRate=false 
    "Set to true if the model has a prescribed heat flow at its heatPort";
  Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b ports[nPorts](
      redeclare each package Medium = Medium) "Fluid inlets and outlets";
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort 
    "Heat port connected to outflowing medium";
  Modelica.SIunits.Temperature T "Temperature of the fluid";
  Modelica.SIunits.Pressure p "Pressure of the fluid";
  Modelica.SIunits.MassFraction Xi[Medium.nXi] 
    "Species concentration of the fluid";
  Medium.ExtraProperty C[Medium.nC](nominal=C_nominal) 
    "Trace substance mixture content";
   // Models for the steady-state and dynamic energy balance.
protected 
  Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation steBal(
    sensibleOnly = true,
    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,
    final show_V_flow = false) if 
        useSteadyStateTwoPort "Model for steady-state balance if nPorts=2";
  Buildings.Fluid.Interfaces.ConservationEquation dynBal(
    redeclare final package Medium = Medium,
    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 C_nominal=C_nominal,
    final fluidVolume = V,
    m(start=V*rho_nominal),
    U(start=V*rho_nominal*Medium.specificInternalEnergy(
        state_start)),
    nPorts=nPorts) if 
        not useSteadyStateTwoPort "Model for dynamic energy balance";
  parameter Medium.ThermodynamicState state_start = Medium.setState_pTX(
      T=T_start,
      p=p_start,
      X=X_start[1:Medium.nXi]) "Start state";
  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";
  ////////////////////////////////////////////////////
  final parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and 
      prescribedHeatFlowRate and (
      energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and (
      massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and (
      substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and (
      traceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) 
    "Flag, true if the model has two ports only and uses a steady state balance";
  Modelica.SIunits.HeatFlowRate Q_flow 
    "Heat flow across boundaries or energy source/sink";
  // Outputs that are needed to assign the medium properties
  Modelica.Blocks.Interfaces.RealOutput hOut_internal(unit="J/kg") 
    "Internal connector for leaving temperature of the component";
  Modelica.Blocks.Interfaces.RealOutput XiOut_internal[Medium.nXi](unit="1") 
    "Internal connector for leaving species concentration of the component";
  Modelica.Blocks.Interfaces.RealOutput COut_internal[Medium.nC](unit="1") 
    "Internal connector for leaving trace substances of the component";

equation 
  ///////////////////////////////////////////////////////////////////////////
  // asserts
  if not allowFlowReversal then
    assert(ports[1].m_flow > -m_flow_small,
"Model has flow reversal, but the parameter allowFlowReversal is set to false.
  m_flow_small    = " + String(m_flow_small) + "
  ports[1].m_flow = " + String(ports[1].m_flow) + "
");
  end if;
// Only one connection allowed to a port to avoid unwanted ideal mixing
  if not useSteadyStateTwoPort then
    for i in 1:nPorts loop
    assert(cardinality(ports[i]) == 2 or cardinality(ports[i]) == 0,"
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;
  end if;
  // actual definition of port variables
  // If the model computes the energy and mass balances as steady-state,
  // and if it has only two ports,
  // then we use the same base class as for all other steady state models.
  if useSteadyStateTwoPort then
  connect(steBal.port_a, ports[1]);

  connect(steBal.port_b, ports[2]);

    connect(hOut_internal,  steBal.hOut);
    connect(XiOut_internal, steBal.XiOut);
    connect(COut_internal,  steBal.COut);
  else
      connect(dynBal.ports, ports);

    connect(hOut_internal,  dynBal.hOut);
    connect(XiOut_internal, dynBal.XiOut);
    connect(COut_internal,  dynBal.COut);
  end if;
  // Medium properties
  p = if nPorts > 0 then ports[1].p else p_start;
  T = Medium.temperature_phX(p=p, h=hOut_internal, X=cat(1,Xi,{1-sum(Xi)}));
  Xi = XiOut_internal;
  C = COut_internal;
  // Port properties
  heatPort.T = T;
  heatPort.Q_flow = Q_flow;

end PartialMixingVolume;

Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolumeWaterPort Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolumeWaterPort

Partial mixing volume that allows adding or subtracting water vapor

Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolumeWaterPort

Information

This is a partial model of an instantaneously mixed volume. It is used as the base class for all fluid volumes of the package Buildings.Fluid.MixingVolumes that add or remove humidity from the volume.

Implementation

The model is partial in order to allow a submodel that can be used with media that contain water as a substance, and a submodel that can be used with dry air. Having separate models is required because calls to the medium property function enthalpyOfLiquid results in a linker error if a medium such as Modelica.Media.Air.SimpleAir is used that does not implement this function.

Extends from Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume (Partial mixing volume with inlet and outlet ports (flow reversal is allowed)).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
VolumeV Volume [m3]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
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.)
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
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports.
Heat transfer
BooleanprescribedHeatFlowRatefalseSet to true if the model has a prescribed heat flow at its heatPort

Connectors

TypeNameDescription
VesselFluidPorts_bports[nPorts]Fluid inlets and outlets
HeatPort_aheatPortHeat port connected to outflowing medium
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

partial model PartialMixingVolumeWaterPort 
  "Partial mixing volume that allows adding or subtracting water vapor"
  extends Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume;

 // additional declarations
  Modelica.Blocks.Interfaces.RealInput mWat_flow(final quantity="MassFlowRate",
                                                 final unit = "kg/s") 
    "Water flow rate added into the medium";
  Modelica.Blocks.Interfaces.RealInput TWat(final quantity="Temperature",
                                            final unit = "K", displayUnit = "degC", min=260) 
    "Temperature of liquid that is drained from or injected into volume";
  Modelica.Blocks.Interfaces.RealOutput X_w "Species composition of medium";
  Medium.MassFlowRate mXi_flow[Medium.nXi] 
    "Mass flow rates of independent substances added to the medium";
  Modelica.SIunits.HeatFlowRate HWat_flow 
    "Enthalpy flow rate of extracted water";

end PartialMixingVolumeWaterPort;

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