unyt.dimensions module

Dimensions of physical quantities

unyt.dimensions.mass = (mass)

mass

unyt.dimensions.length = (length)

length

unyt.dimensions.time = (time)

time

unyt.dimensions.temperature = (temperature)

temperature

unyt.dimensions.angle = (angle)

angle

unyt.dimensions.current_mks = (current_mks)

current_mks

unyt.dimensions.luminous_intensity = (luminous_intensity)

luminous_intensity

unyt.dimensions.dimensionless = 1

dimensionless

unyt.dimensions.logarithmic = (logarithmic)

logarithmic

unyt.dimensions.base_dimensions = [(mass), (length), (time), (temperature), (angle), (current_mks), 1, (luminous_intensity), (logarithmic)]

A list of all of the base dimensions

unyt.dimensions.solid_angle = (angle)**2

solid_angle

unyt.dimensions.velocity = (length)/(time)

velocity

unyt.dimensions.acceleration = (length)/(time)**2

acceleration

unyt.dimensions.jerk = (length)/(time)**3

jerk

unyt.dimensions.snap = (length)/(time)**4

snap

unyt.dimensions.crackle = (length)/(time)**5

crackle

unyt.dimensions.pop = (length)/(time)**6

pop

unyt.dimensions.area = (length)**2

area

unyt.dimensions.volume = (length)**3

volume

unyt.dimensions.momentum = (length)*(mass)/(time)

momentum

unyt.dimensions.force = (length)*(mass)/(time)**2

force

unyt.dimensions.tension = (mass)/(time)**2

surface tension

unyt.dimensions.pressure = (mass)/((length)*(time)**2)

pressure

unyt.dimensions.energy = (length)**2*(mass)/(time)**2

energy

unyt.dimensions.power = (length)**2*(mass)/(time)**3

power

unyt.dimensions.flux = (mass)/(time)**3

flux

unyt.dimensions.specific_flux = (mass)/(time)**2

specific_flux

unyt.dimensions.number_density = (length)**(-3)

number_density

unyt.dimensions.density = (mass)/(length)**3

density

unyt.dimensions.angular_momentum = (length)**2*(mass)/(time)

angular_momentum

unyt.dimensions.specific_angular_momentum = (length)**2/(time)

specific_angular_momentum

unyt.dimensions.specific_energy = (length)**2/(time)**2

specific_energy

unyt.dimensions.count_flux = 1/((length)**2*(time))

count_flux

unyt.dimensions.count_intensity = 1/((angle)**2*(length)**2*(time))

count_intensity

unyt.dimensions.luminous_flux = (angle)**2*(luminous_intensity)

luminous_flux

unyt.dimensions.luminance = (luminous_intensity)/(length)**2

luminance

unyt.dimensions.charge_cgs = (length)**(3/2)*sqrt((mass))/(time)

charge_cgs

unyt.dimensions.current_cgs = (length)**(3/2)*sqrt((mass))/(time)**2

current_cgs

unyt.dimensions.electric_field_cgs = sqrt((mass))/(sqrt((length))*(time))

electric_field_cgs

unyt.dimensions.magnetic_field_cgs = sqrt((mass))/(sqrt((length))*(time))

magnetic_field_cgs

unyt.dimensions.electric_potential_cgs = sqrt((length))*sqrt((mass))/(time)

electric_potential_cgs

unyt.dimensions.resistance_cgs = (time)/(length)

resistance_cgs

unyt.dimensions.magnetic_flux_cgs = (length)**(3/2)*sqrt((mass))/(time)

magnetic_flux_cgs

unyt.dimensions.charge = (current_mks)*(time)

charge

unyt.dimensions.charge_mks = (current_mks)*(time)

charge

unyt.dimensions.electric_field = (length)*(mass)/((current_mks)*(time)**3)

electric_field

unyt.dimensions.electric_field_mks = (length)*(mass)/((current_mks)*(time)**3)

electric_field

unyt.dimensions.magnetic_field = (mass)/((current_mks)*(time)**2)

magnetic_field

unyt.dimensions.magnetic_field_mks = (mass)/((current_mks)*(time)**2)

magnetic_field

unyt.dimensions.electric_potential = (length)**2*(mass)/((current_mks)*(time)**3)

electric_potential

unyt.dimensions.electric_potential_mks = (length)**2*(mass)/((current_mks)*(time)**3)

electric_potential

unyt.dimensions.resistance = (length)**2*(mass)/((current_mks)**2*(time)**3)

resistance

unyt.dimensions.resistance_mks = (length)**2*(mass)/((current_mks)**2*(time)**3)

resistance

unyt.dimensions.capacitance = (current_mks)**2*(time)**4/((length)**2*(mass))

capacitance

unyt.dimensions.capacitance_mks = (current_mks)**2*(time)**4/((length)**2*(mass))

capacitance

unyt.dimensions.magnetic_flux = (length)**2*(mass)/((current_mks)*(time)**2)

magnetic_flux

unyt.dimensions.magnetic_flux_mks = (length)**2*(mass)/((current_mks)*(time)**2)

magnetic_flux

unyt.dimensions.inductance = (length)**2*(mass)/((current_mks)**2*(time)**2)

inductance

unyt.dimensions.inductance_mks = (length)**2*(mass)/((current_mks)**2*(time)**2)

inductance

unyt.dimensions.derived_dimensions = [1/(time), (length)/(time), (length)/(time)**2, (length)/(time)**3, (length)/(time)**4, (length)/(time)**5, (length)/(time)**6, (length)*(mass)/(time), (length)*(mass)/(time)**2, (length)**2*(mass)/(time)**2, (length)**2*(mass)/(time)**3, (length)**(3/2)*sqrt((mass))/(time), sqrt((mass))/(sqrt((length))*(time)), sqrt((mass))/(sqrt((length))*(time)), (angle)**2, (mass)/(time)**3, (mass)/(time)**2, (length)**3, (angle)**2*(luminous_intensity), (length)**2, (length)**(3/2)*sqrt((mass))/(time)**2, (current_mks)*(time), (length)*(mass)/((current_mks)*(time)**3), (mass)/((current_mks)*(time)**2), sqrt((length))*sqrt((mass))/(time), (length)**2*(mass)/((current_mks)*(time)**3), (time)/(length), (length)**2*(mass)/((current_mks)**2*(time)**3), (length)**2*(mass)/((current_mks)*(time)**2), (length)**(3/2)*sqrt((mass))/(time), (luminous_intensity)/(length)**2, 1/(length), (angle)/(time)]

a list containing all derived_dimensions

unyt.dimensions.dimensions = [(mass), (length), (time), (temperature), (angle), (current_mks), 1, (luminous_intensity), (logarithmic), 1/(time), (length)/(time), (length)/(time)**2, (length)/(time)**3, (length)/(time)**4, (length)/(time)**5, (length)/(time)**6, (length)*(mass)/(time), (length)*(mass)/(time)**2, (length)**2*(mass)/(time)**2, (length)**2*(mass)/(time)**3, (length)**(3/2)*sqrt((mass))/(time), sqrt((mass))/(sqrt((length))*(time)), sqrt((mass))/(sqrt((length))*(time)), (angle)**2, (mass)/(time)**3, (mass)/(time)**2, (length)**3, (angle)**2*(luminous_intensity), (length)**2, (length)**(3/2)*sqrt((mass))/(time)**2, (current_mks)*(time), (length)*(mass)/((current_mks)*(time)**3), (mass)/((current_mks)*(time)**2), sqrt((length))*sqrt((mass))/(time), (length)**2*(mass)/((current_mks)*(time)**3), (time)/(length), (length)**2*(mass)/((current_mks)**2*(time)**3), (length)**2*(mass)/((current_mks)*(time)**2), (length)**(3/2)*sqrt((mass))/(time), (luminous_intensity)/(length)**2, 1/(length), (angle)/(time)]

a list containing all dimensions

unyt.dimensions.em_dimensions = {(current_mks): (length)**(3/2)*sqrt((mass))/(time)**2, (current_mks)*(time): (length)**(3/2)*sqrt((mass))/(time), (length)**(3/2)*sqrt((mass))/(time): (current_mks)*(time), (length)**(3/2)*sqrt((mass))/(time)**2: (current_mks), (length)**2*(mass)/((current_mks)*(time)**2): (length)**(3/2)*sqrt((mass))/(time), (length)**2*(mass)/((current_mks)*(time)**3): sqrt((length))*sqrt((mass))/(time), (length)**2*(mass)/((current_mks)**2*(time)**3): (time)/(length), (mass)/((current_mks)*(time)**2): sqrt((mass))/(sqrt((length))*(time)), (time)/(length): (length)**2*(mass)/((current_mks)**2*(time)**3), sqrt((length))*sqrt((mass))/(time): (length)**2*(mass)/((current_mks)*(time)**3), sqrt((mass))/(sqrt((length))*(time)): (mass)/((current_mks)*(time)**2)}

a dict containing a bidirectional mapping from mks dimension to cgs dimension

unyt.dimensions.accepts(**arg_units)[source]

Decorator for checking units of function arguments.

Parameters:

arg_units (dict) – Mapping of function arguments to dimensions, of the form ‘arg1’=dimension1 etc where 'arg1' etc are the function arguments and dimension1 etc are SI base units (or combination of units), eg. length/time.

Notes

Keyword args are not dimensionally check, being directly passed to the decorated function.

Function arguments that don’t have attached units can be skipped can bypass dimensionality checking by not being passed to the decorator. See baz in the examples, where a has no units.

Examples

>>> import unyt as u
>>> from unyt.dimensions import length, time
>>> @accepts(a=time, v=length/time)
... def foo(a, v):
...     return a * v
...
>>> res = foo(a= 2 * u.s, v = 3 * u.m/u.s)
>>> print(res)
6 m
>>> @accepts(a=length, v=length/time)
... def bar(a, v):
...     return a * v
...
>>> bar(a= 2 * u.s, v = 3 * u.m/u.s)
Traceback (most recent call last):
...
TypeError: arg 'a=2 s' does not match (length)
>>> @accepts(v=length/time)
... def baz(a, v):
...     return a * v
...
>>> res = baz(a= 2, v = 3 * u.m/u.s)
>>> print(res)
6 m/s
unyt.dimensions.returns(*r_units, r_unit=None)[source]

Decorator for checking function return units.

Parameters:
  • *r_units (sympy.core.symbol.Symbol) – SI base unit (or combination of units), eg. length/time of the value(s) returned by the original function

  • r_unit (sympy.core.symbol.Symbol) – Deprecated version of r_units which supports only one named return value.

Examples

>>> import unyt as u
>>> from unyt.dimensions import length, time
>>> @returns(length)
... def f(a, v):
...     return a * v
...
>>> res = f(a= 2 * u.s, v = 3 * u.m/u.s)
>>> print(res)
6 m
>>> @returns(length/time)
... def f(a, v):
...     return a * v
...
>>> f(a= 2 * u.s, v = 3 * u.m/u.s)
Traceback (most recent call last):
...
TypeError: result '6 m' does not match (length)/(time)
>>> @returns(length, length/time**2)
... def f(a, v):
...     return a * v, v / a
...
>>> res = f(a= 2 * u.s, v = 3 * u.m/u.s)
>>> print(*res)
6 m 1.5 m/s**2