Dimensions

The Dimensions submodule is concerned with representing and manipulating physical dimensions.

Unless stated otherwise, all types, functions, and constants defined in the submodule are exported to the global scope.

Alicorn.Dimensions.DimensionType
Dimension

The dimension of a physical quantity.

The dimension is expressed as a collection $(a, b, c, d, e, f, g)$ of powers exponentiating each of the seven basic dimensions of the SI system,

\[\mathrm{M}^a \, \mathrm{L}^b \, \mathrm{T}^c \, \mathrm{I}^d \, \mathrm{\Theta}^e \, \mathrm{N}^f \, \mathrm{J}^g,\]

where

  • $\mathrm{M}$: mass dimension
  • $\mathrm{L}$: length dimension
  • $\mathrm{T}$: time dimension
  • $\mathrm{I}$: electrical current dimension
  • $\mathrm{\Theta}$: temperature dimension
  • $\mathrm{N}$: amount of substance dimension
  • $\mathrm{J}$: luminous intensity dimension

Fields

  • massExponent::Real: exponent $a$ of the mass dimension
  • lengthExponent::Real: exponent $b$ of the length dimension
  • timeExponent::Real: exponent $c$ of the time dimension
  • currentExponent::Real: exponent $d$ of the electrical current dimension
  • temperatureExponent::Real: exponent $e$ of the temperature dimension
  • amountExponent::Real: exponent $f$ of the amount of substance dimension
  • luminousIntensityExponent::Real: exponent $g$ of the luminous intensity dimension

Constructor

Dimension(; M::Real=0, L::Real=0, T::Real=0, I::Real=0, θ::Real=0, N::Real=0, J::Real=0)

Raises Exceptions

  • Core.DomainError: if attempting to initialize any field with an infinite number

Remarks

The constructor converts any exponent to Int if possible.

Examples

Quantities describing an energy are of dimension

\[ \mathrm{M} \, \mathrm{L}^{2} \, \mathrm{T}^{-2}\]

The corresponding Dimension object is:

julia> Dimension(M=1, L=2, T=-2)
Dimension M^1 L^2 T^-2

Calling the constructor without any keyword arguments returns exponents that correspond to a dimensionless quantity:

julia> Dimension()
Dimension 1
source

Methods manipulating Dimensions

Base.:*Method
Base.:*(number::Number, dimension::Dimension)
Base.:*(dimension::Dimension, number::Number)

Multiply each exponent in dimension by number.

If a quantity Q is of dimension D, then Q^p is of dimension p * D.

Example

Let us consider a quantity Q of dimension 'length':

julia> ucat = UnitCatalogue() ;

julia> Q = 2 * ucat.meter
2 m

julia> D = dimensionOf(Q)
Dimension L^1

If we raise Q to the power of 3, it has dimension $L^3$ which can be represented by 3 * D:

julia> D2 = dimensionOf(Q^3)
Dimension L^3

julia> D2 == 3 * D
true
source
Base.:*Method
Base.:*(dimension1::Dimension, dimension2::Dimension)

Add each exponent in dimension1 to its counterpart in dimension2.

If a quantity Q1 (Q2) is of dimension D1 (D2), then Q1 * Q2 is of dimension D1 * D2.

Example

julia> ucat = UnitCatalogue() ;

julia> Q1 = 2 * ucat.meter
2 m

julia> D1 = dimensionOf(Q1)
Dimension L^1

julia> Q2 = 3 / ucat.second
3 s^-1

julia> D2 = dimensionOf(Q2)
Dimension T^-1

julia> D = dimensionOf( Q1 * Q2 )
Dimension L^1 T^-1

julia> D == D1 * D2
true
source
Base.:/Method
Base.:/(dimension1::Dimension, dimension2::Dimension)

Subtract each exponent in dimension2 from its counterpart in dimension1.

If a quantity Q1 (Q2) is of dimension D1 (D2), then Q1 / Q2 is of dimension D1 / D2.

Example

julia> ucat = UnitCatalogue() ;

julia> Q1 = 2 * ucat.meter
2 m

julia> D1 = dimensionOf(Q1)
Dimension L^1

julia> Q2 = 3 / ucat.second
3 s^-1

julia> D2 = dimensionOf(Q2)
Dimension T^-1

julia> D = dimensionOf( Q1 / Q2 )
Dimension L^1 T^1

julia> D == D1 / D2
true
source
Base.invMethod
Base.inv(dimension::Dimension)

Invert a physical dimension.

If a quantity Q is of dimension D, then 1/Q is of dimension inv(D).

source
Base.:^Method
Base.:^(dimension::Dimension, exponent::Number)

Exponentiate a physical dimension.

If a quantity Q is of dimension D, then Q^p is of dimension D^p.

source
Base.sqrtMethod
Base.:sqrt(dimension::Dimension)

Square root a physical dimension.

If a quantity Q is of dimension D, then sqrt(Q) is of dimension sqrt(D).

source
Base.Math.cbrtMethod
Base.:cbrt(dimension::Dimension)

Cubic root a physical dimension.

If a quantity Q is of dimension D, then cbrt(Q) is of dimension cbrt(D).

source