Definition of physical dimensions.
Unit systems will be constructed on top of these dimensions.
Most of the examples in the doc use MKS system and are presented from the computer point of view: from a human point, adding length to time is not legal in MKS but it is in natural system; for a computer in natural system there is no time dimension (but a velocity dimension instead) - in the basis - so the question of adding time to length has no meaning.
This class represent the dimension of a physical quantities.
The dimensions may have a name and a symbol. All other arguments are dimensional powers. They represent a characteristic of a quantity, giving an interpretation to it: for example (in classical mechanics) we know that time is different from temperature, and dimensions make this difference (but they do not provide any measure of these quantites).
>>> from sympy.physics.unitsystems.dimensions import Dimension
>>> length = Dimension(length=1)
>>> length
{'length': 1}
>>> time = Dimension(time=1)
Dimensions behave like a dictionary where the key is the name and the value corresponds to the exponent.
Dimensions can be composed using multiplication, division and exponentiation (by a number) to give new dimensions. Addition and subtraction is defined only when the two objects are the same dimension.
>>> velocity = length.div(time)
>>> velocity
{'length': 1, 'time': -1}
>>> length.add(length)
{'length': 1}
>>> length.pow(2)
{'length': 2}
Defining addition-like operations will help when doing dimensional analysis.
Note that two dimensions are equal if they have the same powers, even if their names and/or symbols differ.
>>> Dimension(length=1) == Dimension(length=1, name="length")
True
>>> Dimension(length=1) == Dimension(length=1, symbol="L")
True
>>> Dimension(length=1) == Dimension(length=1, name="length",
... symbol="L")
True
Define the addition for Dimension.
Addition of dimension has a sense only if the second object is the same dimension (we don’t add length to time).
Check if the dimension object has only integer powers.
All the dimension powers should be integers, but rational powers may appear in intermediate steps. This method may be used to check that the final result is well-defined.
DimensionSystem represents a coherent set of dimensions.
In a system dimensions are of three types:
All intermediate computations will use the canonical basis, but at the end one can choose to print result in some other basis.
In a system dimensions can be represented as a vector, where the components represent the powers associated to each base dimension.
Compute the canonical transformation matrix from the canonical to the base dimension basis.
It is the inverse of the matrix computed with inv_can_transf_matrix().
Give the dimension of the system.
That is return the number of dimensions forming the basis.
Extend the current system into a new one.
Take the base and normal units of the current system to merge them to the base and normal units given in argument. If not provided, name and description are overriden by empty strings.
Find a specific dimension which is part of the system.
dim can be a string or a dimension object. If no dimension is found, then return None.
Compute the inverse transformation matrix from the base to the canonical dimension basis.
It corresponds to the matrix where columns are the vector of base dimensions in canonical basis.
This matrix will almost never be used because dimensions are always define with respect to the canonical basis, so no work has to be done to get them in this basis. Nonetheless if this matrix is not square (or not invertible) it means that we have chosen a bad basis.