# Solving Compressible Flow Navier Stokes

**URL:** <https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472>\
**Category:** variational formulation\
**Created:** [June 8, 2020, 2:11pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472 "2020-06-08T14:11:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tkon](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@Tkon](https://fenicsproject.discourse.group/u/Tkon)\
**Post date:** [June 8, 2020, 2:11pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472/1 "2020-06-08T14:11:45Z")

</div>

Hi,

I recently started out simulating incompressible flow Navier Stokes equations.  
Now, I would like to try performing similar simulations for compressible flow.

I have been looking around for examples of compressible flow implementation in FEniCS, however, I was not successful in finding any.

How do I proceed? Do any of you have any good sources/examples that I can use to get started on this project?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [June 8, 2020, 2:42pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472/2 "2020-06-08T14:42:11Z")

</div>

I believe [this work](https://www.diva-portal.org/smash/get/diva2:421860/FULLTEXT01.pdf) used FEniCS, and states the stabilized formulation(s) clearly. I’ve worked with related stabilized methods myself, as written up [here](https://web.me.iastate.edu/jmchsu/files/Xu_et_al-2017-CAF.pdf), although my experience in compressible flow was all using other Fortran and C/C++ research codes.

The pressure–velocity–temperature formulation of the second linked reference remains suitable even in the incompressible limit, which is useful for some applications, and I believe all the tedious matrices of partial derivatives spelled out in the appendices could be automated using UFL’s `diff` function. I did some experiments on this for fun a few years ago, which looked promising, but I never completed the implementation. The 5\times 5 matrix square root would be a bit awkward to implement in UFL, but if you look through the cited references by Hauke, there are simpler formulas that are typically effective in practice.

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [June 8, 2020, 4:17pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472/3 "2020-06-08T16:17:44Z")

</div>

I’ve done it for the steady case with application to aerodynamics. E.g. compressible Navier-Stokes around a NACA0012 airfoil [here](https://bitbucket.org/nate-sime/dolfin_dg/src/master/demo/dolfin/compressible_navier_stokes_naca0012/dg_naca0012_2d.py). Cf. paper [here](https://epubs.siam.org/doi/10.1137/17M1129751). Extension to transient systems is trivial.

Updated links December 2023:  
dolfinx: [dolfin\_dg/demo/dolfinx/compressible\_navier\_stokes\_naca0012/dg\_naca0012\_2d.py at master · nate-sime/dolfin\_dg · GitHub](https://github.com/nate-sime/dolfin_dg/blob/master/demo/dolfinx/compressible_navier_stokes_naca0012/dg_naca0012_2d.py)  
legacy dolfin: [dolfin\_dg/demo/dolfin/compressible\_navier\_stokes\_naca0012/dg\_naca0012\_2d.py at master · nate-sime/dolfin\_dg · GitHub](https://github.com/nate-sime/dolfin_dg/blob/master/demo/dolfin/compressible_navier_stokes_naca0012/dg_naca0012_2d.py)

---

<div class="post-metadata">

**Author:** ![Tkon](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@Tkon](https://fenicsproject.discourse.group/u/Tkon)\
**Post date:** [June 8, 2020, 6:19pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472/4 "2020-06-08T18:19:20Z")

</div>

Thank you very much for your swift response, with help of this example application and the paper I will be able to get started on this matter.

---

<div class="post-metadata">

**Author:** ![Tkon](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@Tkon](https://fenicsproject.discourse.group/u/Tkon)\
**Post date:** [June 8, 2020, 6:20pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472/5 "2020-06-08T18:20:30Z")

</div>

Thank you kamensky for your quick reply and for the examples you provided. I will look into the material and report my progress in the upcoming days.

---

<div class="post-metadata">

**Author:** ![Tkon](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@Tkon](https://fenicsproject.discourse.group/u/Tkon)\
**Post date:** [June 9, 2020, 12:28pm UTC](https://fenicsproject.discourse.group/t/solving-compressible-flow-navier-stokes/3472/6 "2020-06-09T12:28:04Z")

</div>

To solve compressible Navier-Stokes around a NACA0012 airfoil, the Discontinuous Galerkin method was used. Is there a specific reason why you would use discontinuous galerkin methods in this case?

The reason I am asking is because I only used CG methods before and I wonder if DG methods are in some way preferred for compressible NS equations.
