I wanted to simulate the motion of a fluid (continuously filling the entire space) in a given space, say $3$-dimensional Euclidean space. To calculate the dynamics of fluid motion, I used the Navier-Stokes equation and the mass continuity equation.

  Let $\vec{v}$ be a vector of $\mathbb{R}^3$. And let $$\frac{D}{Dt} = \frac{\partial}{\partial t} + \vec{u} \cdot \nabla$$ be the material derivative. Also, assume the following conditions for the fluid.

  • The fluid is compressible.
  • The fluid is viscous.
  • The fluid is isothermal.
  • Dynamic viscosity $\mu$ is a constant in the whole spacetime.

Then, the Navier-Stokes equation is given as $$\rho \frac{D \vec{u}}{Dt} = -\nabla p + \mu \nabla^2 \vec{u} + \frac{1}{3} \mu \nabla (\nabla \cdot \vec{u}) + \rho \vec{g}.$$ And the mass continuity equation is given as $$\frac{\partial \rho}{\partial t} + \nabla \cdot (\rho \vec{u}) = 0.$$   Here, we can categorize existing variables. The independent variables are obviously time $t$ and position $\vec{x}$, and the dependent variables are:

  • unknown variables: $\rho (t, \vec{x})$, $\vec{u} (t, \vec{x})$, $p(t, \vec{x})$
  • given variables: $\vec{g} (t, \vec{x})$, $\mu$

In other words, we have $5$ unknown dynamic fields to be simulated: $\rho$, $u_x$, $u_y$, $u_z$, and $p$. However,

  The Navier-Stokes equation gives $3$ time-dependent equations for the time evolution of $\vec{u}$;
  The mass continuity equation gives $1$ time-dependent equation for the time evolution of $\rho$.

That is, there is a lack of $1$ time-dependent equation for the time evolution of $p$. (Given the initial conditions, the future shape of the system must be determined, so there must be an equation relating $p$ or its time derivatives to $\vec{u}$, $\rho$, and known quantities.) Hence, my question is,

To time-dependently simulate (compressible, viscous, isothermal) fluids, how can we calculate the pressure $p$ at each point in spacetime? What is the relation between $p$ and $\vec{u}$, $\rho$, or the time evolution equation?

  Any help will be appreciated.

  • $\begingroup$ Is this for educational purposes? Is this your first fluid simulation? You might consider starting with a 2D incompressible simulation to get familiar. Jos Stam's paper graphics.cs.cmu.edu/nsp/course/15-464/Fall09/papers/… has long been a nice introduction for people starting with fluid dynamics $\endgroup$ Commented Aug 3, 2023 at 18:54
  • $\begingroup$ @AccidentalTaylorExpansion This simulation isn't for educational purposes, I just want to make it because I saw the simulation videos and wanna try the simulation myself. In fact, I failed in simulating a compressible fluid because of this problem, so I tried simulating a 2D incompressible fluid. I could use the vorticity-stream function formulation, which has the advantage of automatically considering the pressure, and the simulation actually succeeded. (Although it has many flaws, I actually observed Kármán vortex street.) But what I need is a (2D) compressible fluid simulation. $\endgroup$ Commented Aug 3, 2023 at 19:47
  • $\begingroup$ @AccidentalTaylorExpansion Also, thank you for giving me the paper! I will read it carefully. $\endgroup$ Commented Aug 3, 2023 at 19:47
  • $\begingroup$ This question here is basically the same thing, though OP in that linked question is specifically concerned with Euler hydro equations. The answer is still the same: you need an equation of state. $\endgroup$
    – Kyle Kanos
    Commented Aug 3, 2023 at 20:32
  • $\begingroup$ @KyleKanos Wow, thanks for the interesting answer! I saw the equation $\frac{\partial p}{\partial t} + \vec{u} \cdot \nabla p + \gamma p \nabla \cdot \vec{u} = S$ for the first time. Umm, I guess I'll have to think about this a bit more... Thank you! $\endgroup$ Commented Aug 3, 2023 at 22:25

1 Answer 1


As you have figured out, you will need an extra equation relating the variables $p$, $\rho$ and $\mathbf{u}$. For compressible fluids, usually one takes a state equation of the form $\rho(p)$ (as $T$ is held constant in your system). See for example the models here for real gases and here for water in isentropic flows.

  • $\begingroup$ Thank you for answer! Perhaps I don't need a real gas, so the Stiffened equation of state $p = \rho (\gamma - 1) e - p^*$ in sklogwiki.org/SklogWiki/index.php/Stiffened_equation_of_state or the Cole equation of state $p = B ((\frac{\rho}{\rho_0})^\gamma - 1)$ would be sufficient. However, I have questions about the formulas above: $\endgroup$ Commented Aug 3, 2023 at 20:47
  • $\begingroup$ (1) The relationship between $p$ and $\rho$ in the above formula is obtained not from pure classical fluid dynamics, which assumes that the fluid is a continuum, like in the NS equation or the mass continuity equation; but from thermodynamics, which considers the fluid as a set of molecules. And depending on the situation, I will have to use different formulas. Is this true..? This looks a bit strange to me. (2) Just for checking, is $p$ in the above formulas mechanical pressure $p_{mech}$? I referenced physics.stackexchange.com/a/427067/363082. $\endgroup$ Commented Aug 3, 2023 at 20:47
  • $\begingroup$ (3) In the above formulas, $p$ depends only on $\rho$. Is it correct that $p_{mech}$ does not depend on $\vec{u}$? I looked at en.wikipedia.org/wiki/…, and I didn't understand this formula, but thought that $\nabla p$ had something to do with (the derivative of) $\vec{u}$. Thank you! :) $\endgroup$ Commented Aug 3, 2023 at 20:47
  • $\begingroup$ That's not really my area of expertise, but maybe I can help somehow. (1): I don't think different equations are needed as long as the continuous assumptions holds; (2): I would guess that, yes, $p$ is the pressure due to the mechanical entities, since other effects can be inserted into the body force term of the N-S equation; (3) The pressure dependence on $\mathbf{u}$ is included in the N-S equation itself. $\endgroup$
    – Woe
    Commented Aug 4, 2023 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.