# Dimensions and dimension systems¶

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.

class sympy.physics.units.dimensions.Dimension[source]

This class represent the dimension of a physical quantities.

The Dimension constructor takes as parameters a name and an optional symbol.

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.units import Dimension
>>> length = Dimension('length')
>>> length
Dimension(length)
>>> time = Dimension('time')
>>> time
Dimension(time)


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 / time
>>> velocity
Dimension(length/time)


It is possible to use a dimension system object to get the dimensionsal dependencies of a dimension, for example the dimension system used by the SI units convention can be used:

>>> from sympy.physics.units.systems.si import dimsys_SI
>>> dimsys_SI.get_dimensional_dependencies(velocity)
{'length': 1, 'time': -1}
>>> length + length
Dimension(length)
>>> l2 = length**2
>>> l2
Dimension(length**2)
>>> dimsys_SI.get_dimensional_dependencies(l2)
{'length': 2}

has_integer_powers(dim_sys)[source]

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.

property is_dimensionless

Check if the dimension object really has a dimension.

A dimension should have at least one component with non-zero power.

class sympy.physics.units.dimensions.DimensionSystem(*args, **kwargs)[source]

DimensionSystem represents a coherent set of dimensions.

The constructor takes three parameters:

• base dimensions;

• derived dimensions: these are defined in terms of the base dimensions (for example velocity is defined from the division of length by time);

• dependency of dimensions: how the derived dimensions depend on the base dimensions.

Optionally either the derived_dims or the dimensional_dependencies may be omitted.

property can_transf_matrix

Useless method, kept for compatibility with previous versions.

DO NOT USE.

Return 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().

property dim

Useless method, kept for compatibility with previous versions.

DO NOT USE.

Give the dimension of the system.

That is return the number of dimensions forming the basis.

dim_can_vector(dim)[source]

Useless method, kept for compatibility with previous versions.

DO NOT USE.

Dimensional representation in terms of the canonical base dimensions.

dim_vector(dim)[source]

Useless method, kept for compatibility with previous versions.

DO NOT USE.

Vector representation in terms of the base dimensions.

property inv_can_transf_matrix

Useless method, kept for compatibility with previous versions.

DO NOT USE.

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 defined 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.

property is_consistent

Useless method, kept for compatibility with previous versions.

DO NOT USE.

Check if the system is well defined.

is_dimensionless(dimension)[source]

Check if the dimension object really has a dimension.

A dimension should have at least one component with non-zero power.

property list_can_dims

Useless method, kept for compatibility with previous versions.

DO NOT USE.

List all canonical dimension names.

print_dim_base(dim)[source]

Give the string expression of a dimension in term of the basis symbols.

static sort_dims(dims)[source]

Useless method, kept for compatibility with previous versions.

DO NOT USE.

Sort dimensions given in argument using their str function.

This function will ensure that we get always the same tuple for a given set of dimensions.