PSDimensionality

Submitted by grandinetti on Tue, 11/08/2011 - 16:46

Dimensionality

In the SI System seven reference quantities are used to define seven dimensions whose symbols are given below.

Reference Quantity Dimension Symbol
length L
mass M
time T
electric current I
thermodynamic temperature ${\Theta}$
amount of substance N
luminous intensity J

The dimensionality of any physical quantity, $q$, can then be expressed in terms of the seven reference dimensions in the form of a dimensional product \begin{equation} \mbox{dim} \, q = \text{L}^\alpha \text{M}^\beta \text{T}^\gamma \text{I}^\delta{\Theta}^\epsilon \text{N}^\zeta \text{J}^\eta, \end{equation} where the lower case greek symbols represent integers called the dimensional exponents. Dimensionality can also be represented as a point in the space of dimensional exponents $(\alpha, \beta, \gamma, \delta, \epsilon, \zeta, \eta)$. Physical quantities with different meanings can have the same dimensionality. For example, the thermodynamic quantities entropy and heat capacity are different physical quantities having the same physical dimensions. Only physical quantities with the same dimensionality can be added. With the operation of multiplication the physical dimensions form a group.

There also exists dimensionless quantities, such as the angle which has dimensionality of $\text{L}/\text{L}$, or the solid angle with a dimensionality of $\text{L}^2/\text{L}^2$. Representing such dimensionalities requires us to split each dimension exponent into numerator and denominator exponents. Thus, we keep track of these possibilities in PhySy by defining \begin{equation} \mbox{dim} \, q = \left[\frac{\text{L}^{\alpha_+}}{\text{L}^{\alpha_-}} \right] \cdot \left[\frac{\text{M}^{\beta_+}}{\text{M}^{\beta_-}} \right] \cdot \left[\frac{\text{T}^{\gamma_+}}{\text{T}^{\gamma_-}} \right] \cdot \left[\frac{\text{I}^{\delta_+}}{\text{I}^{\delta_-}} \right] \cdot \left[\frac{{\Theta}^{\epsilon_+}}{{\Theta}^{\epsilon_-}} \right] \cdot \left[\frac{\text{N}^{\zeta_+}}{\text{N}^{\zeta_-}} \right] \cdot \left[\frac{\text{J}^{\eta_+}}{\text{J}^{\eta_-}} \right]. \end{equation}

Dimensionalities in PhySy

Dimensionalities in PhySy can be obtained simply with the identifier of the physical quantity. For example,

PSDimensionalityRef force = PSDimensionalityForQuantity(kPSQuantityForce); 
A full list of identifiers can be found here

A dimensionality is displayed in the terminal using

PSDimensionalityShow(force);

which would display

 L•M/T^2

Another way to obtain a dimensionality is using any combination of the symbols for the seven base dimensions, length, mass, time, current, temperature, amount, and luminous intensity, which are L, M, T, I, ϴ, N, and J, respectively. For example,

PSDimensionalityRef acceleration = PSDimensionalityForSymbol(CFSTR("L/T^2")); 

Additionally, one can create a new dimensionality through the mathematical operations of multiplication, division, and exponentiation. For example,

PSDimensionalityRef mass = PSDimensionalityByDividing(force,acceleration); 
PSDimensionalityShow(mass);
would display
M

As an example of multiplication,

PSDimensionalityRef distance = PSDimensionalityForQuantity(kPSQuantityDistance);
PSDimensionalityRef work = PSDimensionalityByMultiplying(force, distance);
PSDimensionalityShow(work);
would display
L^2•M/T^2
and raising to a power,
PSDimensionalityRef area = PSDimensionalityByRaisingToAPower(distance, 2);
PSDimensionalityShow(area);
would display
L^2

In the three functions, PSDimensionalityByMultiplying, PSDimensionalityByDividing, and PSDimensionalityByRaisingToAPower, the numerator and denominator exponents of the returned dimensionality are always reduced to their lowest possible integer values consistent with the dimensionality of the result. If desired, this reduction of numerator and denominator exponents can be avoided with the otherwise identical functions, PSDimensionalityByMultiplyingWithoutReducing, PSDimensionalityByDividingWithoutReducing, and PSDimensionalityByRaisingToAPowerWithoutReducing.

This ability is can be quite useful when dealing with dimensionless quantities. For example, the function call

PSDimensionalityRef angle = PSDimensionalityByDividing(distance,distance);
would result in
PSDimensionalityShow(angle);
displaying
1

Likewise, the function call

PSDimensionalityRef solidAngle = PSDimensionalityByDividing(area,area);
would result in
PSDimensionalityShow(solidAngle);
also displaying
1

Both of these operations returned the same dimensionless dimensionality, i.e., 1. If we instead call

PSDimensionalityRef angleDerived = PSDimensionalityByDividingWithoutReducing(distance,distance);
PSDimensionalityRef solidAngleDerived = PSDimensionalityByDividingWithoutReducing(area,area);
then, calling
PSDimensionalityShow(angleDerived); 
would return
L/L
and calling
PSDimensionalityShow(solidAngleDerived);
would return
L^2/L^2

Thus, while the result of

PSDimensionalityEqual(angle,solidAngle);
is true, the result of
PSDimensionalityEqual(angleDerived,solidAngleDerived);
is false.

On the other hand, the results of both

PSDimensionalityHasSameReducedDimensionality(angle,solidAngle);
and
PSDimensionalityHasSameReducedDimensionality(angleDerived,solidAngleDerived);
are true.

Testing if a dimensionality is dimensionless is accomplished with the function:

PSDimensionalityIsDimensionless(angleDerived);
which, in this context, would return true

PhySy uses a Flyweight design pattern for PSDimensionality. As such, there is no need for memory management of PSDimensionality instances. Notice that there is no create nor copy functions. PhySy maintains an internal library of PSDimensionality instances and, for a given dimensionality, PhySy will always return the same pointer reference. When a dimensionality is requested that doesn't exist in the library, PhySy will create and add that instance to the library. Therefore, there is no need to send a CFRetain or CFRelease to any PSDimensionality.

See the full API of PSDimensionality here.