# Shocktube – rhoCentralFoam TVD Schemes Test

Careful selection of TVD interpolation schemes is important for solving high speed compressible flows. In cases with discontinuities such as shockwaves and contact surfaces, these schemes help keep the simulations free of spurious oscillations. In this post I will use the shock tube tutorial case to test some of the available schemes in OpenFOAM (specifically rhoCentralFoam).

I am going to test the following schemes: vanLeer, vanAlbada, and Gamma (0, 0.5 and 1). To test them, I will first simulate the tutorial case without changing anything. I will then examine how each of the limiters respond to an increase in grid density and also a decrease in CFL (Courant-Freidrichs-Levy) number … also the amazing Canadian Football League :).

Here is a summary of what I’ve found… then you can read through all the plots after!

1. In all cases the results at a cell count of 100 showed oscillatory and therefore unsatisfactory results. As you should already know, grid resolution is important.
2. At a CFL of 0.2, vanLeer in rhoCentralFoam was inconsistent. What I mean by this is when using vanLeer, as you refine your grid the results actually get worse! This is not desirable in a numerical scheme for obvious reasons.
3. At a CFL of 0.1 vanLeer showed good results. This indicates that one should probably avoid using vanLeer unless you are committed to using small timesteps (more computing time).
4. vanAlbada is consistent at both CFL numbers tested. This indicates that by using vanAlbada, it is possible that a larger CFL could be tolerated (assuming sufficient grid density is used).
5. Gamma 0 – Corresponds to central differencing and therefore we expect it to be the least stable (and not total variation diminishing). This is confirmed by the results which are poor in all cases! Decreasing the CFL number helps but it is clear that different schemes should be used.
6. Gamma 0.5 – Corresponds to hybrid central and upwind (TVD) differencing. The results are much better than Gamma 0.  In fact, the results are very similar to the results of vanLeer.
7. Gamma 1 – Corresponds to fully TVD linear upwind interpolation. This scheme should be the most stable.  However, because it is only first order, higher grid resolution is required to get the best results. This is the compromise that must be made between stability and accuracy when using TVD schemes.

In my opinion, the two best options are vanAlbada and Gamma 1. vanAlbada most likely provides the best mix between accuracy and stability (at least for the case examined here). Gamma 1 provides the best option if stability is the most important thing to you. However, because it is first order you will need more cells to get the most accurate solution.

Details of the test case and all of the results are listed below! Hopefully somebody finds this useful. If I have anything wrong please let me know! If you want me to try more schemes or anything different let me know as well!

Cheers,

curiosityFluids

## Shock-tube Case

If you aren’t familiar with the shock tube case, it is the simple one dimensional problem where one side (the driver side) begins at a high pressure. The other side (the driven side) is at a lower pressure. When the simulation begins, the discontinuous initial conditions send a shock wave down the tube. Following the shock wave is a contact surface. Here is an animation of the simulation:

## vanLeer

CFL=0.2

• 100, 1000, 10000 cells

### CFL=0.1

• 100, 1000, 10000 cell

## vanAlbada

### CFL=0.2

• 100, 1000, 10000 cells

### CFL=0.1

• 100, 1000, 10000 cells

## Gamma

• ### CFL=0.2

• 100, 1000, 10000 cells
• ### CFL=0.1

• 100, 1000, 10000 cells

• ### CFL=0.2

• 100, 1000, 10000 cells
• ### CFL=0.1

• 100, 1000, 10000 cells

• ### CFL=0.2

• 100, 1000, 10000 cells
• ### CFL=0.1

• 100, 1000, 10000 cells

# Converging-Diverging Nozzle v2- rhoCentralFoam

Recently I read a CFD Online forum post where the accuracy of rhoCentralFoam was called into question.

The test case was the simple example of a converging diverging nozzle flow. In fact, I have already done a blog post regarding this. However, I tackled the problem using a large reservoir. In fact, it would have been more prudent to just simulate the nozzle and attempt to match the example from the NASA cfd benchmarking website:

http://www.grc.nasa.gov/WWW/wind/valid/cdv/cdv.html

So this is what I’ve done!

The case file can be found here:

Case File Download

The geometry in the case is an axi-symmetric converging diverging nozzle defined by a cosine function. I built the geometry and mesh in PointWise (just for the sake of time… I mean, I already did a detailed nozzle post). The result is here:

Three cases are calculated for comparison on the nasa site given above:

1. Subsonic flow at exit (Pe/Po=0.89)
2. Supersonic flow with shock wave in expanding section (Pe/Po=0.75)
3. Supersonic flow at the exit (Pe/Po=0.16)

## Case 1- Subsonic

For the subsonic case, it is important to remember that the outlet pressure MUST be set. Why? Because for a given nozzle geometry and stagnation pressure there is more than one possible solution since the flow is not choked!

The two most important boundary conditions here are the inlet and outlet. The inlet is specified using the totalPressure boundary condition (in my set-up P0=10000 Pa). You can also specify the total temperature. However, this will not affect the mach number or pressure profiles, only the velocity, density and temperature profiles. I set the temperature to be fixed at 298 K. The nozzle itself is an adiabatic, slip wall. The front and back are wedge types. The outlet is set to zeroGradient for velocity and temperature and the pressure is fixed to 8900 Pa (P/Po=0.89)

The results for pressure distribution and Mach number are shown here. Remember that since we are comparing P/Po and Mach number, it didn’t matter that I used a different pressure and temperature than the test case. I also included gifs showing the unsteady part of the simulation at the start.

Clearly the results match! Woohoo! One down, two to go!

## Case 2- Supersonic with shock in diverging section

Tip for supersonic flow solution: Initialize the problem as a shock tube! Then the throat is choked right away in the simulation and convergence to the solution is faster!

In this case we must also specify the outlet pressure. Why? Because there are multiple solutions possible! Changing the back pressure changes the strength and location of the shock in the diverging section! So the setup is identical to the subsonic case for the inlet and nozzle. The only difference is that the outlet is set to 7500 Pa (P/Po=0.75).  In order to speed convergence, we can use the setFields utility to set the LHS of the nozzle to the stagnation pressure, and the RHS of the nozzle to the outlet pressure.

The results for pressure distribution and Mach number are shown here:

Hurray! Two for two!

## Case 3- Supersonic Flow

The fully supersonic case is in fact the most simple. Recall that a supersonic nozzle is actually an initial value problem! This is in contrast to the subsonic cases, or cases with shocks, where they are boundary value problems (the outlet pressure controls the solution). But in order to achieve the supersonic flow solution we just set the outlet pressure to be zeroGradient. Additionally, we again start the solution as a shock tube.

So you might ask, but we were given a specified outlet pressure! Well, we CAN set this outlet pressure. But this unnecissarily restricts our solution. Having a back pressure very close to, but not exactly the same as the actual supersonic outlet pressure could make things difficult. It is much easier to let the solution converge to where IT THINKS the right answer is. Then, how closely we match the outlet pressure is in fact an indicator of the quality of our solution!

Here are the results:

Three for three! rhoCentralFoam has passed the test.

As always comment and correct me where my mouth (or keyboard) has made error.

Cheers,

curiosityFluids