LBL logo

Buildings.Fluid.Sensors

Package with sensor models

Information

Package Sensors consists of idealized sensor components that provide variables of a medium model and/or fluid ports as output signals. These signals can be, e.g., further processed with components of the Modelica.Blocks library. Also more realistic sensor models can be built, by further processing (e.g., by attaching block Modelica.Blocks.Continuous.FirstOrder to model the time constant of the sensor).

Extends from Modelica.Icons.SensorsPackage (Icon for packages containing sensors).

Package Content

NameDescription
Buildings.Fluid.Sensors.UsersGuide UsersGuide User's Guide
Buildings.Fluid.Sensors.Conversions Conversions Package with conversions for sensor models
Buildings.Fluid.Sensors.Density Density Ideal one port density sensor
Buildings.Fluid.Sensors.DensityTwoPort DensityTwoPort Ideal two port density sensor
Buildings.Fluid.Sensors.EnthalpyFlowRate EnthalpyFlowRate Ideal enthalphy flow rate sensor
Buildings.Fluid.Sensors.SensibleEnthalpyFlowRate SensibleEnthalpyFlowRate Ideal enthalphy flow rate sensor that outputs the sensible enthalpy flow rate only
Buildings.Fluid.Sensors.LatentEnthalpyFlowRate LatentEnthalpyFlowRate Ideal enthalphy flow rate sensor that outputs the latent enthalpy flow rate only
Buildings.Fluid.Sensors.MassFlowRate MassFlowRate Ideal sensor for mass flow rate
Buildings.Fluid.Sensors.MassFraction MassFraction Ideal one port mass fraction sensor
Buildings.Fluid.Sensors.MassFractionTwoPort MassFractionTwoPort Ideal two port mass fraction sensor
Buildings.Fluid.Sensors.Pressure Pressure Ideal pressure sensor
Buildings.Fluid.Sensors.RelativeHumidity RelativeHumidity Ideal one port relative humidity sensor
Buildings.Fluid.Sensors.RelativeHumidityTwoPort RelativeHumidityTwoPort Ideal two port relative humidity sensor
Buildings.Fluid.Sensors.RelativePressure RelativePressure Ideal relative pressure sensor
Buildings.Fluid.Sensors.RelativeTemperature RelativeTemperature Ideal relative temperature sensor
Buildings.Fluid.Sensors.SpecificEnthalpy SpecificEnthalpy Ideal one port specific enthalpy sensor
Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort SpecificEnthalpyTwoPort Ideal two port sensor for the specific enthalpy
Buildings.Fluid.Sensors.SpecificEntropy SpecificEntropy Ideal one port specific entropy sensor
Buildings.Fluid.Sensors.SpecificEntropyTwoPort SpecificEntropyTwoPort Ideal two port sensor for the specific entropy
Buildings.Fluid.Sensors.Temperature Temperature Ideal one port temperature sensor
Buildings.Fluid.Sensors.TemperatureTwoPort TemperatureTwoPort Ideal two port temperature sensor
Buildings.Fluid.Sensors.TemperatureWetBulbTwoPort TemperatureWetBulbTwoPort Ideal wet bulb temperature sensor
Buildings.Fluid.Sensors.TraceSubstances TraceSubstances Ideal one port trace substances sensor
Buildings.Fluid.Sensors.TraceSubstancesTwoPort TraceSubstancesTwoPort Ideal two port sensor for trace substance
Buildings.Fluid.Sensors.VolumeFlowRate VolumeFlowRate Ideal sensor for volume flow rate
Buildings.Fluid.Sensors.Examples Examples Collection of models that illustrate model use and test models
Buildings.Fluid.Sensors.BaseClasses BaseClasses Package with base classes for Buildings.Fluid.Sensors


Buildings.Fluid.Sensors.Density Buildings.Fluid.Sensors.Density

Ideal one port density sensor

Buildings.Fluid.Sensors.Density

Information

This component monitors the density of the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

If using the one port sensor, read the Information first.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputdDensity in port medium [kg/m3]

Modelica definition

model Density "Ideal one port density sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput d(final quantity="Density",
                                          final unit="kg/m3",
                                          min=0) "Density in port medium";

equation 
  d = Medium.density(Medium.setState_phX(port.p, inStream(port.h_outflow), inStream(port.Xi_outflow)));
end Density;

Buildings.Fluid.Sensors.DensityTwoPort Buildings.Fluid.Sensors.DensityTwoPort

Ideal two port density sensor

Buildings.Fluid.Sensors.DensityTwoPort

Information

This component monitors the density of the fluid flowing from port_a to port_b. The sensor is ideal, i.e. it does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
Densityd_startMedium.density(Medium.setSta...Initial or guess value of output (=state) [kg/m3]
TemperatureT_startMedium.T_defaultTemperature used to compute d_start [K]
Pressurep_startMedium.p_defaultPressure used to compute d_start [Pa]
MassFractionX_start[Medium.nX]Medium.X_defaultMass fraction used to compute d_start [1]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputdDensity of the passing fluid [kg/m3]

Modelica definition

model DensityTwoPort "Ideal two port density sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput d(final quantity="Density",
                                          final unit="kg/m3",
                                          min=0) "Density of the passing fluid";
  parameter Medium.Density
    d_start=Medium.density(Medium.setState_pTX(p_start, T_start, X_start)) 
    "Initial or guess value of output (=state)";
  parameter Modelica.SIunits.Temperature T_start=Medium.T_default 
    "Temperature used to compute d_start";
  parameter Modelica.SIunits.Pressure p_start=Medium.p_default 
    "Pressure used to compute d_start";
  parameter Modelica.SIunits.MassFraction X_start[Medium.nX]=Medium.X_default 
    "Mass fraction used to compute d_start";
  Medium.Density dMed(start=d_start) 
    "Medium temperature to which the sensor is exposed";
protected 
  Medium.Density d_a_inflow "Density of inflowing fluid at port_a";
  Medium.Density d_b_inflow 
    "Density of inflowing fluid at port_b or rho_a_inflow, if uni-directional flow";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(d) = 0;
     elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      d = d_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
     d_a_inflow = Medium.density(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     d_b_inflow = Medium.density(Medium.setState_phX(port_a.p, port_a.h_outflow, port_a.Xi_outflow));
     dMed = Modelica.Fluid.Utilities.regStep(port_a.m_flow, d_a_inflow, d_b_inflow, m_flow_small);
  else
     dMed = Medium.density(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     d_a_inflow = dMed;
     d_b_inflow = dMed;
  end if;
  // Output signal of sensor
  if dynamic then
    der(d) = (dMed-d)*k/tau;
  else
    d = dMed;
  end if;
end DensityTwoPort;

Buildings.Fluid.Sensors.EnthalpyFlowRate Buildings.Fluid.Sensors.EnthalpyFlowRate

Ideal enthalphy flow rate sensor

Buildings.Fluid.Sensors.EnthalpyFlowRate

Information

This component monitors the enthalphy flow rate of the medium in the flow between fluid ports. The sensor is ideal, i.e., it does not influence the fluid.

If the parameter tau is non-zero, then the measured specific enthalpy hout that is used to compute the enthalpy flow rate Ḣ = ṁ hout is computed using a first order differential equation. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

For a sensor that measures the latent enthalpy flow rate, use Buildings.Fluid.Sensors.LatentEnthalpyFlowRate.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau0Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
SpecificEnthalpyh_out_startMedium.specificEnthalpy_pTX(...Initial or guess value of measured specific enthalpy [J/kg]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputH_flowEnthalpy flow rate, positive if from port_a to port_b [W]

Modelica definition

model EnthalpyFlowRate "Ideal enthalphy flow rate sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor(tau=0);
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput H_flow(unit="W") 
    "Enthalpy flow rate, positive if from port_a to port_b";
  parameter Modelica.SIunits.SpecificEnthalpy h_out_start=
    Medium.specificEnthalpy_pTX(Medium.p_default, Medium.T_default, Medium.X_default) 
    "Initial or guess value of measured specific enthalpy";
  Modelica.SIunits.SpecificEnthalpy hMed_out(start=h_out_start) 
    "Medium enthalpy to which the sensor is exposed";
  Modelica.SIunits.SpecificEnthalpy h_out(start=h_out_start) 
    "Medium enthalpy that is used to compute the enthalpy flow rate";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(h_out) = 0;
    elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      h_out = h_out_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
    hMed_out = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
                 port_b.h_outflow,
                 port_a.h_outflow, m_flow_small);
  else
    hMed_out = port_b.h_outflow;
  end if;
  // Specific enthalpy measured by sensor
  if dynamic then
    der(h_out) = (hMed_out-h_out)*k/tau;
  else
    h_out = hMed_out;
  end if;
  // Sensor output signal
  H_flow = port_a.m_flow * h_out;
end EnthalpyFlowRate;

Buildings.Fluid.Sensors.SensibleEnthalpyFlowRate Buildings.Fluid.Sensors.SensibleEnthalpyFlowRate

Ideal enthalphy flow rate sensor that outputs the sensible enthalpy flow rate only

Buildings.Fluid.Sensors.SensibleEnthalpyFlowRate

Information

This component monitors the sensible enthalphy flow rate of the medium in the flow between fluid ports. In particular, if the total enthalpy flow rate is

tot = Ḣsen + Ḣlat,

where sen = ṁ (1-Xw) cp,air, then this sensor outputs Ḣ = Ḣsen.

If the parameter tau is non-zero, then the measured specific sensible enthalpy hout that is used to compute the sensible enthalpy flow rate sen = ṁ hout is computed using a first order differential equation. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

For a sensor that measures tot, use Buildings.Fluid.Sensors.EnthalpyFlowRate.
For a sensor that measures lat, use Buildings.Fluid.Sensors.LatentEnthalpyFlowRate.

The sensor is ideal, i.e., it does not influence the fluid. The sensor can only be used with medium models that implement the function enthalpyOfNonCondensingGas(state).

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Buildings.Fluid.BaseClasses.IndexWater (Computes the index of the water substance), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau0Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
SpecificEnthalpyh_out_startMedium.enthalpyOfNonCondensi...Initial or guess value of measured specific sensible enthalpy [J/kg]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputH_flowSensible enthalpy flow rate, positive if from port_a to port_b [W]

Modelica definition

model SensibleEnthalpyFlowRate 
  "Ideal enthalphy flow rate sensor that outputs the sensible enthalpy flow rate only"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor(tau=0);
  extends Buildings.Fluid.BaseClasses.IndexWater;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput H_flow(unit="W") 
    "Sensible enthalpy flow rate, positive if from port_a to port_b";
  parameter Modelica.SIunits.SpecificEnthalpy h_out_start=
    Medium.enthalpyOfNonCondensingGas(
      Medium.temperature(Medium.setState_phX(
        Medium.p_default, Medium.T_default, Medium.X_default))) 
    "
Initial or guess value of measured specific sensible enthalpy
";
  Modelica.SIunits.SpecificEnthalpy hMed_out(start=h_out_start) 
    "Medium sensible enthalpy to which the sensor is exposed";
  Modelica.SIunits.SpecificEnthalpy h_out(start=h_out_start) 
    "Medium sensible enthalpy that is used to compute the enthalpy flow rate";
protected 
  Medium.MassFraction XiActual[Medium.nXi] 
    "Medium mass fraction to which sensor is exposed to";
  Medium.SpecificEnthalpy hActual 
    "Medium enthalpy to which sensor is exposed to";
  Medium.ThermodynamicState sta "Medium state to which sensor is exposed to";
initial equation 
 // Compute initial state
 if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(h_out) = 0;
    elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      h_out = h_out_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
     XiActual = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
                 port_b.Xi_outflow,
                 port_a.Xi_outflow, m_flow_small);
     hActual = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
                 port_b.h_outflow,
                 port_a.h_outflow, m_flow_small);
  else
     XiActual = port_b.Xi_outflow;
     hActual = port_b.h_outflow;
  end if;
  // Specific enthalpy measured by sensor
  sta = Medium.setState_phX(port_a.p, hActual, XiActual);
  hMed_out = (1-XiActual[i_w]) * Medium.enthalpyOfNonCondensingGas(
      Medium.temperature(sta));
  if dynamic then
    der(h_out) = (hMed_out-h_out)*k/tau;
  else
    h_out = hMed_out;
  end if;
  // Sensor output signal
  H_flow = port_a.m_flow * h_out;
end SensibleEnthalpyFlowRate;

Buildings.Fluid.Sensors.LatentEnthalpyFlowRate Buildings.Fluid.Sensors.LatentEnthalpyFlowRate

Ideal enthalphy flow rate sensor that outputs the latent enthalpy flow rate only

Buildings.Fluid.Sensors.LatentEnthalpyFlowRate

Information

This component monitors the latent enthalphy flow rate of the medium in the flow between fluid ports. In particular, if the total enthalpy flow rate is

tot = Ḣsen + Ḣlat,

where sen = ṁ (1-Xw) cp,air, then this sensor outputs Ḣ = Ḣlat.

If the parameter tau is non-zero, then the measured specific latent enthalpy hout that is used to compute the latent enthalpy flow rate lat = ṁ hout is computed using a first order differential equation. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

For a sensor that measures tot, use Buildings.Fluid.Sensors.EnthalpyFlowRate.
For a sensor that measures sen, use Buildings.Fluid.Sensors.SensibleEnthalpyFlowRate.

The sensor is ideal, i.e., it does not influence the fluid. The sensor can only be used with medium models that implement the function enthalpyOfNonCondensingGas(state).

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Buildings.Fluid.BaseClasses.IndexWater (Computes the index of the water substance), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau0Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
SpecificEnthalpyh_out_startMedium.specificEnthalpy_pTX(...Initial or guess value of measured specific latent enthalpy [J/kg]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputH_flowLatent enthalpy flow rate, positive if from port_a to port_b [W]

Modelica definition

model LatentEnthalpyFlowRate 
  "Ideal enthalphy flow rate sensor that outputs the latent enthalpy flow rate only"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor(tau=0);
  extends Buildings.Fluid.BaseClasses.IndexWater;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput H_flow(unit="W") 
    "Latent enthalpy flow rate, positive if from port_a to port_b";
  parameter Modelica.SIunits.SpecificEnthalpy h_out_start=
    Medium.specificEnthalpy_pTX(Medium.p_default, Medium.T_default, Medium.X_default)
    -Medium.enthalpyOfNonCondensingGas(
      Medium.temperature(Medium.setState_phX(
        Medium.p_default, Medium.T_default, Medium.X_default))) 
    "
Initial or guess value of measured specific latent enthalpy
";
  Modelica.SIunits.SpecificEnthalpy hMed_out(start=h_out_start) 
    "Medium latent enthalpy to which the sensor is exposed";
  Modelica.SIunits.SpecificEnthalpy h_out(start=h_out_start) 
    "Medium latent enthalpy that is used to compute the enthalpy flow rate";
protected 
  Medium.MassFraction XiActual[Medium.nXi] 
    "Medium mass fraction to which sensor is exposed to";
  Medium.SpecificEnthalpy hActual 
    "Medium enthalpy to which sensor is exposed to";
  Medium.ThermodynamicState sta "Medium state to which sensor is exposed to";
initial equation 
 // Compute initial state
 if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(h_out) = 0;
    elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      h_out = h_out_start;
    end if;
 end if;
equation 
  if allowFlowReversal then
     XiActual = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
                 port_b.Xi_outflow,
                 port_a.Xi_outflow, m_flow_small);
     hActual = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
                 port_b.h_outflow,
                 port_a.h_outflow, m_flow_small);
  else
     XiActual = port_b.Xi_outflow;
     hActual = port_b.h_outflow;
  end if;
  // Specific enthalpy measured by sensor
  sta = Medium.setState_phX(port_a.p, hActual, XiActual);
  // Compute H_flow as difference between total enthalpy and enthalpy on non-condensing gas.
  // This is needed to compute the liquid vs. gas fraction of water, using the equations
  // provided by the medium model
  hMed_out = (hActual -
     (1-XiActual[i_w]) * Medium.enthalpyOfNonCondensingGas(Medium.temperature(sta)));
  if dynamic then
    der(h_out) = (hMed_out-h_out)*k/tau;
  else
    h_out = hMed_out;
  end if;
  // Sensor output signal
  H_flow = port_a.m_flow * h_out;
end LatentEnthalpyFlowRate;

Buildings.Fluid.Sensors.MassFlowRate Buildings.Fluid.Sensors.MassFlowRate

Ideal sensor for mass flow rate

Buildings.Fluid.Sensors.MassFlowRate

Information

This component monitors the mass flow rate flowing from port_a to port_b. The sensor is ideal, i.e., it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialFlowSensor (Partial component to model sensors that measure flow properties), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Nominal condition
MassFlowRatem_flow_nominal0Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small0For bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputm_flowMass flow rate from port_a to port_b [kg/s]

Modelica definition

model MassFlowRate "Ideal sensor for mass flow rate"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialFlowSensor(
    final m_flow_nominal = 0,
    final m_flow_small = 0);
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput m_flow(quantity="MassFlowRate",
                                               final unit="kg/s") 
    "Mass flow rate from port_a to port_b";

equation 
  m_flow = port_a.m_flow;
end MassFlowRate;

Buildings.Fluid.Sensors.MassFraction Buildings.Fluid.Sensors.MassFraction

Ideal one port mass fraction sensor

Buildings.Fluid.Sensors.MassFraction

Information

This component monitors the mass fraction contained in the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor
StringsubstanceName"water"Name of species substance

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputXMass fraction in port medium

Modelica definition

model MassFraction "Ideal one port mass fraction sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;
  parameter String substanceName = "water" "Name of species substance";

  Modelica.Blocks.Interfaces.RealOutput X(min=0, max=1) 
    "Mass fraction in port medium";

protected 
  parameter Integer ind(fixed=false) 
    "Index of species in vector of auxiliary substances";
  Medium.MassFraction XiVec[Medium.nXi](
      quantity=Medium.extraPropertiesNames) 
    "Trace substances vector, needed because indexed argument for the operator inStream is not supported";
initial algorithm 
  ind:= -1;
  for i in 1:Medium.nX loop
    if ( Modelica.Utilities.Strings.isEqual(string1=Medium.substanceNames[i],
                                            string2=substanceName,
                                            caseSensitive=false)) then
      ind := i;
    end if;
  end for;
  assert(ind > 0, "Species with name '" + substanceName + "' is not present in medium '"
         + Medium.mediumName + "'.\n"
         + "Check sensor parameter and medium model.");
equation 
  XiVec = inStream(port.Xi_outflow);
  X = if ind > Medium.nXi then (1-sum(XiVec)) else XiVec[ind];
end MassFraction;

Buildings.Fluid.Sensors.MassFractionTwoPort Buildings.Fluid.Sensors.MassFractionTwoPort

Ideal two port mass fraction sensor

Buildings.Fluid.Sensors.MassFractionTwoPort

Information

This component monitors the mass fraction of the passing fluid. The sensor is ideal, i.e. it does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
StringsubstanceName"water"Name of species substance
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
MassFractionX_startMedium.X_default[ind]Initial or guess value of output (= state) [kg/kg]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputXMass fraction of the passing fluid

Modelica definition

model MassFractionTwoPort "Ideal two port mass fraction sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  extends Modelica.Icons.RotationalSensor;
  parameter String substanceName = "water" "Name of species substance";
  Modelica.Blocks.Interfaces.RealOutput X(min=0, max=1, start=X_start) 
    "Mass fraction of the passing fluid";
  parameter Medium.MassFraction X_start=Medium.X_default[ind] 
    "Initial or guess value of output (= state)";
  Medium.MassFraction XMed(start=X_start) 
    "Mass fraction to which the sensor is exposed";
protected 
  parameter Integer ind(fixed=false) 
    "Index of species in vector of auxiliary substances";
  Medium.MassFraction XiVec[Medium.nXi](
      quantity=Medium.extraPropertiesNames) 
    "Trace substances vector, needed because indexed argument for the operator inStream is not supported";
initial algorithm 
  // Compute the index of the element in the substance vector
  ind:= -1;
  for i in 1:Medium.nX loop
    if ( Modelica.Utilities.Strings.isEqual(string1=Medium.substanceNames[i],
                                            string2=substanceName,
                                            caseSensitive=false)) then
      ind := i;
    end if;
  end for;
  assert(ind > 0, "Species with name '" + substanceName + "' is not present in medium '"
         + Medium.mediumName + "'.\n"
         + "Check sensor parameter and medium model.");
initial equation 
  // Assign initial conditions
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(X) = 0;
     elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      X = X_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
    XiVec = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
         port_b.Xi_outflow, port_a.Xi_outflow, m_flow_small);
  else
    XiVec = port_b.Xi_outflow;
  end if;
  XMed = if ind > Medium.nXi then (1-sum(XiVec)) else XiVec[ind];
  // Output signal of sensor
  if dynamic then
    der(X)  = (XMed-X)*k/tau;
  else
    X = XMed;
  end if;
end MassFractionTwoPort;

Buildings.Fluid.Sensors.Pressure Buildings.Fluid.Sensors.Pressure

Ideal pressure sensor

Buildings.Fluid.Sensors.Pressure

Information

This component monitors the absolute pressure at its fluid port. The sensor is ideal, i.e., it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputpPressure at port [Pa]

Modelica definition

model Pressure "Ideal pressure sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput p(final quantity="Pressure",
                                          final unit="Pa",
                                          min=0) "Pressure at port";
equation 
  p = port.p;
end Pressure;

Buildings.Fluid.Sensors.RelativeHumidity Buildings.Fluid.Sensors.RelativeHumidity

Ideal one port relative humidity sensor

Buildings.Fluid.Sensors.RelativeHumidity

Information

This component monitors the relative humidity contained in the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

Note that this sensor can only be used with media that contain the variable phi, which is typically the case for moist air models.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputphiRelative humidity in port medium [1]

Modelica definition

model RelativeHumidity "Ideal one port relative humidity sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;

  Modelica.Blocks.Interfaces.RealOutput phi(unit="1", min=0) 
    "Relative humidity in port medium";

protected 
  Medium.BaseProperties med "Medium state at dry bulb temperature";

equation 
  med.p = port.p;
  med.h = inStream(port.h_outflow);
  med.Xi = inStream(port.Xi_outflow);
  phi = med.phi;

end RelativeHumidity;

Buildings.Fluid.Sensors.RelativeHumidityTwoPort Buildings.Fluid.Sensors.RelativeHumidityTwoPort

Ideal two port relative humidity sensor

Buildings.Fluid.Sensors.RelativeHumidityTwoPort

Information

This component monitors the relative humidity of the fluid flowing from port_a to port_b. The sensor is ideal, i.e. it does not influence the fluid.

Note that this sensor can only be used with media that contain the variable phi, which is typically the case for moist air models.

If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
Realphi_start0.5Initial or guess value of output (= state) [1]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputphiRelative humidity of the passing fluid [1]

Modelica definition

model RelativeHumidityTwoPort 
  "Ideal two port relative humidity sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput phi(unit="1",
                                            min=0,
                                            start=phi_start) 
    "Relative humidity of the passing fluid";
  parameter Real phi_start(unit="1", min=0, max=1)=0.5 
    "Initial or guess value of output (= state)";
  Real phiMed(unit="1", min=0, start=phi_start) 
    "Relative humidity to which the sensor is exposed";
protected 
  Medium.BaseProperties med_a_inflow 
    "Medium state of inflowing fluid at port a";
  Medium.BaseProperties med_b_inflow 
    "Medium state of inflowing fluid at port b";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(phi) = 0;
    elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      phi = phi_start;
    end if;
  end if;
equation 
  med_a_inflow.p  = port_a.p;
  med_a_inflow.h  = port_b.h_outflow;
  med_a_inflow.Xi = port_b.Xi_outflow;
  med_b_inflow.p  = port_b.p;
  med_b_inflow.h  = port_a.h_outflow;
  med_b_inflow.Xi = port_a.Xi_outflow;
  if allowFlowReversal then
    phiMed = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
            med_a_inflow.phi,
            med_b_inflow.phi, m_flow_small);
  else
    phiMed = med_a_inflow.phi;
  end if;
  // Output signal of sensor
  if dynamic then
    der(phi) = (phiMed-phi)*k/tau;
  else
    phi = phiMed;
  end if;
end RelativeHumidityTwoPort;

Buildings.Fluid.Sensors.RelativePressure Buildings.Fluid.Sensors.RelativePressure

Ideal relative pressure sensor

Buildings.Fluid.Sensors.RelativePressure

Information

The relative pressure "port_a.p - port_b.p" is determined between the two ports of this component and is provided as output signal. The sensor should be connected in parallel with other equipment, no flow through the sensor is allowed.

Extends from Modelica.Icons.TranslationalSensor (Icon representing a linear measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the sensor

Connectors

TypeNameDescription
replaceable package MediumMedium in the sensor
FluidPort_aport_a 
FluidPort_bport_b 
output RealOutputp_relRelative pressure signal [Pa]

Modelica definition

model RelativePressure "Ideal relative pressure sensor"
  extends Modelica.Icons.TranslationalSensor;
  replaceable package Medium =
    Modelica.Media.Interfaces.PartialMedium "Medium in the sensor";

  Modelica.Fluid.Interfaces.FluidPort_a port_a(m_flow(min=0),
                                p(start=Medium.p_default),
                                redeclare package Medium = Medium);
  Modelica.Fluid.Interfaces.FluidPort_b port_b(m_flow(min=0),
                                p(start=Medium.p_default),
                                redeclare package Medium = Medium);

  Modelica.Blocks.Interfaces.RealOutput p_rel(final quantity="Pressure",
                                              final unit="Pa",
                                              displayUnit="bar") 
    "Relative pressure signal";
equation 
  // Zero flow equations for connectors
  port_a.m_flow = 0;
  port_b.m_flow = 0;

  // No contribution of specific quantities
  port_a.h_outflow = 0;
  port_b.h_outflow = 0;
  port_a.Xi_outflow = zeros(Medium.nXi);
  port_b.Xi_outflow = zeros(Medium.nXi);
  port_a.C_outflow  = zeros(Medium.nC);
  port_b.C_outflow  = zeros(Medium.nC);

  // Relative pressure
  p_rel = port_a.p - port_b.p;
end RelativePressure;

Buildings.Fluid.Sensors.RelativeTemperature Buildings.Fluid.Sensors.RelativeTemperature

Ideal relative temperature sensor

Buildings.Fluid.Sensors.RelativeTemperature

Information

The relative temperature "T(port_a) - T(port_b)" is determined between the two ports of this component and is provided as output signal. The sensor should be connected in parallel with other equipment. There is no flow through the sensor.

Note that this sensor should only be connected to fluid volumes, such as Buildings.Fluid.MixingVolumes.MixingVolume. Otherwise, numerical problems may occur if one of the mass flow rates are close to zero. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Modelica.Icons.TranslationalSensor (Icon representing a linear measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the sensor

Connectors

TypeNameDescription
replaceable package MediumMedium in the sensor
FluidPort_aport_a 
FluidPort_bport_b 
output RealOutputT_relRelative temperature signal [K]

Modelica definition

model RelativeTemperature "Ideal relative temperature sensor"
  extends Modelica.Icons.TranslationalSensor;
  replaceable package Medium =
    Modelica.Media.Interfaces.PartialMedium "Medium in the sensor";
  Modelica.Fluid.Interfaces.FluidPort_a port_a(m_flow(min=0),
                                p(start=Medium.p_default),
                                redeclare package Medium = Medium);
  Modelica.Fluid.Interfaces.FluidPort_b port_b(m_flow(min=0),
                                p(start=Medium.p_default),
                                redeclare package Medium = Medium);
  Modelica.Blocks.Interfaces.RealOutput T_rel(final quantity="Temperature",
                                              final unit = "K", displayUnit = "degC", min=0) 
    "Relative temperature signal";
equation 
  // Zero flow equations for connectors
  port_a.m_flow = 0;
  port_b.m_flow = 0;
  // No contribution of specific quantities
  port_a.h_outflow = 0;
  port_b.h_outflow = 0;
  port_a.Xi_outflow = zeros(Medium.nXi);
  port_b.Xi_outflow = zeros(Medium.nXi);
  port_a.C_outflow  = zeros(Medium.nC);
  port_b.C_outflow  = zeros(Medium.nC);
  // Relative temperature
  T_rel = Medium.temperature(Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow))) -
          Medium.temperature(Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow)));
end RelativeTemperature;

Buildings.Fluid.Sensors.SpecificEnthalpy Buildings.Fluid.Sensors.SpecificEnthalpy

Ideal one port specific enthalpy sensor

Buildings.Fluid.Sensors.SpecificEnthalpy

Information

This component monitors the specific enthalpy of the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputh_outSpecific enthalpy in port medium [J/kg]

Modelica definition

model SpecificEnthalpy "Ideal one port specific enthalpy sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput h_out(final quantity="SpecificEnergy",
                                              final unit="J/kg") 
    "Specific enthalpy in port medium";
equation 
  h_out = inStream(port.h_outflow);
end SpecificEnthalpy;

Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort

Ideal two port sensor for the specific enthalpy

Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort

Information

This component monitors the specific enthalpy of a passing fluid. The sensor is ideal, i.e. it does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
SpecificEnthalpyh_out_startMedium.specificEnthalpy_pTX(...Initial or guess value of output (= state) [J/kg]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputh_outSpecific enthalpy of the passing fluid [J/kg]

Modelica definition

model SpecificEnthalpyTwoPort 
  "Ideal two port sensor for the specific enthalpy"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput h_out(final quantity="SpecificEnergy",
                                              final unit="J/kg",
                                              start=h_out_start) 
    "Specific enthalpy of the passing fluid";
  parameter Modelica.SIunits.SpecificEnthalpy h_out_start=
    Medium.specificEnthalpy_pTX(Medium.p_default, Medium.T_default, Medium.X_default) 
    "Initial or guess value of output (= state)";
  Modelica.SIunits.SpecificEnthalpy hMed_out(start=h_out_start) 
    "Medium enthalpy to which the sensor is exposed";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(h_out) = 0;
    elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      h_out = h_out_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
    hMed_out = Modelica.Fluid.Utilities.regStep(port_a.m_flow,
                 port_b.h_outflow,
                 port_a.h_outflow, m_flow_small);
  else
    hMed_out = port_b.h_outflow;
  end if;
  // Output signal of sensor
  if dynamic then
    der(h_out) = (hMed_out-h_out)*k/tau;
  else
    h_out = hMed_out;
  end if;
end SpecificEnthalpyTwoPort;

Buildings.Fluid.Sensors.SpecificEntropy Buildings.Fluid.Sensors.SpecificEntropy

Ideal one port specific entropy sensor

Buildings.Fluid.Sensors.SpecificEntropy

Information

This component monitors the specific entropy of the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputsSpecific entropy in port medium [J/(kg.K)]

Modelica definition

model SpecificEntropy "Ideal one port specific entropy sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput s(final quantity="SpecificEntropy",
                                          final unit="J/(kg.K)") 
    "Specific entropy in port medium";

equation 
  s = Medium.specificEntropy(Medium.setState_phX(port.p,
          inStream(port.h_outflow), inStream(port.Xi_outflow)));
end SpecificEntropy;

Buildings.Fluid.Sensors.SpecificEntropyTwoPort Buildings.Fluid.Sensors.SpecificEntropyTwoPort

Ideal two port sensor for the specific entropy

Buildings.Fluid.Sensors.SpecificEntropyTwoPort

Information

This component monitors the specific entropy of the passing fluid. The sensor is ideal, i.e. it does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
SpecificEntropys_startMedium.specificEntropy_pTX(M...Initial or guess value of output (= state) [J/(kg.K)]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputsSpecific entropy of the passing fluid [J/(kg.K)]

Modelica definition

model SpecificEntropyTwoPort 
  "Ideal two port sensor for the specific entropy"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput s(final quantity="SpecificEntropy",
                                          final unit="J/(kg.K)",
                                          start=s_start) 
    "Specific entropy of the passing fluid";
  parameter Modelica.SIunits.SpecificEntropy s_start=
    Medium.specificEntropy_pTX(Medium.p_default, Medium.T_default, Medium.X_default) 
    "Initial or guess value of output (= state)";
  Modelica.SIunits.SpecificEntropy sMed(start=s_start) 
    "Medium entropy to which the sensor is exposed";
protected 
  Medium.SpecificEntropy s_a_inflow 
    "Specific entropy of inflowing fluid at port_a";
  Medium.SpecificEntropy s_b_inflow 
    "Specific entropy of inflowing fluid at port_b or s_a_inflow, if uni-directional flow";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(s) = 0;
    elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      s = s_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
     s_a_inflow = Medium.specificEntropy(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     s_b_inflow = Medium.specificEntropy(Medium.setState_phX(port_a.p, port_a.h_outflow, port_a.Xi_outflow));
     s = Modelica.Fluid.Utilities.regStep(port_a.m_flow, s_a_inflow, s_b_inflow, m_flow_small);
  else
     s = Medium.specificEntropy(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     s_a_inflow = s;
     s_b_inflow = s;
  end if;
  // Output signal of sensor
  if dynamic then
    der(s) = (sMed-s)*k/tau;
  else
    s = sMed;
  end if;
end SpecificEntropyTwoPort;

Buildings.Fluid.Sensors.Temperature Buildings.Fluid.Sensors.Temperature

Ideal one port temperature sensor

Buildings.Fluid.Sensors.Temperature

Information

This component monitors the temperature of the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputTTemperature in port medium [K]

Modelica definition

model Temperature "Ideal one port temperature sensor"
    extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;

  Modelica.Blocks.Interfaces.RealOutput T(final quantity="Temperature",
                                          final unit = "K", min=0,
                                          displayUnit = "degC") 
    "Temperature in port medium";

equation 
  T = Medium.temperature(Medium.setState_phX(port.p, inStream(port.h_outflow), inStream(port.Xi_outflow)));
end Temperature;

Buildings.Fluid.Sensors.TemperatureTwoPort Buildings.Fluid.Sensors.TemperatureTwoPort

Ideal two port temperature sensor

Buildings.Fluid.Sensors.TemperatureTwoPort

Information

This component monitors the temperature of the medium in the flow between fluid ports. The sensor does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
TemperatureT_startMedium.T_defaultInitial or guess value of output (= state) [K]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputTTemperature of the passing fluid [K]

Modelica definition

model TemperatureTwoPort "Ideal two port temperature sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  Modelica.Blocks.Interfaces.RealOutput T(final quantity="Temperature",
                                          final unit="K",
                                          displayUnit = "degC",
                                          min = 0,
                                          start=T_start) 
    "Temperature of the passing fluid";
  parameter Modelica.SIunits.Temperature T_start=Medium.T_default 
    "Initial or guess value of output (= state)";
  Medium.Temperature TMed(start=T_start) 
    "Medium temperature to which the sensor is exposed";
protected 
  Medium.Temperature T_a_inflow "Temperature of inflowing fluid at port_a";
  Medium.Temperature T_b_inflow 
    "Temperature of inflowing fluid at port_b or T_a_inflow, if uni-directional flow";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(T) = 0;
     elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      T = T_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
     T_a_inflow = Medium.temperature(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     T_b_inflow = Medium.temperature(Medium.setState_phX(port_a.p, port_a.h_outflow, port_a.Xi_outflow));
     TMed = Modelica.Fluid.Utilities.regStep(port_a.m_flow, T_a_inflow, T_b_inflow, m_flow_small);
  else
     TMed = Medium.temperature(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     T_a_inflow = TMed;
     T_b_inflow = TMed;
  end if;
  // Output signal of sensor
  if dynamic then
    der(T) = (TMed-T)*k/tau;
  else
    T = TMed;
  end if;
end TemperatureTwoPort;

Buildings.Fluid.Sensors.TemperatureWetBulbTwoPort Buildings.Fluid.Sensors.TemperatureWetBulbTwoPort

Ideal wet bulb temperature sensor

Buildings.Fluid.Sensors.TemperatureWetBulbTwoPort

Information

This component monitors the wet bulb temperature of the medium in the flow between fluid ports. The sensor is ideal, i.e., it does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
TemperatureTWetBul_startMedium.T_defaultInitial or guess value of wet bulb temperature (used to compute initial output signal)) [K]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputTWet bulb temperature in port medium [K]

Modelica definition

model TemperatureWetBulbTwoPort "Ideal wet bulb temperature sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  Modelica.Blocks.Interfaces.RealOutput T(
    start=TWetBul_start,
    final quantity="Temperature",
    final unit="K",
    displayUnit = "degC") "Wet bulb temperature in port medium";
  parameter Modelica.SIunits.Temperature TWetBul_start = Medium.T_default 
    "
Initial or guess value of wet bulb temperature (used to compute initial output signal))
";
  Medium.Temperature TMedWetBul(start=TWetBul_start) 
    "Medium wet bulb temperature to which the sensor is exposed";
protected 
  Buildings.Utilities.Psychrometrics.TWetBul_TDryBulXi wetBulMod(
    redeclare package Medium = Medium) "Block for wet bulb temperature";
  Modelica.SIunits.SpecificEnthalpy h "Specific enthalpy";
  Medium.MassFraction Xi[Medium.nXi] 
    "Species vector, needed because indexed argument for the operator inStream is not supported";
initial equation 
  // Initialization of wet bulb temperature
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(T) = 0;
     elseif initType == Modelica.Blocks.Types.Init.InitialState or 
            initType == Modelica.Blocks.Types.Init.InitialOutput then
      T = TWetBul_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
    h  = Modelica.Fluid.Utilities.regStep(port_a.m_flow, port_b.h_outflow,  port_a.h_outflow,  m_flow_small);
    Xi = Modelica.Fluid.Utilities.regStep(port_a.m_flow, port_b.Xi_outflow, port_a.Xi_outflow, m_flow_small);
  else
    h = port_b.h_outflow;
    Xi = port_b.Xi_outflow;
  end if;
  // Compute wet bulb temperature
  wetBulMod.TDryBul = Medium.T_phX(port_a.p, h, cat(1,Xi,{1-sum(Xi)}));
  wetBulMod.Xi = Xi;
  wetBulMod.p  = port_a.p;
  TMedWetBul = wetBulMod.TWetBul;
  // Output signal of sensor
  if dynamic then
    der(T) = (TMedWetBul-T)*k/tau;
  else
    T = TMedWetBul;
  end if;
end TemperatureWetBulbTwoPort;

Buildings.Fluid.Sensors.TraceSubstances Buildings.Fluid.Sensors.TraceSubstances

Ideal one port trace substances sensor

Buildings.Fluid.Sensors.TraceSubstances

Information

This component monitors the trace substances contained in the fluid passing its port. The sensor is ideal, i.e. it does not influence the fluid.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor (Partial component to model a sensor that measures a potential variable), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the sensor
StringsubstanceName"CO2"Name of trace substance

Connectors

TypeNameDescription
FluidPort_aport 
output RealOutputCTrace substance in port medium

Modelica definition

model TraceSubstances "Ideal one port trace substances sensor"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialAbsoluteSensor;
  extends Modelica.Icons.RotationalSensor;
  parameter String substanceName = "CO2" "Name of trace substance";

  Modelica.Blocks.Interfaces.RealOutput C "Trace substance in port medium";

protected 
  parameter Real s[Medium.nC](fixed=false) 
    "Vector with zero everywhere except where species is";
initial algorithm 
  for i in 1:Medium.nC loop
    if ( Modelica.Utilities.Strings.isEqual(string1=Medium.extraPropertiesNames[i],
                                            string2=substanceName,
                                            caseSensitive=false)) then
      s[i] :=1;
    else
      s[i] :=0;
    end if;
  end for;
  assert(abs(1-sum(s)) < 1E-4, "Trace substance '" + substanceName + "' is not present in medium '"
         + Medium.mediumName + "'.\n"
         + "Check sensor parameter and medium model.");
equation 
  // We obtain the species concentration with a vector multiplication
  // because Dymola 7.3 cannot find the derivative in the model
  // Buildings.Examples.VAVSystemCTControl.mo
  // if we set C = CVec[ind];
  C = s*inStream(port.C_outflow);
end TraceSubstances;

Buildings.Fluid.Sensors.TraceSubstancesTwoPort Buildings.Fluid.Sensors.TraceSubstancesTwoPort

Ideal two port sensor for trace substance

Buildings.Fluid.Sensors.TraceSubstancesTwoPort

Information

This component monitors the trace substance of the passing fluid. The sensor is ideal, i.e. it does not influence the fluid. If the parameter tau is non-zero, then its output is computed using a first order differential equation. Setting tau=0 is not recommend. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau1Time constant at nominal flow rate [s]
StringsubstanceName"CO2"Name of trace substance
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
RealC_start Initial or guess value of output (= state)
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputCTrace substance of the passing fluid

Modelica definition

model TraceSubstancesTwoPort 
  "Ideal two port sensor for trace substance"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor;
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput C(min=0,
                                          nominal=Medium.C_nominal,
                                          start=C_start) 
    "Trace substance of the passing fluid";
  parameter String substanceName = "CO2" "Name of trace substance";
  parameter Real C_start(min=0) "Initial or guess value of output (= state)";
  Real CMed(min=0, start=C_start, nominal=Medium.C_nominal) 
    "Medium trace substance to which the sensor is exposed";
protected 
  parameter Real s[Medium.nC](fixed=false) 
    "Vector with zero everywhere except where species is";
initial algorithm 
  for i in 1:Medium.nC loop
    if ( Modelica.Utilities.Strings.isEqual(string1=Medium.extraPropertiesNames[i],
                                            string2=substanceName,
                                            caseSensitive=false)) then
      s[i] :=1;
    else
      s[i] :=0;
    end if;
  end for;
  assert(abs(1-sum(s))<1E-4, "Trace substance '" + substanceName + "' is not present in medium '"
         + Medium.mediumName + "'.\n"
         + "Check sensor parameter and medium model.");
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(C) = 0;
     elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      C = C_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
     CMed = Modelica.Fluid.Utilities.regStep(port_a.m_flow, s*port_b.C_outflow, s*port_a.C_outflow, m_flow_small);
  else
     CMed = s*inStream(port_b.C_outflow);
  end if;
  // Output signal of sensor
  if dynamic then
    der(C) = (CMed-C)*k/tau;
  else
    C = CMed;
  end if;
end TraceSubstancesTwoPort;

Buildings.Fluid.Sensors.VolumeFlowRate Buildings.Fluid.Sensors.VolumeFlowRate

Ideal sensor for volume flow rate

Buildings.Fluid.Sensors.VolumeFlowRate

Information

This component monitors the volume flow rate flowing from port_a to port_b. The sensor is ideal, i.e. it does not influence the fluid. If the parameter tau is non-zero, then the measured density that is used to convert the mass flow rate into volumetric flow rate is computed using a first order differential equation. See Buildings.Fluid.Sensors.UsersGuide for an explanation.

Extends from Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor (Partial component to model sensors that measure flow properties using a dynamic model), Modelica.Icons.RotationalSensor (Icon representing a round measurement device).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Timetau0Time constant at nominal flow rate [s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]
Initialization
InitinitTypeModelica.Blocks.Types.Init.N...Type of initialization (InitialState and InitialOutput are identical)
Densityd_startMedium.density(Medium.setSta...Initial or guess value of density [kg/m3]
TemperatureT_startMedium.T_defaultTemperature used to compute d_start [K]
Pressurep_startMedium.p_defaultPressure used to compute d_start [Pa]
MassFractionX_start[Medium.nX]Medium.X_defaultMass fraction used to compute d_start [1]
Assumptions
BooleanallowFlowReversalsystem.allowFlowReversal= true to allow flow reversal, false restricts to design direction (port_a -> port_b)

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)
output RealOutputV_flowVolume flow rate from port_a to port_b [m3/s]

Modelica definition

model VolumeFlowRate "Ideal sensor for volume flow rate"
  extends Buildings.Fluid.Sensors.BaseClasses.PartialDynamicFlowSensor(tau=0);
  extends Modelica.Icons.RotationalSensor;
  Modelica.Blocks.Interfaces.RealOutput V_flow(final quantity="VolumeFlowRate",
                                               final unit="m3/s") 
    "Volume flow rate from port_a to port_b";
  parameter Medium.Density
    d_start=Medium.density(Medium.setState_pTX(p_start, T_start, X_start)) 
    "Initial or guess value of density";
  parameter Modelica.SIunits.Temperature T_start=Medium.T_default 
    "Temperature used to compute d_start";
  parameter Modelica.SIunits.Pressure p_start=Medium.p_default 
    "Pressure used to compute d_start";
  parameter Modelica.SIunits.MassFraction X_start[Medium.nX]=Medium.X_default 
    "Mass fraction used to compute d_start";
  Medium.Density dMed(start=d_start) 
    "Medium temperature to which the sensor is exposed";
protected 
  Medium.Density d_a_inflow(start=d_start) 
    "Density of inflowing fluid at port_a";
  Medium.Density d_b_inflow(start=d_start) 
    "Density of inflowing fluid at port_b or rho_a_inflow, if uni-directional flow";
  Medium.Density d(start=d_start) "Density of the passing fluid";
initial equation 
  if dynamic then
    if initType == Modelica.Blocks.Types.Init.SteadyState then
      der(d) = 0;
     elseif initType == Modelica.Blocks.Types.Init.InitialState or 
           initType == Modelica.Blocks.Types.Init.InitialOutput then
      d = d_start;
    end if;
  end if;
equation 
  if allowFlowReversal then
     d_a_inflow = Medium.density(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     d_b_inflow = Medium.density(Medium.setState_phX(port_a.p, port_a.h_outflow, port_a.Xi_outflow));
     dMed = Modelica.Fluid.Utilities.regStep(port_a.m_flow, d_a_inflow, d_b_inflow, m_flow_small);
  else
     dMed = Medium.density(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow));
     d_a_inflow = dMed;
     d_b_inflow = dMed;
  end if;
  // Output signal of density sensor that is used to compute
  // the volume flow rate
  if dynamic then
    der(d) = (dMed-d)*k/tau;
  else
    d = dMed;
  end if;
  // Volume flow rate
  V_flow = port_a.m_flow/d;
end VolumeFlowRate;

Automatically generated Tue Jan 8 08:30:38 2013.