GasOptics is a Python library designed to calculate thermodynamic and transport properties of gases. With the introduction of the GasProperties
class, the library now provides a streamlined interface for handling various gas properties under different conditions, along with robust unit conversion capabilities.
- The
GasProperties
Class:- Unified interface for calculating gas properties.
- Dynamic updates to conditions without reinitialization.
- Support for unit conversions using
UnitConverter
.
- Thermal Conductivity Calculations:
- Added support for thermal conductivity (
λ
) calculations for gases and humid air.
- Added support for thermal conductivity (
- Enhanced Unit Handling:
- Seamless input and output unit conversion for temperature, pressure, enthalpy, and more.
- Refactored Codebase:
- Modularized structure for easier maintenance and extensibility.
- Dynamic Property Calculations:
- Specific Heat: ( C_p, C_v )
- Density: ( \rho )
- Dynamic Viscosity: ( \mu )
- Enthalpy: ( h )
- Entropy: ( s )
- Heat Capacity Ratio: ( \gamma )
- Thermal Conductivity: ( \lambda )
- Update Conditions Dynamically:
- Change temperature, pressure, or relative humidity without reinitialization.
- Unit Conversion:
- Flexible input and output unit handling for consistent results.
pip install gasoptics
- Clone the repository:
git clone https://github.com/karimialii/gasoptics.git
- Navigate into the project directory:
cd gasoptics
- Install the package:
pip install .
- Python 3.x
- NumPy
The GasProperties
class provides a convenient interface to calculate various thermodynamic and transport properties of gases.
from gasoptics.properties import GasProperties
# Set global units
GasProperties.set_unit(T="C", p="bar", h="kJ")
# Create a GasProperties instance
props = GasProperties(T=25, p=1, RH=0.5, T_unit="C") # 25°C, 1 bar, 50% RH
# Calculate properties
cp = props.cp()
rho = props.rho()
mu = props.mu()
print(f"Specific Heat (cp): {cp:.2f} kJ/kg·K")
print(f"Density (rho): {rho:.3f} kg/m³")
print(f"Viscosity (mu): {mu:.6f} Pa·s")
# Update conditions dynamically
props.update_conditions(T=30, p=1.5, RH=0.6, T_unit="C")
# Recalculate properties
cp_updated = props.cp()
rho_updated = props.rho()
print(f"Updated Specific Heat (cp): {cp_updated:.2f} kJ/kg·K")
print(f"Updated Density (rho): {rho_updated:.3f} kg/m³")
Method | Description |
---|---|
cp() |
Specific heat at constant pressure (( C_p )). |
cv() |
Specific heat at constant volume (( C_v )). |
rho() |
Density (( \rho )). |
h() |
Enthalpy (( h )). |
s() |
Entropy (( s )). |
gamma() |
Heat capacity ratio (( \gamma )). |
k() |
Thermal conductivity (( \lambda )). |
mu() |
Dynamic viscosity (( \mu )). |
Run the test suite to validate functionality:
pytest tests/
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature
- Make your changes and commit:
git commit -am "Add new feature"
- Push to your branch:
git push origin feature/your-feature
- Submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.