Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The code is based upon the python library pyaga8, which is again based upon the open source rust package aga8 (https://crates.io/crates/aga8)
A class to perform gas property calculations using the AGA8 equations of state, DETAIL [1] and GERG-2008 [2].
Parameters:
equation (str, optional) – The equation of state to use. Must be either ‘GERG-2008’ or ‘DETAIL’. Default is ‘GERG-2008’.
Variables:
equation (str) – The equation of state being used.
adapter (object) – The adapter object corresponding to the selected equation of state.
Methods:
calculate_from_PT(composition, pressure, temperature, pressure_unit=’bara’, temperature_unit=’C’, molar_mass=None) – Calculate gas properties using pressure, temperature, and composition as input.
calculate_from_rhoT(composition, mass_density, temperature, temperature_unit=’C’, molar_mass=None) – Calculate gas properties using mass density, temperature, and composition as input.
.. warning:: – AGA8 is only valid for single-phase gas conditions. It does not check for phase state
and will produce erroneous results if applied in the two-phase or liquid region.
The user is responsible for ensuring that the operating conditions are within the
single-phase gas region before using these calculations.
pressure_unit (str) – Unit of pressure. The default unit is bara.
temperature_unit (str) – Unit of temperature. The default unit is Celsius (C).
molar_mass (float, optional) – Molar mass can be given as an optional input [kg/kmol]. If this is given, this molar mass will be used to calculate the mass density instead of the AGA8 calculated molar mass.
The default is None. In that case the AGA8 calculated molar mass will be used.
Notes
Only valid for single-phase gas conditions. Results will be erroneous if the
operating point falls within the two-phase or liquid region. No phase check is performed.
Returns:
results (TYPE) – Dictionary with properties from AGA8.
’ P - Pressure [kPa]
‘ T - Temperature [k]
‘ Z - Compressibility factor [-]
‘ dPdD - First derivative of pressure with respect to density at constant temperature [kPa/(mol/l)]
‘d2PdD2 - Second derivative of pressure with respect to density at constant temperature [kPa/(mol/l)^2]
‘d2PdTD - Second derivative of pressure with respect to temperature and density [kPa/(mol/l)/K]
‘ dPdT - First derivative of pressure with respect to temperature at constant density (kPa/K)
‘ U - Internal energy [J/mol]
‘ H - Enthalpy [J/mol]
‘ S - Entropy [J/(mol-K)]
‘ Cv - Isochoric heat capacity [J/(mol-K)]
‘ Cp - Isobaric heat capacity [J/(mol-K)]
‘ W - Speed of sound [m/s]
‘ G - Gibbs energy [J/mol]
‘ JT - Joule-Thomson coefficient [K/kPa]
‘ Kappa - Isentropic Exponent [-]
‘ A - Helmholtz energy [J/mol]
‘ D - Molar density [mol/l]
‘ mm - Molar mass [g/mol]
‘ rho - Mass density [kg/m3]
’ gas_composition - Dictionary containing the composition used in the calculations
Calculate gas properties using AGA8 with mass density, temperature and composition as input.
Parameters:
gas_composition (dict) – Dictionary with component name as key and mole percent or mole fraction as value.
mass_density (float) – Mass density [kg/m3]
temperature (float) – Temperature. Unit of measure is defined by temperature_unit.
temperature_unit (TYPE, optional) – Unit of measure for temperature. The default is ‘C’.
molar_mass (float, optional) – Molar mass can be given as an optional input [kg/kmol]. If this is given, this molar mass will be used to calculate the mass density instead of the AGA8 calculated molar mass. The default is None. In that case the AGA8 calculated molar mass will be used.
composition (dict)
Notes
Only valid for single-phase gas conditions. Results will be erroneous if the
operating point falls within the two-phase or liquid region. No phase check is performed.
Returns:
results (dict) – Dictionary with properties from AGA8 (same as for the calculate_from_PT method)
Calculate gas properties using AGA8 with pressure, enthalpy and composition as input.
Parameters:
composition (dict) – The composition of the gas mixture as a dictionary where keys are component names and values are their mole fractions.
pressure (float) – Pressure. Unit is defined by pressure_unit.
enthalpy (float) – Enthalpy, H [J/mol]
pressure_unit (str, optional) – The unit of the pressure, by default ‘bara’.
molar_mass (float, optional) – The molar mass of the gas mixture, by default None. If None, the AGA8 molar mass is used.
Notes
Only valid for single-phase gas conditions. Results will be erroneous if the
operating point falls within the two-phase or liquid region. No phase check is performed.
Returns:
results (dict) – Dictionary with properties from AGA8 (same as for the calculate_from_PT method)
Calculate gas properties using AGA8 with pressure, entropy and composition as input.
Parameters:
composition (dict) – The composition of the gas mixture as a dictionary where keys are component names and values are their mole fractions.
pressure (float) – Pressure. Unit is defined by pressure_unit.
entropy (float) – Entropy, S [J/mol-K]
pressure_unit (str, optional) – The unit of the pressure, by default ‘bara’.
molar_mass (float, optional) – The molar mass of the gas mixture, by default None. If None, the AGA8 molar mass is used.
Notes
Only valid for single-phase gas conditions. Results will be erroneous if the
operating point falls within the two-phase or liquid region. No phase check is performed.
Returns:
results (dict) – Dictionary with properties from AGA8 (same as for the calculate_from_PT method)
Mix fluids consisting of components from the AGA8 component list, based on their masses.
Uses molecular weights from the initialized AGA8 equation of state.
The function can take any number of compositions and corresponding masses, and will return the resulting composition and total mass of the mixture.
Parameters:
compositions (list) – A list of composition dictionaries, where each dictionary contains component names as keys
and mole percent or mole fraction as values. Components should be from the AGA8 component list:
C1, N2, CO2, C2, C3, iC4, nC4, iC5, nC5, nC6, nC7, nC8, nC9, nC10, H2, O2, CO, H2O, H2S, He, Ar.
mix_weights (list) – A list of masses [kg] corresponding to each composition. Must be the same length as compositions.
Can include negative values for subtraction operations.
check_input (bool, optional) – If True, raises exceptions for invalid inputs. If False, returns NaN values for invalid inputs.
Default is False.
Returns:
results (dict) – Dictionary containing:
- ‘composition’: Dictionary with component names as keys and mole percent (0-100) as values.
- ‘total_mass’: Total mass of the mixture [kg].
Raises:
ValueError – If check_input is True and any of the following occur:
- Length of compositions and mix_weights lists don’t match
- Any component moles become negative after mixing (non-physical)
- Total mass becomes negative after mixing
- Invalid component names in compositions