Basics of Dimensional Analysis
Basics of Dimensional Analysis
The goal of this module is to provide a philosophical perspective on why we measure things and how we think dimensionally about those measurements. Dimensional analysis is a common vocabulary that allows us to agree on what a given measurement means, based on the philosophy that measurements are epistemological representations of an objective shared reality.
The following video from Sixty Symbols (5:51 min) gives an excellent summary of the elegance and power of dimensional thinking, a skill that I think should be central to training in quantitative environmental science. Sixty Symbols is generally an excellent math and science education YouTube channel.
Be able to articulate the logic underlying why scientists measure things.
Be able to describe the dimensionality of commonly measured physical variables.
Be able to perform dimensional analyses on equations.
Be able to automatically produce a formatted report from a markdown text file, including professional mathematical notation defined by LaTeX math code.
Understanding why scientists measure things first requires understanding why scientists do science. Let's establish some basic understanding of the philosophy of science (from an inexpert perspective, 4:22 min).
If data represent an objective perspective on reality, then how do we use them to gain understanding or awareness of causality?
Extracting objective understanding of cause and effect from patterns in measurements is the domain of the scientific method. Let's review the scientific method and the philosophy of logic associated with its practice (12:01 min).
This link to Hutto 2012 in BioScience provides some perspective on the common distortions created by imprecise understanding of the scientific method. A clear understanding of the role of research hypotheses and predictions in deductive reasoning and the distinction of research hypotheses from their statistical counterparts are critical to clear understanding of the logic underlying the scientific method.
Slides from videos
The original slides used in these videos are available below.
Click this link to download the Microsoft PowerPoint file
Note that the Google Slides preview window below provides pictures of the slides that do not include the animations in the original file. Please download the original file from the link above if you would like to view the slides with all animations in Microsoft PowerPoint.
If scientists are to agree about the meaning of patterns among measurements, we must share a common perspective on the meaning of any one measurement. Dimensional analysis provides a structured language for mapping the meaning of a given measured variable to some component of our objective reality. I like to call dimensional analysis an epistemological mapping that allows us to use physics to think about cause and effect in our shared reality. The combination of structured vocabulary and mathematical abstraction make dimensional analysis both a powerful generalized communication tool, as well as a powerful tool for checking the integrity of mathematical calculations and derivations.
Let's start with an introduction of dimensions in space, where we already have some intuition for the three dimensions in which we exist. We can start with a single dimension and compare and contrast the abstraction of dimensions with the specific numerical context of units (4:16 min).
Derived dimensions arise from thinking about multidimensional references frames. Spatial dimensions like areas and volumes provide simple examples of derived dimensions and an example of how to carry dimensions through algebraic calculations (7:51 min).
Dimensions are used to define many more basic components of reality than properties of space. Further fundamental dimensions help to describe additional components of space, time, mass, and energy (10:27 min).
Fundamental dimensions can be combined into derived dimensions that describe increasingly complex phenomena important to the study of environmental systems. A dimensional analysis of basic Newtonian physics provides an example of how to derive the dimensions of energy from the fundamental dimensions of length, time, and mass (6:49min).
Dimensions are useful for describing the fundamental meaning of variables, but they are abstract and further context is often necessary. The physical properties of density and concentration are examples of why knowing mass of what or volume of what are important to the interpretation of dimensions (3:31 min).
Finally, we can explore the dimensional relationships between heat and temperature, as well as a few more potentially tricky examples (7:24 min).
With these basics, you already have an elegant and powerful epistemological tool for analyzing the context of variables and derivations performed with those variables. Also, you have an understanding of the fundamental metadata that are necessary to understand the context of phenomenological physical data.
Slides from videos
The original slides used in these videos are available below.
Click this link to download the Microsoft PowerPoint file
Note that the Google Slides preview window below provides pictures of the slides that do not include the animations in the original file. Please download the original file from the link above if you would like to view the slides with all animations in Microsoft PowerPoint.
Let's start working through some examples of mathematical derivations with dimensions. The conventions used for the formatting of dimensions are primarily designed to clearly differentiate them from other symbols used for units or mathematical variables. Surrounding dimensions with square brackets and use of nonitalicized capital letters are the typical practices for providing this differentiation. Using positive and negative exponents rather than mathematical fraction notation for simplified dimensions helps avoid potential ambiguities in the order of operation (3:12 min).
We will be using a couple of stream channel hydraulic models to provide some examples of dimensional analyses to determine dimensional consistency of equations. In turn, dimensional consistency gives us some hints regarding whether the equation was derived from independent theory, or whether it was likely derived from more arbitrary mathematics applied empirically to observed data. Dimensional consistency suggests that equations are derived from independent theory, and any consistent system of units can be used when using these equations for calculations. Equations with dimensional inconsistency suggest that the most convenient mathematics for matching the shape of data relationships were used for the derivation, and extreme care in using the same units used in the intial derivation is often critical when using these equations for calculations. First, lets cover the basics of the Darcy Weisbach equation (3:43 min).
We can compare the Darcy Weisbach equation to the Gauckler Manning equation, which is another channel hydraulic equation used for similar purposes but with a different formulation (0:49 min).
Dimensional analyses of these formulae require substituting the dimensions of the variables into the equations, and then algebraically simplifying to determine if the terms on each side of the equation have the same dimensions. While working through an example of an analysis determining the dimensional consistency of these stream channel hydraulic models, we will walk through how to use the markdown formatting language using LaTeX math code to produce a report with professionally rendered mathematical notation.
Slides from videos
The original slides used in these videos are available below.
Click this link to download the Microsoft PowerPoint file
Note that the Google Slides preview window below provides pictures of the slides that do not include the animations in the original file. Please download the original file from the link above if you would like to view the slides with all animations in Microsoft PowerPoint.
The remainder of this module assumes that you have RStudio installed. While this module does not actually make use of RStudio's tools to facilitate programing in R, future modules will. RStudio does not come with R. You will need to have R installed first, so the RStudio installation can find the current R installation and automatically create the necessary links to it. The links to the R installation used by RStudio can easily be changed in RStudio's Global Options under the Tools menu.
Here are the direct links for installing R and RStudio, in the order in which they should be installed:
The Comprehensive R Archive Network (CRAN) for downloading and installing R (among many other R packages).
Open source RStudio Desktop for downloading and installing RStudio (should install R first).
This module also assumes that plentiful public resources are available for helping with the installation of these software packages on your operating system of choice, and does not provide specific narrative or videos on this topic. The remainder of this module essentially uses RStudio as a convenient front end to the pandoc application, and we will get into exercises with R coding in later modules.
In the process of performing a dimensional analysis on the Darcy Weisbach equation, let's get some practice with a tool that will allow us to report the dimensional analysis with professional mathematical notation in an electronic format. In this example, I will be using the RStudio integrated development environment to render a formatted document from a markdown text file. I highly recommend getting in the habit of using RStudio projects to keep you efforts with coding organized. This video shows you how to set up a basic RStudio project directory (5:11 min).
Note that the file explorer in this video is configured not to hide the extensions on file names (e.g. the .md at the end of a markdown file name). File extensions are often hidden by default in the Windows operating system. Most coders want to be able to see the extensions because they are part of the complete file name that you might use to read or write a file in your code. Configuring what you can or cannot see in the file explorer for windows is accomplished in the View menu on the ribbon bar.
As we progress through the course, you will see more and more examples of why it should be very rare for you to open RStudio in any way other than double clicking on an RStudio project file. The project we are building here is a simple workflow where both the source and target file will be in the same directory, and the need for an RStudio project is less obvious. However, as we get to more and more complex coding projects, you will see how this practice will help you be sure you always know which files and working directories your programs are using when you run them from RStudio. And eventually hopefully you will agree that creating an RStudio project file for any project directory is a good habit, no matter how simple the project.
Once we have a project directory set up with an RStudio project file, we can use it to create a markdown text file in the working directory and start getting familiar with the basics of markdown (4:40 min).
Let's render a markdown file with the bare minimum content to get familiar with how RStudio uses the pandoc program to create the formatted document (3:48 min).
Depending on the type of formatted file you are creating, pandoc may complain about not having information about a title for the document. This video provides a couple of different ways to provide a title via a YAML header in the markdown code, which is a way to pass key value pairs of information to pandoc that it can use in the rendering of the formatted document (3:27 min).
For the sake of simplicity, these videos use the "Preview" button on the text editor in RStudio to process the markdown code into an encapsulated HTML file. However, I would recommend in the long run that you avoid adopting workflows that are dependent on RStudio. An integrated development environment like RStudio is supposed to help you write and debug code, but should not be necessary to run the resulting programs. If you are truly generating fully automated workflow, you should be able to run your programs from an R console or even from your system command line without RStudio being involved. The next video introduces you to using the render() function from the rmarkdown package to compile markdown files into HTML files (5:52 min).
The video walks you through creating a dimension.R script file with the following code, in the same folder as your RStudio project file and markdown file.
If you are in the appropriate working directory based on using your RStudio project file, executing this script in the same directory as the dimension.md file will result in running pandoc to create a dimension.html file. The results should be identical to using the "Preview" button in RStudio, but no longer depend on features of the RStudio graphical interface. That said, your code may still be dependent on the copy of pandoc included in RStudio, in which case you need to install your own copy of pandoc and make sure it is in your system path to be truly independent of RStudio. RStudio has features of convenience that will tempt you away from a truly automated workflow. I recommend resisting the temptation to use these features for anything other than code development and debugging. I try to get myself to the point where the only button I need to use in RStudio to execute my final workflow is the "Source" button for running a given script.
Rendering markdown files to a formatted document is an extremely common task from many different programming languages and across many different development platforms. See the VS Code and Quarto alternative as an example of another way to accomplish the same task in a different IDE.
The following section provides select examples of the formatting features available in markdown, based on the case study of preparing a report on a dimensional analysis. A more general tutorial on the features of markdown is available in the general resources.
We should now have the basic ability to render a formatted document from a markdown file. Let's learn some additional markdown formatting language as we start to generate a report with a dimensional analysis of the Darcy-Weisbach equation. First, we can talk about adding formatted headers to our document (6:01 min).
The previous video suggested that the content following the description of the equation might be a list of variables. We can render a neatly formatted bullet list or numbered list using markdown code (6:43 min).
This example of a rendered document containing a dimensional analysis will ultimately include a great deal of mathematical notation. Markdown borrows from the LaTeX formatting language a method of representing detailed mathematical notation as plain text. This video starts to introduce you to the LaTeX math code that will allow for professionally rendered mathematical notation (4:53 min).
Putting an equation on its own line in a document is a common practice for more complicated mathematics. Equations to be rendered on their own line in markdown should be delimited by two dollar signs on a line by themselves, and the LaTeX math code can use as many lines as needed between those delimiters on lines before and after the equation (4:49 min).
Rendering markdown files to a formatted document is an extremely common task from many different programming languages and across many different development platforms. See the VS Code and Quarto alternative as an example of another way to accomplish the same task in a different IDE.
The following section provides select examples of the formatting features available in markdown, based on the case study of preparing a report on a dimensional analysis. A more general tutorial on the features of markdown is available in the general resources.
The first step of a dimensional analysis is to be sure we know the dimensions of all the variables in the equation. Let's add dimensions to the variables in our markdown (12:55 min).
Then we can substitute the dimensions for each variable into the Darcy Weisbach equation (8:55 min).
Finally we can assess the dimensional consistency of the Darcy Weisbach equation by simplifying the dimensions of the right side of the equation (10:11 min).
This video provides a quick demonstration of rendering markdown to other file types, including Microsoft Word or postscript PDF (10:11 min).
Note that rendering to a PDF is accomplished by first translating markdown to the LaTeX typesetting language and then rending a postscript data file from the LaTeX text file. Rendering the LaTeX may require you to install an external LaTeX compiler (e.g. MikTeX for Windows).
Similar to the exercises above, a section with a dimensional analysis of the Gauckler Manning equation might be added to the formatted document using the markdown code below. Note that a table was used to give the dimensions of the variables in the Gauckler Manning equation, to provide an example of the simple tables that can be generated from markdown. A summary has also been added to provide a synthetic perspective on the topic of dimensional consistency.
Pandoc will render this markdown code renders to an HTML text file that will be displayed as follows in a web browser. Note that this document is intended for learning how to code in markdown as well as for your introduction to dimensional analysis. Comparison of the dimensional analysis of the Darcy Weisbach equation and Gauckler Manning equation is intended to help you understand how dimensional consistency is related to the derivation of an equation from empiricism or theory. In general, this exercise should convince you of the importance in recognizing the dimensionality of an equation when choosing values for variables with the appropriate units for calculations.
A zip file with the contents of the working directory used to create this HTML document is available at the following link.
Link to zip file of the working directory for the dimensional analysis example
This exercise has provided select examples of the formatting features available in markdown, based on the case study of preparing a report on a dimensional analysis. A more general tutorial on the features of markdown is available in the general resources.
Here are a few more examples you can use to challenge yourself in dimensional thinking. These are commonly used equations in hydrology. They are all dimensionally consistent, and thinking through the variables and their dimensions are revealing of the underlying theory. Don't let the differential equations confuse you. The dimensions of a variable are the same if you are talking about the variable itself or its differential. You can plug in a dimension for a variable regarless of whether there is a "d" or "curly d" in front of it. The markdown for these examples will give you some more examples of mathematical notation in LaTeX.
And this markdown renders to the following HTML formatting.
A general tutorial on markdown
A more general tutorial for the features of markdown is available in the general resources for the class.
Link to a full page HTML version of the markdown tutorial in general resources
Table of examples of dimensions commonly used in hydrology
US version of the brochure describing the International System of Units
Appreciation for the more abstract dimensions represented by the International System of Units (SI) is included in its definition.
Unit conversion and dimensional thinking
The unit factor method of converting units is sometimes called "dimensional analysis". However, it is really only a minor component of a much more powerful epistemological tool. That said, the two are related and this video gives a brief description of how.
Examples of mathematical notation using Microsoft's equation editor in Word
Here are some videos of dimensional analyses I have worked in other classes using Microsoft's equation editor. These videos give many tips on shortcuts when working derivations in Microsoft Word.
The following video is not about dimensional an analyses, but has further examples of shortcuts in Microsoft Word's equation editor that might be useful.