LBL logo

Buildings.Fluid.Interfaces.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.Interfaces.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

NameDescription
Buildings.Fluid.Interfaces.Examples.HeaterCoolerPrescribed HeaterCoolerPrescribed Model that tests a heat exchanger model with reverse flow
Buildings.Fluid.Interfaces.Examples.HumidifierPrescribed HumidifierPrescribed  
Buildings.Fluid.Interfaces.Examples.ReverseFlowHumidifier ReverseFlowHumidifier Model that tests the reverse flow for a humidifier
Buildings.Fluid.Interfaces.Examples.ReverseFlowMassExchanger ReverseFlowMassExchanger Model that tests the reverse flow for a mass exchanger


Buildings.Fluid.Interfaces.Examples.HeaterCoolerPrescribed Buildings.Fluid.Interfaces.Examples.HeaterCoolerPrescribed

Model that tests a heat exchanger model with reverse flow

Buildings.Fluid.Interfaces.Examples.HeaterCoolerPrescribed

Information

Model that tests the basic class that is used for the heater models. It adds and removes heat for forward and reverse flow. The top and bottom models should give similar results, although the sign of the temperature difference over the components differ because of the reverse flow. The model uses assert statements that will be triggered if results that are expected to be close to each other differ by more than a prescribed threshold. All temperature sensors are configured as steady-state sensors to avoid differences in temperature due to the dynamic response of the sensor.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model HeaterCoolerPrescribed 
  "Model that tests a heat exchanger model with reverse flow"
  import Buildings;
  extends Modelica.Icons.Example;

 package Medium = Buildings.Media.ConstantPropertyLiquidWater;

  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea1(
                                                         redeclare package
      Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
  Modelica.Blocks.Sources.Constant TDb(k=293.15) "Drybulb temperature";
  Buildings.Fluid.Sources.Boundary_pT sou_1(
    redeclare package Medium = Medium,
    use_T_in=true,
    nPorts=4,
    p(displayUnit="Pa") = 101735,
    T=293.15);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_11(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_12(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.Sources.Boundary_pT sin_1(                       redeclare 
      package Medium = Medium,
    use_p_in=true,
    T=288.15,
    nPorts=4);
    Modelica.Blocks.Sources.Constant POut(k=101325);
    Modelica.Blocks.Sources.Ramp u(
    height=2,
    duration=3600,
    offset=-1,
    startTime=0) "Control signal";
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea2(
                                                 redeclare package Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
  Modelica.Blocks.Math.Gain gain(k=-1);
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea3(
                                                         redeclare package
      Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_2(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_3(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea4(
                                                 redeclare package Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_4(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MixingVolumes.MixingVolume mix1(
                                           redeclare package Medium = Medium, V=
       0.000001,
    nPorts=2,
    m_flow_nominal=0.5);
  Buildings.Utilities.Diagnostics.AssertEquality ass1(startTime=0.2, threShold=
        0.05);
  Buildings.Utilities.Diagnostics.AssertEquality ass2(startTime=0.2, threShold=
        0.05);
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea5(
                                                         redeclare package
      Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_1(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_5(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea6(
                                                 redeclare package Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea7(
                                                         redeclare package
      Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_6(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_7(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed hea8(
                                                 redeclare package Medium =
        Medium, Q_flow_nominal=5000,
    m_flow_nominal=0.5,
    dp_nominal=200) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_8(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MixingVolumes.MixingVolume mix2(
                                           redeclare package Medium = Medium, V=
       0.000001,
    nPorts=2,
    m_flow_nominal=0.5);
  Buildings.Utilities.Diagnostics.AssertEquality ass9(                startTime=
        0.3, threShold=0.05);
  Buildings.Utilities.Diagnostics.AssertEquality ass10(                startTime=
        0.3, threShold=0.05);
  inner Modelica.Fluid.System system(m_flow_start=0, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState);
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem2a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem2b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem1a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem1b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem3a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem3b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem4a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem4b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Utilities.Diagnostics.AssertEquality ass3(startTime=0.2, threShold=
        0.05);
  Buildings.Utilities.Diagnostics.AssertEquality ass4(startTime=0.2, threShold=
        0.05);
  Buildings.Utilities.Diagnostics.AssertEquality ass5(startTime=0.2, threShold=
        0.05);
  Buildings.Utilities.Diagnostics.AssertEquality ass6(startTime=0.2, threShold=
        0.05);
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem6b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem6a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem5b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem5a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Utilities.Diagnostics.AssertEquality ass7(startTime=0.2, threShold=
        0.05);
  Buildings.Utilities.Diagnostics.AssertEquality ass8(startTime=0.2, threShold=
        0.05);
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem8b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem8a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem7b(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
  Buildings.Fluid.Sensors.TemperatureTwoPort
                                      senTem7a(redeclare package Medium = Medium,
    m_flow_nominal=0.5,
    tau=0) "Temperature sensor";
equation 
  connect(POut.y,sin_1. p_in);
  connect(TDb.y,sou_1. T_in);
  connect(u.y, hea1.u);
  connect(gain.y, hea2.u);
  connect(u.y, gain.u);
  connect(u.y, hea3.u);
  connect(gain.y, hea4.u);
  connect(u.y, hea6.u);
  connect(u.y, hea8.u);
  connect(gain.y, hea5.u);
  connect(gain.y, hea7.u);
  connect(sin_1.ports[1], res_12.port_a);
  connect(sin_1.ports[2], res_3.port_a);
  connect(sou_1.ports[1], res_11.port_a);
  connect(sou_1.ports[2], res_2.port_a);
  connect(sin_1.ports[3], res_1.port_a);
  connect(sin_1.ports[4], res_6.port_a);
  connect(sou_1.ports[3], res_5.port_a);
  connect(sou_1.ports[4], res_7.port_a);
  connect(mix1.ports[1], res_4.port_a);
  connect(mix2.ports[1], res_8.port_a);
  connect(senTem1a.T, ass1.u1);
  connect(senTem2a.T, ass1.u2);
  connect(senTem1b.T, ass2.u2);
  connect(senTem2b.T, ass2.u1);
  connect(senTem4a.T, ass4.u2);
  connect(senTem3a.T, ass4.u1);
  connect(senTem4b.T, ass3.u1);
  connect(senTem3b.T, ass3.u2);
  connect(senTem6a.T, ass6.u2);
  connect(senTem5a.T, ass6.u1);
  connect(senTem6b.T, ass5.u1);
  connect(senTem5b.T, ass5.u2);
  connect(senTem8a.T, ass8.u2);
  connect(senTem7a.T, ass8.u1);
  connect(senTem8b.T, ass7.u1);
  connect(senTem7b.T, ass7.u2);
  connect(senTem3a.T, ass10.u1);
  connect(senTem7a.T, ass10.u2);
  connect(senTem2b.T, ass9.u1);
  connect(senTem5b.T, ass9.u2);
  connect(res_12.port_b, senTem2a.port_a);
  connect(senTem2a.port_b, hea2.port_a);
  connect(hea2.port_b, senTem2b.port_a);
  connect(senTem2b.port_b, senTem1b.port_b);
  connect(hea1.port_b, senTem1b.port_a);
  connect(res_11.port_b, senTem1a.port_a);
  connect(senTem1a.port_b, hea1.port_a);
  connect(res_2.port_b, senTem3a.port_a);
  connect(senTem3a.port_b, hea3.port_a);
  connect(hea3.port_b, senTem3b.port_a);
  connect(senTem3b.port_b, mix1.ports[2]);
  connect(hea4.port_b, senTem4b.port_a);
  connect(res_3.port_b, senTem4a.port_a);
  connect(senTem4a.port_b, hea4.port_a);
  connect(senTem4b.port_b, res_4.port_b);
  connect(res_5.port_b, senTem6a.port_a);
  connect(senTem6a.port_b, hea6.port_a);
  connect(hea6.port_b, senTem6b.port_a);
  connect(senTem6b.port_b, senTem5b.port_b);
  connect(senTem5b.port_a, hea5.port_b);
  connect(hea5.port_a, senTem5a.port_b);
  connect(senTem5a.port_a, res_1.port_b);
  connect(res_7.port_b, senTem8a.port_a);
  connect(senTem8a.port_b, hea8.port_a);
  connect(hea8.port_b, senTem8b.port_a);
  connect(senTem8b.port_b, res_8.port_b);
  connect(mix2.ports[2], senTem7b.port_b);
  connect(senTem7b.port_a, hea7.port_b);
  connect(hea7.port_a, senTem7a.port_b);
  connect(senTem7a.port_a, res_6.port_b);
end HeaterCoolerPrescribed;

Buildings.Fluid.Interfaces.Examples.HumidifierPrescribed Buildings.Fluid.Interfaces.Examples.HumidifierPrescribed

Buildings.Fluid.Interfaces.Examples.HumidifierPrescribed

Information

Model that tests the basic class that is used for the humidifier model. It adds and removes water for forward and reverse flow. The top and bottom models should give similar results, although the sign of the humidity difference over the components differ because of the reverse flow. The model uses assert statements that will be triggered if results that are expected to be close to each other differ by more than a prescribed threshold.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
MassFlowRatemWat_flow_nominal0.001Nominal water mass flow rate [kg/s]

Modelica definition

model HumidifierPrescribed
  import Buildings;
  extends Modelica.Icons.Example;

 package Medium = Buildings.Media.PerfectGases.MoistAirUnsaturated;
 parameter Modelica.SIunits.MassFlowRate mWat_flow_nominal = 0.001 
    "Nominal water mass flow rate";
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea1(redeclare package
      Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
  Modelica.Blocks.Sources.Constant TDb(k=293.15) "Drybulb temperature";
  Buildings.Fluid.Sources.Boundary_pT sou_1(
    redeclare package Medium = Medium,
    use_T_in=true,
    nPorts=4,
    p(displayUnit="Pa") = 101435,
    T=293.15);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_11(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_12(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.Sources.Boundary_pT sin_1(                       redeclare 
      package Medium = Medium,
    use_p_in=true,
    T=288.15,
    nPorts=4);
    Modelica.Blocks.Sources.Constant POut(k=101325);
    Modelica.Blocks.Sources.Ramp u(
    duration=3600,
    startTime=0,
    height=1,
    offset=0) "Control signal";
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea2(
                                                 redeclare package Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
  Modelica.Blocks.Math.Gain gain(k=-1);
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea3(redeclare package
      Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_2(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_3(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea4(
                                                 redeclare package Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_4(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MixingVolumes.MixingVolume mix1(
                                           redeclare package Medium = Medium, V=
       0.000001,
    nPorts=2,
    m_flow_nominal=0.5);
  Buildings.Utilities.Diagnostics.AssertEquality ass1(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y1(y=hea2.sta_b.T);
  Modelica.Blocks.Sources.RealExpression y2(y=hea1.sta_b.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass2(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y3(y=hea2.sta_a.T);
  Modelica.Blocks.Sources.RealExpression y4(y=hea1.sta_a.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass3(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y5(y=hea4.sta_b.T);
  Modelica.Blocks.Sources.RealExpression y6(y=hea3.sta_b.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass4(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y7(y=hea4.sta_a.T);
  Modelica.Blocks.Sources.RealExpression y8(y=hea3.sta_a.T);
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea5(redeclare package
      Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_1(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_5(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea6(
                                                 redeclare package Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea7(redeclare package
      Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_6(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_7(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MassExchangers.HumidifierPrescribed hea8(
                                                 redeclare package Medium =
        Medium,
    m_flow_nominal=0.5,
    mWat_flow_nominal=mWat_flow_nominal,
    dp_nominal=50,
    show_T=true) "Heater and cooler";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res_8(
    redeclare package Medium = Medium,
    dp_nominal=5,
    m_flow_nominal=0.5);
  Buildings.Fluid.MixingVolumes.MixingVolume mix2(
                                           redeclare package Medium = Medium, V=
       0.000001,
    nPorts=2,
    m_flow_nominal=0.5);
  Buildings.Utilities.Diagnostics.AssertEquality ass5(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y9(y=hea6.sta_b.T);
  Modelica.Blocks.Sources.RealExpression y10(
                                            y=hea5.sta_b.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass6(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y11(
                                            y=hea6.sta_a.T);
  Modelica.Blocks.Sources.RealExpression y12(
                                            y=hea5.sta_a.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass7(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y13(
                                            y=hea8.sta_b.T);
  Modelica.Blocks.Sources.RealExpression y14(
                                            y=hea7.sta_b.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass8(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y15(
                                            y=hea8.sta_a.T);
  Modelica.Blocks.Sources.RealExpression y16(
                                            y=hea7.sta_a.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass9(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y17(y=hea2.sta_b.T);
  Modelica.Blocks.Sources.RealExpression y18(y=hea5.sta_b.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass10(                startTime=
        0.3, threShold=0.05);
  Modelica.Blocks.Sources.RealExpression y19(y=hea4.sta_a.T);
  Modelica.Blocks.Sources.RealExpression y20(y=hea7.sta_a.T);
  Buildings.Utilities.Diagnostics.AssertEquality ass11(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y21(y=hea2.sta_b.X[1]);
  Modelica.Blocks.Sources.RealExpression y22(y=hea1.sta_b.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass12(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y23(
                                            y=hea2.sta_a.X[1]);
  Modelica.Blocks.Sources.RealExpression y24(
                                            y=hea1.sta_a.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass13(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y25(
                                            y=hea4.sta_b.X[1]);
  Modelica.Blocks.Sources.RealExpression y26(
                                            y=hea3.sta_b.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass14(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y27(
                                            y=hea4.sta_a.X[1]);
  Modelica.Blocks.Sources.RealExpression y28(
                                            y=hea3.sta_a.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass15(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y29(
                                            y=hea6.sta_b.X[1]);
  Modelica.Blocks.Sources.RealExpression y30(
                                            y=hea5.sta_b.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass16(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y31(
                                            y=hea6.sta_a.X[1]);
  Modelica.Blocks.Sources.RealExpression y32(
                                            y=hea5.sta_a.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass17(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y33(
                                            y=hea8.sta_b.X[1]);
  Modelica.Blocks.Sources.RealExpression y34(
                                            y=hea7.sta_b.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass18(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y35(
                                            y=hea8.sta_a.X[1]);
  Modelica.Blocks.Sources.RealExpression y36(
                                            y=hea7.sta_a.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass19(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y37(y=hea2.sta_b.X[1]);
  Modelica.Blocks.Sources.RealExpression y38(y=hea5.sta_b.X[1]);
  Buildings.Utilities.Diagnostics.AssertEquality ass20(threShold=1E-2, startTime=
        0.3);
  Modelica.Blocks.Sources.RealExpression y39(y=hea4.sta_a.X[1]);
  Modelica.Blocks.Sources.RealExpression y40(y=hea7.sta_a.X[1]);
  inner Modelica.Fluid.System system(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState);
equation 
  connect(POut.y,sin_1. p_in);
  connect(TDb.y,sou_1. T_in);
  connect(res_11.port_b, hea1.port_a);
  connect(u.y, hea1.u);
  connect(gain.y, hea2.u);
  connect(u.y, gain.u);
  connect(res_12.port_b, hea2.port_a);
  connect(res_2.port_b, hea3.port_a);
  connect(u.y, hea3.u);
  connect(gain.y, hea4.u);
  connect(res_3.port_b, hea4.port_a);
  connect(hea4.port_b, res_4.port_b);
  connect(hea1.port_b, hea2.port_b);
  connect(y1.y, ass1.u1);
  connect(y2.y, ass1.u2);
  connect(y3.y, ass2.u1);
  connect(y4.y, ass2.u2);
  connect(y5.y, ass3.u1);
  connect(y6.y, ass3.u2);
  connect(y7.y, ass4.u1);
  connect(y8.y, ass4.u2);
  connect(res_1.port_b, hea5.port_a);
  connect(res_5.port_b, hea6.port_a);
  connect(res_6.port_b,hea7. port_a);
  connect(res_7.port_b,hea8. port_a);
  connect(hea8.port_b,res_8. port_b);
  connect(hea5.port_b,hea6. port_b);
  connect(y9.y,ass5. u1);
  connect(y10.y, ass5.u2);
  connect(y11.y, ass6.u1);
  connect(y12.y, ass6.u2);
  connect(y13.y, ass7.u1);
  connect(y14.y, ass7.u2);
  connect(y15.y, ass8.u1);
  connect(y16.y, ass8.u2);
  connect(y17.y,ass9. u1);
  connect(y18.y,ass9. u2);
  connect(y19.y, ass10.u1);
  connect(y20.y, ass10.u2);
  connect(u.y, hea6.u);
  connect(u.y, hea8.u);
  connect(gain.y, hea5.u);
  connect(gain.y, hea7.u);
  connect(y21.y, ass11.u1);
  connect(y22.y, ass11.u2);
  connect(y23.y, ass12.u1);
  connect(y24.y, ass12.u2);
  connect(y25.y, ass13.u1);
  connect(y26.y, ass13.u2);
  connect(y27.y, ass14.u1);
  connect(y28.y, ass14.u2);
  connect(y29.y, ass15.u1);
  connect(y30.y, ass15.u2);
  connect(y31.y, ass16.u1);
  connect(y32.y, ass16.u2);
  connect(y33.y, ass17.u1);
  connect(y34.y, ass17.u2);
  connect(y35.y, ass18.u1);
  connect(y36.y, ass18.u2);
  connect(y37.y, ass19.u1);
  connect(y38.y, ass19.u2);
  connect(y39.y, ass20.u1);
  connect(y40.y, ass20.u2);
  connect(sin_1.ports[1], res_12.port_a);
  connect(sin_1.ports[2], res_3.port_a);
  connect(sou_1.ports[1], res_11.port_a);
  connect(sou_1.ports[2], res_2.port_a);
  connect(sin_1.ports[3], res_1.port_a);
  connect(sin_1.ports[4], res_6.port_a);
  connect(sou_1.ports[3], res_5.port_a);
  connect(sou_1.ports[4], res_7.port_a);
  connect(hea3.port_b, mix1.ports[1]);
  connect(mix1.ports[2], res_4.port_a);
  connect(hea7.port_b, mix2.ports[1]);
  connect(mix2.ports[2], res_8.port_a);
end HumidifierPrescribed;

Buildings.Fluid.Interfaces.Examples.ReverseFlowHumidifier Buildings.Fluid.Interfaces.Examples.ReverseFlowHumidifier

Model that tests the reverse flow for a humidifier

Buildings.Fluid.Interfaces.Examples.ReverseFlowHumidifier

Information

This model tests whether the results for a humidifer are identical for forward flow and reverse flow. If the results differ, then an assert is triggered.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model ReverseFlowHumidifier 
  "Model that tests the reverse flow for a humidifier"
  import Buildings;
  extends Modelica.Icons.Example;
package Medium = Buildings.Media.PerfectGases.MoistAir;
  Buildings.Utilities.Diagnostics.AssertEquality assTem(threShold=0.01) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Utilities.Diagnostics.AssertEquality assEnt(threShold=0.5) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Utilities.Diagnostics.AssertEquality assMas(threShold=1E-5) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Fluid.MassExchangers.HumidifierPrescribed humBac(
    redeclare package Medium = Medium,
    dp_nominal=0,
    m_flow(start=1),
    m_flow_nominal=1,
    T=283.15,
    mWat_flow_nominal=0.1) "Humidifier with backward flow";
  Buildings.Fluid.MassExchangers.HumidifierPrescribed humFor(
    redeclare package Medium = Medium,
    dp_nominal=0,
    m_flow(start=1),
    m_flow_nominal=1,
    T=283.15,
    mWat_flow_nominal=0.1) "Humidifier with forward flow";
  Modelica.Blocks.Sources.Constant u2(k=0.01) "Control input";
  Modelica.Fluid.Sources.MassFlowSource_T source1(
    m_flow=1,
    redeclare package Medium = Medium,
    use_m_flow_in=false,
    use_T_in=false,
    use_X_in=false,
    T(displayUnit="K") = 323.15,
    X={0.01,0.99},
    nPorts=2);
  Modelica.Fluid.Sources.FixedBoundary sink1(
                                            redeclare package Medium = Medium,
      nPorts=2);
  Sensors.SpecificEnthalpy senEnt1(redeclare package Medium = Medium);
  Sensors.Temperature senTem1(redeclare package Medium = Medium);
  Sensors.MassFraction senMas1(redeclare package Medium = Medium);
  Sensors.Temperature senTem2(redeclare package Medium = Medium);
  Sensors.SpecificEnthalpy senEnt2(redeclare package Medium = Medium);
  Sensors.MassFraction senMas2(redeclare package Medium = Medium);
  FixedResistances.FixedResistanceDpM res1(
    redeclare package Medium = Medium,
    m_flow_nominal=1,
    from_dp=true,
    linearized=false,
    dp_nominal=1000) "Fixed resistance";
  FixedResistances.FixedResistanceDpM res2(
    redeclare package Medium = Medium,
    m_flow_nominal=1,
    from_dp=true,
    linearized=false,
    dp_nominal=1000) "Fixed resistance";
  inner Modelica.Fluid.System system;
equation 
  connect(u2.y, humFor.u);
  connect(source1.ports[1], humFor.port_a);
  connect(humBac.port_b, source1.ports[2]);
  connect(u2.y, humBac.u);
  connect(humFor.port_b, senTem1.port);
  connect(humFor.port_b, senEnt1.port);
  connect(humFor.port_b, senMas1.port);
  connect(humBac.port_a, senTem2.port);
  connect(humBac.port_a, senEnt2.port);
  connect(humBac.port_a, senMas2.port);
  connect(humFor.port_b, res1.port_a);
  connect(res1.port_b, sink1.ports[1]);
  connect(humBac.port_a, res2.port_a);
  connect(res2.port_b, sink1.ports[2]);
  connect(senTem1.T, assTem.u1);
  connect(senEnt1.h_out, assEnt.u1);
  connect(senMas1.X, assMas.u1);
  connect(senTem2.T, assTem.u2);
  connect(senEnt2.h_out, assEnt.u2);
  connect(senMas2.X, assMas.u2);
end ReverseFlowHumidifier;

Buildings.Fluid.Interfaces.Examples.ReverseFlowMassExchanger Buildings.Fluid.Interfaces.Examples.ReverseFlowMassExchanger

Model that tests the reverse flow for a mass exchanger

Buildings.Fluid.Interfaces.Examples.ReverseFlowMassExchanger

Information

This model tests whether the results for a mass exchanger are identical for forward flow and reverse flow. If the results differ, then an assert is triggered.

Note that if the latent heat transfer effectiveness is non-zero, then the results will differ. The reason is that the maximum capacity stream is computed using the mass flow rates at port_a1 and port_a2. For reverse flow, they are not equal if moisture is added to the mass flow rate. Using an average mass flow rate in computing the heat and moisture transfer would lead to identical results, but it would introduce additional nonlinear equations that need to be solved. Therefore, the model uses the mass flow rates at port_a1 and port_a2.

Note: This problem fails to translate in Dymola 2012 due to an error in Dymola's support of stream connector. This bug will be corrected in future versions of Dymola.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model ReverseFlowMassExchanger 
  "Model that tests the reverse flow for a mass exchanger"
  import Buildings;
  extends Modelica.Icons.Example;
package Medium = Buildings.Media.PerfectGases.MoistAir;
  Buildings.Utilities.Diagnostics.AssertEquality assTem(threShold=1E-8,
      startTime=0) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Utilities.Diagnostics.AssertEquality assEnt(threShold=1E-8,
      startTime=0) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Utilities.Diagnostics.AssertEquality assMas(threShold=1E-8,
      startTime=0) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Modelica.Fluid.Sources.MassFlowSource_T source2(
    m_flow=1,
    redeclare package Medium = Medium,
    use_m_flow_in=false,
    use_T_in=false,
    use_X_in=false,
    nPorts=1,
    T(displayUnit="degC") = 303.15,
    X={0.02,0.98});
  Buildings.Fluid.MassExchangers.ConstantEffectiveness masExcFor(
    redeclare package Medium1 = Medium,
    redeclare package Medium2 = Medium,
    m1_flow_nominal=1,
    m2_flow_nominal=1,
    dp1_nominal=0,
    dp2_nominal=0,
    epsL=0) "Mass exchanger with forward flow";
  Buildings.Fluid.MassExchangers.ConstantEffectiveness masExcRev(
    redeclare package Medium1 = Medium,
    redeclare package Medium2 = Medium,
    m1_flow_nominal=1,
    m2_flow_nominal=1,
    dp1_nominal=0,
    dp2_nominal=0,
    epsL=0) "Mass exchanger with reverse flow";
  Modelica.Fluid.Sources.FixedBoundary sink2(
                                            redeclare package Medium = Medium,
      nPorts=2);
  FixedResistances.FixedResistanceDpM res3(
    redeclare package Medium = Medium,
    m_flow_nominal=1,
    from_dp=true,
    linearized=false,
    dp_nominal=1000) "Fixed resistance";
  FixedResistances.FixedResistanceDpM res4(
    redeclare package Medium = Medium,
    m_flow_nominal=1,
    from_dp=true,
    linearized=false,
    dp_nominal=1000) "Fixed resistance";
  Sensors.SpecificEnthalpy senEnt3(redeclare package Medium = Medium);
  Sensors.Temperature senTem3(redeclare package Medium = Medium);
  Sensors.MassFraction senMas3(redeclare package Medium = Medium);
  Sensors.SpecificEnthalpy senEnt4(redeclare package Medium = Medium);
  Sensors.Temperature senTem4(redeclare package Medium = Medium);
  Sensors.MassFraction senMas4(redeclare package Medium = Medium);
  Buildings.Utilities.Diagnostics.AssertEquality assTem1(threShold=1E-8,
      startTime=0) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Utilities.Diagnostics.AssertEquality assEnt1(threShold=1E-8,
      startTime=0) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Buildings.Utilities.Diagnostics.AssertEquality assMas1(threShold=1E-8,
      startTime=0) 
    "Assert to test if the outputs of the forward flow and reverse flow model are identical";
  Modelica.Fluid.Sources.MassFlowSource_T source3(
    m_flow=1,
    redeclare package Medium = Medium,
    use_m_flow_in=false,
    use_T_in=false,
    use_X_in=false,
    X={0.01,0.99},
    nPorts=1,
    T(displayUnit="degC") = 293.15);
  Modelica.Fluid.Sources.MassFlowSource_T source4(
    m_flow=1,
    redeclare package Medium = Medium,
    use_m_flow_in=false,
    use_T_in=false,
    use_X_in=false,
    nPorts=1,
    T(displayUnit="degC") = 303.15,
    X={0.02,0.98});

  Modelica.Fluid.Sources.MassFlowSource_T source1(
    m_flow=1,
    redeclare package Medium = Medium,
    use_m_flow_in=false,
    use_T_in=false,
    use_X_in=false,
    X={0.01,0.99},
    nPorts=1,
    T(displayUnit="degC") = 293.15);
  Modelica.Fluid.Sources.FixedBoundary sink1(
                                            redeclare package Medium = Medium,
      nPorts=2);
  Sensors.SpecificEnthalpy senEnt1(redeclare package Medium = Medium);
  Sensors.Temperature senTem1(redeclare package Medium = Medium);
  Sensors.MassFraction senMas1(redeclare package Medium = Medium);
  Sensors.Temperature senTem2(redeclare package Medium = Medium);
  Sensors.SpecificEnthalpy senEnt2(redeclare package Medium = Medium);
  Sensors.MassFraction senMas2(redeclare package Medium = Medium);
  FixedResistances.FixedResistanceDpM res1(
    redeclare package Medium = Medium,
    m_flow_nominal=1,
    from_dp=true,
    linearized=false,
    dp_nominal=1000) "Fixed resistance";
  FixedResistances.FixedResistanceDpM res2(
    redeclare package Medium = Medium,
    m_flow_nominal=1,
    from_dp=true,
    linearized=false,
    dp_nominal=1000) "Fixed resistance";
  inner Modelica.Fluid.System system;
equation 

  connect(res1.port_b, sink1.ports[1]);
  connect(res2.port_b, sink1.ports[2]);
  connect(senTem1.T, assTem.u1);
  connect(senEnt1.h_out, assEnt.u1);
  connect(senMas1.X, assMas.u1);
  connect(senTem2.T, assTem.u2);
  connect(senEnt2.h_out, assEnt.u2);
  connect(senMas2.X, assMas.u2);
  connect(masExcFor.port_b1, res1.port_a);
  connect(masExcFor.port_a1, source1.ports[1]);
  connect(masExcRev.port_a1, res2.port_a);
  connect(source2.ports[1], masExcFor.port_a2);
  connect(masExcRev.port_a1, senTem2.port);
  connect(masExcRev.port_a1, senEnt2.port);
  connect(masExcRev.port_a1, senMas2.port);
  connect(masExcFor.port_b1, senTem1.port);
  connect(masExcFor.port_b1, senEnt1.port);
  connect(masExcFor.port_b1, senMas1.port);
  connect(masExcFor.port_b2, res3.port_a);
  connect(masExcRev.port_a2, res4.port_a);
  connect(res3.port_b, sink2.ports[1]);
  connect(res4.port_b, sink2.ports[2]);
  connect(senTem3.T, assTem1.u1);
  connect(senTem4.T, assTem1.u2);
  connect(senEnt3.h_out, assEnt1.u1);
  connect(senEnt4.h_out, assEnt1.u2);
  connect(senMas3.X, assMas1.u1);
  connect(senMas4.X, assMas1.u2);
  connect(masExcFor.port_b2, senTem3.port);
  connect(masExcFor.port_b2, senEnt3.port);
  connect(masExcFor.port_b2, senMas3.port);
  connect(masExcRev.port_a2, senTem4.port);
  connect(masExcRev.port_a2, senEnt4.port);
  connect(masExcRev.port_a2, senMas4.port);
  connect(source3.ports[1], masExcRev.port_b1);
  connect(source4.ports[1], masExcRev.port_b2);
end ReverseFlowMassExchanger;

Automatically generated Thu Jul 26 10:21:58 2012.