Skip to main content

A lightweight, flexible Python library for handling physical units

Project description

DimPyU

A lightweight, flexible Python library for handling physical units, supporting arithmetic operations, dimensional analysis, and smart conversions.

Features

  • Intuitive Syntax: 10 * reg.km or reg.parse("10 km")
  • Arithmetic: Add, substract, multiply, and divide quantities (m/s, kg * m/s^2).
  • Conversions: Easily convert between compatible units (val.to('km')).
  • SI Prefixes: Automatically handles prefixes like micro, giga, nano (e.g. micrometer).
  • Numpy Support: Seamlessly works with Numpy arrays for high-performance calculations on vectors.
  • Physical Constants: Includes standard constants like Speed of Light ($c$), Gravity ($g_0$), etc.

Installation

From Source (Local)

pip install .

From GitHub

You can install directly from your repository:

pip install git+https://github.com/YOUR_USERNAME/dimpyu.git

From PyPI (Coming working)

pip install dimpyu

Usage

from dimpyu import UnitRegistry

# Initialize registry (loads default units)
reg = UnitRegistry()

# 1. Simple Quantity Creation
distance = 10 * reg.km
time = 0.5 * reg.hr
speed = distance / time
print(speed)                # 20.0 km / hr
print(speed.to('m/s'))      # 5.555... m / s

# 2. String Parsing
q = reg.parse("50 kg * m / s^2")
print(q)                    # 50.0 kg m/s^2
print(q.to('N'))            # 50.0 N

# 3. Array / Numpy Support
lengths = [1, 2, 3] * reg.meter
print(lengths.to('cm'))     # [100., 200., 300.] centimeter

# 4. Physical Constants
from dimpyu import constants
energy = constants.h * constants.c / (500 * reg.nm)
print(energy.to('J'))

Project Structure

  • dimpyu/: Core package code.
  • main.py: Demo script.
  • fluid_mechanics_example.py: Example solution for a pump calculation.
  • heat_transfer_example.py: Example solution for a heat transfer problem.

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

dimpyu-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

dimpyu-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file dimpyu-0.1.0.tar.gz.

File metadata

  • Download URL: dimpyu-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for dimpyu-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5e3d65a875007538b5daa6750ddace39bde1e42862969b90141007f619fd017
MD5 ea8fdd6e0d16829ba4e16dd5395638c8
BLAKE2b-256 261868e05895cad7ff45db0194c71fb2f81cd18fcff47e61565c339175269fcd

See more details on using hashes here.

File details

Details for the file dimpyu-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dimpyu-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for dimpyu-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 509731d3aae287b7f5d78ee4b155873e8e1a4be7a630b0d6ef720c771adcef3d
MD5 d3028a1a6b1014336a5354ef8e99dbe2
BLAKE2b-256 fbcc9140e13a3b3dbb66ac604cf3a5ea2b4e6922420f7b0e39b132e8c445763c

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