Thermodynamics¶
This module contains Oil and Gas classes and associated thermodynamic functions.
- class opgee.thermodynamics.AbstractSubstance(field)¶
AbstractSubstance class is superclass of Oil, Gas and Water
- class opgee.thermodynamics.Air(field, composition)¶
The Air class represents the wet air and dry air chemical properties such as molar weights, density, etc. The wet air and dry air composition are given. The molecular weight is in unit g/mol and density is in unit kg/m3.
- density()¶
- Returns:
(float) dry air density (unit = kg/m3)
- opgee.thermodynamics.Cp(component, kelvin, with_units=True)¶
- Parameters:
kelvin – unit in Kelvin
component –
with_units – (bool) whether to return a pint.Quantity()
- Returns:
(float) specific heat in standard condition (unit = joule/g/kelvin)
- class opgee.thermodynamics.DryAir(field)¶
DryAir class represents the composition of dry air. The composition is obtained from https://www.engineeringtoolbox.com/air-composition-d_212.html
- opgee.thermodynamics.Enthalpy(component, kelvin, phase='gas', with_units=True)¶
calculate enthalpy of component given temperature and phase
- Parameters:
phase –
component –
kelvin –
with_units – (bool) whether to return a pint.Quantity()
- Returns:
(float) enthalpy (unit = joule/mole)
- class opgee.thermodynamics.Gas(field)¶
Describes the thermodynamic properties of gas.
- static Z_factor(reduced_temperature, reduced_pressure)¶
Calculate the compressibility factor (Z) for a given reduced temperature and reduced pressure using the Redlich-Kwong equation of state. The Redlich-Kwong equation of state is a cubic equation. The function calculates the three possible roots (real or complex) and returns the highest real root as the compressibility factor. The input quantities are first converted to dimensionless fractions.
- Args:
reduced_temperature (pint.Quantity): Reduced temperature as a Pint Quantity object, defined as T/Tc (ratio of temperature to critical temperature). reduced_pressure (pint.Quantity): Reduced pressure as a Pint Quantity object, defined as P/Pc (ratio of pressure to critical pressure).
- Returns:
pint.Quantity: Compressibility factor (Z) as a Pint Quantity object (dimensionless fraction) for the given reduced temperature and reduced pressure.
- static combustion_enthalpy(molar_fracs, temperature, phase)¶
calculate OTSG/HRSG combustion enthalpy
- Parameters:
molar_fracs –
temperature –
- Returns:
- component_mass_fractions(molar_fracs)¶
generate moss fractions from molar fractions
- Parameters:
molar_fracs –
- Returns:
- component_molar_fraction(name, stream)¶
- Parameters:
name – (str) component name
stream –
- Returns:
- component_molar_fractions(stream, index=None)¶
- Parameters:
stream –
index – Gas Component’s Index Array
:return:(float) Panda Series component molar fractions
- corrected_pseudocritical_pressure(stream)¶
Calculate the corrected pseudocritical pressure for a given stream.
- Parameters:
stream – Stream object with gas composition and flow rates
- Returns:
float representing the corrected pseudocritical pressure (in psia)
- corrected_pseudocritical_temperature(stream)¶
Calculate the corrected pseudocritical temperature for a given stream.
- Parameters:
stream – Stream object with gas composition and flow rates
- Returns:
float representing the corrected pseudocritical temperature (in Rankine)
- density(stream)¶
- Parameters:
stream –
- Returns:
(float) gas density (unit = tonne/m3)
- energy_flow_rate(stream)¶
Calculate the energy flow rate in “mmbtu/day” in LHV.
- Stream:
(opgee.Stream) the Stream to consider
:return:(pint.Quantity) energy flow rate in “mmBtu/day”
- static heat_capacity(stream)¶
- Parameters:
stream –
- Returns:
(float) gas heat capacity (unit = btu/degF/day)
- mass_energy_density(stream)¶
- Parameters:
stream – (opgee.Stream) the Stream to examine
- Returns:
(float) gas mass energy density (unit = MJ/kg); None if the stream is empty
- mass_energy_density_from_molar_fracs(molar_fracs)¶
calculate gas mass energy density from series
- Parameters:
molar_fracs –
- Returns:
(float) gas mass energy density (unit = MJ/kg)
- molar_flow_rate(stream, name)¶
get molar flow rate from stream
- Parameters:
stream –
name –
- Returns:
(float) molar flow rate (unit = mol/day)
- molar_flow_rates(stream)¶
get molar flow rate from stream
- Parameters:
stream –
name –
- Returns:
(float) molar flow rate (unit = mol/day)
- molar_weight(stream)¶
- Parameters:
stream –
- Returns:
- molar_weight_from_molar_fracs(molar_fracs)¶
Calculate molar weight from molar fraction, where molar fraction is stored in Pandas Series
- Parameters:
molar_fracs –
- Returns:
(float) molar weight (unit = g/mol)
- ratio_of_specific_heat(stream)¶
- Parameters:
stream –
- Returns:
- reduced_pressure(stream)¶
- Parameters:
stream –
- Returns:
- reduced_temperature(stream)¶
- Parameters:
stream –
- Returns:
- specific_gravity(stream)¶
- Parameters:
stream –
- Returns:
- total_molar_flow_rate(stream)¶
- Parameters:
stream –
- Returns:
(float) total molar flow rate (unit = mol/day)
- uncorrected_pseudocritical_temperature_and_pressure(stream)¶
Calculate the uncorrected pseudocritical temperature and pressure for a given stream.
- Parameters:
stream – Stream object with gas composition and flow rates
- Returns:
pandas.Series containing temperature (in Rankine) and pressure (in psia)
- viscosity(stream)¶
Calculate natural gas viscosity using Lee et al.(1966) correlation
- Parameters:
stream –
:return:(float) natural gas viscosity (unit = cP)
- volume_energy_density(stream)¶
Calculate gas volume energy density
- Parameters:
stream –
:return:(float) gas volume energy density (unit = btu/scf)
- volume_factor(stream)¶
- Parameters:
stream –
- Returns:
- volume_flow_rate(stream)¶
Calculate volume flow rate from given stream.
- Parameters:
stream –
- Returns:
(Float) Total gas volume flow rate, unit = m3/day
- volume_flow_rate_STP(stream)¶
Calculate volume flow rate from given stream under standard condition
- Parameters:
stream –
- Returns:
(Float) Total gas volume flow rate, unit = m3/day
- volume_flow_rates_STP(stream)¶
Calculate volume flow rates from given stream under standard condition
- Parameters:
stream –
- Returns:
(pd.Series) gas volume flow rates, unit = m3/day
- opgee.thermodynamics.LHV(component, with_units=True)¶
Return the lower heating value for the given component, with or without Pint units.
- Parameters:
component – (str) the name of a stream component
with_units – (bool) whether to return a pint.Quantity()
- Returns:
(float) lower heating value (unit = joule/mol)
- class opgee.thermodynamics.Oil(field)¶
Describes thermodynamic properties of crude oil.
- static API_from_SG(SG)¶
Calculate API from specific gravity :param SG: :return:
- bubble_point_pressure(oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
- Parameters:
oil_specific_gravity –
gas_specific_gravity –
gas_oil_ratio –
- Returns:
- static bubble_point_solution_GOR(gas_oil_ratio)¶
R_sb = 1.1618 * R_sp R_Sb is GOR at bubblepoint, R_sp is GOR at separator Valco and McCain (2002) give a means to estimate the bubble point gas-oil ratio from the separator gas oil ratio. Since OPGEE takes separator gas oil ratio as an input, we use this
:return:(float) GOR at bubblepoint (unit = scf/bbl)
- density(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
Calculate the density of a mixture of oil and gas in a stream.
- Parameters:
stream – The stream containing the oil and gas mixture
oil_specific_gravity – The specific gravity of the oil component
gas_specific_gravity – The specific gravity of the gas component
gas_oil_ratio – The ratio of gas to oil in the mixture
- Returns:
The density of the mixture (unit = lb/ft**3)
- energy_flow_rate(stream)¶
Calculate the energy flow rate in “mmbtu/day” in LHV.
- Stream:
(opgee.Stream) the Stream to consider
:return:(pint.Quantity) energy flow rate in “mmBtu/day”
- formation_volume_factor(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
the formation volume factor is defined as the ratio of the volume of oil (plus the gas in solution) at the prevailing reservoir temperature and pressure to the volume of oil at standard conditions
:return:(float) final formation volume factor (unit = fraction)
- static isothermal_compressibility(oil_specific_gravity)¶
Regression from …
- Returns:
- isothermal_compressibility_X(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
Isothermal compressibility is the change in volume of a system as the pressure changes while temperature remains constant.
- Returns:
- static liquid_fuel_composition(API)¶
calculate Carbon, Hydrogen, Sulfur, Nitrogen mol per crude oil reference: Fuel Specs, Table Crude oil chemical composition
:return:(float) liquid fuel composition (unit = mol/kg)
- mass_energy_density(API=None, use_LHV=True, with_unit=True)¶
Calculate oil heating value
- Parameters:
API –
use_LHV – whether to use LHV or HHV
with_unit – (float) lower or higher heating value (unit = btu/lb)
- Returns:
heating value mass
- reservoir_solution_GOR()¶
The solution gas oil ratio (GOR) at resevoir condition is the minimum of empirical correlation and bubblepoint GOR
- Returns:
(float) solution gas oil ratio at resevoir condition (unit = scf/bbl)
- saturated_formation_volume_factor(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
The formation volume factor is defined as the ratio of the volume of oil (plus the gas in solution) at the prevailing reservoir temperature and pressure to the volume of oil at standard conditions
- Returns:
(float) saturated formation volume factor (unit = fraction)
- solution_gas_oil_ratio(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
The solution gas-oil ratio (GOR) is a general term for the amount of gas dissolved in the oil
- Returns:
(float) solution gas oil ratio (unit = scf/bbl)
- static specific_gravity(API_grav)¶
Calculate specific gravity of crude oil using the API standard SG at 60C = 141.5/(API+131.5) :param API_grav:
- Returns:
- static specific_heat(API, temperature)¶
Campbell specific heat capacity of oil Campbell equation from Manning and Thompson (1991). cp = (-1.39e-6 * T + 1.847e-3)*API+6.32e-4*T+0.352
- Parameters:
API –
temperature –
:return:(float) specific heat capacity of crude oil (unit = btu/lb/degF)
- unsat_formation_volume_factor(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
The formation volume factor is defined as the ratio of the volume of oil (plus the gas in solution) at the prevailing reservoir temperature and pressure to the volume of oil at standard conditions
- Returns:
(float) unsaturated formation volume factor (unit = fraction)
- volume_energy_density(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
Calculate oil volume energy density
- Parameters:
stream –
oil_specific_gravity –
gas_specific_gravity –
gas_oil_ratio –
:return:(float) volume energy density (unit = mmBtu/bbl)
- volume_flow_rate(stream, oil_specific_gravity, gas_specific_gravity, gas_oil_ratio)¶
Calculate the oil volume flow rate
- Parameters:
stream –
oil_specific_gravity –
gas_specific_gravity –
gas_oil_ratio –
:return:(float) oil volume flow rate (unit = bbl/day)
- opgee.thermodynamics.Pc(component, with_units=True)¶
- Parameters:
component –
with_units – (bool) whether to return a pint.Quantity()
:return:(pint.Quantity or float) critical pressure, with unit=”Pa” if
with_units.
- opgee.thermodynamics.Tc(component, with_units=True)¶
- Parameters:
component –
with_units – (bool) whether to return a pint.Quantity()
- Returns:
(float) critical temperature (unit = kelvin)
- opgee.thermodynamics.Tsat(component, Psat, with_units=True)¶
- Parameters:
Psat – saturated pressure (unit in Pa)
component –
with_units – (bool) whether to return a pint.Quantity()
- Returns:
- class opgee.thermodynamics.Water(field)¶
Water class includes the method to calculate water density, water volume flow rate, etc.
- density(temperature=None, pressure=None)¶
water density
- Returns:
(float) water density (unit = kg/m3)
- enthalpy_PT(pressure, temperature, mass_rate)¶
calculate water enthalpy given pressure and temperature
- Parameters:
pressure –
temperature –
mass_rate –
- Returns:
(float) total water enthalpy (unit = MJ/day)
- classmethod heat_capacity(stream)¶
- Parameters:
stream –
- Returns:
(float) water heat capacity (unit = btu/degF/day)
- static saturated_temperature(saturated_pressure)¶
calculate water saturated temperature given the saturated pressure
- Parameters:
saturated_pressure –
- Returns:
(float) water saturated temperature (unit = degF)
- static specific_heat(temperature)¶
- Parameters:
temperature –
:return:(float) water specific heat (unit = btu/lb/degF)
- steam_enthalpy(pressure, steam_quality, mass_rate)¶
calculate steam enthalpy from steam quality
- Parameters:
pressure –
steam_quality –
mass_rate –
- Returns:
- volume_flow_rate(stream)¶
- Parameters:
stream –
- Returns:
(float) water volume flow rate (unit = bbl_water/d)
- class opgee.thermodynamics.WetAir(field)¶
WetAir class represents the composition of wet air. The composition is N2 = 0.774394, O2 = 0.20531, CO2 = 0.000294, H2O = 0.02
- opgee.thermodynamics.heating_value(component, use_LHV=True, with_units=True)¶
Return the lower or higher heating value for the given component, with or without Pint units.
- Parameters:
component – (str) the name of a stream component
use_LHV – (bool) whether to use LHV, else use HHV
with_units – (bool) whether to return a pint.Quantity()
- Returns:
(float or pint.Quantity) lower or higher heating value (unit = joule/mol if with_units)
- opgee.thermodynamics.rho(component, temperature, pressure, phase)¶
Return the density at the given temperature, pressure, and phase for chemical component.
- Parameters:
component – (str) the name of a chemical
temperature –
pressure –
phase –
- Returns: