To begin, we import the package, buckinghampy. I know, the name is terrible.
There is also a submodule of buckinghampy which as a lot of commonly used parameters, though nothing stops you from defining your own parameters.
Finally, we import some IPython display functions which will help with rendering the results.
In [1]:
import buckinghampy
from buckinghampy.parameters import *
As a first application, we would like to find the nondimnensionalization of the basic Navier-Stokes equation:
\begin{equation} \frac{\partial {\bf u}}{\partial t} + {\bf u} \cdot \nabla {\bf u} = - \nabla P + \eta \nabla^2 {\bf u} \end{equation}Here the fluid has density $\rho$, viscosity $\eta$, and we imagine that it is being driven by some velocity $u$ over some lengthscale $L$.
This is a total of four paramters, which we can put into a list and give to buckinghampy:
In [2]:
parameters = [density, length, velocity, viscosity]
nondimensional_numbers = buckinghampy.find_nondimensional_numbers(parameters)
The function buckinghampy.find_nondimensional_numbers() takes a list of parameters and returns an appropriate set of nondimensional numbers for those parameters. These numbers are returned as strings which can be output to LaTeX in IPython:
In [3]:
nondimensional_numbers
Out[3]:
You may recognize this as the the inverse of the Reynolds number. This brings us to an important point: in general, the nondimensionalization of a set of parameters is nonunique. There are some groupings which are conventional, but buckinghampy might not find those. For problems with more than one nondimensional number, the problem becomes harder: not only are inverses and powers of nondimensional numbers allowed, but so are any multiplicative combinations of the different numbers.
We can look at another example from radiative physics. Consider the blackbody radiation spectrum of an object. We expect this problem to depend on the light frequency, the speed of light, Planck's constant, the Boltzmann constant, and the temperature:
In [4]:
parameters = [boltzmann,temperature, planck, speed_of_light, frequency]
nondimensional_numbers = buckinghampy.find_nondimensional_numbers(parameters)
nondimensional_numbers
Out[4]:
The nondimensionalization recovers the argument of the exponential in a Boltzmann distribution.
As an example of a more complicated system, consider the equations for Rayleigh-Bernard convection in a Boussinesq fluid:
\begin{equation} -\nabla P + \eta \nabla^2 {\bf u} + \delta \rho {\bf g} = 0 \end{equation}\begin{equation} \nabla \cdot {\bf u} = 0 \end{equation}\begin{equation} \frac{\partial T}{\partial t} + {\bf u} \cdot \nabla T = \kappa \nabla^2 T \end{equation}where $T$ is temperature, $\kappa$ is the thermal diffusivity, $g$ is gravity, $\delta \rho = -\rho_0 \alpha T$ is the density variations driving buoyancy, $L$ is the layer depth, and $\Delta T$ is the temperature drop across the convecting layer.
An accounting of the paramters in the set of equations finds $\Delta T$, $\rho_0$, $g$, $\alpha$, $\kappa$, $\eta$, and $L$. However in the governing equations $\rho_0$, $g$, and $\alpha$ only appear when multiplied together, so they should really only count for one parameter, which we will define as the "buoyancy parameter."
Using the Parameter class in buckinghampy.parameters we can define new paramters for $\Delta T$ and the buoyancy paramter (which are not predefined in the module)
In [5]:
buoyancy_parameter = Parameter( '\\rho_0 \\alpha g', {'kg' : 1,\
'm' : -2,\
's' : -2,\
'K' : -1})
delta_T = Parameter( '\\Delta T', {'K' : 1})
We can now create a paramters object for this system and find the nondimensional numbers:
In [6]:
parameters = [buoyancy_parameter, delta_T, length, thermal_diffusivity, viscosity]
nondimensional_numbers = buckinghampy.find_nondimensional_numbers(parameters)
nondimensional_numbers
Out[6]:
Hey, would you look at that, it's one over the Rayleigh number! As a side note, if we had not combined some parameters into the buoyancy parameter, we would have gotten some extra nondimensional numbers:
In [7]:
parameters = [thermal_expansivity, gravity, density, delta_T, length, thermal_diffusivity, viscosity]
nondimensional_numbers = buckinghampy.find_nondimensional_numbers(parameters)
nondimensional_numbers
Out[7]:
Okay, that is a bit uglier, but some judicious multiplying and dividing of these nondimensional numbers will allow you to find the Rayleigh number, density deficit number, and the Prandtl number. These nondimensional numbers would all appear in more complete versions of the governing equations, but the Boussinesq approximation allows for the combination of paramters into the buoyancy parameter above, and the resulting simplification of the nondimensionalization.