Skip to main content

A simple, full-featured, lightweight CoolProp wrapper for Python

Project description

PyFluids

Python License Coverage Code style: black

A simple, full-featured, lightweight CoolProp wrapper for Python.

Installation

The project gets published on PyPI as pyfluids. For install the latest version using pip:

pip install pyfluids

Quick start

All calculations of thermophysical properties are performed in SI units.

The Fluid class is responsible for pure fluids and binary mixtures, the Mixture class - for mixtures with pure fluids components, the HumidAir class - for humid air.

For Fluid use PureFluids, IncompPureFluids, IncompMixturesMF, IncompMixturesVF enums. For Mixture - list of PureFluids.

To update the fluid state use Input enum (for Fluid and Mixture) or HAInput (for HumidAir) enum and their with_value method (always).

You can also convert an instance of Fluid, Mixture or HumidAir to a JSON string or dictionary using methods to_json and to_dict, respectively.

List of properties

For the Fluid and Mixture instances:

  • compressibility - compressibility factor (-)
  • conductivity - thermal conductivity (W/m/K)
  • critical_pressure - absolute pressure at the critical point (Pa)
  • critical_temperature - absolute temperature at the critical point (K)
  • density - mass density (kg/m3)
  • dynamic_viscosity - dynamic viscosity (Pa*s)
  • enthalpy - mass specific enthalpy (J/kg)
  • entropy - mass specific entropy (J/kg/K)
  • freezing_temperature - temperature at freezing point (for incompressible fluids) (K)
  • internal_energy - mass specific internal energy (J/kg)
  • max_pressure - maximum pressure limit (Pa)
  • max_temperature - maximum temperature limit (K)
  • min_pressure - minimum pressure limit (Pa)
  • min_temperature - minimum temperature limit (K)
  • molar_mass - molar mass (kg/mol)
  • phase - phase
  • prandtl - Prandtl number (-)
  • pressure - absolute pressure (Pa)
  • quality - mass vapor quality (-)
  • sound_speed - sound speed (m/s)
  • specific_heat - mass specific constant pressure specific heat (J/kg/K)
  • surface_tension - surface tension (N/m)
  • temperature - absolute temperature (K)
  • triple_pressure - absolute pressure at the triple point (Pa)
  • triple_temperature - absolute temperature at the triple point (K)

For the HumidAir instances:

  • compressibility - compressibility factor (-)
  • conductivity - thermal conductivity (W/m/K)
  • density - mass density per humid air unit (kg/m3)
  • dew_temperature - dew-point absolute temperature (K)
  • dynamic_viscosity - dynamic viscosity (Pa*s)
  • enthalpy - mass specific enthalpy per humid air (J/kg)
  • entropy - mass specific entropy per humid air (J/kg/K)
  • humidity - absolute humidity ratio (kg/kg d.a.)
  • partial_pressure - partial pressure of water vapor (Pa)
  • pressure - absolute pressure (Pa)
  • relative_humidity - relative humidity ratio (from 0 to 1) (-)
  • specific_heat - mass specific constant pressure specific heat per humid air (J/kg/K)
  • temperature - absolute dry-bulb temperature (K)
  • wb_temperature - absolute wet-bulb temperature (K)

NB. If the required property is not present in the instance of the fluid, then you can add it using the add_props method.

Examples

To calculate the specific heat of saturated water vapour at 101325 Pa:

from pyfluids import Fluid, PureFluids, Input

water_vapour = Fluid(PureFluids.Water)
water_vapour.update(Input.Pressure.with_value(101325), Input.Quality.with_value(1))
print(water_vapour.specific_heat)  # 2079.937085633241

To calculate the dynamic viscosity of propylene glycol aqueous solution with 60 % mass fraction at 101325 Pa and 253.15 K:

from pyfluids import Fluid, IncompMixturesMF, Input

propylene_glycol = Fluid(IncompMixturesMF.MPG, 0.6)
propylene_glycol.update(
    Input.Pressure.with_value(101325), Input.Temperature.with_value(253.15)
)
print(propylene_glycol.dynamic_viscosity)  # 0.13907391053938847

To calculate the density of ethanol aqueous solution (with ethanol 40 % mass fraction) at 200 kPa and 277.15 K:

from pyfluids import Mixture, PureFluids, Input

mixture = Mixture([PureFluids.Water, PureFluids.Ethanol], [0.6, 0.4])
mixture.update(Input.Pressure.with_value(200e3), Input.Temperature.with_value(277.15))
print(mixture.density)  # 883.3922771627759

To calculate the wet bulb temperature of humid air at 99 kPa, 303.15 K and 50 % relative humidity:

from pyfluids import HumidAir, HAInput

humid_air = HumidAir()
humid_air.update(
    HAInput.Pressure.with_value(99e3),
    HAInput.Temperature.with_value(303.15),
    HAInput.RelativeHumidity.with_value(0.5),
)
print(humid_air.wb_temperature)  # 295.0965785590792

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

pyfluids-1.0.2.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

pyfluids-1.0.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file pyfluids-1.0.2.tar.gz.

File metadata

  • Download URL: pyfluids-1.0.2.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for pyfluids-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fe3f00de0ebcff2bfb507d8464a3676d7128f51dbb43427b52790156a6fe2b41
MD5 658e691ab39ebd5703ecaf4423d0cce2
BLAKE2b-256 bbb9a307d927e9fd23d5d0487bae3be551284e78a1b085fe084bf8369fb2c150

See more details on using hashes here.

File details

Details for the file pyfluids-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyfluids-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for pyfluids-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b06c621d3482be5788930c6642f3733938ef6da58d7615f030e29328960719c9
MD5 8d9cf2306f41927c9f6193644d9c185e
BLAKE2b-256 1543af9bbc9701ff0d4c30cd50c5b9896d2934a9d87d55c61693614ec3d36c74

See more details on using hashes here.

Supported by

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