| 3 | The Riemann problem is the solution of a system of hyperbolic conservation laws (in our case the Euler equations). This solver assumes two one-dimensional ideal gases separated at the origin x=0, with initial densities, velocities, and pressures given as input. It gives a solution to the set of equations |
| 4 | |
| 5 | {{{#!latex |
| 6 | $\rho + \rho u = 0$ |
| 7 | |
| 8 | $\rho u + \rho u^2 + p = 0$ |
| 9 | |
| 10 | $E + u(E + p) = 0$ |
| 11 | }}} |
| 12 | |
| 13 | with initial conditions |
| 14 | |
| 15 | |
| 16 | {{{#!latex |
| 17 | $\rho(x,0) = \begin{cases} \rho_L, & x < 0 \\ \rho_R, & x > 0 \end{cases}$ |
| 18 | |
| 19 | $\rho(x,0)u(x,0) = \begin{cases} \rho_L u_L, & x < 0 \\ \rho_R u_R, & x > 0 \end{cases}$ |
| 20 | |
| 21 | $E(x,0) = \begin{cases} E_L, & x < 0 \\ E_R, & x > 0 \end{cases}$ |
| 22 | }}} |
| 23 | |
| 24 | The solutions to this IVP at later times are split into four regions - to the left, the initial left state, unperturbed by interaction with the right; between the left and center-left regions, there will either be a rarefaction fan or a shock (assumed ideal), across which the new equilibrium left state holds; the left and right fluids will be separated by a contact discontinuity, across which the new equilibrium right state holds (note that the right and left equilibrium states differ only in their densities); the center-right region will then be separated by a rarefaction fan or (again ideal) shock from the rightmost region, which is still in the initial right state. |
| 25 | |
| 26 | The program reads input from a file called problem.data, and stores many of the relevant parameters in global variables. |
| 27 | |
| 28 | {{{#!fortran |
| 29 | NAMELIST/ProblemData/ rhoL,uL,pL,rhoR,uR,pR,gamma,tol,starttime,finaltime,frames,xL,xR,res |
| 30 | |
| 31 | inquire(file='problem.data', exist=ex) |
| 32 | if (ex) then |
| 33 | OPEN(UNIT=30, FILE='problem.data', STATUS="OLD") |
| 34 | READ(30,NML=ProblemData) ! read into variables in namelist |
| 35 | CLOSE(30) |
| 36 | else |
| 37 | print *, 'Missing problem.data. Exiting.' |
| 38 | stop ! exit if missing |
| 39 | end if |
| 40 | }}} |
| 41 | |
| 42 | The state vectors W,,L,, and W,,R,, are created with overloaded constructors that also calculate useful parameters A and B and the speed of sound c for use later in the program. |
| 43 | |
| 44 | |
| 45 | These state vectors are then passed to the Newton-Raphson solver, which calls a subroutine to guess a good value for p,,0,, (currently not very effective - just uses tol) and then iterates until the tolerance for change in pressure between steps is met. |
| 46 | |
| 47 | |
| 48 | {{{#!latex |
| 49 | $f_reg(p_*) = (p_* - p_reg) [\frac{2}{(\gamma + 1) \rho_reg (p_* + \frac{\gamma - 1}{\gamma + 1} p_reg)}]$ |
| 50 | }}} |
| 51 | |
| 52 | |
| 53 | See below for derivation of function f. |
| 54 | |
| 55 | From the shock jump conditions |
| 56 | |
| 57 | {{{#!latex |
| 58 | $\rho_L \hat{u_L} = \rho_{*L} \hat{u_*}$ |
| 59 | |
| 60 | $\rho_L \hat{u_L}^2 + p_L = \rho_{*L} \hat{u_*}^2 + p_*$ |
| 61 | |
| 62 | $\hat{u_L}(\hat{E_L} + p_L) = \hat{u_*}(\hat{E_{*L}} + p_*)$ |
| 63 | }}} |
| 64 | |
| 65 | and the energy and EOS of an ideal gas |
| 66 | |
| 67 | {{{#!latex |
| 68 | $e = \frac{p}{(\gamma - 1) \rho}$ |
| 69 | |
| 70 | $p = \rho R T$ |
| 71 | }}} |
| 72 | |
| 73 | where $\hat{u} = u_L - S_L$ is the velocity of the fluid in the frame of the shock, the function $f_L(p_*) = u_L - u_*$, |
| 74 | |
| 75 | {{{#!latex |
| 76 | $f_L(p_*) = (p_* - p_L) [\frac{2}{(\gamma + 1) \rho_L (p_* + \frac{\gamma - 1}{\gamma + 1} p_L)}]$ |
| 77 | }}} |
| 78 | |
| 79 | can be derived to connect the left state with the pressure in the central, interaction region in the case of a shock. Similarly, in the case of a rarefaction, instead of the shock jump conditions, the isentropic equation |
| 80 | |
| 81 | {{{#!latex |
| 82 | $\frac{p_*}{\rho_*} = \frac{p_L}{\rho_L}$ |
| 83 | }}} |
| 84 | |
| 85 | and the Generalized Riemann Invariant |
| 86 | |
| 87 | {{{#!latex |
| 88 | $u_L + \frac{2 c_L}{\gamma - 1} = u_* + \frac{2 c_{*L}}{\gamma - 1}$ |
| 89 | }}} |
| 90 | |
| 91 | where $c = \sqrt{\frac{\gamma p}{\rho}}$ is the speed of sound in the region, can be used to construct |
| 92 | |
| 93 | {{{#!latex |
| 94 | $f_L(p_*) = \frac{2 c_L}{\gamma - 1}[(\frac{p_*}{p_L})^{\frac{\gamma - 1}{2 \gamma}} - 1]$ |
| 95 | }}} |
| 96 | |
| 97 | The same analysis can be performed on the right side of the system to yield the same results. |
| 98 | |
| 99 | The Riemann problem can then be solved by finding the value $p = p_*$ such that |
| 100 | |
| 101 | {{{#!latex |
| 102 | $f_L(p_*) + f_R(p_*) + u_R - u_L = 0$ |
| 103 | }}} |
| 104 | |
| 105 | The function and its first and second derivatives are well-behaved and monotonic, so we can use a simple Newton-Raphson iterative method, derived from a Taylor series expansion of f(p_*): |
| 106 | |
| 107 | If our initial guess is $p_k$ and $f(p_k) \ne 0$, we want to change $p_k$ so that $f(p_k + \delta) = f(p_{k+1}) = 0$; the Taylor expansion is given by |
| 108 | |
| 109 | {{{#!latex |
| 110 | $f(p_k + \delta) = f(p_k) + \delta f'(p_k) + O(\delta^2)$ |
| 111 | }}} |
| 112 | |
| 113 | Dropping second order and higher terms, since we have $f(p_k + \delta) = 0$, we know $f(p_k) + \delta f'(p_k) = 0$, and solving for $\delta$, |
| 114 | |
| 115 | {{{#!latex |
| 116 | $\delta = -\frac{f(p_k)}{f'(p_k)}$ |
| 117 | }}} |
| 118 | |
| 119 | and |
| 120 | |
| 121 | {{{#!latex |
| 122 | $p_{k + 1} = p_k + \delta = p_k - \frac{f(p_k)}{f'(p_k)}$ |
| 123 | }}} |
| 124 | |
| 125 | The iteration procedure is terminated at the term such that |
| 126 | |
| 127 | {{{#!latex |
| 128 | $|\frac{2 (p_{k + 1} - p_k)}{p_{k + 1} + p_k}| < Tol$ |
| 129 | }}} |
| 130 | |
| 131 | where $Tol$ is the (generally small) tolerance passed to the solver. |
| 132 | |
| 133 | Source: See Toro, Riemann Solvers and Numerical Methods for Fluid Dynamics |