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 of the rod, the mass of the bob, the acceleration of gravity , the angle of the rod with respect to the downwards vertical direction, and the period of the swinging pendulum.
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"
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 τ θ
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, .
The last one is simply the angle and the first one is the sought-after adimensional relation for the period:
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 , respectively, while the rows correspond to the dimensions , 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 of the rod, whose dimension is . Taking the logarithm of this expression, we find
As for the acceleration of gravity, , whose dimension is , we have
Similarly,
One can think of , and as vectors in a three-dimensional space of "dimensions", with 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 quantities in which fundamental (base) dimensions are involved. Then, there are adimensional groups which can be expressed as monomials of the given quantities.
So, the adimensional groups, let's call them as originally done, are found as monomials
By considering the dimesion of the group, and of each parameter, and taking the logarithm of the relation so obtained, we find
Since we want each to be adimensional, we require , hence . Therefore, we would like to solve the system
The parameters have mixed dimensions, so, in order to solve the above system, we rewrite the dimension of each parameter in terms of the fundamental dimensions, say :
where the are suitable powers for each parameter and each dimension. Taking the logarithm, we have
Each vector forms one column of the "parameter-to-dimension" matrix mentioned above:
By substituting the expression (11) for in the system of equations (9), we rewrite the system in matrix form
Now it becomes clear that the solutions form the null space of the matrix . If , 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 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 . In doing so, we find the null space of by looking for the null space of .
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 .
The full pivoting algorithm yields two permutation vectors and , a square lower-triangular matrix , and an upper-triangular matrix such that where and are the permutation matrices associated with the permutation vectors and . 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 for the null space by solving with of the form and of the form .
Hence, we solve
to find , and we solve
to find .
Let us not forget that the columns have been permuted according to the vector . Hence, the columns, which originally corresponded to the (logarithm of the dimension of the) parameters , now correspond to (idem) , respectively. Then, taking this into consideration, equation (9), in this case, takes the form
and
Rewriting them, we have
Exponentiating them, we finally obtain the two adimensional groups
This concludes the analysis.