Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Incorrect fluid property calculations when using multiple media.

Incorrect fluid property calculations when using multiple media.

In the package below (sorry, could not get attachments to work) there are 2 test cases, Working and Not_Working.

They each have 2 fluid streams, 1 using air and 1 using water.  In the Not_Working case the h_outflow from the water_inlet is incorrect.  Instead it is coming out at the same value as air_inlet.

In the Working case the only difference is that water_inlet is an instance of a class that extends from MassFlowSource_T and gives this type a different name -> MassFlowSource_T_ALT.

If you look in OMC_Fluid_Bug_No_Working_functions.c you can see that there is only a single function:

omc_Modelica_Fluid_Sources_MassFlowSource__T_Medium_specificEnthalpy__pTX

which uses the equation _h = (1005.45 * (-298.15 + _T)); (this is correct for air)

If you look in OMC_Fluid_Bug_Working_functions.c you can see the above function and the additional function:

omc_OMC__Fluid__Bug_MassFlowSource__T__ALT_Medium_specificEnthalpy__pTX

which uses the equation   _h = (4184.0 * (-273.15 + _T)); (this is correct for water.



This was ran with r18381 but I get similar results with r17628.



Is this a known bug?  Is there any fix planned?


Thanks

Tom


######################################################################

within ;
package OMC_Fluid_Bug
  "Demonstrate incorrect OMC behaviour with multiple fluid components"
  model Not_Working "Gives wrong outlet enthalpy for the water_inlet"

    inner Modelica.Fluid.System system
      annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
    Modelica.Fluid.Sources.MassFlowSource_T air_inlet(
      nPorts=1,
      redeclare package Medium = Modelica.Media.Air.SimpleAir,
      m_flow=1) annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
    Modelica.Fluid.Fittings.SimpleGenericOrifice air_orifice(
      diameter=0.01,
      use_zeta=false,
      m_flow_nominal=1,
      redeclare package Medium = Modelica.Media.Air.SimpleAir,
      zeta=1,
      dp_nominal=100000)
      annotation (Placement(transformation(extent={{-40,0},{-20,20}})));
    Modelica.Fluid.Sources.Boundary_pT air_sink(nPorts=1, redeclare package
        Medium = Modelica.Media.Air.SimpleAir) annotation (Placement(
          transformation(
          extent={{-10,-10},{10,10}},
          rotation=180,
          origin={10,10})));
    Modelica.Fluid.Sources.MassFlowSource_T water_inlet(
      nPorts=1,
      redeclare package Medium =
          Modelica.Media.Water.ConstantPropertyLiquidWater,
      m_flow=1)
      annotation (Placement(transformation(extent={{-80,-40},{-60,-20}})));

    Modelica.Fluid.Fittings.SimpleGenericOrifice water_orifice(
      diameter=0.01,
      use_zeta=false,
      m_flow_nominal=1,
      redeclare package Medium =
          Modelica.Media.Water.ConstantPropertyLiquidWater,
      zeta=1,
      dp_nominal=100000)
      annotation (Placement(transformation(extent={{-40,-40},{-20,-20}})));

    Modelica.Fluid.Sources.Boundary_pT water_sink(nPorts=1, redeclare package
        Medium = Modelica.Media.Water.ConstantPropertyLiquidWater) annotation (
        Placement(transformation(
          extent={{-10,-10},{10,10}},
          rotation=180,
          origin={10,-30})));
  equation
    connect(air_orifice.port_a, air_inlet.ports[1]) annotation (Line(
        points={{-40,10},{-60,10}},
        color={0,127,255},
        smooth=Smooth.None));
    connect(air_orifice.port_b, air_sink.ports[1]) annotation (Line(
        points={{-20,10},{0,10}},
        color={0,127,255},
        smooth=Smooth.None));
    connect(water_orifice.port_a, water_inlet.ports[1]) annotation (Line(
        points={{-40,-30},{-60,-30}},
        color={0,127,255},
        smooth=Smooth.None));
    connect(water_orifice.port_b, water_sink.ports[1]) annotation (Line(
        points={{-20,-30},{0,-30}},
        color={0,127,255},
        smooth=Smooth.None));
    annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
              -100},{100,100}}), graphics));
  end Not_Working;
  annotation (uses(Modelica(version="3.2.1")));
  model MassFlowSource_T_ALT
    "Identical to MassFlowSource_T but with a different name"
    extends Modelica.Fluid.Sources.MassFlowSource_T;
    annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
              -100},{100,100}}), graphics={Text(
            extent={{-100,-100},{100,-20}},
            lineColor={0,255,0},
            textString="ALT")}));
  end MassFlowSource_T_ALT;

  model Working "Gives correct outlet enthalpy for the water_inlet"

    inner Modelica.Fluid.System system
      annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
    Modelica.Fluid.Sources.MassFlowSource_T air_inlet(
      nPorts=1,
      redeclare package Medium = Modelica.Media.Air.SimpleAir,
      m_flow=1) annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
    Modelica.Fluid.Fittings.SimpleGenericOrifice air_orifice(
      diameter=0.01,
      use_zeta=false,
      m_flow_nominal=1,
      redeclare package Medium = Modelica.Media.Air.SimpleAir,
      zeta=1,
      dp_nominal=100000)
      annotation (Placement(transformation(extent={{-40,0},{-20,20}})));
    Modelica.Fluid.Sources.Boundary_pT air_sink(nPorts=1, redeclare package
        Medium = Modelica.Media.Air.SimpleAir) annotation (Placement(
          transformation(
          extent={{-10,-10},{10,10}},
          rotation=180,
          origin={10,10})));
    MassFlowSource_T_ALT                    water_inlet(
      nPorts=1,
      redeclare package Medium =
          Modelica.Media.Water.ConstantPropertyLiquidWater,
      m_flow=1)
      annotation (Placement(transformation(extent={{-80,-40},{-60,-20}})));

    Modelica.Fluid.Fittings.SimpleGenericOrifice water_orifice(
      diameter=0.01,
      use_zeta=false,
      m_flow_nominal=1,
      redeclare package Medium =
          Modelica.Media.Water.ConstantPropertyLiquidWater,
      zeta=1,
      dp_nominal=100000)
      annotation (Placement(transformation(extent={{-40,-40},{-20,-20}})));

    Modelica.Fluid.Sources.Boundary_pT water_sink(nPorts=1, redeclare package
        Medium = Modelica.Media.Water.ConstantPropertyLiquidWater) annotation (
        Placement(transformation(
          extent={{-10,-10},{10,10}},
          rotation=180,
          origin={10,-30})));
  equation
    connect(air_orifice.port_a, air_inlet.ports[1]) annotation (Line(
        points={{-40,10},{-60,10}},
        color={0,127,255},
        smooth=Smooth.None));
    connect(air_orifice.port_b, air_sink.ports[1]) annotation (Line(
        points={{-20,10},{0,10}},
        color={0,127,255},
        smooth=Smooth.None));
    connect(water_orifice.port_a, water_inlet.ports[1]) annotation (Line(
        points={{-40,-30},{-60,-30}},
        color={0,127,255},
        smooth=Smooth.None));
    connect(water_orifice.port_b, water_sink.ports[1]) annotation (Line(
        points={{-20,-30},{0,-30}},
        color={0,127,255},
        smooth=Smooth.None));
    annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
              -100},{100,100}}), graphics));
  end Working;
end OMC_Fluid_Bug;

There are 0 guests and 0 other users also viewing this topic
You are here: