wiki:u/adebrech/code

Version 2 (modified by adebrech, 8 years ago) ( diff )

Exact Riemann Solver (no vacuum)

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

with initial conditions

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.

The program reads input from a file called problem.data, and stores many of the relevant parameters in global variables.

NAMELIST/ProblemData/ rhoL,uL,pL,rhoR,uR,pR,gamma,tol,starttime,finaltime,frames,xL,xR,res

inquire(file='problem.data', exist=ex)
if (ex) then
 OPEN(UNIT=30, FILE='problem.data', STATUS="OLD")
 READ(30,NML=ProblemData)                               ! read into variables in namelist
 CLOSE(30)
else
 print *, 'Missing problem.data. Exiting.'
 stop           ! exit if missing
end if

The state vectors WL and WR 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.

These state vectors are then passed to the Newton-Raphson solver, which calls a subroutine to guess a good value for p0 (currently not very effective - just uses tol) and then iterates until the tolerance for change in pressure between steps is met.

See below for derivation of function f.

From the shock jump conditions

and the energy and EOS of an ideal gas

where is the velocity of the fluid in the frame of the shock, the function ,

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

and the Generalized Riemann Invariant

where is the speed of sound in the region, can be used to construct

The same analysis can be performed on the right side of the system to yield the same results.

The Riemann problem can then be solved by finding the value such that

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_*):

If our initial guess is and , we want to change so that ; the Taylor expansion is given by

Dropping second order and higher terms, since we have , we know , and solving for ,

and

The iteration procedure is terminated at the term such that

where is the (generally small) tolerance passed to the solver.

Source: See Toro, Riemann Solvers and Numerical Methods for Fluid Dynamics

Attachments (10)

Note: See TracWiki for help on using the wiki.