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.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.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),
    show_T=true,
    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),
    show_T=true,
    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.

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 Fri May 06 14:13:01 2011.