Dimension Module

The dimension module provides classes for representing physical dimensions.

BaseDimension

class physities.src.dimension.base_dimensions.BaseDimension(value)[source]

Bases: IntEnum

LENGTH = 0
MASS = 1
TEMPERATURE = 2
TIME = 3
AMOUNT = 4
ELECTRIC_CURRENT = 5
LUMINOUS_INTENSITY = 6

The 7 SI base dimensions:

Name

Value

Description

LENGTH

0

Length (meters)

MASS

1

Mass (kilograms)

TEMPERATURE

2

Thermodynamic temperature (kelvin)

TIME

3

Time (seconds)

AMOUNT

4

Amount of substance (moles)

ELECTRIC_CURRENT

5

Electric current (amperes)

LUMINOUS_INTENSITY

6

Luminous intensity (candelas)

Dimension

class physities.src.dimension.dimension.Dimension(*, dimensions_tuple)[source]

Bases: object

Represents physical dimensions using the 7 SI base dimensions.

Thin wrapper around Rust PhysicalDimension.

Parameters:

dimensions_tuple (tuple[float, float, float, float, float, float, float])

property dimensions_tuple: tuple[float, float, float, float, float, float, float]
property length: float
property mass: float
property temperature: float
property time: float
property amount: float
property electric_current: float
property luminous_intensity: float
classmethod new_time(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_length(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_temperature(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_mass(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_amount(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_electric_current(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_luminous_intensity(power=None)[source]
Return type:

Self

Parameters:

power (float)

classmethod new_dimensionless()[source]
Return type:

Self

classmethod new_instance(dimensions_tuple)[source]
Return type:

Self

Parameters:

dimensions_tuple (tuple)

get_dimensions()[source]
Return type:

list[BaseDimension]

get(index)[source]
Return type:

float

Parameters:

index (BaseDimension)

static has_rust_backend()[source]
Return type:

bool

static is_rust_enabled()[source]
Return type:

bool

static enable_rust()[source]
static disable_rust()[source]
__add__(other)[source]
__sub__(other)[source]
__mul__(other)[source]
__eq__(other)[source]

Return self==value.

show_dimension()[source]
Return type:

str

Usage Examples

Creating Dimensions

from physities.src.dimension import Dimension

# Using factory methods
length = Dimension.new_length()
time = Dimension.new_time()
mass = Dimension.new_mass()

# With power
area = Dimension.new_length(power=2)  # L²
inverse_time = Dimension.new_time(power=-1)  # T⁻¹

# Dimensionless
dimensionless = Dimension.new_dimensionless()

# From tuple
velocity = Dimension.new_instance((1, 0, 0, -1, 0, 0, 0))  # L/T

Dimension Operations

from physities.src.dimension import Dimension

length = Dimension.new_length()
time = Dimension.new_time()

# Addition combines exponents (for multiplication of quantities)
velocity = length + (time * -1)  # L¹T⁻¹

# Subtraction (for division of quantities)
acceleration = velocity - time  # L¹T⁻²

# Scalar multiplication (for powers)
area = length * 2  # L²
volume = length * 3  # L³

Accessing Dimension Properties

from physities.src.dimension import Dimension

# Create a force dimension (M·L·T⁻²)
force = Dimension.new_instance((1, 1, 0, -2, 0, 0, 0))

# Access individual exponents
print(force.length)  # 1
print(force.mass)    # 1
print(force.time)    # -2

# Get non-zero dimensions
dims = force.get_dimensions()
# [BaseDimension.LENGTH, BaseDimension.MASS, BaseDimension.TIME]

# Display string
print(force.show_dimension())  # "Lm / t²"

Common Derived Dimensions

from physities.src.dimension import Dimension

# Velocity: L/T
velocity = Dimension.new_instance((1, 0, 0, -1, 0, 0, 0))

# Acceleration: L/T²
acceleration = Dimension.new_instance((1, 0, 0, -2, 0, 0, 0))

# Force: M·L/T²
force = Dimension.new_instance((1, 1, 0, -2, 0, 0, 0))

# Energy: M·L²/T²
energy = Dimension.new_instance((2, 1, 0, -2, 0, 0, 0))

# Power: M·L²/T³
power = Dimension.new_instance((2, 1, 0, -3, 0, 0, 0))

# Pressure: M/(L·T²)
pressure = Dimension.new_instance((-1, 1, 0, -2, 0, 0, 0))