Skip to main content

physu

A modular Python physics library with strict unit and dimensional validation powered by Pint.

Features

  • Strict dimensional safety: Rejects incompatible dimensions (such as mass where velocity is expected) via pint.DimensionalityError.
  • Physical domain validation: Rejects non-physical inputs (negative time, zero radius, unreachable trajectories, NaN, or non-finite values) via PhysicalDomainError (a ValueError subclass).
  • Centralized UnitRegistry: Shares a single physu.ureg across all modules and normalizes strings ("72 km/h"), physu.ureg quantities, and quantities from external Pint registries.
  • Clean SI outputs: Calculations return normalized SI pint.Quantity objects that can be converted to any compatible unit with .to(...).

Installation

pip install physu

For local development (including pytest, ruff, and mypy):

pip install -e ".[dev]"

Requires Python >= 3.10.

Examples

Runnable scripts covering every module and submodule live in examples/:

Modules

  • physu.units: Centralized ureg, Quantity, to_quantity, check_dimension, convert_to, to_si, and to_unit.
  • physu.exceptions: PhysuError and PhysicalDomainError.
  • physu.validation: validate_quantity, require_non_negative, require_positive, require_non_zero, and require_range.
  • physu.constants: Fundamental SI / CODATA 2022 constants (STANDARD_GRAVITY, SPEED_OF_LIGHT, GRAVITATIONAL_CONSTANT, PLANCK_CONSTANT, ELEMENTARY_CHARGE, BOLTZMANN_CONSTANT, AVOGADRO_CONSTANT, MOLAR_GAS_CONSTANT, STANDARD_ATMOSPHERE, ELECTRON_MASS, PROTON_MASS, VACUUM_PERMITTIVITY, VACUUM_PERMEABILITY).
  • physu.kinematics:
    • uniform: MRU (displacement, position, average_velocity, travel_time)
    • accelerated: MRUA / SUVAT (final_velocity, displacement, position, displacement_from_velocities, acceleration, torricelli_velocity, time_to_velocity, time_to_displacement)
    • vertical: Free fall and vertical throw (vertical_position, vertical_velocity, free_fall_distance, free_fall_speed, free_fall_time, time_to_peak, max_height, time_to_height)
    • projectile: 2D projectile motion (velocity_components, projectile_flight_time, projectile_max_height, projectile_range, projectile_position, projectile_velocity)
    • circular: Uniform circular motion (tangential_speed, angular_velocity_from_speed, centripetal_acceleration, period_from_frequency, frequency_from_period, angular_velocity_from_period, angular_velocity_from_frequency, period_from_angular_velocity, frequency_from_angular_velocity, angular_displacement, arc_length)
  • physu.dynamics:
    • newton: Newton's laws, weight, and inclined planes (force, acceleration, mass, weight, inclined_parallel_force, inclined_normal_force)
    • friction: Static and kinetic friction (max_static_friction, kinetic_friction, friction_coefficient, normal_force, critical_incline_angle)
    • elasticity: Hooke's law and springs (spring_force, spring_force_magnitude, spring_constant, spring_displacement, series_spring_constant, parallel_spring_constant)
    • momentum: Linear momentum, impulse, and 1D collisions (linear_momentum, impulse, momentum_change, average_force, collision_velocities, elastic_collision_velocities, inelastic_collision_velocity)
    • gravitation: Universal gravitation and circular dynamics (gravitational_force, gravitational_field_strength, orbital_speed, centripetal_force)

Development

pytest
ruff check src tests
mypy src

License

MIT

Metadata

Release files for physu 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for physu 0.2.0
File Size Uploaded Provenance Actions
physu-0.2.0.tar.gz 26.9 kB Without provenance Details for physu-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for physu 0.2.0
File Interpreter ABI Platform Actions
physu-0.2.0-py3-none-any.whl Python 3 none any Details for physu-0.2.0-py3-none-any.whl

Total release size: 52.8 kB

Release files / physu-0.2.0.tar.gz

Download URL physu-0.2.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7ee09432f1cde364588a2a7d04d2a4129aa45f5bb5ddc01154f93d3690e9738b
BLAKE2b-256 checksum
How to use checksums
563628c7ebed89303bcd0776c5f94cfe3cf6760b807c7684523f82069e2ce4a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / physu-0.2.0-py3-none-any.whl

Download URL physu-0.2.0-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7277f3d53992c6a68c9775db397e4bc737dd5a3f99c0cae3944c6a1b65d8b5f6
BLAKE2b-256 checksum
How to use checksums
b90832c95d4e8a2a6176c948a8fde2f473b0123718e2afefb807f51b218683b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for physu 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page