Skip to main content

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 z_units 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.Pressure(15, 'psi').to('MPag')
<Pressure(0.0020963594, 'MPag')>

Related to gauge pressure, local atmospheric pressure (default: 101325 Pa) can be altered:

>>> from z_units 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


Download files

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

Source Distribution

z_units-0.1.4.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.

z_units-0.1.4-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file z_units-0.1.4.tar.gz.

File metadata

  • Download URL: z_units-0.1.4.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.8.2 CPython/3.10.10

File hashes

Hashes for z_units-0.1.4.tar.gz
Algorithm Hash digest
SHA256 99153990c986488c48b20cc70f6e4d2d9d4b59ada044522c6a0fbc13ab0b24ea
MD5 c4ad08e1e2b04a7a8978eea8b0b5af8b
BLAKE2b-256 a10d267d94237b852cbab6629758e0dfcee0e0765681566f593693d80a970855

See more details on using hashes here.

File details

Details for the file z_units-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: z_units-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.8.2 CPython/3.10.10

File hashes

Hashes for z_units-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b0e2e43292f0a7d40bd61a8435fb9eb29e330dfc50da286260c45ad89ca227f2
MD5 5ffb7550e4dfafdd025f15a917c12314
BLAKE2b-256 77fcd95a8e8e9a5636f6cdcb8f602a93e5982e986d7419583464a2150ede9b95

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