Dimensions#
- class Dimensions(dim_pwrs: list | ndarray)#
Bases:
objectDefines relationships between fundamental physical quantities. Provides dimensional information for the main purpose of creating units.
These quantities are derived from three of the SI unit system’s base units [[1]]: Mass from the kilogram, Length from the meter, and Time from the second. Additionaly, a fourth “dimension” — Angle — is included due to its relevance to many unitary applications despite the inherent non-dimensionality of angles.
Summarily, these quantities are:
Mass
Length
Time
Angle
And their power relations are stored in a 1x4 power vector where each element corresponds to the above dimensions in the same order.
- Parameters:
dim_pwrs (
listornumpy.ndarray) –A 1x4 vector of integers representing the power relations to each of the four physical dimensions defined by the Dimensions class as:
[Mass, Length, Time, Angle]
For example, the power vector of force would be given as:
[1, 1, -2, 0]
Where force is defined as Mass multiplied by Length per Time squared. Angles do not contribute to this dimension and so are given a zero power.
See also
scarabaeus.UnitsUtilizes Dimensions in its construction.
scarabaeus.ArrayWUnitsDependent on Units and Dimensions.
Notes
The property
nameis automatically generated upon intialization as a string that either provides the name of the dimension if one exists (e.g. square length is known as area) or, in the case no name exists, a description of the dimensional relations in words. For example, assume that velocity is not a named dimension:namewould then be assigned'Length per Time'.Dimensions determines if a name exists by mapping the given power vector to one in its internal library of named dimensional combinations. The method
disp_named_dims()displays a formatted list of all existing named dimensions and their respective power vectors.Even if a list is passed to
dim_pwrsas an argument during construction, Dimensions will automatically convert it to annp.arraywhen ingesting and storing to the propertypowers. This means that whenpowersis requested, no matter the type passed on construction, a 1x4np.arraywill always be returned.References
Examples
Dimensions objects can be constructed with
listornp.arrayobjects. The names of Dimensions objects are automatically generated upong construction.>>> import scarabaeus as scb >>> area_dim = scb.Dimensions([0, 2, 0, 0]) # initialize with a list... >>> print(area_dim) # known (named) dimension Area >>> comp_dim = scb.Dimensions(np.array([3, 0, -2, 1])) # ... or a numpy array >>> print(comp_dim) # unnamed compound dimension Cubic Mass times Angle per Square Time
- Attributes:
Methods
def_new_named_dim(name, powers)Adds a new named dimension to the Dimensions library.
Displays all existing named dimensions and their respective dimensional power vectors.
- classmethod def_new_named_dim(name: str, powers: ndarray | list) None#
Adds a new named dimension to the Dimensions library.
- Parameters:
- Return type:
Notes
When defining a new named dimension, remember to follow the naming convention adopted by the class’ built-in named dimensions: capitalize the first letter of each word in name.
Examples
>>> import scarabaeus as scb >>> unnamed = scb.Dimensions([1 ,1, 1, 1]) >>> print(unnamed) # unrecognized dimension Mass times Length times Time times Angle >>> scb.Dimensions.def_new_named_dim('My New Dim', [1, 1, 1, 1]) # add to dim library >>> new_dim = scb.Dimensions([1 ,1, 1, 1]) >>> print(new_dim) # will register as the name we gave it My New Dim
- classmethod disp_named_dims() None#
Displays all existing named dimensions and their respective dimensional power vectors.
Includes base dimensions.
- Return type: