Python implementation of the GERG-88 standard for natural gas properties
Project description
PyGERG
Python implementation of the GERG-88 standard for calculating compression factors and other properties of natural gases. A simple, dependency-free package for gas engineering applications.
Overview
PyGERG provides a complete implementation of the GERG-88 virial equation for calculating compression factors of natural gases using a simplified gas analysis. The GERG-88 standard was developed by the European Group for Gas Research (Groupe Européen de Recherches Gazières) and is widely used in the natural gas industry.
This implementation is based on the original FORTRAN code by J.P.J. Michels & J.A. Schouten from 1991 and has been carefully translated to modern Python with additional error checking, improved documentation, and type annotations.
Features
- Implementation of the GERG-88 virial equation
- Calculation of compression factors for natural gases
- Simplified gas analysis based on just four parameters
- No external dependencies required
- Type-annotated for modern Python development
- Comprehensive error handling and input validation
Installation
Install PyGERG using pip:
pip install pygerg
Usage
The main function sgerg() calculates compression factors using a simplified gas analysis:
from pygerg import sgerg
# Example parameters:
x3 = 0.01 # Mole fraction CO2 (0.0 -> 0.3)
hs = 37.0 # Calorific value in MJ/m^3 (20 -> 48)
rm = 0.7443 # Relative density (0.55 -> 0.9)
x5 = 0.00 # Mole fraction H2 (0.0 -> 0.1)
p = 8.0 # Pressure in bar (0 -> 120)
tc = 15.0 # Temperature in degrees Celsius (-23 -> 65)
# Calculate compression factor and other properties
x2, z, d = sgerg(x3, hs, rm, x5, p, tc)
print(f"Calculated N2 fraction: {x2:.4f}")
print(f"Compression factor Z: {z:.6f}")
print(f"Molar density: {d:.6f} mol/m^3")
For more advanced usage, you can also use the GERG88 class directly:
from pygerg import GERG88
calculator = GERG88()
x2, z, d = calculator.sgerg(x3, hs, rm, x5, p, tc)
Input Parameters
x3: Mole fraction of CO2 (range: 0.0 - 0.3)hs: Calorific value in MJ/m³ (range: 20 - 48)rm: Relative density (range: 0.55 - 0.9)x5: Mole fraction of H2 (range: 0.0 - 0.1)p: Pressure in bar (range: 0 - 120)tc: Temperature in degrees Celsius (range: -23 - 65)
Output Values
x2: Calculated mole fraction of N2z: Compression factord: Molar density in mol/m³
Documentation
The code is fully documented with docstrings and type annotations. You can generate API documentation using tools like Sphinx or access docstrings via Python's built-in help() function:
import pygerg
help(pygerg.sgerg)
Background
The GERG-88 standard is used for calculating thermodynamic properties of natural gases. The algorithm uses a simplified approach based on four key parameters (CO2 content, calorific value, relative density, and H2 content) to determine the full gas composition and calculate compression factors.
This implementation is based on the original work:
- Groupe Européen de Recherches Gazières (GERG)
- Original FORTRAN implementation by J.P.J. Michels & J.A. Schouten, August 16, 1991
- Python conversion by Tijs van der Velden, April 2nd, 2025
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygerg-0.1.0.tar.gz.
File metadata
- Download URL: pygerg-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0647df03ad69205fccf4467dc7938180bd248766c95d0aad2eac3d21e99332fc
|
|
| MD5 |
544b76c841ff13bf4a2ae30a6bc9f7d1
|
|
| BLAKE2b-256 |
9fb5e88efabcbaba0605e61acebf0f3b507fefbf1a5cb1c5a56e8e3e47fb07e8
|
File details
Details for the file pygerg-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pygerg-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b640acc0bb358d20b6ffab1c2e53a3b0ce12484e316c06b6b24246ad2400b9d0
|
|
| MD5 |
4a0e9a93c63408e6631da61c561e74f4
|
|
| BLAKE2b-256 |
03c36f14d7281659b2f59b33cf4ecdac1acb8898dc81427938f6d7275311a77d
|