Buckingham-Pi Theorem and the UnitfulBuckinghamPi.jl package

2 May 2021 | R. Rosa

Introduction

Dimensional analysis is a powerful tool in many areas. It helps in establishing "first-order" approximations to a given problem, in checking for dimensional correctness of certain models, in reducing the number of relevant parameters in models, and so on.

Its basis is the Buckingham-Pi Theorem, which gives conditions, and a recipe, to obtain adimensional groups of parameters from a list of dimensional parameters.

The essence of the proof of the Buckingham-Pi Theorem is the Rank–nullity theorem, from Linear Algebra.

The package rmsrosa/UnitfulBuckinghamPi.jl has been developed with the intent of using the recipe given in the proof of the Buckingham-Pi Theorem, via the Rank-nullity Theorem, to yield the adimensional groups present in a list of parameters.

The package exploits the tools given by the PainterQubits/Unitful.jl package to facilitate handling the dimensional aspects of the quantities, units and dimensions that comprise the list of parameters.

The aim of this article is to briefly discuss the proof of the Buckingham-Pi Theorem and to present the package rmsrosa/UnitfulBuckinghamPi.jl.

The simple pendulum

We illustrate the discussion with the simple pendulum:

simple pendulum

We would like to obtain a relation between the period of the swinging pendulum and the parameters we believe that are relevant to the problem.

In this case, we consider the length \ell of the rod, the mass mm of the bob, the acceleration of gravity gg, the angle θ\theta of the rod with respect to the downwards vertical direction, and the period τ\tau of the swinging pendulum.

Using Unitful.jl to define the parameters

We use PainterQubits/Unitful.jl to define the parameters mentioned above. We define most of them as Unitful.FreeUnits, except the acceleration of gravity, which is a constant and which is given as a Unitful.Quantity.

using Unitful

ℓ = u"m"
g = 9.8u"m/s^2"
m = u"g"
τ = u"s"
θ = u"NoDims"

Feeding the parameters to UnitfulBuckinghamPi.jl

In order to use UnitfulBuckingham.jl to find the adimensional groups, we use the macro @setparameters, to "register" the parameters for the package:

using UnitfulBuckinghamPi

@setparameters ℓ g m τ θ

Finding the adimensional groups with UnitfulBuckinghamPi.jl

With the parameters registered in UnitfulBuckinghamPi.jl, we find the adimensional groups with the function pi_groups():

Π = pi_groups()
2-element Vector{Expr}:
 :(g ^ (1 // 2) * ℓ ^ (-1 // 2) * τ ^ (1 // 1))
 :(θ ^ (1 // 1))

Notice the result is of type Vector{Expr}, with two elements, corresponding to the two adimensional groups obtained from the set of parameters, Π=[Π1,Π2]\Pi = [\Pi_1, \Pi_2].

The last one is simply the angle Π2=θ\Pi_2 = \theta and the first one is the sought-after adimensional relation for the period:

Π1=g1/2τ1/2. \Pi_1 = \frac{g^{1/2} \tau}{\ell^{1/2}}.

How does it work?

During the execution of pi_groups(), the package builds the "parameter-to-dimension" matrix, which associates each parameter to the combination of base dimensions in it:

pdmat = UnitfulBuckinghamPi.parameterdimensionmatrix()
3×5 Matrix{Rational{Int64}}:
 0  -2  0  1  0
 0   0  1  0  0
 1   1  0  0  0

Notice this is a Matrix of Rational elements. The double slash means division, for Rational elements. Rational elements are used to avoid floating point errors messing up with the powers.

The columns correspond to the parameters ,g,m,τ,θ\ell, g, m, τ, θ, respectively, while the rows correspond to the dimensions T,M,LT, M, L, standing for time, mass and length. The coefficients of the matrix are the powers of each dimension in each parameter.

The coefficients of this matrix can also be seen as the multiplicative factors in the log-log relation between the dimensions and the parameters. More precisely, let us take the length \ell of the rod, whose dimension is []=L=T0L1M0[\ell] = L = T^0 L^1 M^0. Taking the logarithm of this expression, we find

log[]=0logT+0logM+1logL=(0,0,1)(logTlogMlogL). \log[\ell] = 0 \log T + 0 \log M + 1 \log L = (0, 0, 1) \left(\begin{matrix} \log T \\ \log M \\ \log L \end{matrix}\right).

As for the acceleration of gravity, gg, whose dimension is [g]=L/T=T2L1M0[g] = L/T = T^{-2} L^1 M^0, we have

log[g]=2logT+0logM+1logL=(2,0,1)(logTlogMlogL). \log[g] = -2 \log T + 0 \log M + 1 \log L = (-2, 0, 1) \left(\begin{matrix} \log T \\ \log M \\ \log L\end{matrix}\right).

Similarly,

log[m]=0logT+1logM+0logL=(0,1,0)(logTlogMlogL). \log[m] = 0 \log T + 1 \log M + 0 \log L = (0, 1, 0) \left(\begin{matrix} \log T \\ \log M \\ \log L \end{matrix}\right). log[τ]=1logT+0logM+0logL=(1,0,0)(logTlogMlogL). \log[\tau] = 1 \log T + 0 \log M + 0 \log L = (1, 0, 0) \left(\begin{matrix} \log T \\ \log M \\ \log L\end{matrix}\right). log[θ]=0logT+0logM+0logL=(0,0,0)(logTlogMlogL). \log[\theta] = 0 \log T + 0 \log M + 0 \log L = (0, 0, 0) \left(\begin{matrix} \log T \\ \log M \\ \log L\end{matrix}\right).

One can think of log[],log[g],log[m],log[τ]\log[\ell], \log[g], \log[m], \log[\tau], and log[θ]\log[\theta] as vectors in a three-dimensional space of "dimensions", with {logT,logM,logL}\{\log T, \log M, \log L\} being a basis for this space, and with the expressions above as the representation of those vectors in this basis.

The matrix whose rows are composed of the representation of those vectors in this basis is our "parameter-to-dimension" matrix.

Note, however, that this log-log relation is an informal way of addressing the powers of the dimensions involved in a dimensional group. The logarithm is, in principle, only defined for nondimensional quantities. We can very well arrive at the results below by working directly with the powers.

Now, the Buckingham-Pi Theorem states that

Theorem (Buckingham-Pi) Consider a system with nn quantities in which mm fundamental (base) dimensions are involved. Then, there are nmn-m adimensional groups which can be expressed as monomials of the given quantities.

So, the adimensional groups, let's call them π1,,πnm\pi_1, \ldots, \pi_{n-m} as originally done, are found as monomials

πj=q1a1jqnanj,j=1,,nm. \pi_j = q_1^{a^j_1}\cdots q_n^{a^j_n}, \quad j=1, \ldots, n-m.

By considering the dimesion of the group, and of each parameter, and taking the logarithm of the relation so obtained, we find

log[πj]=a1jlog[q1]++anjlog[qn],j=1,,nm. \log[\pi_j] = a^j_1\log[q_1] + \cdots + a^j_n \log[q_n], \quad \quad j=1, \ldots, n-m.

Since we want each πj\pi_j to be adimensional, we require [πj]=1[\pi_j] = 1, hence log[πj]=0\log[\pi_j] = 0. Therefore, we would like to solve the system

a1jlog[q1]++anjlog[qn]=0,j=1,,nm. a^j_1\log[q_1] + \cdots + a^j_n \log[q_n] = 0, \qquad \quad j=1, \ldots, n-m.

The parameters have mixed dimensions, so, in order to solve the above system, we rewrite the dimension [qi][q_i] of each parameter in terms of the fundamental mm dimensions, say D1,,DmD_1, \ldots, D_m:

[qi]=D1β1iDmβmi, [q_i] = D_1^{\beta_1^i}\ldots D_m^{\beta_m^i},

where the βji\beta_j^i are suitable powers for each parameter and each dimension. Taking the logarithm, we have

log[qi]=β1ilogD1++βmilogDm. \log[q_i] = \beta_1^i \log D_1 + \ldots + \beta_m^i \log D_m.

Each vector (βji)j=1m(\beta_j^i)_{j=1}^m forms one column of the "parameter-to-dimension" matrix mentioned above:

A=[β11β1nβm1βmn]. A = \left[ \begin{matrix} \beta_1^1 & \ldots & \beta_1^n \\ \vdots & & \vdots \\ \beta_m^1 & \ldots & \beta_m^n \end{matrix}\right].

By substituting the expression (11) for log[qi]\log[q_i] in the system of equations (9), we rewrite the system in matrix form

[β11β1nβm1βmn](a1janj)=(00). \left[ \begin{matrix} \beta_1^1 & \ldots & \beta_1^n \\ \vdots & & \vdots \\ \beta_m^1 & \ldots & \beta_m^n \end{matrix}\right] \left(\begin{matrix} a^j_1 \\ \vdots \\ a^j_n \end{matrix}\right) = \left(\begin{matrix} 0 \\ \vdots \\ 0 \end{matrix}\right).

Now it becomes clear that the solutions form the null space of the matrix AA. If n>mn>m, there are infinitely many solutions. There are, correspondingly, infinitely many adimensional groups. What we can do is to select just a few, just enough to span the whole null space. This will give us a "minimal" set of adimensional groups.

Hence, what we need is to find a basis for the null space. This may be obtained in several ways, by factoring AA in one of many forms, such as QR, LU, SVG, and so on.

However, since we want to preserve the Rational type of the elements of the "parameter-to-dimension" matrix, we choose to perform an LU factorization of the matrix AA. In doing so, we find the null space of AA by looking for the null space of UU.

Of course, any decent computer language used in Scientific Computing has implementation for several different factorizations. The difficulty, however, is to find one that supports Rational types and for which the LU decomposition preserves this type. Such an LU factorization is available in the standard LinearAlgebra package of the Julia programming language.

The only problem, however, is that this implementation of the LU factorization does not include full pivoting, only row pivoting. This means the factorization may fail when the matrix is singular and needs column pivoting.

In order to overcome this problem, we implement, in UnitfulBuckinghamPi.jl, our own LU factorization, with full pivoting. And we take care of preserving the eltype of the matrix AA.

The full pivoting algorithm yields two permutation vectors p\vec{p} and q\vec{q}, a square m×mm\times m lower-triangular matrix LL, and an upper-triangular m×nm\times n matrix UU such that LU=PAQ,LU = PAQ, where PP and QQ are the permutation matrices associated with the permutation vectors p\vec{p} and q\vec{q}. In Julia vector/matrix notation, this is the same as L*U = A[p;q].

Going back to the matrix pdmat obtained for the simple pendulum problem above, we perform the factorization

L, U, p, q = UnitfulBuckinghamPi.lu_pq(pdmat)

Then, we obtain the matrix L:

3×3 Matrix{Rational{Int64}}:
   1    0  0
 -1//2  1  0
   0    0  1

The matrix U:

3×5 Matrix{Rational{Int64}}:
 -2  0  0   1    0
  0  1  0  1//2  0
  0  0  1   0    0

The permutation vector p:

3-element Vector{Int64}:
 1
 3
 2

And the permutation vector q:

5-element Vector{Int64}:
 2
 1
 3
 4
 5

By looking at the matrix U, we see that the first three columns are linearly independent, while column four is a linear combination of the first two and the fifth column is plain zero. Hence, U has full rank three, and null space with dimension two. We may find a basis {vα,vβ}\{\vec{v}_\alpha, \vec{v}_\beta\} for the null space by solving Uv=0U\vec{v} = 0 with v=vα\vec{v} = \vec{v}_\alpha of the form vα=(v1,v2,v3,1,0)\vec{v}_\alpha = (v_1,v_2,v_3,1,0) and v=vβ\vec{v} = \vec{v}_\beta of the form vβ=(v1,v2,v3,0,1)\vec{v}_\beta = (v_1, v_2, v_3, 0, 1).

Hence, we solve

[200010001](v1v2v3)=(11/20), \left[ \begin{matrix} -2 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{matrix}\right] \left(\begin{matrix} v_1 \\ v_2 \\ v_3 \end{matrix} \right) = - \left(\begin{matrix} 1 \\ 1/2 \\ 0 \end{matrix}\right),

to find vα=(1/2,1/2,0,1,0)\vec{v}_\alpha = (1/2, -1/2, 0, 1, 0), and we solve

[200010001](v1v2v3)=(000), \left[ \begin{matrix} -2 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{matrix}\right] \left(\begin{matrix} v_1 \\ v_2 \\ v_3 \end{matrix} \right) = - \left(\begin{matrix} 0 \\ 0 \\ 0 \end{matrix}\right),

to find vβ=(0,0,0,0,1)\vec{v}_\beta = (0, 0, 0, 0, 1).

Let us not forget that the columns have been permuted according to the vector q=(2,1,3,4,5)\vec{q} = (2,1,3,4,5). Hence, the columns, which originally corresponded to the (logarithm of the dimension of the) parameters ,g,m,τ,θℓ, g, m, τ, θ, now correspond to (idem) g,,m,τ,θg, ℓ, m, τ, θ, respectively. Then, taking this into consideration, equation (9), in this case, takes the form

(1/2)log[g]+(1/2)log[]+(0)log[m]+(1)log[τ]+(0)log[θ]=0 (1/2) \log[g] + (-1/2) \log[\ell] + (0)\log[m] + (1)\log[\tau] + (0)\log[\theta] = 0

and

(0)log[g]+(0)log[]+(0)log[m]+(0)log[τ]+(1)log[θ]=0. (0) \log[g] + (0) \log[\ell] + (0)\log[m] + (0)\log[\tau] + (1)\log[\theta] = 0.

Rewriting them, we have

(1/2)log[g]+(1/2)log[]+(1)log[τ]=0,log[θ]=0. (1/2) \log[g] + (-1/2) \log[\ell] + (1)\log[\tau] = 0, \qquad \log[\theta] = 0.

Exponentiating them, we finally obtain the two adimensional groups

Π1=g1/2τ1/2,Π2=θ. \Pi_1 = \frac{g^{1/2}\tau}{\ell^{1/2}}, \qquad \Pi_2 = \theta.

This concludes the analysis.