Skip to main content

A library for thermodynamic and transport property calculations of gases.

Project description


GasOptics

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.


What's New in Version 0.3.1

  • 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.
  • Enhanced Unit Handling:
    • Seamless input and output unit conversion for temperature, pressure, enthalpy, and more.
  • Refactored Codebase:
    • Modularized structure for easier maintenance and extensibility.

Features

The GasProperties Class

  • 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.

Installation

Option 1: Install from PyPI

pip install gasoptics

Option 2: Install from Source

  1. Clone the repository:
    git clone https://github.com/karimialii/gasoptics.git
    
  2. Navigate into the project directory:
    cd gasoptics
    
  3. Install the package:
    pip install .
    

Requirements

  • Python 3.x
  • NumPy

Usage

Using GasProperties

The GasProperties class provides a convenient interface to calculate various thermodynamic and transport properties of gases.

Example 1: Basic Usage

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")

Example 2: Dynamic Updates

# 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³")

Available Methods in GasProperties

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 )).

Tests

Run the test suite to validate functionality:

pytest tests/

Contributing

Contributions are welcome! Follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature/your-feature
    
  3. Make your changes and commit:
    git commit -am "Add new feature"
    
  4. Push to your branch:
    git push origin feature/your-feature
    
  5. Submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gasoptics-0.3.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gasoptics-0.3.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file gasoptics-0.3.1.tar.gz.

File metadata

  • Download URL: gasoptics-0.3.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for gasoptics-0.3.1.tar.gz
Algorithm Hash digest
SHA256 941983af9db5513b956515f1bdf821a80cc153d55751463540b52dac24185be8
MD5 d783b8b7502ab5f811d8696077042f7b
BLAKE2b-256 dcd991aa6cc25360ad167137f5b2913b1bdbd26a102691717923ad6667e55bad

See more details on using hashes here.

File details

Details for the file gasoptics-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: gasoptics-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for gasoptics-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8aba35c55d5008ca8d9c29b810329f918d618458cf4d56717d6bbe0ef48cfd36
MD5 81ab62db243765735cf4a1f7c29e411a
BLAKE2b-256 25947ca4dddc30be6dc8c5de4b4703e2b38f5f4e84a0b9df20cfa5ff94508a56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page