Air: Simple dry air model (0..100 degC)

within Modelica.Media.Air;
package SimpleAir "Air: Simple dry air model (0..100 degC)"
  extends Modelica.Icons.MaterialProperty;
  extends Interfaces.PartialSimpleIdealGasMedium(
    mediumName="SimpleAir",
    cp_const=1005.45,
    MM_const=0.0289651159,
    R_gas=Constants.R/MM_const,
    eta_const=1.82e-5,
    lambda_const=0.026,
    T_min=Cv.from_degC(0),
    T_max=Cv.from_degC(100),
    fluidConstants=airConstants,
    Temperature(min=Modelica.Units.Conversions.from_degC(0), max=
          Modelica.Units.Conversions.from_degC(100)));

  import Modelica.Constants;

  constant Modelica.Media.Interfaces.Types.Basic.FluidConstants[nS]
    airConstants={Modelica.Media.Interfaces.Types.Basic.FluidConstants(
        iupacName="simple air",
        casRegistryNumber="not a real substance",
        chemicalFormula="N2, O2",
        structureFormula="N2, O2",
        molarMass=Modelica.Media.IdealGases.Common.SingleGasesData.N2.MM)}
    "Constant data for the fluid";
end SimpleAir;


within Modelica.Media.IdealGases;
package MixtureGases "Medium models consisting of mixtures of ideal gases"
  extends Modelica.Icons.VariantsPackage;

  package CombustionAir "Air as mixture of N2 and O2"
    extends Common.MixtureGasNasa(
      mediumName="CombustionAirN2O2",
      data={Common.SingleGasesData.N2,
     Common.SingleGasesData.O2},
      fluidConstants={Common.FluidData.N2,
        Common.FluidData.O2},
      substanceNames = {"Nitrogen", "Oxygen"},
      reference_X={0.768,0.232});
  end CombustionAir;

  package AirSteam "Air and steam mixture (no condensation!, pseudo-mixture)"
    extends Common.MixtureGasNasa(
       mediumName="MoistAir",
       data={Common.SingleGasesData.H2O, Common.SingleGasesData.Air},
      fluidConstants={Common.FluidData.H2O,
        Common.FluidData.N2},
       substanceNames = {"Water","Air"},
       reference_X={0.0,1.0});
  end AirSteam;

  package SimpleMoistAir = AirSteam(reference_X={0.03,0.97})
    "Moist air without condensation";

  package FlueGasLambdaOnePlus
    "Simple flue gas for overstochiometric O2-fuel ratios"
    extends Common.MixtureGasNasa(
       mediumName="FlueGasLambda1plus",
       data={Common.SingleGasesData.N2,
      Common.SingleGasesData.O2,
      Common.SingleGasesData.H2O,
      Common.SingleGasesData.CO2},
       fluidConstants={Common.FluidData.N2,
         Common.FluidData.O2,
         Common.FluidData.H2O,
         Common.FluidData.CO2},
       substanceNames = {"Nitrogen","Oxygen","Water", "Carbondioxide"},
       reference_X={0.768,0.232,0.0,0.0});
  end FlueGasLambdaOnePlus;

  package FlueGasSixComponents
    "Simplest flue gas for over-and understochiometric combustion of hydrocarbons"
    extends Common.MixtureGasNasa(
       mediumName="FlueGasSixComponents",
       data={Common.SingleGasesData.N2,
      Common.SingleGasesData.H2,
      Common.SingleGasesData.CO,
      Common.SingleGasesData.O2,
      Common.SingleGasesData.H2O,
      Common.SingleGasesData.CO2},
       fluidConstants={Common.FluidData.N2,
         Common.FluidData.H2,
         Common.FluidData.CO,
         Common.FluidData.O2,
         Common.FluidData.H2O,
         Common.FluidData.CO2},
       substanceNames = {"Nitrogen","Hydrogen,","Carbonmonoxide","Oxygen","Water","Carbondioxide"},
       reference_X={0.768,0.0,0.0,0.232,0.0,0.0});
  end FlueGasSixComponents;

  package SimpleNaturalGas "Simple natural gas mix with 6 components"
    extends Common.MixtureGasNasa(
       mediumName="SimpleNaturalGas",
       data={Common.SingleGasesData.CH4,
      Common.SingleGasesData.C2H6,
      Common.SingleGasesData.C3H8,
      Common.SingleGasesData.C4H10_n_butane,
      Common.SingleGasesData.N2,
      Common.SingleGasesData.CO2},
       fluidConstants={Common.FluidData.CH4,
         Common.FluidData.C2H6,
         Common.FluidData.C3H8,
         Common.FluidData.C4H10_n_butane,
         Common.FluidData.N2,
         Common.FluidData.CO2},
       substanceNames = {"Methane","Ethane","Propane","N-Butane,","Nitrogen","Carbondioxide"},
       reference_X={0.92,0.048,0.005,0.002,0.015,0.01});
  end SimpleNaturalGas;

  package SimpleNaturalGasFixedComposition
    "Same as SimpleNaturalGas but with fixed composition"
  extends SimpleNaturalGas(fixedX=true);
  end SimpleNaturalGasFixedComposition;
end MixtureGases;


within Modelica.Media;
package IdealGases "Data and models of ideal gases (single, fixed and dynamic mixtures) from NASA source"
  extends Modelica.Icons.VariantsPackage;
end IdealGases;


within Modelica.Media.IdealGases;
package SingleGases "Media models of ideal gases from NASA tables"
  extends Modelica.Icons.VariantsPackage;

  package Ar "Ideal gas \"Ar\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
     mediumName="Argon",
     data=Common.SingleGasesData.Ar,
     fluidConstants={Common.FluidData.Ar});
  end Ar;

  package CH4 "Ideal gas \"CH4\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Methane",
       data=Common.SingleGasesData.CH4,
       fluidConstants={Common.FluidData.CH4});
  end CH4;

  package CH3OH "Ideal gas \"CH3OH\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Methanol",
       data=Common.SingleGasesData.CH3OH,
       fluidConstants={Common.FluidData.CH3OH});
  end CH3OH;

  package CO "Ideal gas \"CO\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Carbon Monoxide",
       data=Common.SingleGasesData.CO,
       fluidConstants={Common.FluidData.CO});
  end CO;

  package CO2 "Ideal gas \"CO2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Carbon Dioxide",
       data=Common.SingleGasesData.CO2,
       fluidConstants={Common.FluidData.CO2});
  end CO2;

  package C2H2_vinylidene
    "Ideal gas \"C2H2_vinylidene\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Acetylene",
       data=Common.SingleGasesData.C2H2_vinylidene,
       fluidConstants={Common.FluidData.C2H2_vinylidene});
  end C2H2_vinylidene;

  package C2H4 "Ideal gas \"C2H4\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Ethylene",
       data=Common.SingleGasesData.C2H4,
       fluidConstants={Common.FluidData.C2H4});
  end C2H4;

  package C2H5OH "Ideal gas \"C2H5OH\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Ethanol",
       data=Common.SingleGasesData.C2H5OH,
       fluidConstants={Common.FluidData.C2H5OH});
  end C2H5OH;

  package C2H6 "Ideal gas \"C2H6\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Ethane",
       data=Common.SingleGasesData.C2H6,
       fluidConstants={Common.FluidData.C2H6});
  end C2H6;

  package C3H6_propylene
    "Ideal gas \"C3H6_propylene\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Propylene",
       data=Common.SingleGasesData.C3H6_propylene,
       fluidConstants={Common.FluidData.C3H6_propylene});
  end C3H6_propylene;

  package C3H8 "Ideal gas \"C3H8\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Propane",
       data=Common.SingleGasesData.C3H8,
       fluidConstants={Common.FluidData.C3H8});
  end C3H8;

  package C3H8O_1propanol
    "Ideal gas \"C3H8O_1propanol\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="1-Propanol",
       data=Common.SingleGasesData.C3H8O_1propanol,
       fluidConstants={Common.FluidData.C3H7OH});
  end C3H8O_1propanol;

  package C4H8_1_butene
    "Ideal gas \"C4H8_1_butene\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="1-Butene",
       data=Common.SingleGasesData.C4H8_1_butene,
       fluidConstants={Common.FluidData.C4H8_1_butene});
  end C4H8_1_butene;

  package C4H10_n_butane
    "Ideal gas \"C4H10_n_butane\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="N-Butane",
       data=Common.SingleGasesData.C4H10_n_butane,
       fluidConstants={Common.FluidData.C4H10_n_butane});
  end C4H10_n_butane;

  package C5H10_1_pentene
    "Ideal gas \"C5H10_1_pentene\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="1-Pentene",
       data=Common.SingleGasesData.C5H10_1_pentene,
       fluidConstants={Common.FluidData.C5H10_1_pentene});
  end C5H10_1_pentene;

  package C5H12_n_pentane
    "Ideal gas \"C5H12_n_pentane\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName = "N-Pentane",
       data=Common.SingleGasesData.C5H12_n_pentane,
       fluidConstants={Common.FluidData.C5H12_n_pentane});
  end C5H12_n_pentane;

  package C6H6 "Ideal gas \"C6H6\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Benzene",
       data=Common.SingleGasesData.C6H6,
       fluidConstants={Common.FluidData.C6H6});
  end C6H6;

  package C6H12_1_hexene
    "Ideal gas \"C6H12_1_hexene\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="1-Hexene",
       data=Common.SingleGasesData.C6H12_1_hexene,
       fluidConstants={Common.FluidData.C6H12_1_hexene});
  end C6H12_1_hexene;

  package C6H14_n_hexane
    "Ideal gas \"C6H14_n_hexane\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="N-Hexane",
       data=Common.SingleGasesData.C6H14_n_hexane,
       fluidConstants={Common.FluidData.C6H14_n_hexane});
  end C6H14_n_hexane;

  package C7H14_1_heptene
    "Ideal gas \"C7H14_1_heptene\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="1-Heptene",
       data=Common.SingleGasesData.C7H14_1_heptene,
       fluidConstants={Common.FluidData.C7H14_1_heptene});
  end C7H14_1_heptene;

  package C7H16_n_heptane
    "Ideal gas \"C7H16_n_heptane\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="N-Heptane",
       data=Common.SingleGasesData.C7H16_n_heptane,
       fluidConstants={Common.FluidData.C7H16_n_heptane});
  end C7H16_n_heptane;

  package C8H10_ethylbenz
    "Ideal gas \"C8H10_ethylbenz\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Ethylbenzene",
       data=Common.SingleGasesData.C8H10_ethylbenz,
       fluidConstants={Common.FluidData.C8H10_ethylbenz});
  end C8H10_ethylbenz;

  package C8H18_n_octane
    "Ideal gas \"C8H18_n_octane\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="N-Octane",
       data=Common.SingleGasesData.C8H18_n_octane,
       fluidConstants={Common.FluidData.C8H18_n_octane});
  end C8H18_n_octane;

  package CL2 "Ideal gas \"Cl2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Chlorine",
       data=Common.SingleGasesData.CL2,
       fluidConstants={Common.FluidData.CL2});
  end CL2;

  package F2 "Ideal gas \"F2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Fluorine",
       data=Common.SingleGasesData.F2,
       fluidConstants={Common.FluidData.F2});
  end F2;

  package H2 "Ideal gas \"H2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Hydrogen",
       data=Common.SingleGasesData.H2,
       fluidConstants={Common.FluidData.H2});
  end H2;

  package H2O "Ideal gas \"H2O\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="IdealGasSteam",
       data=Common.SingleGasesData.H2O,
       fluidConstants={Common.FluidData.H2O});
  end H2O;

  package He "Ideal gas \"He\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Helium",
       data=Common.SingleGasesData.He,
       fluidConstants={Common.FluidData.He});
  end He;

  package NH3 "Ideal gas \"NH3\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="IdealGasAmmonia",
       data=Common.SingleGasesData.NH3,
       fluidConstants={Common.FluidData.NH3});
  end NH3;

  package NO "Ideal gas \"NO\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Nitric Oxide",
       data=Common.SingleGasesData.NO,
       fluidConstants={Common.FluidData.NO});
  end NO;

  package NO2 "Ideal gas \"NO2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Nitrogen Dioxide",
       data=Common.SingleGasesData.NO2,
       fluidConstants={Common.FluidData.NO2});
  end NO2;

  package N2 "Ideal gas \"N2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Nitrogen",
       data=Common.SingleGasesData.N2,
       fluidConstants={Common.FluidData.N2});
  end N2;

  package N2O "Ideal gas \"N2O\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Nitrous Oxide",
       data=Common.SingleGasesData.N2O,
       fluidConstants={Common.FluidData.N2O});
  end N2O;

  package Ne "Ideal gas \"Ne\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Neon",
       data=Common.SingleGasesData.Ne,
       fluidConstants={Common.FluidData.Ne});
  end Ne;

  package O2 "Ideal gas \"O2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Oxygen",
       data=Common.SingleGasesData.O2,
       fluidConstants={Common.FluidData.O2});
  end O2;

  package SO2 "Ideal gas \"SO2\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Sulfur Dioxide",
       data=Common.SingleGasesData.SO2,
       fluidConstants={Common.FluidData.SO2});
  end SO2;

  package SO3 "Ideal gas \"SO3\" from NASA Glenn coefficients"
    extends Common.SingleGasNasa(
       mediumName="Sulfur Trioxide",
       data=Common.SingleGasesData.SO3,
       fluidConstants={Common.FluidData.SO3});
  end SO3;
end SingleGases;


within Modelica.Media.IdealGases.Common;
package FluidData "Critical data, dipole moments and related data"

  extends Modelica.Icons.Package;

  import Modelica.Media.IdealGases.Common.SingleGasesData;

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants N2(
                       chemicalFormula =        "N2",
                       iupacName =              "molecular nitrogen",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7727-37-9",
                       meltingPoint =            63.15,
                       normalBoilingPoint =      77.35,
                       criticalTemperature =    126.20,
                       criticalPressure =        33.98e5,
                       criticalMolarVolume =     90.10e-6,
                       acentricFactor =           0.037,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.N2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Nitrogen";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants O2(
                       chemicalFormula =        "O2",
                       iupacName =              "molecular oxygen",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7782-44-7",
                       meltingPoint =            54.36,
                       normalBoilingPoint =      90.17,
                       criticalTemperature =    154.58,
                       criticalPressure =        50.43e5,
                       criticalMolarVolume =     73.37e-6,
                       acentricFactor =         0.022,
                       dipoleMoment =           0.0,
                       molarMass =              SingleGasesData.O2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Oxygen";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants CL2(
                       chemicalFormula =        "CL2",
                       iupacName =              "molecular chlorine",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7782-50-5",
                       meltingPoint =           172.19,
                       normalBoilingPoint =     239.12,
                       criticalTemperature =    417.00,
                       criticalPressure =        77.00e5,
                       criticalMolarVolume =    124.00e-6,
                       acentricFactor =         0.069,
                       dipoleMoment =           0.0,
                       molarMass =              SingleGasesData.CL2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Chlorine";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants F2(
                       chemicalFormula =        "F2",
                       iupacName =              "molecular fluorine",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7782-41-4",
                       meltingPoint =            53.48,
                       normalBoilingPoint =      84.95,
                       criticalTemperature =    144.30,
                       criticalPressure =        52.15e5,
                       criticalMolarVolume =     66.20e-6,
                       acentricFactor =           0.051,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.F2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Fluorine";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants CO2(
                       chemicalFormula =        "CO2",
                       iupacName =              "unknown",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "124-38-9",
                       meltingPoint =           216.58,
                       normalBoilingPoint =     -1.0,
                       criticalTemperature =    304.12,
                       criticalPressure =        73.74e5,
                       criticalMolarVolume =     94.07e-6,
                       acentricFactor =           0.225,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.CO2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Carbon Dioxide"; // does not exist!

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants CO(
                       chemicalFormula =        "CO",
                       iupacName =              "carbon monoxide",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "630-08-0",
                       meltingPoint =            68.15,
                       normalBoilingPoint =      81.66,
                       criticalTemperature =    132.85,
                       criticalPressure =        34.94e5,
                       criticalMolarVolume =     93.10e-6,
                       acentricFactor =           0.045,
                       dipoleMoment =             0.1,
                       molarMass =              SingleGasesData.CO.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Carbon Monoxide";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants H2(
                       chemicalFormula =        "H2",
                       iupacName =              "molecular hydrogen",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "800000-51-5",
                       meltingPoint =            13.56,
                       normalBoilingPoint =      20.38,
                       criticalTemperature =     33.25,
                       criticalPressure =        12.97e5,
                       criticalMolarVolume =     65.00e-6,
                       acentricFactor =          -0.216,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.H2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Hydrogen";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants H2O(
                       chemicalFormula =        "H2O",
                       iupacName =              "oxidane",
                       structureFormula =       "H2O",
                       casRegistryNumber =      "7732-18-5",
                       meltingPoint =           273.15,
                       normalBoilingPoint =     373.124,
                       criticalTemperature =    647.096,
                       criticalPressure =       220.64e5,
                       criticalMolarVolume =     55.95e-6,
                       acentricFactor =           0.344,
                       dipoleMoment =             1.8,
                       molarMass =              SingleGasesData.H2O.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Steam";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants N2O(
                       chemicalFormula =        "N2O",
                       iupacName =              "nitrous oxide",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "10024-97-2",
                       meltingPoint =           182.33,
                       normalBoilingPoint =     184.67,
                       criticalTemperature =    309.60,
                       criticalPressure =        72.55e5,
                       criticalMolarVolume =     97.00e-6,
                       acentricFactor =         0.142,
                       dipoleMoment =           0.2,
                       molarMass =              SingleGasesData.N2O.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Nitrous Oxide";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants NO(
                       chemicalFormula =        "NO",
                       iupacName =              "nitric oxide",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "10102-43-9",
                       meltingPoint =           109.51,
                       normalBoilingPoint =     121.38,
                       criticalTemperature =    180.00,
                       criticalPressure =        64.80e5,
                       criticalMolarVolume =     58.00e-6,
                       acentricFactor =           0.582,
                       dipoleMoment =             0.2,
                       molarMass =              SingleGasesData.NO.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Nitric Oxide";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants NO2(
                       chemicalFormula =        "NO2",
                       iupacName =              "unknown",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "10102-44-0",
                       meltingPoint =           261.95,
                       normalBoilingPoint =     294.0,
                       criticalTemperature =    431.35,
                       criticalPressure =       101.33e5,
                       criticalMolarVolume =    82.5e-6,
                       acentricFactor =         0.849,
                       dipoleMoment =           0.32,
                       molarMass =              SingleGasesData.NO2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Nitrogen Dioxide";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants NH3(
                       chemicalFormula =        "NH3",
                       iupacName =              "azane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7664-41-7",
                       meltingPoint =           195.41,
                       normalBoilingPoint =     239.82,
                       criticalTemperature =    405.40,
                       criticalPressure =       113.53e5,
                       criticalMolarVolume =     72.47e-6,
                       acentricFactor =           0.257,
                       dipoleMoment =             1.5,
                       molarMass =              SingleGasesData.NH3.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Ammonia";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants SO2(
                       chemicalFormula =        "SO2",
                       iupacName =              "sulfur dioxide",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7446-09-5",
                       meltingPoint =           197.67,
                       normalBoilingPoint =     263.13,
                       criticalTemperature =    430.80,
                       criticalPressure =        78.84e5,
                       criticalMolarVolume =    122.00e-6,
                       acentricFactor =         0.245,
                       dipoleMoment =           1.6,
                       molarMass =              SingleGasesData.SO2.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Sulfur Dioxide";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants SO3(
                       chemicalFormula =        "SO3",
                       iupacName =              "sulfur trioxide",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7446-11-9",
                       meltingPoint =           289.95,
                       normalBoilingPoint =     317.90,
                       criticalTemperature =    490.90,
                       criticalPressure =        82.10e5,
                       criticalMolarVolume =    126.50e-6,
                       acentricFactor =         0.422,
                       dipoleMoment =           0.0,
                       molarMass =              SingleGasesData.SO3.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Sulfur Trioxide";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants Ar(
                       chemicalFormula =        "Ar",
                       iupacName =              "argon",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7440-37-1",
                       meltingPoint =            83.80,
                       normalBoilingPoint =      87.27,
                       criticalTemperature =    150.86,
                       criticalPressure =        48.98e5,
                       criticalMolarVolume =     74.57e-6,
                       acentricFactor =          -0.002,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.Ar.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Argon";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants He(
                       chemicalFormula =        "He",
                       iupacName =              "helium",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7440-59-7",
                       meltingPoint =             2.15,
                       normalBoilingPoint =       4.30,
                       criticalTemperature =      5.19,
                       criticalPressure =         2.27e5,
                       criticalMolarVolume =     57.30e-6,
                       acentricFactor =          -0.390,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.He.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Helium";

 constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants Ne(
                       chemicalFormula =        "Ne",
                       iupacName =              "neon",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "7440-01-9",
                       meltingPoint =            24.56,
                       normalBoilingPoint =      27.07,
                       criticalTemperature =     44.40,
                       criticalPressure =        27.60e5,
                       criticalMolarVolume =     41.70e-6,
                       acentricFactor =          -0.016,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.Ne.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Neon";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants CH4(
                       chemicalFormula =        "CH4",
                       iupacName =              "methane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "74-82-8",
                       meltingPoint =            90.69,
                       normalBoilingPoint =     111.66,
                       criticalTemperature =    190.56,
                       criticalPressure =        45.99e5,
                       criticalMolarVolume =     98.60e-6,
                       acentricFactor =           0.011,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.CH4.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Methane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C2H6(
                       chemicalFormula =        "C2H6",
                       iupacName =              "ethane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "74-84-0",
                       meltingPoint =            90.35,
                       normalBoilingPoint =     184.55,
                       criticalTemperature =    305.32,
                       criticalPressure =        48.72e5,
                       criticalMolarVolume =    145.50e-6,
                       acentricFactor =           0.099,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C2H6.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Ethane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C3H8(
                       chemicalFormula =        "C3H8",
                       iupacName =              "propane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "74-98-6",
                       meltingPoint =            91.45,
                       normalBoilingPoint =     231.02,
                       criticalTemperature =    369.83,
                       criticalPressure =        42.48e5,
                       criticalMolarVolume =    200.00e-6,
                       acentricFactor =           0.152,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C3H8.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Propane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C4H10_n_butane(
                       chemicalFormula =        "C4H10",
                       iupacName =              "butane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "106-97-8",
                       meltingPoint =           134.79,
                       normalBoilingPoint =     272.66,
                       criticalTemperature =    425.12,
                       criticalPressure =        37.96e5,
                       criticalMolarVolume =    255.00e-6,
                       acentricFactor =           0.20,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C4H10_n_butane.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "N-Butane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C5H12_n_pentane(
                       chemicalFormula =        "C5H12",
                       iupacName =              "pentane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "109-66-0",
                       meltingPoint =           143.43,
                       normalBoilingPoint =     309.22,
                       criticalTemperature =    469.70,
                       criticalPressure =        33.70e5,
                       criticalMolarVolume =    311.00e-6,
                       acentricFactor =           0.252,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C5H12_n_pentane.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "N-Pentane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C6H14_n_hexane(
                       chemicalFormula =        "C6H14",
                       iupacName =              "hexane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "110-54-3",
                       meltingPoint =           177.84,
                       normalBoilingPoint =     341.88,
                       criticalTemperature =    507.60,
                       criticalPressure =        30.25e5,
                       criticalMolarVolume =    368.00e-6,
                       acentricFactor =           0.300,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C6H14_n_hexane.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "N-Hexane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C7H16_n_heptane(
                       chemicalFormula =        "C7H16",
                       iupacName =              "heptane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "142-82-5",
                       meltingPoint =           182.59,
                       normalBoilingPoint =     371.57,
                       criticalTemperature =    540.20,
                       criticalPressure =        27.40e5,
                       criticalMolarVolume =    428.00e-6,
                       acentricFactor =           0.350,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C7H16_n_heptane.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "N-Heptane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C2H4(
                       chemicalFormula =        "C2H4",
                       iupacName =              "ethene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "74-85-1",
                       meltingPoint =           103.99,
                       normalBoilingPoint =     169.42,
                       criticalTemperature =    282.34,
                       criticalPressure =        50.41e5,
                       criticalMolarVolume =    131.10e-6,
                       acentricFactor =           0.087,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C2H4.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Ethylene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C3H6_propylene(
                       chemicalFormula =        "C3H6",
                       iupacName =              "prop-1-ene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "115-07-1",
                       meltingPoint =            87.89,
                       normalBoilingPoint =     225.46,
                       criticalTemperature =    364.90,
                       criticalPressure =        46.00e5,
                       criticalMolarVolume =    184.60e-6,
                       acentricFactor =           0.142,
                       dipoleMoment =             0.4,
                       molarMass =              SingleGasesData.C3H6_propylene.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Propylene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C4H8_1_butene(
                       chemicalFormula =        "C4H8",
                       iupacName =              "but-1-ene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "106-98-9",
                       meltingPoint =            87.79,
                       normalBoilingPoint =     266.92,
                       criticalTemperature =    419.50,
                       criticalPressure =        40.20e5,
                       criticalMolarVolume =    240.80e-6,
                       acentricFactor =           0.194,
                       dipoleMoment =             0.3,
                       molarMass =              SingleGasesData.C4H8_1_butene.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "1-Butene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C5H10_1_pentene(
                       chemicalFormula =        "C5H10",
                       iupacName =              "pent-1-ene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "109-67-1",
                       meltingPoint =           106.95,
                       normalBoilingPoint =     303.11,
                       criticalTemperature =    464.80,
                       criticalPressure =        35.60e5,
                       criticalMolarVolume =    298.40e-6,
                       acentricFactor =           0.237,
                       dipoleMoment =             0.4,
                       molarMass =              SingleGasesData.C5H10_1_pentene.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "1-Pentene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C6H12_1_hexene(
                       chemicalFormula =        "C6H12",
                       iupacName =              "hex-1-ene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "592-41-6",
                       meltingPoint =           133.34,
                       normalBoilingPoint =     336.63,
                       criticalTemperature =    504.00,
                       criticalPressure =        31.43e5,
                       criticalMolarVolume =    355.10e-6,
                       acentricFactor =           0.281,
                       dipoleMoment =             0.4,
                       molarMass =              SingleGasesData.C6H12_1_hexene.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "1-Hexene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C7H14_1_heptene(
                       chemicalFormula =        "C7H14",
                       iupacName =              "hept-1-ene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "592-76-7",
                       meltingPoint =           153.45,
                       normalBoilingPoint =     366.79,
                       criticalTemperature =    537.30,
                       criticalPressure =        29.20e5,
                       criticalMolarVolume =    409.00e-6,
                       acentricFactor =           0.343,
                       dipoleMoment =             0.3,
                       molarMass =              SingleGasesData.C7H14_1_heptene.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "1-Heptene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C2H2_vinylidene(
                       chemicalFormula =        "C2H2",
                       iupacName =              "acetylene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "74-86-2",
                       meltingPoint =           192.35,
                       normalBoilingPoint =     188.40,
                       criticalTemperature =    308.30,
                       criticalPressure =        61.14e5,
                       criticalMolarVolume =    112.20e-6,
                       acentricFactor =           0.189,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C2H2_vinylidene.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Acetylene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C6H6(
                       chemicalFormula =        "C6H6",
                       iupacName =              "benzene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "71-43-2",
                       meltingPoint =           278.68,
                       normalBoilingPoint =     353.24,
                       criticalTemperature =    562.05,
                       criticalPressure =        48.95e5,
                       criticalMolarVolume =    256.00e-6,
                       acentricFactor =           0.210,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C6H6.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Benzene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C8H18_n_octane(
                       chemicalFormula =        "C8H18",
                       iupacName =              "octane",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "111-65-9",
                       meltingPoint =           216.39,
                       normalBoilingPoint =     398.82,
                       criticalTemperature =    568.70,
                       criticalPressure =        24.90e5,
                       criticalMolarVolume =    492.00e-6,
                       acentricFactor =           0.399,
                       dipoleMoment =             0.0,
                       molarMass =              SingleGasesData.C8H18_n_octane.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "N-Octane";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C8H10_ethylbenz(
                       chemicalFormula =        "C8H10",
                       iupacName =              "ethylbenzene",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "100-41-4",
                       meltingPoint =           178.18,
                       normalBoilingPoint =     409.36,
                       criticalTemperature =    617.15,
                       criticalPressure =        36.09e5,
                       criticalMolarVolume =    374.00e-6,
                       acentricFactor =           0.304,
                       dipoleMoment =             0.4,
                       molarMass =              SingleGasesData.C8H10_ethylbenz.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Ethylbenzene";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants CH3OH(
                       chemicalFormula =        "CH3OH",
                       iupacName =              "methanol",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "67-56-1",
                       meltingPoint =           175.49,
                       normalBoilingPoint =     337.69,
                       criticalTemperature =    512.64,
                       criticalPressure =        80.97e5,
                       criticalMolarVolume =    118.00e-6,
                       acentricFactor =           0.565,
                       dipoleMoment =             1.7,
                       molarMass =              SingleGasesData.CH3OH.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Methanol";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C2H5OH(
                       chemicalFormula =        "C2H5OH",
                       iupacName =              "ethanol",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "64-17-5",
                       meltingPoint =           159.05,
                       normalBoilingPoint =     351.80,
                       criticalTemperature =    513.92,
                       criticalPressure =        61.48e5,
                       criticalMolarVolume =    167.00e-6,
                       acentricFactor =           0.649,
                       dipoleMoment =             1.7,
                       molarMass =              SingleGasesData.C2H5OH.MM,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "Ethanol";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C3H7OH(
                       chemicalFormula =        "C3H7OH",
                       iupacName =              "propan-1-ol",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "71-23-8",
                       meltingPoint =           147.00,
                       normalBoilingPoint =     370.93,
                       criticalTemperature =    536.78,
                       criticalPressure =        51.75e5,
                       criticalMolarVolume =    219.00e-6,
                       acentricFactor =           0.629,
                       dipoleMoment =             1.7,
                       molarMass =              60.1e-3,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "1-Propanol";

  constant Modelica.Media.Interfaces.Types.IdealGas.FluidConstants C4H9OH(
                       chemicalFormula =        "C4H9OH",
                       iupacName =              "butan-1-ol",
                       structureFormula =       "unknown",
                       casRegistryNumber =      "71-36-3",
                       meltingPoint =           183.35,
                       normalBoilingPoint =     390.88,
                       criticalTemperature =    563.05,
                       criticalPressure =        44.23e5,
                       criticalMolarVolume =    275.00e-6,
                       acentricFactor =           0.589,
                       dipoleMoment =             1.8,
                       molarMass =              74.12e-3,
                       hasDipoleMoment =       true,
                       hasIdealGasHeatCapacity=true,
                       hasCriticalData =       true,
                       hasAcentricFactor =     true) "1-Butanol";
end FluidData;


within Modelica.Media.IdealGases.Common;
package Functions
  "Basic Functions for ideal gases: cp, h, s, thermal conductivity, viscosity"
  extends Modelica.Icons.FunctionsPackage;

  constant Boolean excludeEnthalpyOfFormation=true
    "If true, enthalpy of formation Hf is not included in specific enthalpy h";
  constant Modelica.Media.Interfaces.Choices.ReferenceEnthalpy referenceChoice=Modelica.Media.Interfaces.Choices.ReferenceEnthalpy.ZeroAt0K
    "Choice of reference enthalpy";
  constant Modelica.Media.Interfaces.Types.SpecificEnthalpy h_offset=0.0
    "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
  constant Integer methodForThermalConductivity(min=1,max=2)=1;

  function cp_T
    "Compute specific heat capacity at constant pressure from temperature and gas data"
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    output SI.SpecificHeatCapacity cp "Specific heat capacity at temperature T";
  algorithm
    cp := smooth(0,if T < data.Tlimit then data.R_s*(1/(T*T)*(data.alow[1] + T*(
      data.alow[2] + T*(1.*data.alow[3] + T*(data.alow[4] + T*(data.alow[5] + T
      *(data.alow[6] + data.alow[7]*T))))))) else data.R_s*(1/(T*T)*(data.ahigh[1]
       + T*(data.ahigh[2] + T*(1.*data.ahigh[3] + T*(data.ahigh[4] + T*(data.
      ahigh[5] + T*(data.ahigh[6] + data.ahigh[7]*T))))))));
  end cp_T;

  function cp_Tlow
    "Compute specific heat capacity at constant pressure, low T region"
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    output SI.SpecificHeatCapacity cp "Specific heat capacity at temperature T";
  algorithm
    cp := data.R_s*(1/(T*T)*(data.alow[1] + T*(
      data.alow[2] + T*(1.*data.alow[3] + T*(data.alow[4] + T*(data.alow[5] + T
      *(data.alow[6] + data.alow[7]*T)))))));
  end cp_Tlow;

  function cp_Tlow_der
    "Compute derivative of specific heat capacity at constant pressure, low T region"
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    input Real dT(unit="K/s") "Temperature derivative";
    output Real cp_der(unit="J/(kg.K.s)") "Derivative of specific heat capacity";
  algorithm
    cp_der := dT*data.R_s/(T*T*T)*(-2*data.alow[1] + T*(
      -data.alow[2] + T*T*(data.alow[4] + T*(2.*data.alow[5] + T
      *(3.*data.alow[6] + 4.*data.alow[7]*T)))));
  end cp_Tlow_der;

  function h_T "Compute specific enthalpy from temperature and gas data; reference is decided by the
    refChoice input, or by the referenceChoice package constant by default"
    import Modelica.Media.Interfaces.Choices;
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    input Boolean exclEnthForm=excludeEnthalpyOfFormation
      "If true, enthalpy of formation Hf is not included in specific enthalpy h";
    input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy
                                    refChoice=referenceChoice
      "Choice of reference enthalpy";
    input SI.SpecificEnthalpy h_off=h_offset
      "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
    output SI.SpecificEnthalpy h "Specific enthalpy at temperature T";

  algorithm
    h := smooth(0,(if T < data.Tlimit then data.R_s*((-data.alow[1] + T*(data.
      blow[1] + data.alow[2]*Math.log(T) + T*(1.*data.alow[3] + T*(0.5*data.
      alow[4] + T*(1/3*data.alow[5] + T*(0.25*data.alow[6] + 0.2*data.alow[7]*T))))))
      /T) else data.R_s*((-data.ahigh[1] + T*(data.bhigh[1] + data.ahigh[2]*
      Math.log(T) + T*(1.*data.ahigh[3] + T*(0.5*data.ahigh[4] + T*(1/3*data.
      ahigh[5] + T*(0.25*data.ahigh[6] + 0.2*data.ahigh[7]*T))))))/T)) + (if
      exclEnthForm then -data.Hf else 0.0) + (if (refChoice
       == Choices.ReferenceEnthalpy.ZeroAt0K) then data.H0 else 0.0) + (if
      refChoice == Choices.ReferenceEnthalpy.UserDefined then h_off else
            0.0));
  end h_T;

  function h_T_der "Derivative function for h_T"
    import Modelica.Media.Interfaces.Choices;
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    input Boolean exclEnthForm=excludeEnthalpyOfFormation
      "If true, enthalpy of formation Hf is not included in specific enthalpy h";
    input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy
                                    refChoice=referenceChoice
      "Choice of reference enthalpy";
    input SI.SpecificEnthalpy h_off=h_offset
      "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
    input Real dT(unit="K/s") "Temperature derivative";
    output Real h_der(unit="J/(kg.s)") "Derivative of specific enthalpy at temperature T";
  algorithm
    h_der := dT*Modelica.Media.IdealGases.Common.Functions.cp_T(
                     data,T);
  end h_T_der;

  function h_Tlow "Compute specific enthalpy, low T region; reference is decided by the
    refChoice input, or by the referenceChoice package constant by default"
    import Modelica.Media.Interfaces.Choices;
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    input Boolean exclEnthForm=excludeEnthalpyOfFormation
      "If true, enthalpy of formation Hf is not included in specific enthalpy h";
    input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy
                                    refChoice=referenceChoice
      "Choice of reference enthalpy";
    input SI.SpecificEnthalpy h_off=h_offset
      "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
    output SI.SpecificEnthalpy h "Specific enthalpy at temperature T";

  algorithm
    h := data.R_s*((-data.alow[1] + T*(data.
      blow[1] + data.alow[2]*Math.log(T) + T*(1.*data.alow[3] + T*(0.5*data.
      alow[4] + T*(1/3*data.alow[5] + T*(0.25*data.alow[6] + 0.2*data.alow[7]*T))))))
      /T) + (if
      exclEnthForm then -data.Hf else 0.0) + (if (refChoice
       == Choices.ReferenceEnthalpy.ZeroAt0K) then data.H0 else 0.0) + (if
      refChoice == Choices.ReferenceEnthalpy.UserDefined then h_off else
            0.0);
  end h_Tlow;

  function h_Tlow_der "Compute derivative of specific enthalpy, low T region; reference is decided by the
    refChoice input, or by the referenceChoice package constant by default"
    import Modelica.Media.Interfaces.Choices;
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    input Boolean exclEnthForm=excludeEnthalpyOfFormation
      "If true, enthalpy of formation Hf is not included in specific enthalpy h";
    input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy
                                    refChoice=referenceChoice
      "Choice of reference enthalpy";
    input SI.SpecificEnthalpy h_off=h_offset
      "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
    input Real dT(unit="K/s") "Temperature derivative";
    output Real h_der(unit="J/(kg.s)")
      "Derivative of specific enthalpy at temperature T";
  algorithm
    h_der := dT*Modelica.Media.IdealGases.Common.Functions.cp_Tlow(
                        data,T);
  end h_Tlow_der;

  function s0_T "Compute specific entropy from temperature and gas data"
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    output SI.SpecificEntropy s "Specific entropy at temperature T";
  algorithm
    s := if T < data.Tlimit then data.R_s*(data.blow[2] - 0.5*data.alow[
      1]/(T*T) - data.alow[2]/T + data.alow[3]*Math.log(T) + T*(
      data.alow[4] + T*(0.5*data.alow[5] + T*(1/3*data.alow[6] + 0.25*data.alow[
      7]*T)))) else data.R_s*(data.bhigh[2] - 0.5*data.ahigh[1]/(T*T) - data.
      ahigh[2]/T + data.ahigh[3]*Math.log(T) + T*(data.ahigh[4]
       + T*(0.5*data.ahigh[5] + T*(1/3*data.ahigh[6] + 0.25*data.ahigh[7]*T))));
  end s0_T;

  function s0_Tlow "Compute specific entropy, low T region"
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    output SI.SpecificEntropy s "Specific entropy at temperature T";
  algorithm
    s := data.R_s*(data.blow[2] - 0.5*data.alow[
      1]/(T*T) - data.alow[2]/T + data.alow[3]*Math.log(T) + T*(
      data.alow[4] + T*(0.5*data.alow[5] + T*(1/3*data.alow[6] + 0.25*data.alow[
      7]*T))));
  end s0_Tlow;

  function s0_Tlow_der "Compute derivative of specific entropy, low T region"
    extends Modelica.Icons.Function;
    input IdealGases.Common.DataRecord data "Ideal gas data";
    input SI.Temperature T "Temperature";
    input Real T_der(unit="K/s") "Temperature derivative";
    output Real s_der(unit="J/(kg.K.s)") "Derivative of specific entropy at temperature T";
  algorithm
    s_der := data.R_s*T_der*(data.alow[1]/(T*T*T) + data.alow[2]/(T*T) + data.alow[3]/T + data.alow[4] + T*(data.alow[5] + T*(data.alow[6] + T*data.alow[7])));
  end s0_Tlow_der;

  function dynamicViscosityLowPressure
    "Dynamic viscosity of low pressure gases"
    extends Modelica.Icons.Function;
    input SI.Temperature T "Gas temperature";
    input SI.Temperature Tc "Critical temperature of gas";
    input SI.MolarMass M "Molar mass of gas";
    input SI.MolarVolume Vc "Critical molar volume of gas";
    input Real w "Acentric factor of gas";
    input Modelica.Media.Interfaces.Types.DipoleMoment mu
      "Dipole moment of gas molecule";
    input Real k =  0.0 "Special correction for highly polar substances";
    output SI.DynamicViscosity eta "Dynamic viscosity of gas";
  protected
    parameter Real Const1_SI=40.785*10^(-9.5)
      "Constant in formula for eta converted to SI units";
    parameter Real Const2_SI=131.3/1000.0
      "Constant in formula for mur converted to SI units";
    Real mur=Const2_SI*mu/sqrt(Vc*Tc)
      "Dimensionless dipole moment of gas molecule";
    Real Fc=1 - 0.2756*w + 0.059035*mur^4 + k
      "Factor to account for molecular shape and polarities of gas";
    Real Tstar "Dimensionless temperature defined by equation below";
    Real Ov "Viscosity collision integral for the gas";

  algorithm
    Tstar := 1.2593*T/Tc;
    Ov := 1.16145*Tstar^(-0.14874) + 0.52487*Modelica.Math.exp(-0.7732*Tstar) + 2.16178*Modelica.Math.exp(-2.43787
      *Tstar);
    eta := Const1_SI*Fc*sqrt(M*T)/(Vc^(2/3)*Ov);
  end dynamicViscosityLowPressure;

  function thermalConductivityEstimate
    "Thermal conductivity of polyatomic gases (Eucken and Modified Eucken correlation)"
    extends Modelica.Icons.Function;
    input Modelica.Media.Interfaces.Types.SpecificHeatCapacity Cp
      "Constant pressure heat capacity";
    input Modelica.Media.Interfaces.Types.DynamicViscosity eta
      "Dynamic viscosity";
    input Integer method(min=1,max=2)=1
      "1: Eucken Method, 2: Modified Eucken Method";
    input IdealGases.Common.DataRecord data "Ideal gas data";
    output Modelica.Media.Interfaces.Types.ThermalConductivity lambda
      "Thermal conductivity [W/(m.k)]";
  algorithm
    lambda := if method == 1 then eta*(Cp - data.R_s + (9/4)*data.R_s)
                             else eta*(Cp - data.R_s)*(1.32 + 1.77/((Cp/data.R_s) - 1.0));
  end thermalConductivityEstimate;
end Functions;