In Praise of Dimensional Analysis

After six and a half years, I still get email about my article "PID Without a PhD"

formatting link
from people who are asking for clarifications, or are asking questions that go beyond what I could say in the 5000 word limit that Embedded Systems Programming magazine imposed.

The one I got today made me think.

It didn't make me think because it was hard to figure out the answer, or because it was hard to explain the answer so it would be understood. It made me think because the writer was asking me about the dimensions of the gains in a PID controller, and I was impressed that someone who was obviously just approaching the subject was paying enough attention to want to do a correct job of dimensional analysis.

It made me think of the innumerable times when I've done some complex calculation and ended up proving something absurd such as measures of length in units of gallons, and the subsequent discovery of my error. It made me think of the Mars Climate Orbiter which crashed because one team specified a motor in pound-seconds while another one used Newton-seconds

formatting link
It made me think of how much I like MathCad, because I can set variable values with the correct units, and how inconvenient nearly every other programming language is because numbers are just that -- anonymous numbers.

So I thought I'd write a little bit about dimensional analysis, why I like it, and why you should use it, even if you think it is tedious and trite.

Dimensional analysis is a method used by engineers and scientists that extends the notion that "you can't compare apples to oranges" to the nth degree. Dimensional analysis says that every variable in any physical problem has units, and that you ignore these units at your peril.

The basic rules of dimensional analysis are these:

  1. There are very few naked (i.e. dimensionless) numbers.
  2. You can only add (or compare) two numbers of like dimension -- you can't compare feet with pounds, and if you're being strict you can't even compare pounds (which is strictly a measure of force) with kilograms (which is strictly a measure of mass).
  3. You can multiply (or divide) numbers of any dimension you want; the result is a new dimension. So if I pour water into a pan, the water at the base of the pan exerts a certain force on each bit of area, the resulting pressure is measured in pounds/square inch (PSI), or in Newtons per square meter (N/m^2, or Pascal).
3a. You can honor famous people by naming dimensions after them -- Pascal is the metric unit of pressure, Ampere of current. Avins, Grise, and Wescott have yet to be defined.

So why is dimensional analysis so cool?

If you are doing a long calculation and you track your dimensions, some mistakes will show up as incorrect dimensions.

It can give you insight into the operation of a system -- most explanations of fluid dynamics that I have seen rely heavily on dimensional analysis in their arguments, and when they do so such aerodynamically important quantities as Reynold's numbers and Mach numbers fall out.

When you do design with physical systems, careful dimensional analysis keeps you out of trouble, even when you're getting the math right. Remember that Mars Lander? Had someone been carefully checking dimensions instead of looking at numbers and making assumptions, it would have been a successful mission instead of a famous crash.

How do you use dimensional analysis?

For working forward, such as finding the relationship between an aircraft's speed and it's lift, or finding the relationship between mass, speed and energy (remember E = mC^2?) you find out the dimensions that your answer _must_ have, then you hunt down candidates in that field.

For working backward, you do all of your calculations with dimensions, then make sure that, for example, if you're commanding a system in feet it's moving in feet, and not apples/minute. If your answer ends up being in gallons/inch^2, you know you're close but may have to multiply by a constant.

For a more full exposition of dimensional analysis I refer you to the Wikipedia article

formatting link
or whatever your own web searches turn up.

In the mean time, the next time you're dealing with a knotty problem -- make sure to track those dimensions. The Martian lander you save may be yours!

Reply to
Tim Wescott
Loading thread data ...

My high-school physics book had a cartoon in it where Einstein was standing in front of a chalkboard, having crossed out E=mc and E=mc^3. The caption was something along the lines of, "Aha! So the units *do* work out in that one!"

Reply to
Joel Kolstad

Very good post! We tend to get lazy doing plain ohm's law calculations, since they are so simple. But this creates the bad habit of ignoring the dimensions on more complex problems where errors are more likely.

We need to break these old bad habits and reinforce new ones. Your article is a very good place to start.

Thanks!

Mike Monett

Reply to
Mike Monett

Essential in electro-mechanical system design and analysis!

Reply to
Charles

Perhaps you can say dimensional analysis is where theory and reality meet.

Reply to
Randy Yates

In a PID controller, we are summing voltages (which is fine) but they also represent an error, the time integral of an error, and the derivative of an error.

The error is in volts. The integral is in volt-seconds. But we sum them, and nothing explodes!

John

Reply to
John Larkin

...

Hear! hear! We need more of this. (T as the dimension of gain is absurd.)

But those are vitally important. The arguments to transcendental functions had darn well be dimensionless, even if you need to do extra work (normalize) to make them so. The sine if two meters is a mistake.

Sometimes you can't even compare numbers of like dimension. For example, the dimensions of torque and work are the same, but they are inherently incommensurable. The MKS dimensions of volts are obscure, but electromagnetic dimensions hang together even if they stand apart from the more common ones. (The unit of flux is a volt-second; the unit of inductance is volt-second/ampere-turn. "Turn", like radian. is dimensionless.)

...

Our educators should make more of a big deal of this than they do. Thanks, Tim.

Jerry

Reply to
Jerry Avins

If the output of the integrator is in volts, then it's gain must be in volt/volt-second.

If the integrator is buried in software, then it's gain is in counts/count-tick, though you'll often see integrator gain expressed as (something)/(something-seconds) -- because someone has taken it on themselves to obscure the sampled nature of the controller by scaling the integrator (and derivative) gain.

Reply to
Tim Wescott

Yes.

No. It's volts. The gain of the integrator has the unit V/(Vs), and the integration is volts over time, so the seconds cancel out and you get volts again. A similar arguments holds for the differential term.

robert

Reply to
Robert Latest

BUT. It is *very* useful to specify "dimensionless" numbers with their underlying dimensions, eg voltage regulation in volts per volt or if really good, in millivolts per volt; the latter giving a clue to a sensitivity or gain in the system. Also rather useful in error analysis.

Reply to
Robert Baer

Hmmm... X double dot = - X

Reply to
Robert Baer

Actually, my science teacher in High School emphasized units; minimal steps that must be shown in solving a given problem was 1) present the equation in standard form (E = I * R), 2) substitute the knowns WITH UNITS (22 Volts = I Amps * 11 Ohms), 3) solve for the unknown AND GIVE UNITS (I = 2 Amps); draw a box around the answer WITH UNITS so it can be found. Any of these criteria found missing will result in a grade of ZERO for that question (therefore, since there is no box, i get a ZERO). It was acceptable to add any number of intervening steps either for clarity or ease of calculation.

Saved my butt in college as i was able to derive an equation from the units involved in the question; with that, i solved the problem and passed the test.

Reply to
Robert Baer

He deserves kudos. I'm amazed how many IEEE papers you see where units are left off of graphs, equations containing "magic constants" are presented without specifying the units assumes that are required to make the constant correct, etc.!

Reply to
Joel Kolstad

No wonder. The PhDs without the PIDs are much more common, then the PIDs without the PhDs.

BTW, in the theoretical physics, they use the dimensionless units to avoid the heavyweight dimension constants:

e = c = h = 1

How about that?

No. It crashed because it is impossible to be perfect in all but in the very small projects. This problem is mich wider then just the agreement about the dimensions.

The beloved Microsoft style is using the so-called 'hungarian notation' to avoid that sort of mistakes. lpSTR, HANDLE, DWORD and such.

Charles Simonai, who is the inventor of this style, just recently made it safely to the space and back :)

C++ allows you defining the explicit types like "VOLTAGE", "CURRENT" and such, so the dumb mistakes are avoided. However, this approach is seen by many as the counter productive and resulting in the inefficient code.

Dimensional analysis is just a trivial check to avoid a class of a simple mistakes at the low level.

"Wescott" would better be reserved as the name of the not yet discovered radioactive chemical element of the halogen group. "Avins" is a parameter of a Markov source. What could be "Grise" ?

Because it is generating so much traffic! It is trivial, so anyone can add his two cents.

There is a method of thermodynamic potentials, which derives a useful formulae from the dimension considerations by means of differentiation and integration. However if you divide your phone number by your SSN, it is not going to be very usefull.

This is the basic thing not worth mentioning which every professional should do automatically.

It would crashed of some other trivial or non-trivial reason. Or at some other time. Somebody else would be sacrificed as a scapegoat. That's the only difference.

Vladimir Vassilevsky

DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

...

Spoilsport! :-)

Jerry

Reply to
Jerry Avins

(snip)

This reminds me of something that has occurred to me in the past, and that I would like to see if people here agree.

It seems to me that in calculations physicists usually give variables quantities with dimensions, where engineers usually factor out the dimensions. For example,

A physicist might say:

F = m a, where the variable m might have the value 3kg or 5g.

An engineer might say:

F(Newtons) = m(kg) * a (m s**-2), such that m has the value 3 or 0.005.

That is, the dimensions belong to the equation, but not to variables.

It might be because most programming languages don't keep units with variables, so that one must factor them out before assigning a value to a variable.

I would be interested to see if others agree or disagree.

-- glen

Reply to
glen herrmannsfeldt

I think that's true--engineers are typically taught to pull out all those fundamental factors of hbar, 4*pi/c**2, and so on, crunching them all into some anonymous constant to save labour and blunders. When you do that, you have to keep track of the units by hand, whereas in the physicists' method, the units get carried along automatically.

In fact, people doing relativistic field theory usually use c=1 style, in which all the calculations are done with just numbers, and the proper conversion factors get figured out at the end, by reverse dimensional analysis--sticking in the right powers of c, hbar, G and so on to make the units come out right. It turns out that this is a well-defined procedure, so it saves labour and you still get the right answer at the end. (I'm not a field theorist, so I've never done this.)

Cheers,

Phil Hobbs

Reply to
Phil Hobbs

The one I remember has E=mc and E=mc**3 written down, and someone straightening up the books on a nearby bookshelf saying. "Well now that's all squared away."

-- glen

Reply to
glen herrmannsfeldt

In that example, you showed kilograms or grams -- I grew up with thousands prefixes, so I change them on the fly as it suits me. A 1k resistor has always been, and always will be, a 1000 ohm resistor as well, and not a 1 * (1000 / 1k) resistor. :^P

Tim

Reply to
Tim Williams

Reply to
RRogers

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.