Build Statuscodecov


Dimensionless is a package built on top of Unitful.jl. It contains tools to conduct dimensional analysis.


The following example is taken from the Similitude Wikipedia article:

A free body diagram is constructed and the relevant relationships of force and velocity are formulated using techniques from continuum mechanics. The variables which describe the system are:

VariableApplicationScaled modelUnits
L (Diameter of submarine)11/40(m)
V (Speed)5Calculate(m/s)
ρ (Density)1028998(kg/m^3)
μ (Dynamic viscosity)1.88x10−31.00x10−3Pa·s (N s/m^2)
F (Force)CalculateTo be measuredN (kg m/s^2)

Let's analyze this examplary problem using Dimensionless.jl. We start by calculating the number of dimensions that characterize the problem:

julia> using Dimensionless, Unitful

julia> number_of_dimensions(u"m", u"m/s", u"kg/m^3", u"Pa*s", u"N")

According to Buckinghams π theorem, the problem is governed by two dimensionless numbers (5 variables - 3 dimensions = 2 dimensional numbers):

julia> number_of_dimensionless(u"m", u"m/s", u"kg/m^3", u"Pa*s", u"N")

In order to find the required power of the submarine, we need to find a dimensional basis for the problem. In Dimensionless.jl, this is done by creating a DimBasis. As calculated before, there need to be three linear independent basis vectors to span the dimensional space:

julia> basis = DimBasis(u"m", u"m/s", u"kg/m^3", u"Pa*s") # Invalid basis
ERROR: Invalid basis! There are 4 basis vectors of which only 3 are linear independent.

julia> basis = DimBasis(u"m/s", u"kg/m^3", u"Pa*s") # Valid basis

A valid basis! It can be used to select a set of two dimensionless numbers:

julia> print_dimensionless("v"=>u"m/s", basis)
v L ρ μ^-1

julia> print_dimensionless("F"=>u"N", basis)
F ρ μ^-2

The first found number is the Reynolds number Re and the second found number is the product of the drag coefficient cd and Re2. All equations describing the problem can be scaled using these numbers.

It is possible to add names and quantities to a DimBasis. Let's construct two bases that describe the submarine model and the real submarine:

julia> applications_basis = DimBasis("L"=>1u"m", "ρ"=>1028u"kg/m^3", "μ"=>1.88e-3u"Pa*s")

julia> model_basis = DimBasis("L"=>0.025u"m", "ρ"=>998u"kg/m^3", "μ"=>1e-3u"Pa*s")

It is easy to transform values from one dimensional bases to the other in order to fill the missing values in the table:

julia> v_model = change_basis(5u"m/s", applications_basis, model_basis)
109.58 m s^-1 

julia> change_basis(u"N", model_basis, applications_basis)

julia> P_application_fac = v_model * change_basis(u"W", model_basis, applications_basis)
17.156 m s^-1

In order achieve similarity between the model and the application, the model velocity has to be 109.6 m/s, which is 21.9 times higher than the application velocity. The measured drag forces acting on the model under these circumstances need to be multiplied by 3.4 to determine the drag forces acting on the full scale submarine. The necessary propulsion power equates to Papplication = Fmodel · vmodel · (Papplication/Pmodel) = Fmodel · 17.2 m/s.

As a last point, it is often helpful to be able to remove and restore the dimensions of variables in a given dimensional basis:

julia> dim_vars = (1u"cm/g", 1u"mm/s")
(1 cm g^-1, 1 mm s^-1)

julia> dimless_vars = dimensionless.(dim_vars, model_basis)
(6.2375, 24.95)

julia> dimensionful.(dimless_vars, (u"cm/g", u"mm/s"), model_basis)
(1.0 cm g^-1, 1.0 mm s^-1)