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

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

Package Content

NameDescription
FixedResistance  
FixedResistancesExplicit Test of multiple resistances in series
FixedResistancesParallel  
FixedResistancesSeries Test of multiple resistances in series
SplitterFixedResistanceDpM  


Buildings.Fluid.FixedResistances.Examples.FixedResistance

Buildings.Fluid.FixedResistances.Examples.FixedResistance

Modelica definition

model FixedResistance
  import Buildings;

 package Medium =
        Buildings.Media.ConstantPropertyLiquidWater;
    Modelica.Blocks.Sources.Constant PAtm(k=101325);
    Modelica.Blocks.Sources.Ramp P(
      duration=1,
    height=20,
    offset=101315);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res1(
    redeclare package Medium = Medium,
    from_dp=true,
    m_flow_nominal=5,
    dp_nominal=10);
  Buildings.Fluid.Sources.Boundary_pT sou1(          redeclare package Medium
      = Medium,
    use_p_in=true,
    T=293.15,
    nPorts=3);
  Buildings.Fluid.Sources.Boundary_pT sin1(          redeclare package Medium
      = Medium, T=283.15,
    use_p_in=true,
    nPorts=3);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res2(
    redeclare package Medium = Medium,
    from_dp=true,
    m_flow_nominal=5,
    dp_nominal=10,
    use_dh=true);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res3(
    redeclare package Medium = Medium,
    from_dp=true,
    m_flow_nominal=5,
    dp_nominal=10,
    use_dh=true);
  FixedResistances.LosslessPipe pipCon(redeclare package Medium = Medium,
      m_flow_nominal=5) "Lossless pipe connection";
  Buildings.Fluid.Sensors.MassFlowRate masFlo2(redeclare package Medium = Medium) 
    "Mass flow rate sensor";
  Buildings.Fluid.Sensors.MassFlowRate masFlo3(redeclare package Medium = Medium) 
    "Mass flow rate sensor";
  Buildings.Utilities.Diagnostics.AssertEquality assEqu(threShold=1E-4, message=
        "Inputs differ, check that lossless pipe is correctly implemented.") 
    "Assert equality of the two mass flow rates";
  inner Modelica.Fluid.System system;
equation 
  connect(res2.port_b, masFlo2.port_a);
  connect(res3.port_b, masFlo3.port_a);
  connect(masFlo3.port_b, pipCon.port_a);
  connect(P.y, sou1.p_in);
  connect(sou1.ports[1], res1.port_a);
  connect(sin1.ports[1], res1.port_b);
  connect(masFlo3.m_flow, assEqu.u1);
  connect(masFlo2.m_flow, assEqu.u2);
  connect(PAtm.y, sin1.p_in);
  connect(sou1.ports[2], res2.port_a);
  connect(sou1.ports[3], res3.port_a);
  connect(sin1.ports[2], masFlo2.port_b);
  connect(sin1.ports[3], pipCon.port_b);
end FixedResistance;

Buildings.Fluid.FixedResistances.Examples.FixedResistancesExplicit

Test of multiple resistances in series

Buildings.Fluid.FixedResistances.Examples.FixedResistancesExplicit

Information


This model tests whether inverse functions are being used by the code
translator. In Dymola 7.2, there should only be one non-linear equation system
in one variable after the symbolic manipulations.

Modelica definition

model FixedResistancesExplicit 
  "Test of multiple resistances in series"
  import Buildings;

 package Medium = Modelica.Media.Air.SimpleAir;
  Buildings.Fluid.Sources.Boundary_ph sou(             redeclare package Medium
      =        Medium,
    nPorts=1,
    p(displayUnit="Pa") = 101335,
    use_p_in=true);
  Buildings.Fluid.Sources.Boundary_ph sin(             redeclare package Medium
      =        Medium,
    nPorts=1,
    use_p_in=false,
    p=101325);

    Buildings.Fluid.FixedResistances.FixedResistanceDpM res(
    redeclare package Medium = Medium,
    from_dp = false,
    m_flow_nominal=2,
    dp_nominal=5);
  inner Modelica.Fluid.System system(p_ambient=101325);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res1(
    redeclare package Medium = Medium,
    from_dp = false,
    m_flow_nominal=2,
    dp_nominal=5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res2(
    redeclare package Medium = Medium,
    m_flow_nominal=2,
    dp_nominal=5,
    from_dp=true);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res3(
    redeclare package Medium = Medium,
    m_flow_nominal=2,
    dp_nominal=5,
    from_dp=true);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res4(
    redeclare package Medium = Medium,
    from_dp = false,
    m_flow_nominal=2,
    dp_nominal=5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res5(
    redeclare package Medium = Medium,
    from_dp = false,
    m_flow_nominal=2,
    dp_nominal=5);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res6(
    redeclare package Medium = Medium,
    m_flow_nominal=2,
    dp_nominal=5,
    from_dp=true);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res7(
    redeclare package Medium = Medium,
    m_flow_nominal=2,
    dp_nominal=5,
    from_dp=true);
  Buildings.Fluid.Sources.MassFlowSource_h bou(
    redeclare package Medium = Medium,
    m_flow=1,
    nPorts=1);
  Buildings.Fluid.Sources.MassFlowSource_h bou1(
    redeclare package Medium = Medium,
    m_flow=1,
    nPorts=1);
  Buildings.Fluid.Sources.Boundary_pT sin1(            redeclare package Medium
      =        Medium, T=273.15 + 10,
    nPorts=2,
    use_p_in=false,
    p=101325);
  Buildings.Fluid.Sources.Boundary_ph sin2(            redeclare package Medium
      =        Medium,
    nPorts=1,
    use_p_in=false,
    p=101325);
  Buildings.Fluid.Sources.Boundary_ph sou1(            redeclare package Medium
      =        Medium,
    nPorts=1,
    p(displayUnit="Pa") = 101335,
    use_p_in=true);
    Modelica.Blocks.Sources.Ramp P(
      duration=1,
    height=20,
    offset=101315);
  Buildings.Fluid.Sensors.MassFlowRate senMasFlo(redeclare package Medium =
        Medium) "Mass flow rate sensor";
  Buildings.Fluid.Sensors.MassFlowRate senMasFlo1(redeclare package Medium =
        Medium) "Mass flow rate sensor";
  Buildings.Fluid.Sensors.MassFlowRate senMasFlo2(redeclare package Medium =
        Medium) "Mass flow rate sensor";
  Buildings.Fluid.Sensors.MassFlowRate senMasFlo3(redeclare package Medium =
        Medium) "Mass flow rate sensor";
  Buildings.Utilities.Diagnostics.AssertEquality assertEquality;
  Buildings.Utilities.Diagnostics.AssertEquality assertEquality1;
equation 
  connect(res.port_b, res1.port_a);
  connect(res3.port_b, res2.port_a);
  connect(res4.port_b, res5.port_a);
  connect(res7.port_b, res6.port_a);
  connect(sou.ports[1], res.port_a);
  connect(bou.ports[1], res4.port_a);
  connect(bou1.ports[1], res7.port_a);
  connect(sou1.ports[1], res3.port_a);
  connect(P.y, sou.p_in);
  connect(P.y, sou1.p_in);
  connect(res1.port_b, senMasFlo.port_a);
  connect(res2.port_b, senMasFlo1.port_a);
  connect(res5.port_b, senMasFlo2.port_a);
  connect(res6.port_b, senMasFlo3.port_a);
  connect(senMasFlo2.port_b, sin1.ports[1]);
  connect(senMasFlo3.port_b, sin1.ports[2]);
  connect(senMasFlo.port_b, sin.ports[1]);
  connect(senMasFlo1.port_b, sin2.ports[1]);
  connect(senMasFlo2.m_flow, assertEquality1.u1);
  connect(senMasFlo3.m_flow, assertEquality1.u2);
  connect(senMasFlo.m_flow, assertEquality.u1);
  connect(senMasFlo1.m_flow, assertEquality.u2);
end FixedResistancesExplicit;

Buildings.Fluid.FixedResistances.Examples.FixedResistancesParallel

Buildings.Fluid.FixedResistances.Examples.FixedResistancesParallel

Modelica definition

model FixedResistancesParallel
  import Buildings;

 package Medium =
        Buildings.Media.ConstantPropertyLiquidWater;
    Modelica.Blocks.Sources.Constant PAtm(k=101325);
    Modelica.Blocks.Sources.Ramp P(
      duration=1,
    height=20,
    offset=101315);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res1(
    redeclare package Medium = Medium,
    m_flow_nominal=5,
    dp_nominal=10,
    deltaM=0.3,
    linearized=false,
    from_dp=false);
  Buildings.Fluid.Sources.Boundary_pT sou1(          redeclare package Medium
      = Medium,
    T=293.15,
    nPorts=2,
    use_p_in=true);
  Buildings.Fluid.Sources.Boundary_pT sin1(          redeclare package Medium
      = Medium,
    T=283.15,
    nPorts=2,
    use_p_in=true);
    Buildings.Fluid.FixedResistances.FixedResistanceDpM res2(
    redeclare package Medium = Medium,
    m_flow_nominal=5,
    dp_nominal=10,
    deltaM=0.3,
    linearized=false,
    from_dp=false);
  Buildings.Fluid.Sensors.MassFlowRate masFlo2(redeclare package Medium = Medium) 
    "Mass flow rate sensor";
  Buildings.Utilities.Diagnostics.AssertEquality assEqu(threShold=1E-4, message=
        "Inputs differ, check that lossless pipe is correctly implemented.") 
    "Assert equality of the two mass flow rates";
  Buildings.Fluid.Sensors.MassFlowRate masFlo1(redeclare package Medium = Medium) 
    "Mass flow rate sensor";
  inner Modelica.Fluid.System system(p_ambient=101325);
equation 
  connect(PAtm.y, sin1.p_in);
  connect(P.y, sou1.p_in);
  connect(res2.port_b, masFlo2.port_a);
  connect(res1.port_b, masFlo1.port_a);
  connect(sou1.ports[1], res1.port_a);
  connect(sou1.ports[2], res2.port_a);
  connect(sin1.ports[1], masFlo1.port_b);
  connect(sin1.ports[2], masFlo2.port_b);
  connect(masFlo2.m_flow, assEqu.u1);
  connect(masFlo1.m_flow, assEqu.u2);
end FixedResistancesParallel;

Buildings.Fluid.FixedResistances.Examples.FixedResistancesSeries

Test of multiple resistances in series

Buildings.Fluid.FixedResistances.Examples.FixedResistancesSeries

Parameters

TypeNameDefaultDescription
Pressuredp_nominal5Nominal pressure drop for each resistance [Pa]
IntegernRes10Number of resistances

Modelica definition

model FixedResistancesSeries "Test of multiple resistances in series"

 package Medium = Modelica.Media.Air.SimpleAir;

    Modelica.Blocks.Sources.Constant PAtm(k=101325);
   parameter Modelica.SIunits.Pressure dp_nominal = 5 
    "Nominal pressure drop for each resistance";
    Modelica.Blocks.Sources.Ramp P(
      duration=1,
    height=2*dp_nominal*nRes,
    offset=101325 - dp_nominal*nRes);
  Buildings.Fluid.Sources.Boundary_pT sou(             redeclare package Medium
      =        Medium, T=273.15 + 20,
    use_p_in=true,
    nPorts=1);
  Buildings.Fluid.Sources.Boundary_pT sin(             redeclare package Medium
      =        Medium, T=273.15 + 10,
    use_p_in=true,
    nPorts=1);
  parameter Integer nRes( min=2) = 10 "Number of resistances";
    Buildings.Fluid.FixedResistances.FixedResistanceDpM[
                       nRes] res(
    redeclare each package Medium = Medium,
    each dp_nominal=dp_nominal,
    each from_dp = false,
    each m_flow_nominal=2);
  inner Modelica.Fluid.System system(p_ambient=101325);
equation 
  for i in 1:nRes-1 loop
  connect(res[i].port_b, res[i+1].port_a);
  end for;
  connect(PAtm.y, sin.p_in);
  connect(P.y, sou.p_in);
  connect(sin.ports[1], res[nRes].port_b);
  connect(sou.ports[1], res[1].port_a);
end FixedResistancesSeries;

Buildings.Fluid.FixedResistances.Examples.SplitterFixedResistanceDpM

Buildings.Fluid.FixedResistances.Examples.SplitterFixedResistanceDpM

Modelica definition

model SplitterFixedResistanceDpM

 package Medium = Modelica.Media.Air.SimpleAir;

  Buildings.Fluid.FixedResistances.SplitterFixedResistanceDpM spl(
    m_flow_nominal={1,2,3},
    dh={1,2,3},
    redeclare package Medium = Medium,
    dp_nominal(displayUnit="Pa") = {5,10,15}) "Splitter";
  Buildings.Fluid.Sources.Boundary_pT bou1(             redeclare package
      Medium = Medium, T=273.15 + 10,
    use_p_in=true,
    nPorts=1);
  Buildings.Fluid.Sources.Boundary_pT bou2(             redeclare package
      Medium = Medium, T=273.15 + 20,
    use_p_in=true,
    nPorts=1);
  Buildings.Fluid.Sources.Boundary_pT bou3(             redeclare package
      Medium = Medium, T=273.15 + 30,
    use_p_in=true,
    nPorts=1);
    Modelica.Blocks.Sources.Constant P2(k=101325);
    Modelica.Blocks.Sources.Ramp P1(
    offset=101320,
    height=10,
    duration=0.5);
    Modelica.Blocks.Sources.Ramp P3(
      offset=101320,
      height=10,
    duration=0.5,
    startTime=0.5);
  inner Modelica.Fluid.System system(p_ambient=101325);
equation 
  connect(P1.y, bou1.p_in);
  connect(P2.y, bou2.p_in);
  connect(bou3.p_in, P3.y);
  connect(bou1.ports[1], spl.port_1);
  connect(bou3.ports[1], spl.port_3);
  connect(spl.port_2, bou2.ports[1]);
end SplitterFixedResistanceDpM;

HTML-documentation generated by Dymola Thu Jun 24 16:54:12 2010.