A simple unit converter for chemical engineers
Project description
z-units
A simple unit-converter for chemical engineers
Feature
- Gauge pressure units (MPag, kPag, psig, ...) are ready for use
- Friendly to HYSYS user
Install
pip install z-units
Quickstart
>>> from zunits import quantity as q
>>> f = q.MolarFlow(3)
>>> f
<MolarFlow(3, 'kmol/s')>
f.value, f.unit
(3, <Unit('kmol/s')>)
>>> f.to('kmol/h')
<MolarFlow(10800.0, 'kmol/h')>
>>> q.Length(100, 'cm') == q.Length(1000, 'mm')
True
>>> q.Temperature('100C')
<Temperature(1, 'C')>
>>> q.Pressure(15, 'psi').to('MPag')
<Pressure(0.0020963594, 'MPag')>
>>> from zunits import convert
>>> convert(1, 'm', 'ft')
<Length(3.2808399, 'ft')>
Related to gauge pressure, local atmospheric pressure (default: 101325 Pa) can be altered:
>>> from zunits import config
# Before
>>> q.Pressure(100, 'kPa').to('kPag')
<Pressure(-1.325, 'kPag')>
# Set to 50e3 Pa (50 kPa)
>>> config.set_local_atmospheric_pressure(50e3)
# After
>>> q.Pressure(100, 'kPa').to('kPag')
<Pressure(50.0, 'kPag')>
Standard temperature (default: 20 degC) can be redefined, affecting standard cubic meter "Sm**3":
# Before
>>> q.Substance(100, 'Nm3').to('Sm3')
<Substance(107.321984, 'Sm3')>
# Set to 15 degC
>>> config.set_standard_temperature(15)
# After
>>> q.Substance(100, 'Nm3').to('Sm3')
<Substance(105.491488, 'Sm3')>
Format quantity to string with styles:
# Only value
>>> format(q.MolarEntropy(100))
'100'
# With unit, quick style
>>> format(q.MolarEntropy(100), 'u')
'100 kJ/kmol-C'
# With unit, definition style
>>> format(q.MolarEntropy(100), 'up')
'100 kJ/(kmol*C)'
Predefined Quantities
- Length
- Area
- Volume
- Time
- Mass
- Force
- Substance
- Energy
- Velocity
- Temperature
- DeltaTemperature
- Pressure
- VolumeFlow
- MassDensity
- HeatFlow
- MolarFlow
- MassFlow
- MolarDensity
- MolarHeatCapacity
- MolarEntropy
- MolarHeat
- ThermalConductivity
- Viscosity
- SurfaceTension
- MassHeatCapacity
- MassEntropy
- MassHeat
- StandardGasFlow
- KinematicViscosity
- MolarVolume
- Fraction
- Dimensionless
About it
As a chemical engineer, the Gauge-Pressure units are very useful to me. Unfortunately those units are not supported in some popular modules, so I reinvent the wheel.
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 z_units-0.1.7.tar.gz.
File metadata
- Download URL: z_units-0.1.7.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.15.4 CPython/3.10.12 Linux/6.5.0-1022-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9fb1717bff74b6d22cad3c00cc8711ec5a0c7931496ca907e0ce5799e0802e3
|
|
| MD5 |
984ca1f1d7812e8f0c7f62057a798b5b
|
|
| BLAKE2b-256 |
ae1a981bf15715861731c7131e5aa3fc0e8b51ed38f7aef212a054c486a95d7c
|
File details
Details for the file z_units-0.1.7-py3-none-any.whl.
File metadata
- Download URL: z_units-0.1.7-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.15.4 CPython/3.10.12 Linux/6.5.0-1022-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b510ecede73e0ea6923122ccaf5fc327cd4c6943212808720c4c6ff1016f49d
|
|
| MD5 |
e09b4ac038366098d4af6963d5cf4da6
|
|
| BLAKE2b-256 |
94f8f88372ebb652a0fa65adf62241b1439c0cbf37ca642d4828ae5f0bd1cab1
|