compute compound pressure
PLR = 0.5*(ppLL + ppRR + rhLL*(SL-uuLL)*(SP-uuLL)+
rhRR*(SR-uuRR)*(SP-uuRR))
Ds[3] = SP # compute~D
if (SL >= 0.0)
for m = 1:3
f[i,m] = fL[i,m]
end
elseif (SR <= 0.0)
for m =1:3
f[i,m] = fR[i,m]
end
elseif ((SP >=0.0) & (SL <= 0.0))
for m = 1:3
f[i,m] = (SP*(SL*uL[i,m]-fL[i,m]) + SL*PLR*Ds[m])/(SL-SP)
end
elseif ((SP <= 0.0) & (SR >= 0.0))
for m = 1:3
f[i,m] = (SP*(SR*uR[i,m]-fR[i,m]) + SR*PLR*Ds[m])/(SR-SP)
end
end
end
end
✝ ✆
```
**Figure 13.** Evolution of density, velocity, energy, and pressure at *t* = 0.2 for the shock tube problem computed using Riemann solver based on Harten-Lax-van Leer Contact (HLLC) scheme. The true solution is calculated with *N* = 8192 grid resolution with Δ*t* = 0.00005 and the low-resolution results are for *N* = 256 grid resolution with Δ*t* = 0.0001.

#### *5.3. Rusanov's Riemann Solver*

We show the implementation of Riemann solver using Rusanov scheme. This is similar to what we discussed in Section 4.2. The Riemann solver based on Rusanov scheme is simple compared to Roe's Riemann solver and HLLC based Riemann solver. For Euler equations, instead of solving one equation (as in inviscid Burgers equation), now we have to follow the procedure for three equations (i.e., density, velocity, and energy). We need to approximate wave propagation speed at the interface *ci*<sup>+</sup>1/2 to compute flux at the interface. For Rusanov scheme, we simply use maximum eigenvalue of the Jacobian matrix as the wave propagation speed. We have *ci*<sup>+</sup>1/2 = max(*u*¯, |*u*¯ + *a*¯|, |*u*¯ − *a*¯|), where *u*¯ and *a*¯ are computed using Roe averaging. Figure 14 shows the density, velocity, pressure, and energy at final time *t* = 0.2 computed using Riemann solver based on Rusanov scheme. The oscillations in the numerical solution calculated by the Rusanov scheme is more than those calculated by the Roe's Riemann solver or HLLC scheme based Riemann solver. One of the advantage of Rusanov scheme is that it is simple to implement and is computationally faster. The true solution is computed using *N* = 8192 grid points and Δ*t* = 0.00005 and is compared with the low-resolution results for *N* = 256 grid points and Δ*t* = 0.0001. The implementation of Riemann solver based on Rusanov's scheme is given in Listing 17.

**Figure 14.** Evolution of density, velocity, energy, and pressure at *t* = 0.2 for the shock tube problem computed using Riemann solver based on Rusanov scheme. The true solution is calculated with *N* = 8192 grid resolution with Δ*t* = 0.00005 and the low-resolution results are for *N* = 256 grid resolution with Δ*t* = 0.0001.

**Listing 17.** Implementation of Julia function to calculate the interface flux using Riemann solver based on Rusanov scheme. ✞ ☎

```