Buildings.Fluid.Sensors.Examples

Collection of models that illustrate model use and test models

Information


This package contains examples for the use of models
that can be found in 
Buildings.Fluid.Sensors.

Extends from Buildings.BaseClasses.BaseIconExamples (Icon for Examples packages).

Package Content

NameDescription
DryBulbTemperature  
EnthalpyFlowRate Test model for enthalpy flow rate
ExtraProperty  
MassFraction  
MoistAirEnthalpyFlowRate Test model for sensible and latent enthalpy flow rate
RelativeHumidity Test model for relative humidity sensor
WetBulbTemperature  


Buildings.Fluid.Sensors.Examples.DryBulbTemperature

Buildings.Fluid.Sensors.Examples.DryBulbTemperature

Information


This examples is a unit test for the dynamic dry bulb temperature sensor.

Modelica definition

model DryBulbTemperature

// package Medium = Buildings.Media.PerfectGases.MoistAir "Medium model" annotation 1;
 package Medium = Modelica.Media.Air.MoistAir;
  Buildings.Fluid.Sources.Boundary_pT sin(             redeclare package Medium
      = Medium,
    nPorts=1,
    T=293.15);
  Buildings.Fluid.Sources.MassFlowSource_T masFloRat(
    redeclare package Medium = Medium,
    use_T_in=true,
    use_m_flow_in=true,
    nPorts=1);
    Modelica.Blocks.Sources.Ramp TDB(
    height=10,
    duration=1,
    offset=273.15 + 30) "Dry bulb temperature";
    Modelica.Blocks.Sources.Ramp XHum(
    height=(0.0133 - 0.0175),
    offset=0.0175,
    duration=60) "Humidity concentration";
  Modelica.Blocks.Sources.Constant const;
  Modelica.Blocks.Math.Feedback feedback;
  Buildings.Utilities.Diagnostics.AssertEquality assertEquality(
      threShold=0.001, startTime=0);
  Modelica.Blocks.Continuous.FirstOrder firOrd(T=10,
    initType=Modelica.Blocks.Types.Init.InitialState,
    y_start=293.15);
  Buildings.Fluid.Sensors.TemperatureTwoPort temSteSta(
                                               redeclare package Medium =
        Medium) "Steady state temperature sensor";
  inner Modelica.Fluid.System system;
    Modelica.Blocks.Sources.Pulse m_flow(
    offset=-1,
    amplitude=2,
    period=30) "Mass flow rate";
  Buildings.Fluid.Sensors.TemperatureDryBulbDynamic temDyn(
    redeclare package Medium = Medium,
    initType=Modelica.Blocks.Types.Init.InitialState,
    m_flow_nominal=1,
    T_start=293.15);
equation 
  connect(TDB.y, masFloRat.T_in);
  connect(const.y, feedback.u1);
  connect(XHum.y, feedback.u2);
  connect(XHum.y, masFloRat.X_in[1]);
  connect(feedback.y, masFloRat.X_in[2]);
  connect(temSteSta.T, firOrd.u);
  connect(masFloRat.ports[1], temSteSta.port_a);
  connect(firOrd.y, assertEquality.u1);
  connect(m_flow.y, masFloRat.m_flow_in);
  connect(temSteSta.port_b, temDyn.port_a);
  connect(temDyn.port_b, sin.ports[1]);
  connect(temDyn.T, assertEquality.u2);
end DryBulbTemperature;

Buildings.Fluid.Sensors.Examples.EnthalpyFlowRate

Test model for enthalpy flow rate

Buildings.Fluid.Sensors.Examples.EnthalpyFlowRate

Modelica definition

model EnthalpyFlowRate "Test model for enthalpy flow rate"
  import Buildings;

  package Medium = Modelica.Media.Air.SimpleAir;
  Buildings.Fluid.Sensors.EnthalpyFlowRate senH_flow(redeclare package Medium
      = Medium) "Sensor for enthalpy flow rate";
  Buildings.Fluid.Sources.MassFlowSource_h sou(
    use_m_flow_in=true,
    use_h_in=true,
    redeclare package Medium = Medium,
    nPorts=1);
  Buildings.Fluid.Sources.Boundary_ph sin(use_h_in=true, redeclare package
      Medium = Medium,
    nPorts=1);
  Modelica.Blocks.Sources.Ramp ramp(
    duration=1,
    height=-2,
    offset=1);
  Modelica.Blocks.Sources.Constant const(k=10);
  Modelica.Blocks.Sources.Constant const1(k=20);
  inner Modelica.Fluid.System system;
  Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort senH(redeclare package Medium
      = Medium);
  Buildings.Fluid.Sensors.MassFlowRate senM_flow(redeclare package Medium =
        Medium);
  Buildings.Utilities.Diagnostics.AssertEquality assertEquality;
  Modelica.Blocks.Math.Product product;
equation 
  connect(ramp.y, sou.m_flow_in);
  connect(const.y, sou.h_in);
  connect(const1.y, sin.h_in);
  connect(sou.ports[1], senH_flow.port_a);
  connect(senH_flow.port_b, senH.port_a);
  connect(senH.port_b, senM_flow.port_a);
  connect(senM_flow.port_b, sin.ports[1]);
  connect(senH_flow.H_flow, assertEquality.u1);
  connect(senH.h_out, product.u1);
  connect(senM_flow.m_flow, product.u2);
  connect(product.y, assertEquality.u2);
end EnthalpyFlowRate;

Buildings.Fluid.Sensors.Examples.ExtraProperty

Buildings.Fluid.Sensors.Examples.ExtraProperty

Modelica definition

model ExtraProperty
  import Buildings;
 package Medium = Buildings.Media.GasesPTDecoupled.SimpleAir(extraPropertiesNames={"CO2"});

  MixingVolumes.MixingVolume vol(
    redeclare package Medium = Medium,
    V=2*3*3,
    nPorts=4) "Mixing volume";
  inner Modelica.Fluid.System system;
  Sources.PrescribedExtraPropertyFlowRate sou(redeclare package Medium = Medium,
    nPorts=3,
    use_m_flow_in=true);
  Modelica.Blocks.Sources.Constant step(k=8.18E-6);
  Buildings.Fluid.Sensors.TraceSubstances senVol(
                    redeclare package Medium = Medium) "Sensor at volume";
  Buildings.Fluid.Sensors.TraceSubstances senSou(
                    redeclare package Medium = Medium, substanceName="CO2") 
    "Sensor at source";
  Modelica.Blocks.Sources.Constant m_flow(k=15*1.2/3600) "Fresh air flow rate";
  Buildings.Fluid.Sources.MassFlowSource_T mSou(
                                          redeclare package Medium = Medium,
    use_m_flow_in=true,
    nPorts=2);
  Modelica.Blocks.Math.Gain gain(k=-1);
  Buildings.Fluid.Sources.MassFlowSource_T mSin(
                                          redeclare package Medium = Medium,
    use_m_flow_in=true,
    nPorts=2);
  Conversions.MassFractionVolumeFraction masFraSou(MMMea=Modelica.Media.
        IdealGases.Common.SingleGasesData.CO2.MM);
  Conversions.MassFractionVolumeFraction masFraVol(MMMea=Modelica.Media.
        IdealGases.Common.SingleGasesData.CO2.MM);
  Buildings.Fluid.Sensors.RelativePressure dp(
                      redeclare package Medium = Medium);
  Buildings.Utilities.Diagnostics.AssertEquality assertEquality(startTime=0,
      threShold=1E-8);
  Modelica.Blocks.Sources.Constant zer(k=0) "Zero signal";
  Buildings.Fluid.Sensors.Pressure preSen(  redeclare package Medium = Medium) 
    "Pressure sensor";
equation 
  connect(m_flow.y, mSou.m_flow_in);
  connect(m_flow.y, gain.u);
  connect(gain.y, mSin.m_flow_in);
  connect(senSou.C, masFraSou.m);
  connect(senVol.C, masFraVol.m);
  connect(dp.p_rel, assertEquality.u1);
  connect(zer.y, assertEquality.u2);
  connect(mSou.ports[1], dp.port_a);
  connect(mSin.ports[1], dp.port_b);
  connect(mSou.ports[2], vol.ports[1]);
  connect(mSin.ports[2], vol.ports[2]);
  connect(vol.ports[4], senVol.port);
  connect(sou.ports[1], vol.ports[3]);
  connect(sou.ports[2], preSen.port);
  connect(sou.ports[3], senSou.port);
  connect(step.y, sou.m_flow_in);
end ExtraProperty;

Buildings.Fluid.Sensors.Examples.MassFraction

Buildings.Fluid.Sensors.Examples.MassFraction

Information


This examples is a unit test for the mass fraction sensor.

Modelica definition

model MassFraction

  import Buildings;

 package Medium = Buildings.Media.PerfectGases.MoistAirUnsaturated 
    "Medium model";

  Buildings.Fluid.Sources.Boundary_pT sin(             redeclare package Medium
      = Medium,
    T=293.15,
    nPorts=1);
  Buildings.Fluid.Sources.MassFlowSource_T masFloRat(
    redeclare package Medium = Medium,
    nPorts=1,
    use_m_flow_in=false,
    use_T_in=false,
    X={0.02,0.98},
    m_flow=10);
  inner Modelica.Fluid.System system;
  Buildings.Fluid.Sensors.MassFraction masFra(redeclare package Medium =
        Medium) "Mass fraction";
  Buildings.Fluid.MixingVolumes.MixingVolume vol(
    redeclare package Medium = Medium,
    nPorts=3,
    V=1) "Volume";
  Buildings.Fluid.FixedResistances.FixedResistanceDpM dp(
    redeclare package Medium = Medium,
    m_flow_nominal=10,
    dp_nominal=200);
equation 
  connect(masFloRat.ports[1], vol.ports[1]);
  connect(masFra.port, vol.ports[2]);
  connect(dp.port_b, sin.ports[1]);
  connect(dp.port_a, vol.ports[3]);
end MassFraction;

Buildings.Fluid.Sensors.Examples.MoistAirEnthalpyFlowRate

Test model for sensible and latent enthalpy flow rate

Buildings.Fluid.Sensors.Examples.MoistAirEnthalpyFlowRate

Modelica definition

model MoistAirEnthalpyFlowRate 
  "Test model for sensible and latent enthalpy flow rate"
  import Buildings;

  package Medium = Modelica.Media.Air.MoistAir;
  Buildings.Fluid.Sensors.EnthalpyFlowRate senH_flow(redeclare package Medium
      = Medium) "Sensor for enthalpy flow rate";
  Buildings.Fluid.Sources.MassFlowSource_T sou(
    use_m_flow_in=true,
    redeclare package Medium = Medium,
    nPorts=1,
    X=Medium.X_default,
    T=293.15);
  Buildings.Fluid.Sources.Boundary_pT sin(               redeclare package
      Medium = Medium,
    nPorts=1,
    T=313.15,
    X={0.02,0.98});
  Modelica.Blocks.Sources.Ramp ramp(
    duration=1,
    height=-2,
    offset=1);
  inner Modelica.Fluid.System system;
  Buildings.Fluid.Sensors.SpecificEnthalpyTwoPort senH(redeclare package Medium
      = Medium);
  Buildings.Fluid.Sensors.MassFlowRate senM_flow(redeclare package Medium =
        Medium);
  Buildings.Utilities.Diagnostics.AssertEquality assEqu1;
  Modelica.Blocks.Math.Product product;
  Buildings.Fluid.Sensors.LatentEnthalpyFlowRate senHLat_flow(redeclare package
      Medium =         Medium) "Sensor for latent enthalpy flow rate";
  Buildings.Fluid.Sensors.SensibleEnthalpyFlowRate senHSen_flow(redeclare 
      package Medium = Medium) "Sensor for sensible enthalpy flow rate";
  Modelica.Blocks.Math.Add add1;
  Buildings.Utilities.Diagnostics.AssertEquality assEqu2;
equation 
  connect(ramp.y, sou.m_flow_in);
  connect(sou.ports[1], senH_flow.port_a);
  connect(senH_flow.port_b, senH.port_a);
  connect(senH.port_b, senM_flow.port_a);
  connect(senH_flow.H_flow, assEqu1.u1);
  connect(senH.h_out, product.u1);
  connect(senM_flow.m_flow, product.u2);
  connect(product.y, assEqu1.u2);
  connect(senHLat_flow.H_flow, add1.u1);
  connect(senHSen_flow.H_flow, add1.u2);
  connect(senM_flow.port_b, senHLat_flow.port_a);
  connect(senHLat_flow.port_b, senHSen_flow.port_a);
  connect(senH_flow.H_flow, assEqu2.u1);
  connect(add1.y, assEqu2.u2);
  connect(senHSen_flow.port_b, sin.ports[1]);
end MoistAirEnthalpyFlowRate;

Buildings.Fluid.Sensors.Examples.RelativeHumidity

Test model for relative humidity sensor

Buildings.Fluid.Sensors.Examples.RelativeHumidity

Information


This examples is a unit test for the relative humidity sensor.

Modelica definition

model RelativeHumidity "Test model for relative humidity sensor"
  import Buildings;

 package Medium = Buildings.Media.PerfectGases.MoistAir "Medium model";

  Buildings.Fluid.Sources.Boundary_pT sin(             redeclare package Medium
      = Medium,
    nPorts=1,
    use_p_in=false,
    T=293.15);
  Buildings.Fluid.Sources.MassFlowSource_T massFlowRate(            redeclare 
      package Medium = Medium, m_flow=1,
    use_T_in=true,
    use_X_in=true,
    nPorts=1,
    use_m_flow_in=true);
    Modelica.Blocks.Sources.Ramp TDB(
    height=10,
    duration=1,
    offset=273.15 + 30) "Dry bulb temperature";
    Modelica.Blocks.Sources.Ramp XHum(
    duration=1,
    height=(0.0133 - 0.0175),
    offset=0.0175) "Humidity concentration";
  Modelica.Blocks.Sources.Constant const(k=1);
  Modelica.Blocks.Math.Feedback feedback;
  inner Modelica.Fluid.System system;
  Buildings.Fluid.FixedResistances.FixedResistanceDpM dp(
    redeclare package Medium = Medium,
    m_flow_nominal=10,
    dp_nominal=200);
  Buildings.Fluid.Sensors.RelativeHumidity senRelHum(redeclare package Medium
      = Medium);
    Modelica.Blocks.Sources.Ramp m_flow(
    duration=1,
    height=-2,
    offset=1) "Mass flow rate";
equation 
  connect(TDB.y, massFlowRate.T_in);
  connect(const.y, feedback.u1);
  connect(XHum.y, feedback.u2);
  connect(XHum.y, massFlowRate.X_in[1]);
  connect(feedback.y, massFlowRate.X_in[2]);
  connect(dp.port_a, massFlowRate.ports[1]);
  connect(senRelHum.port, dp.port_b);
  connect(dp.port_b, sin.ports[1]);
  connect(m_flow.y, massFlowRate.m_flow_in);
end RelativeHumidity;

Buildings.Fluid.Sensors.Examples.WetBulbTemperature

Buildings.Fluid.Sensors.Examples.WetBulbTemperature

Information


This examples is a unit test for the wet bulb sensor.
The problem setup is such that the moisture concentration and
the dry bulb temperature are varied simultaneously in such a way
that the wet bulb temperature is constant.
This wet bulb temperature is checked against a constant value with
an assert statement.
In case this assert is triggered, then either the wet bulb sensor or
the medium model got broken (assuming that the inputs remained unchanged).

Modelica definition

model WetBulbTemperature
  import Buildings;

 package Medium = Buildings.Media.PerfectGases.MoistAir "Medium model";

    Modelica.Blocks.Sources.Ramp p(
    duration=1,
    offset=101325,
    height=250);
  Buildings.Fluid.Sources.Boundary_pT sin(             redeclare package Medium
      = Medium,
    use_p_in=true,
    nPorts=1,
    T=293.15);
  Buildings.Fluid.Sensors.TemperatureWetBulb senWetBul(redeclare package Medium
      =        Medium) "Wet bulb temperature sensor";
  Buildings.Fluid.Sources.MassFlowSource_T massFlowRate(            redeclare 
      package Medium = Medium, m_flow=1,
    use_T_in=true,
    use_X_in=true,
    nPorts=1);
    Modelica.Blocks.Sources.Ramp TDB(
    height=10,
    duration=1,
    offset=273.15 + 30) "Dry bulb temperature";
    Modelica.Blocks.Sources.Ramp XHum(
    duration=1,
    height=(0.0133 - 0.0175),
    offset=0.0175) "Humidity concentration";
  Modelica.Blocks.Sources.Constant const(k=1);
  Modelica.Blocks.Math.Feedback feedback;
  Buildings.Utilities.Diagnostics.AssertEquality assertEquality(threShold=0.05);
  Modelica.Blocks.Sources.Constant TWBExp(k=273.15 + 25) 
    "Expected wet bulb temperature";
  inner Modelica.Fluid.System system;
  Buildings.Fluid.Sensors.MassFraction masFra(
                      redeclare package Medium = Medium) "Mass fraction";
equation 
  connect(TDB.y, massFlowRate.T_in);
  connect(const.y, feedback.u1);
  connect(XHum.y, feedback.u2);
  connect(XHum.y, massFlowRate.X_in[1]);
  connect(feedback.y, massFlowRate.X_in[2]);
  connect(p.y, sin.p_in);
  connect(massFlowRate.ports[1], senWetBul.port_a);
  connect(senWetBul.port_b, sin.ports[1]);
  connect(TWBExp.y, assertEquality.u1);
  connect(senWetBul.T, assertEquality.u2);
  connect(senWetBul.port_a, masFra.port);
end WetBulbTemperature;

HTML-documentation generated by Dymola Thu Jun 24 16:55:06 2010.