Simplicity is the ultimate sophistication.

― Clare Boothe Luce

When one is solving problems involving a flow of some sort, conservation principles are quite attractive since these principles follow nature’s “true” laws (true to the extent we know things are conserved!). With flows involving shocks and discontinuities, the conservation brings even greater benefits as the Lax-Wendroff theorem demonstrates (https://wjrider.wordpress.com/2013/09/19/classic-papers-lax-wendroff-1960/). In a nutshell you have guarantees about the solution through the use of conservation form that are far weaker without it. **A particular set of variables is the obvious variables because they arise naturally in conservation form**. For fluid flow these are density, momentum and total energy. The most seemingly straightforward thing to do is use these same variables to discretize the equations. This is generally a bad choice and should be avoided unless one does not care about the quality of results.

**While straightforward and obvious, the choice of using conserved variables is almost always a poor one, and far better results can be achieved through the use of primitive variables for most of the discretization and approximation work**. This is even true if one is using characteristic variables (which usually imply some sort of entirely one-dimensional character). The primitive variables have simple and intuitive meaning physically, and often equate directly to what can be observed in nature (conservedvariables don’t). The beauty of primitive variables is that they trivially generalize to multiple dimensions in ways that characteristic variables do not. The other advantages are equally clear specifically the ability to extend the physics of the problem in a natural and simple manner. This sort of extension usually causes the characteristic approach to either collapse or at least become increasingly unwieldy. A key aspect to keep in mind at all times is that one returns to the conservation variables for the final approximation and update of the equations. Keeping the conservation form for the accounting of the complete solution is essential.

To keep the bulk of the discussion simple, I will focus on the Euler equations of fluid dynamics. These equations describe the conservations of mass, , momentum, and total energy, in one dimension. **Even in this very simple setting the primitive variables are immensely useful as demonstrated by HT Huynh, in another of his massively under-appreciated papers. In this paper he masterfully covers the whole of the techniques and utility of primitive variables**. Arguably, the use of primitive variables went mainstream with the papers of Colella and Woodward. In spite of the broad appreciation of that paper, the use of primitive variables in work is still more a niche than common practice. The benefits become manifestly obvious whether one is analyzing the equations (which is equivalent to the more complex variable set!), or discretizing the solutions.

Study the past if you would define the future.

― Confucius

The use of the “primitive variables” came from a number of different directions. **Perhaps the earliest use of the term “primitive” came from meteorology in terms of the work of Bjerknes (1921) whose primitive equations formed the basis of early work in computing weather in an effort led by Jules Charney (1955).** Another field to use this concept is the solution of incompressible flows. The primitive variables are the velocities and pressure, which is distinguished from the vorticity-streamfunction approach (Roache 1972). In two dimensions the vorticity-streamfunction solution is more efficient, but lacks simple connection to measurable quantities. The same sort of notion separates the conserved variables from the primitive variables in compressible flow.** The use of primitive variables as an effective approach computationally may have begun in the computational physics work at Livermore in the 1970’s (see e.g., Debar)**. The connection of the primitive variables to classical analysis of compressible flows and simple physical interpretation also plays a role.

**What are the primitive variables?** The basic conserved variables form compressible fluid flow are density, , momentum, , and total energy, . Here the velocity is and the internal energy is . One also has the equation of state as the constitutive relation. Let’s take the Euler equations and rewrite them using the primitive variables, the conservations of mass, , momentum, and total energy, . Except for the energy equation, the expressions are simpler to work with, but this is the veritable tip of the proverbial iceberg.

**What are the equations for the primitive variables?** The primitive variables can be expressed and evolved using simpler equations, which are primarily evolution equations dependent on differentiability, which must be present for any sort of accuracy to be in play anyway. The mass equation is the same although one might expand the derivative, . The momentum equation is replaced by an equation of motion, . The energy equation could be replaced with a pressure equation, ( is the generalized isentropic derivative ) or an internal energy equation, . **One can use either energy representation to good measure, or better yet, use both and avoid having to evaluate the equation of state**. Moreover if one wants you can evaluate the difference between the pressure from the evolution equation and the state relation as an error measure.

**How does on convert to the primitive variables, and convert back to the conserved variables?** If one is interested in analysis of the conservative equations, then one linearizes the equations about a point, where is the vector of conserved varibles, and is the flux function. The matrix is the flux Jacobian. One does an eigenvalue decomposition, $ to analyze the equations. From this decomposition, , one can get the eigenvalues, , and the characteristic variables, . The analysis is difficult and non-intuitive with the conserved variables.

Here we get to the cool part of this whole thing, there is a much easier and more intuitive path through the primitive variables. One can get a matrix representation of the primitive variables which I’ll call in vector form, . One can get the terms in easily from the differential forms, and recognizing that , with being the speed of sound, **the eigen-analysis is so simple that it can be done by hand (and it’s a total piece of cake for Mathematica)**. Using similar notation as the conserved form, . The first thing to note is that is exactly the same, i.e., the eigenvalues are identical. One then gets a result for the characteristics, that matches the textbooks, and that . All the differences in the transformation are bound up in the right eigenvectors and , and the ease of physical insight provided by the analysis.

Now we can elucidate how to move between these two forms, and even use the primitive variables for the analysis of the conserved form directly. Using Huynh’s paper as a guide and repeating the main results one defines a matrix of partial derivatives of the conserved variables, with respect to the primitive variables, , . **This matrix then can be inverted into and we then may define an identity, , which might allow the conserved eigen-analysis to be executed in terms of the more convenient primitive variables**. The eigenvalues of and are the same. We can get the left and right eigenvectors through and . All of this follows the simple application of the chain rule to the linearized versions of the governing equations.

The primitive variable idea can be extended in a variety of nifty and useful ways. One can augment the variable set in ways that can yield some extra efficiency to the solution by avoiding extra evaluations of the constitutive (or state) relations. **This would most classically involve using both a pressure and energy equation in the system**. Miller and Puckett provide a nice example of this technique in practice, building upon the work of Colella, Glaz and Ferguson where expensive equation of state evaluations are avoided. One must note that the system of equations being used to discretize the system is carrying redundant information that may have utility beyond efficiency.

One can go beyond this to add variables to the system of equations that are redundant, but carry information implicit in their approximation that may be useful in solving equations. One might add an equation for the specific volume of the fluid to compare with density. Similar things could be done with kinetic energy, vorticity, or entropy. **In each case the redunency might be used to discover or estimate error or smoothness of the underlying solution and perhaps adapt the solution method on the basis of this information.**

Using the primitive variables for discretization is almost as good as using characteristic variables in terms of solution fidelity. Generally if you can get away with 1-D ideas, the characteristic variables are unambiguously the best. The primitive variables are almost as good. **The key is to use a local transformation to the primitive variables for the work of discretization even when your bookkeeping is all in conserved variables**. Even if you are doing characteristic variables, the construction and use of them is enabled by primitive variables. The resulting expressions for the characteristics are simpler in primitive variables. Perhaps almost as important the expressions for the variables themselves are far more intuitively expressed in primitive variables.

A real source of power of the primitive variables comes when you extend past the simpler case of the Euler equations to things like magneto-hydrodynamics (MHD i.e., compressible magnetic fluids). Doing discretization of the MHD with conserved variables is a severe challenge and analysis of their mathematical characteristic structure can be a decent into utter madness. **Doing the work in these more complex systems using the primitive variables is extremely advantageous.** It is an approach that is far too often left out and the quality and fidelity of numerical methods suffers as a result.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.

― Ernst F. Schumacher

Lax, Peter, and Burton Wendroff. “Systems of conservation laws.”*Communications on Pure and Applied mathematics* 13, no. 2 (1960): 217-237.

Huynh, Hung T. “Accurate upwind methods for the Euler equations.” *SIAM Journal on Numerical Analysis* 32, no. 5 (1995): 1565-1619.

Colella, Phillip, and Paul R. Woodward. “The piecewise parabolic method (PPM) for gas-dynamical simulations.” *Journal of computational physics* 54, no. 1 (1984): 174-201.

Woodward, Paul, and Phillip Colella. “The numerical simulation of two-dimensional fluid flow with strong shocks.” *Journal of computational physics*54, no. 1 (1984): 115-173.

Van Leer, Bram. “Upwind and high-resolution methods for compressible flow: From donor cell to residual-distribution schemes.” *Communications in Computational Physics* 1, no. 192-206 (2006): 138.

Bjerknes, V. “The Meteorology of the Temperate Zone and the General Atmospheric CIRCULATION. 1.” *Monthly Weather Review* 49, no. 1 (1921): 1-3.

Charney, J. “The use of the primitive equations of motion in numerical prediction.” *Tellus* 7, no. 1 (1955): 22-26.

Roache, Patrick J. Computational fluid dynamics. Hermosa publishers, 1972.

DeBar, R. B. *Method in two-D Eulerian hydrodynamics*. No. UCID-19683. Lawrence Livermore National Lab., CA (USA), 1974.

Miller, Gregory Hale, and Elbridge Gerry Puckett. “A high-order Godunov method for multiple condensed phases.” *Journal of Computational Physics*128, no. 1 (1996): 134-164.

Colella, P., H. M. Glaz, and R. E. Ferguson. “Multifluid algorithms for Eulerian finite difference methods.” *preprint* (1996).

Kori Smith

said:I’ve been following your blog for a couple months now and it’s probably the most informative, natural approach to CFD topics that I’ve seen so far. Even added the RSS feed to a widget on my phone for an occasional read on the bus 🙂 Just wanted to say thank you for your updates and that your work has been a huge help and inspiration to this grad student!

Pingback: Standard Tests without Metrics Stall Progress | The Regularized Singularity

Pingback: Tricks of the trade: Making a method robust | The Regularized Singularity