Skip to main content

A Pythonic object-oriented wrapper for CoolProp with property validation and state management

Project description

CoolProp-OOP

An object-oriented wrapper for CoolProp thermodynamic properties. This library provides an intuitive, Pythonic interface to CoolProp's functionality for both humid air and pure fluid property calculations.

Features

  • Object-oriented interface to CoolProp's functionality
  • Property validation to prevent physically impossible states
  • Automatic caching of calculated properties for better performance
  • Support for both Humid Air (StateHA) and Pure Fluids (StatePROPS)
  • Comprehensive state validation with helpful error messages
  • Fully Pythonic API with property-based getters and setters

Installation

pip install coolprop-oop

Usage

Humid Air Properties

from coolprop_oop import StateHA

# Create a state for humid air (OOP style, recommended)
state = StateHA()
state.tempc = 20      # Temperature in °C
state.press = 101325  # Pressure in Pa
state.relhum = 0.5    # Relative humidity (0-1)

# Access properties
print(f"Temperature: {state.tempc:.1f}°C")
print(f"Relative Humidity: {state.relhum * 100:.0f}%")
print(f"Humidity Ratio: {state.humrat:.6f} kg/kg")
print(f"Dew Point: {state.dewpoint - 273.15:.1f}°C")
print(f"Enthalpy: {state.enthalpy:.1f} J/kg")
print(f"Density: {state.density:.4f} kg/m³")

# Check which properties are currently constraining the state
print(f"Constraints: {state.constraints}")  # ['press', 'relhum', 'tempc']

Pure Fluid Properties

from coolprop_oop import StatePROPS

# Create a state for water (OOP style, recommended)
state = StatePROPS(fluid='Water')  # Set fluid first
state.tempc = 100     # Temperature in °C
state.press = 101325  # Pressure in Pa

# Access properties
print(f"Temperature: {state.tempc:.1f}°C")
print(f"Pressure: {state.press/1000:.2f} kPa")
print(f"Density: {state.dens:.2f} kg/m³")
print(f"Enthalpy: {state.enthalpy:.1f} J/kg")
print(f"Quality: {state.quality}")  # None if not in two-phase region

# Get extensive state information
constraints = state.constraints
print(f"Fluid state: {constraints['status']}")  # e.g., 'liquid', 'gas', 'two_phase'
print(f"Set properties: {', '.join(constraints['properties'])}")

Error Handling and Validation

The library automatically validates inputs to prevent physically impossible states:

try:
    state = StateHA()
    state.tempc = -300  # Below absolute zero
except ValueError as e:
    print(f"Error: {e}")  # "Error: Temperature cannot be below absolute zero"

Documentation

For more examples and detailed API documentation, see the examples directory in the GitHub repository.

License

MIT

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

coolprop_oop-1.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

coolprop_oop-1.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file coolprop_oop-1.1.0.tar.gz.

File metadata

  • Download URL: coolprop_oop-1.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for coolprop_oop-1.1.0.tar.gz
Algorithm Hash digest
SHA256 846f223b47b35878d5b7bdbe3c3f3212679d568720561976c3e61c326699e062
MD5 29cc345042ffa815226c84af88ebc8da
BLAKE2b-256 b6a9813844ea7d6b99cefd02a30f4c64cc830bb88746fbc4ca36139d7a27e7d4

See more details on using hashes here.

File details

Details for the file coolprop_oop-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: coolprop_oop-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for coolprop_oop-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4288a18c8cd0579d8169f0a9e9ed6bc3ea03a9da89bb6ce7fd26c1787b47244
MD5 9292ea377492ab0a42a82ff601c0c5fb
BLAKE2b-256 ded66d73bfa31b6008f001e63c5707a7ec8790cbe3c0c729630af69732210f4d

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