# Compressible Navier-Stokes equations

**URL:** <https://community.freefem.org/t/compressible-navier-stokes-equations/3084>\
**Category:** General Discussion\
**Created:** [April 5, 2024, 3:36am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084 "2024-04-05T03:36:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![syq129](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@syq129](https://community.freefem.org/u/syq129)\
**Post date:** [April 5, 2024, 3:36am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/1 "2024-04-05T03:36:35Z")

</div>

Dear all,

I am looking for an or more examples of FreeFEM codes for solving the complete time-dependent compressible Navier-Stokes equations.

Many thanks.

Regards.

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [April 5, 2024, 8:40am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/2 "2024-04-05T08:40:39Z")

</div>

I suggest you look around in the [Stabfem](https://gitlab.com/stabfem/StabFem/-/tree/master/SOURCES_FREEFEM?ref_type=heads) library.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [April 5, 2024, 10:37am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/3 "2024-04-05T10:37:52Z")

</div>

An example is [Third derivative - #4 by fb77](https://community.freefem.org/t/third-derivative/3068/4) but it does not handle shocks.

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [April 5, 2024, 11:48am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/4 "2024-04-05T11:48:00Z")

</div>

You can also see some examples in [ff-bifbox](https://github.com/cmd8/ff-bifbox). These examples can all be time integrated with adaptive remeshing using the `tdnscompute.edp` routine. These use a simple first-order fully implicit solver, so they are relatively stable but not optimized for efficient time stepping.  
See examples/fani\_etal\_2018 for a compressible nonreacting flow case and examples/brokof\_etal\_2024 for a reacting compressible flow case. You may also be interested in the weakly compressible (low Mach) reacting flow case at examples/douglas\_etal\_2023.

---

<div class="post-metadata">

**Author:** ![syq129](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@syq129](https://community.freefem.org/u/syq129)\
**Post date:** [April 5, 2024, 12:11pm UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/5 "2024-04-05T12:11:03Z")

</div>

Thank all of you, Aszaboa, François Bouchut and Chris, for the nice and kind information! It is really helpful.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [April 5, 2024, 12:21pm UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/6 "2024-04-05T12:21:18Z")

</div>

It seems to me that in all the Stabfem and ff-bifbox libraries, the considered equations are always linear (linearized compressible NS around some particular steady flows) thus focusing on wave emission and stability studies.

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [April 5, 2024, 3:11pm UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/7 "2024-04-05T15:11:15Z")

</div>

The tdnscompute.edp routine (time-domain nonlinear simulation) is fully nonlinear. I believe StabFEM has nonlinear timestepping capabilities as well. You are correct though that these tools are not really optimized for time integration.

---

<div class="post-metadata">

**Author:** ![clthu](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@clthu](https://community.freefem.org/u/clthu)\
**Post date:** [June 11, 2024, 3:58am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/8 "2024-06-11T03:58:51Z")

</div>

Hi, Chris. Thanks for your nice suggestions!  
I see the compressible flow examples in ff-bifbox, which helps me a lot. The case of /fani\_etal\_2018 is simple and I have also calculated this case within stabfem before. But somewhere in the case of /brokof\_etal\_2024 seems strange to me.  
In examples/brokof\_etal\_2024/eqns\_brokof\_etal\_2024.idp, I find the residual part for momentum equation in line 70 is defined as:

- -ubrho\*ugradu(ub, ub, v) - div(v)\*ubp …

I think it might be:

- -ubrho\*ugradu(ub, ub, v) + div(v)\*ubp …

but I am not sure whether it is related to the boundary condition for BCin and BCout:

- int1d(Th, BCin, BCout)( (vp + vdotu(v, ub))\* ubrho \*ndotu(ub) - ndotgraduT(v, ub)/params[“Re”] )

I think the first term comes from the continuity equation and the last term comes from the viscous term in momentum equation, but I could not figure out where the second term comes from.

- vdotu(v, ub))\* ubrho \*ndotu(ub)

Thansk again ~

---

<div class="post-metadata">

**Author:** ![clthu](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@clthu](https://community.freefem.org/u/clthu)\
**Post date:** [June 11, 2024, 4:20am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/9 "2024-06-11T04:20:26Z")

</div>

I’m sorry for the early message, I made a foolish mistake 😓.  
I didn’t notice that the definition of convection term is different in two scripts. The convection term is integrated by parts as well in examples/brokof\_etal\_2024/eqns\_brokof\_etal\_2024.idp but not in /fani\_etal\_2018, which I failed to observe earlier. And I am no longer confused about this .  
Thank you again for your work.

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [June 11, 2024, 7:51am UTC](https://community.freefem.org/t/compressible-navier-stokes-equations/3084/10 "2024-06-11T07:51:42Z")

</div>

Hi there, glad to hear you found them helpful! Yes, the integration by parts is a key difference; you are exactly right. The BCs in the brokof\_etal\_2024 case are based on acoustic characteristics that appear in the boundary integrals for the mass and momentum flux terms. This is detailed in a PROCI paper that will come out next month. Let me know if you have any further questions!
