Tyomich
Tyomich

Reputation: 137

Mixture gas in modelica

I use OpenModelica and I have some model gas mixture

package ExhaustGas
import Modelica.Media.IdealGases.Common;
  extends Modelica.Media.IdealGases.Common.MixtureGasNasa(mediumName = "ExhaustGas", data = {Common.SingleGasesData.O2, Common.SingleGasesData.CO2, Common.SingleGasesData.H2O, Common.SingleGasesData.N2, Common.SingleGasesData.Ar, Common.SingleGasesData.SO2}, fluidConstants = {Common.FluidData.O2, Common.FluidData.CO2, Common.FluidData.H2O, Common.FluidData.N2, Common.FluidData.Ar, Common.FluidData.SO2}, substanceNames = {"Oxygen", "Carbondioxide", "Water", "Nitrogen", "Argon", "Sulfurdioxide"}, reference_X = {0.1383, 0.032, 0.0688, 1 - 0.1383 - 0.032 - 0.0688 - 0.0000000001 - 0.0000000001, 0.0000000001, 0.0000000001});
end ExhaustGas;

I run the code:

algorithm
for i in 1:6 loop
      etaX[i] := ExhaustGas.fluidConstants[i].criticalTemperature;
end for;

and I get

{154.58, 154.58, 154.58, 154.58, 154.58, 154.58}

That is, only oxygen values are written to the array.

The same loop is used in the function Modelica.Media.IdealGases.Common.MixtureGasNasa.dynamicViscosity. Can this function be considered to work correctly? What am I doing wrong?

Upvotes: 1

Views: 264

Answers (1)

Hans Olsson
Hans Olsson

Reputation: 12507

I could not see any similar issue in Dymola (used Dymola 2018 for no obvious reason), so that seems like an issue in OpenModelica.

To get the example to run I used:

model ExhaustGas
  import Modelica.Media.IdealGases.Common;
  package P=Modelica.Media.IdealGases.Common.MixtureGasNasa (
    mediumName="ExhaustGas",
    data={Common.SingleGasesData.O2,Common.SingleGasesData.CO2,Common.SingleGasesData.H2O,
        Common.SingleGasesData.N2,Common.SingleGasesData.Ar,Common.SingleGasesData.SO2},
    fluidConstants={Common.FluidData.O2,Common.FluidData.CO2,Common.FluidData.H2O,
        Common.FluidData.N2,Common.FluidData.Ar,Common.FluidData.SO2},
    substanceNames={"Oxygen","Carbondioxide","Water","Nitrogen","Argon","Sulfurdioxide"},
    reference_X={0.1383,0.032,0.0688,1 - 0.1383 - 0.032 - 0.0688 - 0.0000000001 -
        0.0000000001,0.0000000001,0.0000000001});

  Real etaX[6];
algorithm 
  for i in 1:6 loop
      etaX[i] =  P.fluidConstants[i].criticalTemperature;
  end for;
end ExhaustGas;

Since a model inheriting from a package isn't legal. I noticed two warnings for the normalBoilingPoint being out of range.

Changed: I changed it to use algorithm instead of equation, it doesn't make a difference in Dymola, and I don't see any reason why it should matter.

Upvotes: 3

Related Questions