This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

\newdate

date01052013

An Introduction to Fluid Dynamics and Numerical Solution of Shock Tube Problem by Using Roe Solver

Soumen Roy
St.Xavier’s College & Bose Institute
Department of Physics
Kolkata 700091
(\displaydatedate)
Acknowledgements

First and foremost, I offer my sincerest gratitude to my supervisor, Prof. Sanjay K. Ghosh, who has supported me throughout my thesis with his patience and knowledge whilst allowing me the room to work in my own way. I attribute the level of my Masters degree to his encouragement and effort and without him this thesis, too, would not have been completed or written. One simply could not wish for a better or friendlier supervisor.

I would like to thank the administration of Bose Institute, which played an instrumental role during the course of my project by providing me requisite computer facility.

My parents, Sukumar and Lila Roy, have been a constant source of support – emotional, moral and of source financial – during my whole life.

Abstract

The study of fluids has been a topic of intense research for several hundred years. Over the years, this has further increased due to improved computational facility, which makes it easy to numerically simulate the fluid dynamics, which was beyond the analytical reach before. In this project, we discuss the general transport theorem for moving control volume system, apply this theory to control mass system which gives the continuity equation, and on momentum conservation from which we get the Navier-Stokes equation and energy conservation. By approximating the three equations for the ideal gas flow, we get one dimensional Euler equation. These equations are non-linear, and their analytic solutions are highly non-trivial. We will use Riemann solvers to get the exact solution numerically. In this project, we have considered only the Sod’s Shock Tube problem. Finally, we focus on the exact and approximate solution of density, pressure, velocity, entropy, and Mach number using Python code.

[Uncaptioned image]

1 Introduction

1.1 What is a Fluid?

A fluid is any substance that deforms continuously when subjected to a shear stress, no matter how small. Usually a liquid or a gas.

1.2 Newton’s Law of Viscosity:

The shear viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds. It can be defined through the idealized situation known as a Couette flow, where a layer of fluid is trapped between two horizontal plates, one fixed and one moving horizontally at constant speed . (The plates are assumed to be very large, so that one need not consider what happens near their edges.)If the speed of the top plate is small enough, the fluid particles will move parallel to it, and their speed will vary linearly from zero at the bottom to at the top. Each layer of fluid will move faster than the one just below it, and friction between them will give rise to a force resisting their relative motion. In particular, the fluid will apply on the top plate a force in the direction opposite to its motion, and an equal but opposite to the bottom plate. An external force is therefore required in order to keep the top plate moving at constant speed.

Refer to caption
Figure 1: Laminar shear of fluid between two plates.

The magnitude F of this force is found to be proportional to the speed u and the area A of each plate , and inversely proportional to the separation y. i.e.

F=μAuy\textbf{F}=\mu A\frac{\textbf{u}}{y}

the proportionality factor μ\mu is this formula the viscosity of the fluid The ratio uy\frac{\textbf{u}}{y} is called the rate of shear deformation or shear velocity, and is the derivative of the fluid speed in the direction perpendicular to the plates. Isaac Newton expressed the viscous forces by the differential equation

τ=μuy\tau=\mu\frac{\partial\textbf{u}}{\partial y}

where τ=fA\tau=\frac{\textbf{f}}{A} and uy\frac{\partial\textbf{u}}{\partial y} is the local shear velocity. and similar case for 2 D

τxy=μ(uy+vx)\tau_{xy}=\mu\left(\frac{\partial\textbf{u}}{\partial y}+\frac{\partial\textbf{v}}{\partial x}\right)

This is also known as Newton’s Second law of Viscosity.

1.3 Specification of motion

Fluids are treated as continuous media. There are four main physical idea which forms the basis of fluid dynamics:

  1. \ast

    The continuum hypothesis,

  2. \ast

    Conservation of mass,

  3. \ast

    Balance of momentum (Newton‘s second law of motion) and

  4. \ast

    Balance (conservation) of energy. The last of these is not needed in the description of some types of flows

Motion and state can be specified in terms of the velocity u, pressure P, density ρ\rho etc evaluated at every point in space x and time t. To define the density at a point, for example, suppose the point to be surrounded by a very small element (small compared with length scales of interest in experiments) which nevertheless contains a very large number of molecules. The density is then the total mass of all the molecules in the element divided by the volume of the element. Considering the velocity, pressure etc as functions of time and position in space is consistent with measurement techniques using fixed instruments in moving fluids. It is called the Eulerian specification. However, Newton’s laws of motion (see below) are expressed in terms of individual particles, or fluid elements, which move about. Specifying a fluid motion in terms of the position x(t)\textbf{x}(t) of an individual particle (identified by its initial position, say) is called the Lagrangian specification. The two are linked by the fact that the velocity of such an element is equal to the velocity of the fluid evaluated at the position occupied by the element:

dxdt=u(x(t),t)\frac{d\textbf{x}}{dt}=\textbf{u}(\textbf{x}(t),t)

Path Line: The path followed by a fluid element is called a particle path or path line. Mathematically obtained by

dx=udtd\textbf{x}=\textbf{u}dt
x=x0+t0t1u(x(t),t)𝑑t\Rightarrow\textbf{x}=\textbf{x}_{0}+\int_{t_{0}}^{t_{1}}\textbf{u}(x(t),t)dt

Stream Line: A streamline is a continuous line within a fluid such that the tangent at each point is the direction of the velocity vector at that point.stream lines are defined as

dxdtu=0\frac{d\textbf{x}}{dt}\otimes\textbf{u}=0

the components of u and x are related by from upper expression

dxu=dyv=dzdw\frac{dx}{u}=\frac{dy}{v}=\frac{dz}{dw}

Streak Lines: A streak line is the locus of the temporary locations of all particles that have passed though a fixed point in the flow field at any instant of time.

1.4 Material Derivative

Identify (or label) a material of the fluid; track (or follow) it as it moves, and monitor change in its properties. The properties may be velocity, temperature, density, mass, concentration etc in the flow field. In Lagrangian Approach the trajectory of each individual fluid parcel as it moves from some initial location, often described as “―placing a coordinate system on each fluid parcel“ and “―riding on that parcel as it travels through the fluid.“

In Eulerian Approach This corresponds to a coordinate system fixed in space, and in which fluid properties are studied as functions of time as the flow passes fixed spatial locations.

suppose a fluid property f is function of coordinate (x,y,z,t) as like f = f(x,y,z,t) and velocity vector U(u,v,w)T\textbf{U}\equiv(u,v,w)^{T} then

df=ftdt+fxdx+fydy+fzdzdf=\frac{\partial f}{\partial t}dt+\frac{\partial f}{\partial x}dx+\frac{\partial f}{\partial y}dy+\frac{\partial f}{\partial z}dz
dfdt=ft+fxdxdt+fydydt+fzdzdt\Rightarrow\frac{df}{dt}=\frac{\partial f}{\partial t}+\frac{\partial f}{\partial x}\frac{dx}{dt}+\frac{\partial f}{\partial y}\frac{dy}{dt}+\frac{\partial f}{\partial z}\frac{dz}{dt}
dfdt=ft+ufx+vfy+wfz\Rightarrow\frac{df}{dt}=\frac{\partial f}{\partial t}+u\frac{\partial f}{\partial x}+v\frac{\partial f}{\partial y}+w\frac{\partial f}{\partial z}
dfdt=ft+(U)f\Rightarrow\frac{df}{dt}=\frac{\partial f}{\partial t}+\left(\textbf{U}\cdot\nabla\right)f

the term ft\frac{\partial f}{\partial t} is the local acceleration and (U)\left(\textbf{U}\cdot\nabla\right) the convective acceleration. The convective acceleration is nonlinear in f,which is the source of the great complexity of the mathematics and physics of fluid motion.

2 General Transport Theorem

The general transport theorem shows a beautiful equation from which the all conservation equations can be derived. This equation gives a expression for the variation of a physical quantity distributed in a scalar or vectorial field inside a deformable volume. This deformable volume can have variable mass if its boundary is permeable (open system). The basic Reynolds Transport Theorem shows the relation for a constant mass volume and a fixed volume, but it can be easily expanded to consider changes in a generic volume. The most interesting fact about these theorem is that it is only a geometrical relation. Physics only gets into the transport theorem when we define changes in a constant mass volume, which can use known physical laws, specially from thermodynamics.

2.1 Control System

Control Mass:

  1. 1.

    It is a system of fixed mass.

  2. 2.

    This type of system is usually referred to as “closed system”.

  3. 3.

    There is no mass transfer across the system boundary.

  4. 4.

    Energy transfer may be take place into or out of the system.

Control Volume:

  1. 1.

    It is a system of fixed Volume.

  2. 2.

    This type of system usually referred to as “Open System” or a ”Control Volume“.

  3. 3.

    Mass transfer take place across the control volume.

  4. 4.

    Energy Transfer also occur into or out of the system.

2.2 Reynolds Transport Theorem:

The question arise as to how a given quantity changes ψ\psi (where, ψ(x,t)\psi(\textbf{x},t) some fluid property per unit volume) with respect to time as a material volume deforms.

We define the material volume as: An arbitrary chosen control volume of fluid whose surface moves at the particle velocity.

The significance of the volume moving at the same rate as the particle velocity is that no mass is transported across the chosen control surface that encloses the control volume. In addition, we state by definition that the material control volume deforms with the body motion.

Refer to caption
Figure 2: Material Control Volume

Consider a material volume Vm(t)V_{m}(t) with surface area Sm(t)S_{m}(t). The unit normal to the surface is denoted by n¯\underline{\textbf{n}} and the surface velocity is denoted by v¯\underline{\textbf{v}}. But in our calculation n¯n^\underline{\textbf{n}}\Leftrightarrow\hat{\textbf{n}} and v¯U\underline{\textbf{v}}\Leftrightarrow\textbf{U}. Within this control volume is a property of the continuum ψ\psi that is of interest. We would like to determine how ψ\psi changes with time. The total amount of ψ\psi present in the volume Vm(t)V_{m}(t) can be expressed as:

F(t)=Vm(t)ψ(x,t)𝑑V\textbf{F}(t)=\int_{V_{m}(t)}\psi(\textbf{x},t)dV (2.1)

The time rate of change if the fluid property is defined as:

dFdt=ddtVm(t)ψ(x,t)𝑑V\frac{d\textbf{F}}{dt}=\frac{d}{dt}\int_{V_{m}(t)}\psi(\textbf{x},t)dV (2.2)

Since integration limit Vm(t)V_{m}(t) is function of time so we can not take the derivative inside the               integration directly. In order to overcome this problem we transform the volume, and material property from a spatial representation to a reference/material representation. Recall that any differential volume element at time t is

dV=JdV0dV=JdV_{0}

where dV0dV_{0} is differential volume at t = 0 and Jacobian J is defined as

J=detF=[x1X1x2X1x3X1x1X2x2X2x3X2x1X3x2X3x3X3]J=detF=\begin{bmatrix}\vspace{2mm}\frac{\partial x_{1}}{\partial X_{1}}&\frac{\partial x_{2}}{\partial X_{1}}&\frac{\partial x_{3}}{\partial X_{1}}\\ \vspace{2mm}\par\frac{\partial x_{1}}{\partial X_{2}}&\frac{\partial x_{2}}{\partial X_{2}}&\frac{\partial x_{3}}{\partial X_{2}}\\ \frac{\partial x_{1}}{\partial X_{3}}&\frac{\partial x_{2}}{\partial X_{3}}&\frac{\partial x_{3}}{\partial X_{3}}\end{bmatrix} (2.3)

Given x=Φ(X,t)\textbf{x}=\Phi(\textbf{X},t) also Ψ(x,t)\Psi(\textbf{x},t) can be expressed in terms of material coordinates by employing the results is

Ψ(x,t)=Ψ(Φ(x,t),t)=Ψ(X,t)\Psi(\textbf{x},t)=\Psi({\Phi(\textbf{x},t)},t)=\Psi(\textbf{X},t)

Therefore we can express the integral in equation  2.2 in terms of the material coordinates:

dFdt=V0ddt[Ψ(X,t)J]𝑑V0\frac{d\textbf{F}}{dt}=\int_{V_{0}}\frac{d}{dt}\left[\Psi(\textbf{X},t)J\right]dV_{0}
dFdt=V0[dΨ(X,t)dtJ+Ψ(X,t)dJdt]𝑑V0\Rightarrow\frac{d\textbf{F}}{dt}=\int_{V_{0}}\left[\frac{d\Psi(\textbf{X},t)}{dt}J+\Psi(\textbf{X},t)\frac{dJ}{dt}\right]dV_{0}
dFdt=V0[(Ψ(X,t)t+(U)Ψ)J+Ψ(X,t)dJdt]𝑑V0\Rightarrow\frac{d\textbf{F}}{dt}=\int_{V_{0}}\left[\left(\frac{\partial\Psi(\textbf{X},t)}{\partial t}+(\textbf{U}\cdotp\nabla)\Psi\right)J+\Psi(\textbf{X},t)\frac{dJ}{dt}\right]dV_{0} (2.4)

Where U is the velocity of control volume Now we recall J, from equation 2.3 we can say the J is function of xX\frac{\partial\textbf{x}}{\partial\textbf{X}} i.e.

J=J(xX)J=J\left(\frac{\partial\textbf{x}}{\partial\textbf{X}}\right)
dJ=J(xX)d(xX)\Rightarrow dJ=\frac{\partial J}{\partial\left(\frac{\partial\textbf{x}}{\partial\textbf{X}}\right)}d(\frac{\partial\textbf{x}}{\partial\textbf{X}})
dJdt=J(xX)ddt(xX)\Rightarrow\frac{dJ}{dt}=\frac{\partial J}{\partial\left(\frac{\partial\textbf{x}}{\partial\textbf{X}}\right)}\frac{d}{dt}\left(\frac{\partial\textbf{x}}{\partial\textbf{X}}\right)
dJdt=J(xX)X(dxdt)\Rightarrow\frac{dJ}{dt}=\frac{\partial J}{\partial\left(\frac{\partial\textbf{x}}{\partial\textbf{X}}\right)}\frac{\partial}{\partial X}\left(\frac{d\textbf{x}}{dt}\right)
dJdt=J(U)\Rightarrow\frac{dJ}{dt}=J\left(\nabla\cdot\textbf{U}\right) (2.5)

Now putting the value of dJdt\frac{dJ}{dt} in equation  2.5 we get,

dFdt=V0[Ψ(X,t)t+(U)Ψ+Ψ(X,t)(U)]J𝑑V0\frac{d\textbf{F}}{dt}=\int_{V_{0}}\left[\frac{\partial\Psi(\textbf{X},t)}{\partial t}+(\textbf{U}\cdotp\nabla)\Psi+\Psi(\textbf{X},t)\left(\nabla\cdot\textbf{U}\right)\right]JdV_{0}
dFdt=Vm(t)[Ψt+(UΨ)]𝑑Vm\Rightarrow\frac{d\textbf{F}}{dt}=\int_{V_{m}(t)}\left[\frac{\partial\Psi}{\partial t}+\nabla\cdot\left(\textbf{U}\Psi\right)\right]dV_{m}
ddtVm(t)Ψ(x,t)𝑑Vm=Vm(t)[Ψt+(UΨ)]𝑑Vm\Rightarrow\frac{d}{dt}\int_{V_{m}(t)}\Psi(\textbf{x},t)dV_{m}=\int_{V_{m}(t)}\left[\frac{\partial\Psi}{\partial t}+\nabla\cdot\left(\textbf{U}\Psi\right)\right]dV_{m} (2.6)

This is known as Reynold’s Transport Theorem.[6] Now applying Gauss’s Divergence Theorem in 2nd2^{nd} of the integral for the surface area Sm(t)S_{m}(t) of the control volume of volume Vm(t)V_{m}(t) we get

dFdt=Vm(t)Ψt𝑑Vm+Sm(t)ΨUn^𝑑Sm\frac{d\textbf{F}}{dt}=\int_{V_{m}(t)}\frac{\partial\Psi}{\partial t}dV_{m}+\int_{S_{m}(t)}\Psi\textbf{U}\cdot\hat{\textbf{n}}dS_{m}
ddtVm(t)Ψ(x,t)𝑑Vm=Vm(t)Ψt𝑑Vm+Sm(t)ΨUn^𝑑Sm\frac{d}{dt}\int_{V_{m}(t)}\Psi\left(\textbf{x},t\right)dV_{m}=\int_{V_{m}(t)}\frac{\partial\Psi}{\partial t}dV_{m}+\int_{S_{m}(t)}\Psi\textbf{U}\cdot\hat{\textbf{n}}dS_{m} (2.7)

                                                       Rate of change at          Net flow of Ψ\Psi                                                                                                                                           .                                                           a point volume           across the surface Sm(t)S_{m}(t)

This is another form of RTT which is known as General Transport Theorem.\textbf{General Transport Theorem}.

3 Conservation of Mass

Conservation of mass The constancy of mass is inherent in the definition of a control mass system and therefore we can write

(dmdt)CMS=0\left(\frac{dm}{dt}\right)_{CMS}=0 (3.1)

The total mass of the the control volume can be defined as

m=Vm(t)ρ𝑑Vmm=\int_{V_{m(t)}}\rho dV_{m}

To develop the analytical statement for the conservation of mass of a control volume, by using equation  2.6 we get,

dmdt=Vm(t)[ρt+(Uρ)]𝑑Vm\frac{d\textbf{m}}{dt}=\int_{V_{m}(t)}\left[\frac{\partial\rho}{\partial t}+\nabla\cdot\left(\textbf{U}\rho\right)\right]dV_{m}
Vm(t)[ρt+(Uρ)]𝑑Vm=0\Rightarrow\int_{V_{m}(t)}\left[\frac{\partial\rho}{\partial t}+\nabla\cdot\left(\textbf{U}\rho\right)\right]dV_{m}=0
ρt+(Uρ)=0\frac{\partial\rho}{\partial t}+\nabla\cdot\left(\textbf{U}\rho\right)=0 (3.2)

This known as mass conservation equation also known as differential form of continuity equation.

4 ConservatioFconsern of Momentum

Conservation of Momentum or Momentum Theorem The principle of conservation of momentum as applied to a control volume is usually referred to as the momentum theorem.The first step in deriving the analytical statement of linear momentum theorem is to write the equation  2.7 for the property Ψ\Psi as the linear-momentum mum\textbf{u} and the velocity u along x-direction . Then it becomes

ddtVm(t)ρu𝑑Vm=Vm(t)[t(ρu)+(ρuU)]𝑑Vm\frac{d}{dt}\int_{V_{m}(t)}\rho udV_{m}=\int_{V_{m}(t)}\left[\frac{\partial}{\partial t}\left(\rho u\right)+\nabla\cdot\left(\rho u\textbf{U}\right)\right]dV_{m} (4.1)
ddtVm(t)ρu𝑑Vm=Vm(t)[t(ρu)+(ρuU)]𝑑Vm\Rightarrow\frac{d}{dt}\int_{V_{m}(t)}\rho udV_{m}=\int_{V_{m}(t)}\left[\frac{\partial}{\partial t}\left(\rho u\right)+\nabla\cdot\left(\rho u\textbf{U}\right)\right]dV_{m}
=Vm(t)u[ρt+ρU]+[ρut+ρUu]dVm=\int_{V_{m}(t)}u\left[\frac{\partial\rho}{\partial t}+\nabla\cdot\rho\textbf{U}\right]+\left[\rho\frac{\partial u}{\partial t}+\rho\textbf{U}\cdot\nabla u\right]dV_{m}

The last term of 1st1^{st} term of the integral and first term of 2nd2^{nd} term of the integral create shows the equation of mass conservation which gives zero. so that

Vm(t)[ρρt+ρUu]𝑑Vm=Vm(t)ρdudt𝑑Vm\int_{V_{m}(t)}\left[\rho\frac{\partial\rho}{\partial t}+\rho\textbf{U}\cdot\nabla u\right]dV_{m}=\int_{V_{m}(t)}\rho\frac{du}{dt}dV_{m} (4.2)

From equation  4.1 and  4.2 we get (similar equations can be derived for v and w as well)

Vm(t)ρdUdt𝑑Vm=Vm(t)FB𝑑Vm+Sm(t)FS𝑑Sm\int_{V_{m}(t)}\rho\frac{d\textbf{U}}{dt}dV_{m}=\int_{V_{m}(t)}\textbf{F}_{B}dV_{m}+\int_{S_{m}(t)}\textbf{F}_{S}dS_{m} (4.3)

We begin by noting that FS\textbf{F}_{S} be a vector that there must be a matrix say T such that

Fs=Tn^\textbf{F}_{s}=\textbf{T}\cdot\hat{\textbf{n}}

Notice that the ”dot” notation for the matrix-vector product is used to emphasize that each component of FS\textbf{F}_{S} is the (vector) dot product of the corresponding row of T with the unit column vector n^\hat{\textbf{n}}. So we get

Vm(t)ρdUdt𝑑Vm=Vm(t)FB𝑑Vm+Sm(t)Tn^𝑑Sm\int_{V_{m}(t)}\rho\frac{d\textbf{U}}{dt}dV_{m}=\int_{V_{m}(t)}\textbf{F}_{B}dV_{m}+\int_{S_{m}(t)}\textbf{T}\cdot\hat{\textbf{n}}dS_{m}

By using Gauss Divergence Theorem for the last term of RHS and recalling Vm(t)V_{m}(t) as arbitrary fluid element, we get

ρdUdtFBT=0\rho\frac{d\textbf{U}}{dt}-\textbf{F}_{B}-\nabla\cdot\textbf{T}=0 (4.4)

This provides a fundamental and very general momentum balance that is valid at all points of any fluid flow (following the continuum hypothesis). T is reason of surface force. Now we are not going to more expression of T. Now writing the final form of T

T=[P+τxxτxyτxzτyxP+τyyτyzτzxτzyP+τzz]\textbf{T}=\begin{bmatrix}\vspace{2 mm}-P+\tau_{xx}&\tau_{xy}&\tau_{xz}\\ \vspace{2 mm}\tau_{yx}&-P+\tau_{yy}&\tau_{yz}\\ \tau_{zx}&\tau_{zy}&-P+\tau_{zz}\end{bmatrix} (4.5)
T=PI+τ\Rightarrow\textbf{T}=-P\textbf{I}+\tau

In this equation I is the identity matrix, and τ\tau is often termed the viscous stress tensor. The expression will be clear from the picture

Refer to caption
Figure 3: Stress Function

From Newton’s law of viscosity we can express the components of shear stress

τxy=μ(uy+vx)\tau_{xy}=\mu\left(\frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right)

Putting this value in equation  4.4 we get(in component form)

ρdudt=Px+μ(uxx+uyy+uzz)+FB,xρdvdt=Py+μ(vxx+vyy+vzz)+FB,yρdvdt=Pz+μ(wxx+wyy+wzz)+FB,z\begin{split}\rho\frac{du}{dt}=-P_{x}+\mu\left(u_{xx}+u_{yy}+u_{zz}\right)+F_{B_{,x}}\\ \rho\frac{dv}{dt}=-P_{y}+\mu\left(v_{xx}+v_{yy}+v_{zz}\right)+F_{B_{,y}}\\ \rho\frac{dv}{dt}=-P_{z}+\mu\left(w_{xx}+w_{yy}+w_{zz}\right)+F_{B_{,z}}\end{split} (4.6)

Now divide these equations by ρ\rho on both side and express them as

ut+uux+vuy+wuz=Px+νu+1ρ+FB,xvt+uvx+vvy+wvz=Py+νv+1ρ+FB,ywt+uwx+vwy+wwz=Pz+νw+1ρ+FB,z\begin{split}\frac{\partial u}{\partial t}+u\frac{\partial u}{\partial x}+v\frac{\partial u}{\partial y}+w\frac{\partial u}{\partial z}=\frac{\partial P}{\partial x}+\nu\triangle u+\frac{1}{\rho}+F_{B_{,x}}\\ \frac{\partial v}{\partial t}+u\frac{\partial v}{\partial x}+v\frac{\partial v}{\partial y}+w\frac{\partial v}{\partial z}=\frac{\partial P}{\partial y}+\nu\triangle v+\frac{1}{\rho}+F_{B_{,y}}\\ \frac{\partial w}{\partial t}+u\frac{\partial w}{\partial x}+v\frac{\partial w}{\partial y}+w\frac{\partial w}{\partial z}=\frac{\partial P}{\partial z}+\nu\triangle w+\frac{1}{\rho}+F_{B_{,z}}\end{split} (4.7)

Here, ν\nu is kinematic viscosity, the ratio of viscosity μ\mu to density ρ\rho and \triangle is the second-order partial differential operator (given here in Cartesian coordinates)

=2x2+2y2+2z2\triangle=\frac{\partial^{2}}{\partial x^{2}}+\frac{\partial^{2}}{\partial y^{2}}+\frac{\partial^{2}}{\partial z^{2}}

This is known as momentum conservation equation but well known as Nevier-Stokes Equation. and they provide a pointwise description of essentially any time-dependent incompressible fluid flow.

5 Energy Conservation

Let E be the total energy of the fluid, sum of its kinetic energy and internal energy:

E=Ek+Eint=12Vm(t)ρu2𝑑Vm+Vm(t)ρϵ𝑑VmE=E_{k}+E_{int}=\frac{1}{2}\int_{V_{m}(t)}\rho\textbf{u}^{2}dV_{m}+\int_{V_{m}(t)}\rho\epsilon dV_{m}

Principle of energy conservation: “the variation in time of the total energy of a portion of fluid is equal to the work done per unit time over the system by the stresses (internal forces) and the external forces”. Apply E in 𝐑𝐓𝐓\bf{RTT} equation  2.6, we get

dEdt=ddtVm(t)(12ρu2+ρϵ)𝑑Vm=Vm(t)[t(12ρu2+ρϵ)+(12uρu2+uρϵ)]𝑑Vm\frac{dE}{dt}=\frac{d}{dt}\int_{V_{m}(t)}\left(\frac{1}{2}\rho\textbf{u}^{2}+\rho\epsilon\right)dV_{m}=\int_{V_{m}(t)}\left[\frac{\partial}{\partial t}\left(\frac{1}{2}\rho\textbf{u}^{2}+\rho\epsilon\right)+\nabla\cdot\left(\frac{1}{2}\textbf{u}\rho\textbf{u}^{2}+\textbf{u}\rho\epsilon\right)\right]dV_{m} (5.1)

Here, t(12ρu2)=ρuiuit\frac{\partial}{\partial t}\left(\frac{1}{2}\rho u^{2}\right)=\rho u_{i}\frac{\partial u_{i}}{\partial t} and substituting in equation  4.7, we get

uit=ukuixk1ρPxi+uiσikxk\frac{\partial u_{i}}{\partial t}=-u_{k}\frac{\partial u_{i}}{\partial x_{k}}-\frac{1}{\rho}\frac{\partial P}{\partial x_{i}}+u_{i}\frac{\partial\sigma_{ik}}{\partial x_{k}}

The result is

t(12ρu2)=ρu(u)uuP+uiσikxk\frac{\partial}{\partial t}\left(\frac{1}{2}\rho\textbf{u}^{2}\right)=-\rho\textbf{u}\cdot\left(\textbf{u}\cdot\nabla\right)\textbf{u}-\textbf{u}\cdot\nabla P+u_{i}\frac{\partial\sigma_{ik}}{\partial x_{k}}
t(12ρu2)=ρ(u)(u22+Pρ)+(uσ)σikuixk\Rightarrow\frac{\partial}{\partial t}\left(\frac{1}{2}\rho\textbf{u}^{2}\right)=-\rho\left(\textbf{u}\cdot\nabla\right)\left(\frac{u^{2}}{2}+\frac{P}{\rho}\right)+\nabla(\textbf{u}\cdot\sigma)-\sigma_{ik}\frac{\partial u_{i}}{\partial x_{k}}

Here uσ\textbf{u}\cdot\sigma denotes the vector whose components are uiσiku_{i}\sigma_{ik}. Since u=0\nabla\cdot\textbf{u}=0 for an incompressible fluid, we can write the first term on the right as a divergence:

t(12ρu2)=[ρu(12u2+Pρ)uσ]σikuixk\frac{\partial}{\partial t}\left(\frac{1}{2}\rho\textbf{u}^{2}\right)=-\nabla\cdot\left[\rho\textbf{u}\left(\frac{1}{2}\textbf{u}^{2}+\frac{P}{\rho}\right)-\textbf{u}\cdot\sigma\right]-\sigma_{ik}\frac{\partial u_{i}}{\partial x_{k}} (5.2)

\Downarrow                      \Downarrow                 \Downarrow

Energy Flux       Energy Flux       Energy Flux

due to actual       due to Friction     due to momentum

mass transfer                                       change

Now from equation  5.1, we get

Vm(t)[t(12ρu2+ρϵ)+((12ρu2+ρϵ+P)uuσ)]𝑑Vm=Vm(t)σikuixk\int_{V_{m}(t)}\left[\frac{\partial}{\partial t}\left(\frac{1}{2}\rho\textbf{u}^{2}+\rho\epsilon\right)+\nabla\cdot\left(\left(\frac{1}{2}\rho\textbf{u}^{2}+\rho\epsilon+P\right)\textbf{u}-\textbf{u}\cdot\sigma\right)\right]dV_{m}=-\int_{V_{m}(t)}\sigma_{ik}\frac{\partial u_{i}}{\partial x_{k}} (5.3)

This is known as Energy conservation equation.[2]

6 Euler Equation:

The purpose of this note derivation of Euler’s equation for fluid flow on the basis of conservation of mass, conservation of momentum and Newton’s laws.

To set the stage, consider the example shown in figure 4. The top half is a snapshot of the fluid at some initial time t0t_{0} and the bottom half is a snapshot at some slightly later time t1t_{1}. One parcel of fluid has been marked with blue dye, and another parcel has been marked with red dye. The rectangle represents an imaginary box, also called the “Control Volume” we will be particularly interested in what is happening within this box.

Refer to caption
Figure 4: fluid element in imaginary box

There are some qualitative observations that we can make immediately:

  1. \ast

    The fluid is flowing left-to-right.

  2. \ast

    The density depends on position: The red parcel is denser than the blue parcel.

  3. \ast

    The density depends on time: The density in the control volume decreases as time passes from t0t_{0} to t1t_{1}.

  4. \ast

    The velocity depends on position: during the time interval in question, the right edge of the blue parcel moves a relatively short distance, while the right edge of the red parcel moves a relatively long distance.

  5. \ast

    The total number of red particles does not change, and the total number of blue particles does not change. (Some particles that flow out of the frame of the diagram are not accounted for, but all particles -red, blue, or black-that affect the control volume are accounted for.

In our calculations, we consider the following assumptions

  1. The fluid is ideal gas.

  2. There is no viscous force i.e μ=0\mu=0

  3. There is no external force.

  4. Fluid flow is one dimensional.

Now applying this assumption on equation  3.2

ρt+(ρu)=0\frac{\partial\rho}{\partial t}+\nabla\cdot\left(\rho\textbf{u}\right)=0
ρt+(ρu)x=0\Rightarrow\frac{\partial\rho}{\partial t}+\frac{\partial\left(\rho u\right)}{\partial x}=0 (6.1)

This is Mass Conservation equation for ideal gas.

\star Momentum Conservation: In some volume of fluid with surface Sm(t)S_{m}(t) the total force acting on the volume Vm(t)V_{m}(t) is Sm(t)P𝑑Sm=Vm(t)PdVm-\int_{S_{m}(t)}PdS_{m}=-\int_{V_{m}(t)}\nabla PdV_{m} where P is the pressure. Applying force on unit volume ρdudt\rho\frac{d\textbf{u}}{dt} (Newton’s 2nd2^{nd} Law). Then we may be written as

ρdudt=P\rho\frac{d\textbf{u}}{dt}=-\nabla P

By using RTT equation  2.6, we get

(ρu)t+[u(ρu)]=0\frac{\partial(\rho\textbf{u})}{\partial t}+\nabla\cdot\left[\textbf{u}\otimes\left(\rho\textbf{u}\right)\right]=0
(ρuj)t+i=13(ρuiuj)xi+Pxj=0\Rightarrow\frac{\partial\left(\rho u_{j}\right)}{\partial t}+\sum_{i=1}^{3}\frac{\partial\left(\rho u_{i}u_{j}\right)}{\partial x_{i}}+\frac{\partial P}{\partial x_{j}}=0

But for one dimensional case i=j=1i=j=1, then

(ρu)t+(ρu2+P)x=0\frac{\partial\left(\rho u\right)}{\partial t}+\frac{\partial\left(\rho u^{2}+P\right)}{\partial x}=0 (6.2)

This is Momentum conservation and now applying the assumption on energy equation  5.3:

Vm(t)[(ρu2+ρϵ)t+((12ρu2+ρϵ+P)u)]𝑑Vm=0\int_{V_{m}(t)}\left[\frac{\partial\left(\rho\textbf{u}^{2}+\rho\epsilon\right)}{\partial t}+\nabla\cdot\left(\left(\frac{1}{2}\rho\textbf{u}^{2}+\rho\epsilon+P\right)\textbf{u}\right)\right]dV_{m}=0

recalling arbitrary value of elementary volume and applying one dimensional case

(ρu2+ρϵ)t+x[(12ρu2+ρϵ+P)u]=0\Rightarrow\frac{\partial\left(\rho u^{2}+\rho\epsilon\right)}{\partial t}+\frac{\partial}{\partial x}\left[\left(\frac{1}{2}\rho u^{2}+\rho\epsilon+P\right)u\right]=0

Total energy of ideal gas e=12ρu2+ρϵe=\frac{1}{2}\rho u^{2}+\rho\epsilon, so

et+x[u(e+P)]=0\frac{\partial e}{\partial t}+\frac{\partial}{\partial x}\left[u\left(e+P\right)\right]=0 (6.3)

This is known as Energy Conservation equation for ideal gas.

7 Finite Volume Method

The finite-volume method[5] is a method for representing and evaluating partial differential equations in the form of algebraic equations. In this method values are calculated from at discrete places at meshed geometry. ”Finite Volume” refers small volume surroundings about mesh grid point. The evaluated terms are Fluxes at the surface of referred volume. Because the flux entering a given volume is identical to that leaving the adjacent volume, these methods are conservative. This method is used in many CFD packages.

Let us consider a 1 Dimensional Hyperbolic Equation can be defined by partial differential equation

ρt+Ψx=0,t0\frac{\partial\rho}{\partial t}+\frac{\partial\Psi}{\partial x}=0,\hskip 19.91692ptt\geq 0 (7.1)

Where, ρ=ρ(x,t)\rho=\rho(x,t) represents the state variable and Ψ=Ψ(x,t)\Psi=\Psi(x,t) represents the flux or flow of ρ\rho .Conventionally, positive Ψ\Psi indicates flow from left to right and negative Ψ\Psi indicates flow from right to left.If we assume that equation (7.1) represents a flowing medium of constant area, we can sub-divide the spatial domain x, into finite volumes or cells with cell center index i. For a particular cell ’i’ we can define the volume average value of ρi(t)=ρ(x,t)\rho_{i}(t)=\rho(x,t) at time t = t1t_{1} and x[xi1/2,xi+1/2]x\in[x_{i-1/2},x_{i+1/2}]. Just look at the figure

Refer to caption
Figure 5: A simple one dimensional grid

Now average value equation is

ρi¯(t1)=1xi+1/2xi1/2xi1/2xi+1/2ρ(x,t1)𝑑x\bar{\rho_{i}}(t_{1})=\frac{1}{x_{i+1/2}-x_{i-1/2}}\int_{x_{i-1/2}}^{x_{i+1/2}}\rho(x,t_{1})dx (7.2)

At time t=t2t=t_{2}, the average value equation is

ρi¯(t2)=1xi+1/2xi1/2xi1/2xi+1/2ρ(x,t2)𝑑x\bar{\rho_{i}}(t_{2})=\frac{1}{x_{i+1/2}-x_{i-1/2}}\int_{x_{i-1/2}}^{x_{i+1/2}}\rho(x,t_{2})dx (7.3)

Where, xi1/2x_{i-1/2} and xi+1/2x_{i+1/2} represent locations of the upstream and downstream faces or edges respectively of the ithi^{th} cell. Now integrating equation(7.1) with respect to time, we have:

ρi(t2)=ρi(t1)t1t2Ψx(x,t)𝑑t\rho_{i}(t_{2})=\rho_{i}(t_{1})-\int_{t_{1}}^{t_{2}}\Psi_{x}(x,t)dt (7.4)

where Ψx=Ψx\Psi_{x}=\frac{\partial\Psi}{\partial x}, To obtain the volume average ρ(x,t)\rho(x,t) at time t=t2t=t_{2} we integrate ρ(x,t2)\rho(x,t_{2}) over the cell volume [xi1/2,xi+1/2][x_{i-1/2},x_{i+1/2}] after then we divide the result by xi=xi+1/2xi1/2\triangle x_{i}=x_{i+1/2}-x_{i-1/2} , implies that

ρi¯(t2)=1xixi1/2xi+1/2[ρ(x,t1)t1t2Ψx(t,x)]𝑑x\bar{\rho_{i}}(t_{2})=\frac{1}{\triangle x_{i}}\int_{x_{i-1/2}}^{x_{i+1/2}}\textbf{[}\rho(x,t_{1})-\int_{t_{1}}^{t_{2}}\Psi_{x}(t,x)\textbf{]}dx (7.5)

we can assume that Ψ\Psi is well behaved and flow is normal to the surface area, even for 1 D case ΨxΨ\Psi_{x}\sim\bigtriangledown\Psi, so we can apply gauss divergence theorem in equation(7.5) over the x region [xi1/2,xi+1/2][x_{i-1/2},x_{i+1/2}] even x and t are independent to each other i.e. we can interchange the integration of dx and dt, now we have:

ρi¯(t2)=1xixi1/2xi+1/2ρ(x,t1)𝑑x1xit1t2[xi1/2xi+1/2Ψx(t,x)𝑑x]𝑑t\bar{\rho_{i}}(t_{2})=\frac{1}{\triangle x_{i}}\int_{x_{i-1/2}}^{x_{i+1/2}}\rho(x,t_{1})dx-\frac{1}{\triangle x_{i}}\int_{t_{1}}^{t_{2}}\textbf{[}\int_{x_{i-1/2}}^{x_{i+1/2}}\Psi_{x}(t,x)dx\textbf{]}dt (7.6)
ρi¯(t2)=ρ¯(x,t1)1xit1t2[Ψxi+1/2Ψxi1/2]dt\bar{\rho_{i}}(t_{2})=\bar{\rho}(x,t_{1})-\frac{1}{\triangle x_{i}}\int_{t_{1}}^{t_{2}}\textbf{[}\Psi_{x_{i+1/2}}-\Psi_{x_{i-1/2}}\textbf{]}dt (7.7)

We can therefore derive semi discrete numerical method with cell center index i and edges at i±1/2i\pm 1/2 :

dρi¯dt=1xi[Ψi+1/2Ψi1/2]\frac{d\bar{\rho_{i}}}{dt}=\frac{1}{\triangle x_{i}}{\textbf{[}{\Psi_{i+1/2}-\Psi_{i-1/2}}\textbf{]}} (7.8)

where values for the edge fluxes, Ψi+1/2,Ψi1/2\Psi_{i+1/2},\Psi_{i-1/2} can be reconstructed by interpolation or extrapolation of the cell averages. Equation (7.8) is exact for the volume averages; i.e., no approximations have been made during its derivation.

8 Roe Scheme Method

Roe Scheme Method[1] is a method to solve fluid conservation laws which are based on exploiting the information obtained by considering a sequence of Riemann Problem. It is argued that in existing schemes much of this information is degraded, and that only certain features of the exact solution are worth striving.

we consider the initial value problem for a hyperbolic system of conservation laws, such that

ut+Fx=0\textbf{u}_{t}+\textbf{F}_{x}=0 (8.1)

where, u=u(x,t)\textbf{u}=\textbf{u}(x,t) and

u(x,0)=u0(x)\textbf{u}(x,0)=\textbf{u}_{0}(x) (8.2)

Where, F is some vector-valued function of u, such that the Jacobian matrix A=FuA=\frac{\partial\textbf{F}}{\partial\textbf{u}} has only real eigenvalues, by using the discrete representation xi=x0+ixx_{i}=x_{0}+i\triangle x and tn=t0+ntt_{n}=t_{0}+n\triangle t and consider uin\textbf{u}_{i}^{n} is some approximation of u(xi,tn)\textbf{u}(x_{i},t_{n}) but a multitude of strategies are required to obtain the numerical result which is unclear, so we recall Riemann Problem and condition are:

u(x,0)uL(x<0);u(x,0)=uR(x>0)\textbf{u}(x,0)\equiv\textbf{u}_{L}\hskip 19.91692pt(x<0);\hskip 28.45274pt\textbf{u}(x,0)=\textbf{u}_{R}\hskip 19.91692pt(x>0) (8.3)

Now we can solve exactly equation  8.1 by using this initial condition and corresponding system equation where equation(8.1) will be converted to ut+Aux=0\textbf{u}_{t}+A\textbf{u}_{x}=0, which is our exact solution, but now we try to solve the equation(8.1) by boundary value and which gives us the approximate solution.

we consider the approximate solutions

ut+A~ux=0\textbf{u}_{t}+\tilde{A}\textbf{u}_{x}=0 (8.4)

where, A~=A~(uL,uR)\tilde{A}=\tilde{A}(\textbf{u}_{L},\textbf{u}_{R}) which satisfy the properties:

  1. 1.

    It constitutes a linear mapping from the vector space u to the vector space F

  2. 2.

    As uLuRu\textbf{u}_{L}\textbf{u}_{R}\rightarrow\textbf{u}, A¯(ul,uR)A(u)\bar{A}(\textbf{u}_{l},\textbf{u}_{R})\rightarrow A(\textbf{u}), where A=FuA=\frac{\partial\textbf{F}}{\partial\textbf{u}}

  3. 3.

    For any uL\textbf{u}_{L},uR\textbf{u}_{R}, A~(uL,uR)×(uLuR)=FLFR\tilde{A}(\textbf{u}_{L},\textbf{u}_{R})\times(\textbf{u}_{L}-\textbf{u}_{R})=\textbf{F}_{L}-\textbf{F}_{R}

  4. 4.

    The eigenvectors of A~\tilde{A} are linearly independent.

8.1 Parameter Vector:

In this section we will use experience in analytic geometry that a plane curve y(x) may in some cases be much more easily described by a parametric form y = y(t) and x = x(t). we may therefore expect that a multidimensional manifold such as F(u)\textbf{F}(\textbf{u}) may sometimes be more amenable if represented as F=F(w)\textbf{F}=\textbf{F}(\textbf{w}), u=u(w)\textbf{u}=\textbf{u}(\textbf{w}) where w as a parameter vector. Now we exhibit parameter vector for the Euler Equations, which we write as

ut+Fx=0,\textbf{u}_{t}+\textbf{F}_{x}=0, (8.5)

where

u=[ρρue],F=[ρuP+ρu2u(P+e)]\boxed{\textbf{u}=\begin{bmatrix}\rho\\ \rho u\\ e\\ \end{bmatrix},\hskip 42.67912pt\textbf{F}=\begin{bmatrix}\rho u\\ P+\rho u^{2}\\ u(P+e)\\ \end{bmatrix}} (8.6)

in which ρ\rho = density, P = static pressure, u = velocity in Cartesian coordinate x, and e is total energy per unit volume. For ideal gas equation :

P=ρRT=ρ(CPCV)T=ρ(γ1)CVT=ρ(γ1)e¯P=\rho RT=\rho(C_{P}-C_{V})T=\rho(\gamma-1)C_{V}T=\rho(\gamma-1)\bar{e} (8.7)

e¯\bar{e} = internal energy per unit mass, so internal energy per unit volume ρ¯e¯=P/(γ1)\rho\bar{}\bar{e}=P/(\gamma-1)so Total energy = Kinetic energy + Thermal energy i.e.

e=12ρu2+P/(γ1)\boxed{e=\frac{1}{2}\rho u^{2}+P/(\gamma-1)} (8.8)

Now we take the parameter vector as like w=ρ12(1,u,h)T\textbf{w}=\rho^{\frac{1}{2}}(1,u,h)^{T} where h = enthalpy is defined as

ρh=e+P=12ρu2+P(γ1)+P\rho h=e+P=\frac{1}{2}\rho u^{2}+\frac{P}{(\gamma-1)}+P (8.9)
hu22=γP(γ1)ρ\boxed{h-\frac{u^{2}}{2}=\frac{\gamma P}{(\gamma-1)\rho}} (8.10)
(γ1)(hu22)=γPρ\boxed{(\gamma-1)(h-\frac{u^{2}}{2})=\frac{\gamma P}{\rho}} (8.11)

Now from the expression of w and from equation  8.6, we have

u1=w12,u2=w1w2,u3=w1w3γ+γ12γw22u_{1}=w_{1}^{2},\hskip 19.91692ptu_{2}=w_{1}w_{2},\hskip 19.91692ptu_{3}=\frac{w_{1}w_{3}}{\gamma}+\frac{\gamma-1}{2\gamma}w_{2}^{2} (8.12)

and

F1=w1w2F_{1}=w_{1}w_{2}
F2=P+ρu2F_{2}=P+\rho u^{2}
=γ1γ(ρhρu22)+ρu2=\frac{\gamma-1}{\gamma}(\rho h-\frac{\rho u^{2}}{2})+\rho u^{2}
=γ1γρh+γ+12γρu2=\frac{\gamma-1}{\gamma}\rho h+\frac{\gamma+1}{2\gamma}\rho u^{2}
=γ1γw1w3+γ+12γw22=\frac{\gamma-1}{\gamma}w_{1}w_{3}+\frac{\gamma+1}{2\gamma}w_{2}^{2}
F3=u(P+e)=uρh=w2w3F_{3}=u(P+e)=u\rho h=w_{2}w_{3} (8.13)

8.2 Eigenvalues and Eigenvectors for Euler Equation

It is now very easy to represent any jump in space u,F in terms of its image in the space w. For example, given any pair of states (uL,uR)(\textbf{u}_{L},\textbf{u}_{R}) and their images (wL,wr)(\textbf{w}_{L},\textbf{w}_{r}) we can write

(uLuR)B~(wLwR)\left(\textbf{u}_{L}-\textbf{u}_{R}\right)\equiv\tilde{\textbf{B}}\left(\textbf{w}_{L}-\textbf{w}_{R}\right) (8.14)

and

(FLFR)C~(wLwR)\left(\textbf{F}_{L}-\textbf{F}_{R}\right)\equiv\tilde{\textbf{C}}\left(\textbf{w}_{L}-\textbf{w}_{R}\right) (8.15)

where B~\tilde{\textbf{B}},C~\tilde{\textbf{C}} are 3×33\times 3 matrix, now B~\tilde{\textbf{B}} can be evaluated by the process:

uL1uR1)=B~11(wL1wR1)+B~12(wL2wR2)+B~13(wL3wR3)u_{L1}-u_{R1})=\tilde{B}_{11}\left(w_{L1}-w_{R1}\right)+\tilde{B}_{12}\left(w_{L2}-w_{R2}\right)+\tilde{B}_{13}\left(w_{L3}-w_{R3}\right)
(wL12uR12)=B~11(wL1wR1)+B~12(wL2wR2)+B~13(wL3wR3)(w_{L1}^{2}-u_{R1}^{2})=\tilde{B}_{11}(w_{L1}-w_{R1})+\tilde{B}_{12}(w_{L2}-w_{R2})+\tilde{B}_{13}(w_{L3}-w_{R3})

So there is only one solution for B~11=wL12wL22wL1wR1=w¯1\tilde{B}_{11}=\frac{w_{L1}^{2}-w_{L2}^{2}}{w_{L1}-w_{R1}}=\bar{w}_{1} where w¯1=12(wL1+wR1)\bar{w}_{1}=\frac{1}{2}(w_{L1}+w_{R1}) and B~12\tilde{B}_{12},B~13\tilde{B}_{13} are zero. Similarly we evaluate another component of B~\tilde{\textbf{B}}

uL2uR2=B~21(wL1wR1)+B~22(wL2wR2)+B~23(wL3wR3)u_{L2}-u_{R2}=\tilde{B}_{21}(w_{L1}-w_{R1})+\tilde{B}_{22}(w_{L2}-w_{R2})+\tilde{B}_{23}(w_{L3}-w_{R3})
wL1wL2wR1wR2=B~21(wL1wR1)+B~22(wL2wR2)+B~23(wL3wR3)\Rightarrow w_{L1}w_{L2}-w_{R1}w_{R2}=\tilde{B}_{21}(w_{L1}-w_{R1})+\tilde{B}_{22}(w_{L2}-w_{R2})+\tilde{B}_{23}(w_{L3}-w_{R3})

Here B~23=0\tilde{B}_{23}=0, because LHS have no term of wL3w_{L3} or wR3w_{R3}. Now we try to solve the reduced equation. There are two solution but we have to choose the solution which containing wLw_{L} and wRw_{R} both. So the reduced equation is

wL1wL2wR1wR2=B~21(wL1wR1)+B~22(wL2wR2)w_{L1}w_{L2}-w_{R1}w_{R2}=\tilde{B}_{21}(w_{L1}-w_{R1})+\tilde{B}_{22}(w_{L2}-w_{R2})

Where B~21=12(wL2+wR2)=w¯2\tilde{B}_{21}=\frac{1}{2}(w_{L2}+w_{R2})=\bar{w}_{2} and B~22=\tilde{B}_{22}= 12(wL1+wR2)=w¯1\frac{1}{2}(w_{L1}+w_{R2})=\bar{w}_{1}, similarly solving the third equation we have the matrix B~\tilde{\textbf{B}} as

B~=[2w¯100w¯2w¯10w3¯γγ1γw2¯w¯1γ]\tilde{\textbf{B}}=\begin{bmatrix}\vspace{3mm}2\bar{w}_{1}&0&0\\ \vspace{3mm}\bar{w}_{2}&\bar{w}_{1}&0\\ \frac{\bar{w_{3}}}{\gamma}&\frac{\gamma-1}{\gamma}\bar{w_{2}}&\frac{\bar{w}_{1}}{\gamma}\\ \end{bmatrix} (8.16)

and by using equivalent method

C~=[w¯2w¯10γ1γw¯3γ+1γw¯2γ1γw¯10w¯3w¯2]\tilde{\textbf{C}}=\begin{bmatrix}\vspace{3mm}\bar{w}_{2}&\bar{w}_{1}&0\\ \vspace{3mm}\frac{\gamma-1}{\gamma}\bar{w}_{3}&\frac{\gamma+1}{\gamma}\bar{w}_{2}&\frac{\gamma-1}{\gamma}\bar{w}_{1}\\ 0&\bar{w}_{3}&\bar{w}_{2}\end{bmatrix} (8.17)

Obviously these very simple formulas are closely related to the homogeneous property of the Euler equations. We will wish to construct the eigenvalues and the eigenvectors of some matrix A~\tilde{A} which maps u\triangle\textbf{u} and F\triangle\textbf{F} with property u. Evidently we may choose A~=(C~)(B~)1\tilde{A}=(\tilde{\textbf{C}})(\tilde{\textbf{B}})^{-1}. To find the find the eigenvalues and eigenvectors we simplify the matrix B~\tilde{\textbf{B}} and C~\tilde{\textbf{C}} divide by w¯1\bar{w}_{1} without loss of property.

w¯2w¯1=ρL12uL+ρR12uRρL12+ρR12=u¯\boxed{\frac{\bar{w}_{2}}{\bar{w}_{1}}=\frac{\rho_{L}^{\frac{1}{2}}u_{L}+\rho_{R}^{\frac{1}{2}}u_{R}}{\rho_{L}^{\frac{1}{2}}+\rho_{R}^{\frac{1}{2}}}=\bar{u}} (8.18)
w¯3w¯1=ρL12hL+ρR12hRρL12+ρR12=h¯\boxed{\frac{\bar{w}_{3}}{\bar{w}_{1}}=\frac{\rho_{L}^{\frac{1}{2}}h_{L}+\rho_{R}^{\frac{1}{2}}h_{R}}{\rho_{L}^{\frac{1}{2}}+\rho_{R}^{\frac{1}{2}}}=\bar{h}} (8.19)

we use Python code to determine the eigenvalues and eigenvector of new B~\tilde{\textbf{B}} and C~\tilde{\textbf{C}}:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sympy import S, pprint,symbols, simplify
from sympy.matrices import *
from sympy.interactive.printing import init_printing
init_printing = init_printing(use_unicode=False,
wrap_line=False,no_global=True)
u, h, gamma = symbols(’u h gamma’)
gammaA = ((gamma-1)/gamma)
gammaB = ((gamma+1)/gamma)
C = Matrix([[u, 1, 0], [gammaA*h, gammaB*u, gammaA], [0, h, u]])
BP = Matrix([[2, 0, 0], [u, 1, 0], [h/gamma, gammaA*u, 1/gamma]])
B = Inverse(BP)
A = C*B
lam = A.eigenvals()
vec = A.eigenvects()

Corresponding results are :

A~=[010u¯22γ(γ23γ)u¯(γ23γ)γγ1u¯(a¯2γh¯)2a¯2h¯+2γh¯γu¯]\tilde{A}=\begin{bmatrix}\vspace{3mm}0&1&0\\ \vspace{3mm}\frac{\bar{u}^{2}}{2\gamma}(\gamma^{2}-3\gamma)&\frac{-\bar{u}(\gamma^{2}-3\gamma)}{\gamma}&\gamma-1\\ \bar{u}(\bar{a}^{2}-\gamma\bar{h})&-2\bar{a}^{2}-\bar{h}+2\gamma\bar{h}&\gamma\bar{u}\end{bmatrix} (8.20)
λ1=u¯,λ2=a¯,λ3=u¯+a¯\boxed{\lambda_{1}=\bar{u},\hskip 28.45274pt\lambda_{2}=\bar{a},\hskip 28.45274pt\lambda_{3}=\bar{u}+\bar{a}} (8.21)
e1=[1u¯a¯h¯u¯a¯],e2=[1u¯u¯22],e3=[1u¯+a¯h¯+u¯a¯]\boxed{e_{1}=\begin{bmatrix}\vspace{3 mm}1\\ \vspace{3 mm}\bar{u}-\bar{a}\\ \bar{h}-\bar{u}\bar{a}\\ \end{bmatrix},\hskip 14.22636pte_{2}=\begin{bmatrix}\vspace{3 mm}1\\ \vspace{3 mm}\bar{u}\\ \frac{\bar{u}^{2}}{2}\end{bmatrix},\hskip 14.22636pte_{3}=\begin{bmatrix}\vspace{3 mm}1\\ \vspace{3 mm}\bar{u}+\bar{a}\\ \bar{h}+\bar{u}\bar{a}\\ \end{bmatrix}} (8.22)

Here a¯2=(γ1)(h¯u¯2/2)=γP¯ρ¯\bar{a}^{2}=(\gamma-1)(\bar{h}-\bar{u}^{2}/2)=\frac{\gamma\bar{P}}{\bar{\rho}} (by using equation  8.11 ), λ\lambda ’s are eigenvalues and eie_{i} are eigenvectors.

8.3 Approximate Riemann Solver

To complete the analysis we must show how to project an arbitrary u\triangle u onto the eigenvectors as basis i.e., we have to find coefficient αi\alpha_{i} in

u=i=13αiei\triangle u=\sum_{i=1}^{3}\alpha_{i}e_{i} (8.23)

A routine calculation yields

u1=α1+α2+α3\triangle u_{1}=\alpha_{1}+\alpha_{2}+\alpha{3}
u2=α1(u¯a¯)+α2u¯+α3(u¯+a¯)\triangle u_{2}=\alpha_{1}(\bar{u}-\bar{a})+\alpha_{2}\bar{u}+\alpha_{3}(\bar{u}+\bar{a})
u2=(α1+α2+α3)u¯+(α3α1)a¯\Rightarrow\triangle u_{2}=(\alpha_{1}+\alpha_{2}+\alpha{3})\bar{u}+(\alpha_{3}-\alpha_{1})\bar{a}
u2u¯u1=(α3α1)a¯\Rightarrow\triangle u_{2}-\bar{u}\triangle u_{1}=(\alpha_{3}-\alpha_{1})\bar{a}
u3=α1(h¯u¯a¯)+α2u¯22+α3(h¯+u¯a¯)\triangle u_{3}=\alpha_{1}(\bar{h}-\bar{u}\bar{a})+\alpha_{2}\frac{\bar{u}^{2}}{2}+\alpha_{3}(\bar{h}+\bar{u}\bar{a})
u3=(α3α1)u¯a¯+α2u¯22+(α1+α3)h¯\Rightarrow\triangle u_{3}=(\alpha_{3}-\alpha_{1})\bar{u}\bar{a}+\alpha_{2}\frac{\bar{u}^{2}}{2}+(\alpha_{1}+\alpha_{3})\bar{h}
u3=(u2u¯u1)u¯+α2u¯22+(u1α2)h¯\Rightarrow\triangle u_{3}=(\triangle u_{2}-\bar{u}\triangle u_{1})\bar{u}+\alpha_{2}\frac{\bar{u}^{2}}{2}+(\triangle u_{1}-\alpha_{2})\bar{h}
u3=(h¯u¯2)u1+α2u22+u¯u2\Rightarrow\triangle u_{3}=(\bar{h}-\bar{u}^{2})\triangle u_{1}+\alpha_{2}\frac{u^{2}}{2}+\bar{u}\triangle u_{2}
a¯2γ1α2=(h¯u¯2)u1+uu2u3\Rightarrow\frac{\bar{a}^{2}}{\gamma-1}\alpha{2}=(\bar{h}-\bar{u}^{2})\triangle u_{1}+u\triangle u_{2}-\triangle u_{3}
a2γ1α2=(a¯2γ1u¯22)u1+u¯u2u3\Rightarrow\frac{a^{2}}{\gamma-1}\alpha{2}=(\frac{\bar{a}^{2}}{\gamma-1}-\frac{\bar{u}^{2}}{2})\triangle u_{1}+\bar{u}\triangle u_{2}-\triangle u_{3}
α2=(1(γ1)u¯22a¯2)u1+(γ1)u¯a¯2u2γ1a¯2u3\Rightarrow\boxed{\alpha_{2}=(1-\frac{(\gamma-1)\bar{u}^{2}}{2\bar{a}^{2}})\triangle u_{1}+\frac{(\gamma-1)\bar{u}}{\bar{a}^{2}}\triangle u_{2}-\frac{\gamma-1}{\bar{a}^{2}}\triangle u_{3}} (8.24)

Now from the 1st1^{st} equation :

α1+α3=u1α2\alpha_{1}+\alpha_{3}=\triangle u_{1}-\alpha_{2}
α1+α3=(γ1)u¯22a¯2u1(γ1)u¯a¯2u2+(γ1)a¯2u3\Rightarrow\alpha_{1}+\alpha_{3}=\frac{(\gamma-1)\bar{u}^{2}}{2\bar{a}^{2}}\triangle u_{1}-\frac{(\gamma-1)\bar{u}}{\bar{a}^{2}}\triangle u_{2}+\frac{(\gamma-1)}{\bar{a}^{2}}\triangle u_{3}

and from 2nd2^{nd} equation:

α1+α3=1a(u2uu1)-\alpha_{1}+\alpha_{3}=\frac{1}{a}(\triangle u_{2}-u\triangle u_{1})

So we are able to solve α1\alpha_{1} and α3\alpha_{3}:

α1=u¯4a¯[2+(γ1)u¯a¯]u112a¯[1+(γ1)u¯a¯]u2+γ12a¯2u3\boxed{\alpha_{1}=\frac{\bar{u}}{4\bar{a}}\left[2+\frac{(\gamma-1)\bar{u}}{\bar{a}}\right]\triangle u_{1}-\frac{1}{2\bar{a}}\left[1+\frac{(\gamma-1)\bar{u}}{\bar{a}}\right]\triangle u_{2}+\frac{\gamma-1}{2\bar{a}^{2}}\triangle u_{3}} (8.25)
α3=u¯4a¯[2+(γ1)u¯a¯]u1+12a¯[1(γ1)u¯a¯]u2+γ12a¯2u3\boxed{\alpha_{3}=-\frac{\bar{u}}{4\bar{a}}\left[2+\frac{(\gamma-1)\bar{u}}{\bar{a}}\right]\triangle u_{1}+\frac{1}{2\bar{a}}\left[1-\frac{(\gamma-1)\bar{u}}{\bar{a}}\right]\triangle u_{2}+\frac{\gamma-1}{2\bar{a}^{2}}\triangle u_{3}} (8.26)

Now we construct F\triangle F, which will construct by the eigenvalues and eigenvectors of A~\tilde{A} which maps u\triangle u and F\triangle F and must be multiplied by αi\alpha_{i} ’s because A~\tilde{A} in image space w. So we have:

F=iλiαiei\triangle F=\sum_{i}\lambda_{i}\alpha_{i}e_{i}

Now we have have the information FiF_{i} and Fi+1F_{i+1} on the mesh grid point so intermediate Flux is given by:

Fi+1/2=12(Fi+1+Fi)12λiαieiF_{i+1/2}=\frac{1}{2}(F_{i+1}+F_{i})-\frac{1}{2}\sum{\lambda_{i}\alpha_{i}e_{i}}
Fi+1/2=12(FL+FR)12λiαiei\Rightarrow F_{i+1/2}=\frac{1}{2}(F_{L}+F_{R})-\frac{1}{2}\sum{\lambda_{i}\alpha_{i}e_{i}} (8.27)

8.4 Harten Sonic Entropy Fix

when, u¯=a¯\bar{u}=\bar{a} then λ1=u¯a¯=0\lambda_{1}=\bar{u}-\bar{a}=0 so

Fi+1/2=12(FL+FR)\Rightarrow F_{i+1/2}=\frac{1}{2}(F_{L}+F_{R})

This means that central discretization is used, without artificial viscosity so that there is a danger that entropy decreases, and that discontinuities are insufficiently smear out. The flow is not sonic , then we do not have central discretization , and there may be enough dissipation to prevent violation of the entropy condition. this is confirmed by the correct approximation by the subsonic fans.

An often used artifice to add dissipation to the Roe scheme near sonic condition has been proposed by Harten(1984). The eigenvalues λ1\lambda_{1} and λ3\lambda{3} are slightly increased in the vicinity of zero, replacing them in value λi\lambda_{i}’s by

λ~i=λiifλiϵ,i=1,3;\boxed{\mid\tilde{\lambda}_{i}\mid=\mid\lambda_{i}\mid\hskip 14.22636ptif\hskip 8.53581pt\mid\lambda_{i}\mid\geq\epsilon,\hskip 8.53581pti=1,3;}
λ~i=12(λi2ϵ+ϵ)ifλi<ϵ,p=i,3;\boxed{\mid\tilde{\lambda}_{i}\mid=\frac{1}{2}(\frac{\lambda_{i}^{2}}{\epsilon}+\epsilon)\hskip 14.22636ptif\hskip 8.53581pt\mid\lambda_{i}\mid<\epsilon,\hskip 8.53581ptp=i,3;} (8.28)

for some small value of ϵ\epsilon. Since equation  8.21 becomes into play when u¯a¯\bar{u}\approx\bar{a} this is called sonic entropy fix.[8] For super sonic tube ϵ=0.5\epsilon=0.5 corresponding numerical solution is given in section 13.

9 One-Dimensional Shock-Tube Problem

shock tube is a very long pipe in which a strong shock wave is generated. In the initial configuration, the tube is divided by a diaphragm into two compartments: the driver section containing the gas with the higher pressure P1P_{1} and the driven section with the gas at the lower pressure P4P_{4}.Here, we omitting the parts about reflected shock and expansion waves as well as some theory considered too general. The right-running normal shock is treated on page 21 and the solution to the complete problem is given on page 21.

Refer to caption
Figure 6: Shock Tube after the Diaphragm Broken

We start from the continuity, momentum and energy equations for a stationary normal shock wave[3]:

ρ4u4=ρ3u3\rho_{4}u_{4}=\rho_{3}u_{3} (9.1)
P4+ρ4u42=P3+ρ3u32P_{4}+\rho_{4}u_{4}^{2}=P_{3}+\rho_{3}u_{3}^{2} (9.2)
h4+u422=h3+u322h_{4}+\frac{u_{4}^{2}}{2}=h_{3}+\frac{u_{3}^{2}}{2} (9.3)

where the index 4 refers to gas upstream of the wave, index 3 to gas downstream of the wave.The important point is that u4u_{4} and u3u_{3} are interpreted as velocities relative to the wave; because it is stationary, they are in this case also relative to the laboratory. For the moving wave the velocities relative to the wave are WW (for the gas ahead) and WupW-u_{p} (for the gas behind) also making the total velocity equal to Wu4W-u_{4} because In figure, with the shock wave propagating to the right . After replacing u4u_{4} and u3u_{3}, equation  9.1 to  9.3 become

ρ4(Wu4)=ρ3(Wup)\rho_{4}\left(W-u_{4}\right)=\rho_{3}\left(W-u_{p}\right) (9.4)
P4+ρ4(Wu4)2=P3+ρ3(Wup)2P_{4}+\rho_{4}\left(W-u_{4}\right)^{2}=P_{3}+\rho_{3}\left(W-u_{p}\right)^{2} (9.5)
h4+(Wu4)22=h3+(Wup)22h_{4}+\frac{\left(W-u_{4}\right)^{2}}{2}=h_{3}+\frac{\left(W-u_{p}\right)^{2}}{2} (9.6)

Equations  9.4 to  9.6 are the normal-shock equations for a shock moving with velocity W into a stagnant gas. They can be rearranged and substituted, using h = e+p/ρ\rho, to obtain

e3e4=P4+P32(V4V3)e_{3}-e_{4}=\frac{P_{4}+P_{3}}{2}\left(V_{4}-V_{3}\right) (9.7)

The states after the shock are connected by the Rankine Hugoniot shock jump conditions[9] (Landau page no. 334) is valid, because we assume the case of polytropic gas, e=CPTe=C_{P}T, T=PVRT=\frac{PV}{R} and V=1ρV=\frac{1}{\rho}; equation  9.7 becomes

V3V4=P3P4(γ+1γ1+P3P41+γ+1γ1)\boxed{\frac{V_{3}}{V_{4}}=\frac{P_{3}}{P_{4}}\Bigg{(}\frac{\frac{\gamma+1}{\gamma-1}+\frac{P_{3}}{P_{4}}}{1+\frac{\gamma+1}{\gamma-1}}\Bigg{)}} (9.8)
ρ3ρ4=γ+1γ1+P3P41+γ+1γ1\boxed{\Rightarrow\frac{\rho_{3}}{\rho_{4}}=\frac{\frac{\gamma+1}{\gamma-1}+\frac{P_{3}}{P_{4}}}{1+\frac{\gamma+1}{\gamma-1}}} (9.9)

Equations  9.8 and  9.9 give the temperature and density ratios across the shock wave as functions of the pressure ratio. We define the moving shock Mach number as

MaS=Wu4a4Ma_{S}=\frac{W-u_{4}}{a_{4}}

By taking the polytropic gas relations and Eqn.  9.4 to  9.6 into account, we can derive

P3P4=1+2γγ+1(MaS21)\frac{P_{3}}{P_{4}}=1+\frac{2\gamma}{\gamma+1}\left(Ma_{S}^{2}-1\right)
MaS=γ+12γ(P3P41)+1\Rightarrow Ma_{S}=\sqrt{\frac{\gamma+1}{2\gamma}\left(\frac{P_{3}}{P_{4}}-1\right)+1} (9.10)

Since MaS=(Wu4)/a4Ma_{S}=(W-u_{4})/a_{4}, Eqn.  9.10 leads to

Wu4=a4γ+12γ(P3P41)+1W-u_{4}=a_{4}\sqrt{\frac{\gamma+1}{2\gamma}\left(\frac{P_{3}}{P_{4}}-1\right)+1} (9.11)

Equation  9.11 relates the velocity of the moving shock wave to the pressure ratio across the wave and the local speed of sound of the gas ahead of the shock wave.

The last quantity we are interested in is the velocity up of the mass motion induced by the shock wave. Equation  9.4 can be rewritten

up=W+(Wu4)(ρ4ρ3)\boxed{u_{p}=W+\left(W-u_{4}\right)\left(-\frac{\rho_{4}}{\rho_{3}}\right)} (9.12)

After substitution of Eqn.  9.9 and  9.11 into Eqn.  9.12, we obtain

up=u4+a4γ(P3P4)(2γγ+1P3P4+γ1γ+1)1/2\boxed{u_{p}=u_{4}+\frac{a_{4}}{\gamma}\left(\frac{P_{3}}{P_{4}}\right)\left(\frac{\frac{2\gamma}{\gamma+1}}{\frac{P_{3}}{P_{4}}+\frac{\gamma-1}{\gamma+1}}\right)^{1/2}} (9.13)

With what we have derived so far, we can obtain for a given pressure ratio P3/P4P_{3}/P_{4} and speed of sound a4a_{4} the corresponding values of ρ3/ρ4\rho_{3}/\rho_{4}, T3/T4T_{3}/T_{4}, W and up from Eqn  9.8,  9.9,  9.11 and  9.13. The next section deals with the counterpart of the moving shock wave, namely the expansion wave.

9.1 The incident expansion wave

In the last section discussions about the relations between the regions 3 and 4 of Fig.  6. In this section we examine the regions 1 and 2. The formulas relate to a left-running expansions wave; they would be similar for a right-running one except some changes of the signs in the equations. We use the fact that the gas in region 1 feels as if a piston was pulled to the right with velocity u4u_{4}. In fact, u4u_{4} is the mass-motion velocity of the gas behind the expansion wave[3] because this portion is high pressure region realtive to region 4.

Inside the wave, a mass motion with velocity u is induced, directed toward right. Temperature T and subsequently the local speed of sound a are reduced; because of this the head of the wave propagates faster into region 1 than other parts of the wave, so the wave is spreading out while running down the tube.

Refer to caption
Figure 7: Characteristics for incident expansion wave centred at 0.

The tail of the wave moves at velocity dx/dt=u2a2dx/dt=u_{2}-a_{2}. Note that if u2>a2u_{2}>a_{2}, i. e., u2u_{2} is supersonic, the tail of the wave propagates to the right although the wave is left-running. It can be shown that the characteristics of the expansion wave are straight lines and thus the values of u, a (and consequently also p, ρ\rho, T etc.) are constant along them. Such a wave is called a simple wave; a non simple waves where the characteristics are curved comes up for example when the expansion wave is reflected.

To obtain a closed analytical form for the expansion wave, we use Riemann invariant form [9] (page no. 394)

u+2aγ1=constant through the waveu+\frac{2a}{\gamma-1}=\text{constant through the wave} (9.14)

Applying this equation in region 1, we get

u1+2a1γ1=constantu_{1}+\frac{2a_{1}}{\gamma-1}=\text{constant} (9.15)

Combining these equations we get

aa1=1γ12(ua1u1a1)\boxed{\frac{a}{a_{1}}=1-\frac{\gamma-1}{2}\left(\frac{u}{a_{1}}-\frac{u_{1}}{a_{1}}\right)} (9.16)

Which relates u and a within the expansion wave. Because a=γRTa=\sqrt{\gamma RT} Eqn  9.16 also gives

TT1=(1γ12(ua1u1a1))2\frac{T}{T_{1}}=\left(1-\frac{\gamma-1}{2}\left(\frac{u}{a_{1}}-\frac{u_{1}}{a_{1}}\right)\right)^{2} (9.17)

For isentropic process s=0\triangle s=0

P=(constant)ργ,T=(constant)ργ1,a=(constant)ρ(γ1)/2P=(\text{constant})\rho^{\gamma},\hskip 8.53581ptT=(\text{constant})\rho^{\gamma-1}\hskip 8.53581pt,a=(\text{constant})\rho^{(\gamma-1)/2}

Then from Eqn.  9.17, we get

PP1=(1γ12(ua1u1a1))2γ/(γ1)\boxed{\frac{P}{P_{1}}=\left(1-\frac{\gamma-1}{2}\left(\frac{u}{a_{1}}-\frac{u_{1}}{a_{1}}\right)\right)^{2\gamma/(\gamma-1)}} (9.18)

and

ρρ1=(1γ12(ua1u1a1))2/(γ1)\boxed{\frac{\rho}{\rho_{1}}=\left(1-\frac{\gamma-1}{2}\left(\frac{u}{a_{1}}-\frac{u_{1}}{a_{1}}\right)\right)^{2/(\gamma-1)}} (9.19)

These equations give all properties within the simple expansion wave as a function of the local gas velocity u. To get them as function of x and t, we use straight line characteristics as

dxdt=(ua)t\frac{dx}{dt}=\left(u-a\right)t
x=(ua)t+u1\Rightarrow x=\left(u-a\right)t+u_{1}

Using this relation in Eqn.  9.16

x=(uu1a1+γ12u)tx=\left(u-u_{1}-a_{1}+\frac{\gamma-1}{2}u\right)t
u=u1+2γ1(a1+xt)\boxed{\Rightarrow u=u_{1}+\frac{2}{\gamma-1}\left(a_{1}+\frac{x}{t}\right)} (9.20)

The properties can be determined within the expansion wave, u1a1x/tu2a2u_{1}-a_{1}\leqslant x/t\leqslant u_{2}-a_{2}

9.2 Final Expression of Shock Tube

Finally, we combine the last two section for a closed analytical solution. End of the day we recall that u2=u3=upu_{2}=u_{3}=u_{p} and P2=P3P_{2}=P_{3} across the contact surface; last expression of upu_{p} was

up=u3=u4+a4γ(P3P4)(2γγ+1P3P4+γ1γ+1)1/2u_{p}=u_{3}=u_{4}+\frac{a_{4}}{\gamma}\left(\frac{P_{3}}{P_{4}}\right)\left(\frac{\frac{2\gamma}{\gamma+1}}{\frac{P_{3}}{P_{4}}+\frac{\gamma-1}{\gamma+1}}\right)^{1/2}

Applying Eqn.  9.18 to the tail of the expansion wave,

P2P1=(1γ12(u2a1u1a1))2γ/(γ1)\frac{P_{2}}{P_{1}}=\left(1-\frac{\gamma-1}{2}\Big{(}\frac{u_{2}}{a_{1}}-\frac{u_{1}}{a_{1}}\Big{)}\right)^{2\gamma/(\gamma-1)} (9.21)
u2=u1+2a1γ1(1(P2P1)(γ1)/2γ)\Rightarrow u_{2}=u_{1}+\frac{2a_{1}}{\gamma-1}\left(1-\Big{(}\frac{P_{2}}{P_{1}}\Big{)}^{(\gamma-1)/2\gamma}\right)

Putting P2=P3P_{2}=P_{3}

u2=u1+2a1γ1(1(P3P1)(γ1)/2γ)u_{2}=u_{1}+\frac{2a_{1}}{\gamma-1}\left(1-\Big{(}\frac{P_{3}}{P_{1}}\Big{)}^{(\gamma-1)/2\gamma}\right)

Since u2=u3u_{2}=u_{3}, so we apply in last Eqn. and equation  9.13, we get

u4+a4γ(P3P4)(2γγ+1P3P4+γ1γ+1)1/2=u1+2a1γ1(1(P3P1)(γ1)/2γ)u_{4}+\frac{a_{4}}{\gamma}\bigg{(}\frac{P_{3}}{P_{4}}\bigg{)}\Bigg{(}\frac{\frac{2\gamma}{\gamma+1}}{\frac{P_{3}}{P_{4}}+\frac{\gamma-1}{\gamma+1}}\Bigg{)}^{1/2}=u_{1}+\frac{2a_{1}}{\gamma-1}\left(1-\Big{(}\frac{P_{3}}{P_{1}}\Big{)}^{(\gamma-1)/2\gamma}\right)
P4P1=P4P3(1+(u1u4)(γ1)2a1(γ1)(a4a1)(P3P41)2γ((γ1)+(γ+1)P3P4))2γ/(γ1)\boxed{\frac{P_{4}}{P_{1}}=\frac{P_{4}}{P_{3}}\left(1+\frac{\big{(}u_{1}-u_{4}\big{)}\big{(}\gamma-1\big{)}}{2a_{1}}-\frac{\Big{(}\gamma-1\Big{)}\Big{(}\frac{a_{4}}{a_{1}}\Big{)}\Big{(}\frac{P_{3}}{P_{4}}-1\Big{)}}{\sqrt{2\gamma\Bigg{(}\Big{(}\gamma-1\Big{)}+\Big{(}\gamma+1\Big{)}\frac{P_{3}}{P_{4}}\Bigg{)}}}\right)^{2\gamma/(\gamma-1)}} (9.22)

Equation (9.22) gives the incident shock strength P3/P4P_{3}/P_{4} as an implicit function of the diaphragm pressure ratio P1/P4P_{1}/P_{4}. We can now unfold a recipe for the solution of the shock tube problem, which consists of all the boxed equations:

  1. \ast

    Calculate P3/P4P_{3}/P_{4} from Eqn.  9.22 to get the strength of the shock wave.

  2. \ast

    Calculate all other shock properties from Eqn.  9.8,  9.9,  9.11 and  9.13.

  3. \ast

    Calculate P2/P1=(P2/P4)/(P1/P4)=(P3/P4)/(P1/P4)P_{2}/P_{1}=(P_{2}/P_{4})/(P_{1}/P_{4})=(P_{3}/P_{4})/(P_{1}/P_{4}) to get the strength of the expansion wave.

  4. \ast

    All other properties behind the expansion wave can be found using

    P2P1=(ρ2ρ1)γ\frac{P_{2}}{P_{1}}=\left(\frac{\rho_{2}}{\rho_{1}}\right)^{\gamma}
  5. \ast

    The properties inside the expansion wave can be found from Eqs.  9.16 to  9.19 and  9.20.

9.3 Implementation in Python

Source code of these mathematics is given in section  13.3, where xgrid is a vector containing the x-positions where the solution is evaluated rho , u ,c(=a),P,machE and entropy_Eentropy\_E are vectors of the size of x_grid containing the density, local velocity,sound velocity,pressure, Mach number and entropy at the corresponding positions.

t_endt\_end specifies at what time the solution is to be evaluated;rhoL(=ρ1=\rho_{1}), rhoR (=ρ4)(=\rho_{4}) , PrL (P1)(P_{1}), PrR (=P4)(=P_{4}), uL = u1u_{1} uR = u4u_{4} initial settings for density, pressure and local velocity in the two compartments.

After parsing the input and optionally setting default values, some constants are specified: the heat capacity gamma = 1.4 and position of diaphragm at 0.5 . Next local speed and the densities for region 1 and 4 are computed from the quantities known so far. To get P3, rho3, rho2, u2 and c2 we solve Eqn  9.22 for P3/P4P_{3}/P_{4} that means we have to find a P3/P4P_{3}/P_{4} satisfying

P4P3(1+(u1u4)(γ1)2a1(γ1)(a4a1)(P3P41)2γ((γ1)+(γ+1)P3P4))2γ/(γ1)P4P1=0\frac{P_{4}}{P_{3}}\left(1+\frac{\big{(}u_{1}-u_{4}\big{)}\big{(}\gamma-1\big{)}}{2a_{1}}-\frac{\Big{(}\gamma-1\Big{)}\Big{(}\frac{a_{4}}{a_{1}}\Big{)}\Big{(}\frac{P_{3}}{P_{4}}-1\Big{)}}{\sqrt{2\gamma\Bigg{(}\Big{(}\gamma-1\Big{)}+\Big{(}\gamma+1\Big{)}\frac{P_{3}}{P_{4}}\Bigg{)}}}\right)^{2\gamma/(\gamma-1)}-\frac{P_{4}}{P_{1}}=0 (9.23)

This equation is solved by python function fsolve which can gives the iterative solution about a point of iterative solution by using Newton’s method, bisection method etc.

Now, the mesh x_gridx\_grid is initialized, usually to a size of 1 x 300, but the number of points could also be changed to some other value if desired. Before iterating through all the solution vectors, the boundaries of the regions are determined using the knowledge about the velocities of head and tail of the expansion wave.

  1. \ast

    Starting expansion fan i.e Boundary between leftmost driver gas and expansion wave.                                                                                       

    pos1=0.5+(u1a1)t_endpos1=0.5+(u_{1}-a_{1})*t\_end
    pos1=0.5+(uLaL)t_end\Rightarrow pos1=0.5+(uL-aL)*t\_end
  2. \ast

    End of expansion fan i.e. Boundary between expansion wave and lower pressure driver gas.                                                                                      

    pos2=0.5+(u3a3)t_endpos2=0.5+(u_{3}-a_{3})*t\_end
    pos2=0.5+(u2+uRc2)t_end, because u2 = u3\Rightarrow pos2=0.5+(u2+uR-c2)*t\_end\hskip 8.53581pt\text{, because u2 = u3}
  3. \ast

    Position of contact discontinuity i.e. Boundary between driver gas and driven gas.                                                                                      

    conpos=0.5+u_pt_endconpos=0.5+u\_p*t\_end
    conpos=0.5+(u2+uR)t_end\Rightarrow conpos=0.5+(u2+uR)*t\_end
  4. \ast

    Shock Position i.e Location of the shock wave.                                                                                      

    spos=0.5+t_endWspos=0.5+t\_end*W
    spos=0.5+t_end(a4γ+12γ(P3P41)+1+u4)\Rightarrow spos=0.5+t\_end*\left(a_{4}\sqrt{\frac{\gamma+1}{2\gamma}\left(\frac{P_{3}}{P_{4}}-1\right)+1}+u_{4}\right)
    spos=0.5+t_end(a4γ12γ+γ+12γP3P4+u4)\Rightarrow spos=0.5+t\_end*\left(a_{4}\sqrt{\frac{\gamma-1}{2\gamma}+\frac{\gamma+1}{2\gamma}\frac{P_{3}}{P_{4}}}+u_{4}\right)
    spos=0.5+t_end(cRγ12γ+γ+12γP3P4+uR)\Rightarrow spos=0.5+t\_end*\left(cR\sqrt{\frac{\gamma-1}{2\gamma}+\frac{\gamma+1}{2\gamma}\frac{P3}{P4}}+uR\right)

10 Sod Shock Tube

The Sod shock tube problem, named after Gary A. Sod, is a common test for the accuracy of computational fluid codes, like Riemann solvers and was heavily investigated by Sod in 1978. The test consists of a one dimensional Riemann problem with the following parameters, for left and right states of an ideal gas.

(ρLuLPL)=(1.00.01.0)(ρRvRPR)=(0.1250.00.1)\begin{pmatrix}\rho_{L}\\ u_{L}\\ P_{L}\end{pmatrix}=\begin{pmatrix}1.0\\ 0.0\\ 1.0\end{pmatrix}\begin{pmatrix}\rho_{R}\\ v_{R}\\ P_{R}\end{pmatrix}=\begin{pmatrix}0.125\\ 0.0\\ 0.1\end{pmatrix} (10.1)

The time evolution of this problem can be described by solving the Euler equations. Which leads to three characteristics, describing the propagation speed of the various regions of the system. Namely the rarefaction wave, the contact discontinuity and the shock discontinuity. If this is solved numerically, one can test against the analytical solution, and get information how well a code captures and resolves shocks and contact discontinuities and reproduce the correct density profile of the rarefaction wave.

11 Result:

11.1 Shock tube Data Plot after Breaking the Diaphragm

In this case

Quantity left side right side
Density 1.0 0.125
Pressure 1.0 0.1
Velocity 0.0 0.0
t_endt\_end=0.17 Sec N=300 μ\mu=0.35
Table 1: Shock tube data at t = 0
Refer to caption
Figure 8: Density Distribution
Refer to caption
Figure 9: Pressure Distribution
Refer to caption
Figure 10: Velocity Distribution
Refer to caption
Figure 11: Mach Number Distribution
Refer to caption
Figure 12: Entropy Distribution

Comparison to measurements yields respectable results, actually this result is only for stationary shock tube.but our program simulation for both cases. Three Python scripts on the accompanying movies, which visualize the density,pressure,velocity, Mach number and entropy in shock tube after breaking the diaphragm.See Appendix  LABEL:subsec:_Contents_in_CD for details on the CD.

Script file Video file Quantity
exact.py exact.avi Exact value by Shock tube formula
approximate.py approximate.avi Approximate solution by Roe Solver
approximate_exact.py approximate_exact.avi Both solution
Table 2: Scripts for video files visualizing the analytical and approximate solution

12 Conclusions

We described a strategy for obtaining numerical solutions to hyperbolic initial-value problems by Roe Scheme Method[1]. In the project we have the details of one element in that strategy. Our investigations into the Euler equations have revealed some very tidy structures. Also the existence of a fast exact Riemann solver is found more generally useful. Our programming experience is that the present direct method is about a time-consuming as one cycle of the iterative procedures. Iterations needed to obtain more exact solutions. Also we use Harten entropy fix assuming the Harten original approach: the entropy fix as means to select the physically relevant weak solution, corresponding to the vanishing viscosity solution.

References

13 Appendix

13.1 Implementation in Python of Roe Scheme:

we will apply the Roe Scheme to the one test case of shock tube. We discretize the flow of quantity u by finite volume method of equation  7.7 in time by explicit Euler method

u¯i(t2)=u¯i(t1)txi[Fi+1/2Fi1/2]\bar{u}_{i}(t_{2})=\bar{u}_{i}(t_{1})-\frac{\triangle t}{\triangle x_{i}}[F_{i+1/2}-F_{i-1/2}]
u¯i(t2)=u¯i(t1)ν[Fi+1/2Fi1/2]\Rightarrow\bar{u}_{i}(t_{2})=\bar{u}_{i}(t_{1})-\nu[F_{i+1/2}-F_{i-1/2}] (13.1)

The exact solution is used to prescribe u1(t)u_{1}(t) and ui(t)u_{i}(t). The time step t\triangle t and mesh size xi\triangle x_{i}’s are constant .

  1. \ast

    Grid of Physical Quantity Take x_grid, density grid, pressure grid, velocity grid all have same no of grid point(in our case 300) last three grid maintain Riemann Problem given in equation  8.2 i.e. first half grid value will rhoL, PrL, uL and last half grid value rhoR, PrR, uR.

  2. \ast

    Energy Momentum Calculate total energy, momentum, total enthalpy by using equation  8.8 and  8.9

  3. \ast

    Average Calculation Calculate density average velocity, enthalpy average by using equation  8.18 and  8.19 similarly calculate the flux averages and apply on all grid point.

  4. \ast

    Grid of New Average Calculation From this new grid calculate Aav by using equation  8.11 also alpha1,Eqn  8.25 alpha2,  8.24 alpha3  8.26, lambda’s  8.21 now we have all the eigenvalues and corresponding eigenvector but to remove the problem of artificial viscosity apply Harten sonic entropy fix condition  8.28

  5. \ast

    Flux Average Calculate roe flux’s Eqn  8.27 where for 1st term is flux averages.

  6. \ast

    Average data for grid formation since we have the average data between two grid point so we can fill centering grid point by using  13.1 , which is our new grid.

  7. \ast

    Entropy End of the program calculate entropy

    entropy=log(P/ργ)entropy=log(P/\rho**\gamma)

Since at t = 0 all left and right side data are same so when we calculate the average value gives us ’-nan’ so next time gives two ’-nan’ data so it will be dangerous. To remove this problem if Ui==nanU_{i}==-nan then Ui=Ui1U_{i}=U_{i-1} .

13.2 Python Code

#!/usr/bin/env python
"""
Roe Scheme for one-dimensional Euler equations of Perfect
Gas in Adiabatic Process....
"""
import numpy as np
from pylab import *
from decimal import *
""" -----o---Specification of Riemann problems---o--- """
PrL = 1.0; PrR = 0.1; rhoL = 1.0; rhoR = 0.125;
uL = 0; uR = 0; t_end = 0.17; mu = 0.35; # nu = dt/dx
""" -------- Input Section -------- """
gamma = 1.4 # Ratio of specific heat
N = 300.0 # Number of grid cells
"""-------END I/P ----- """
gammaA = gamma - 1 ; gammaB = 1/(gamma - 1)
dx = 1/N # Cell Size
dt = mu*dx # Time step
n = int(t_end/dt)
"""
Definition of grid numbering
x=0 x=1
grid |--o--|--o--|--o--|--o-- .... ---|--o--|
1 1 2 2 3 3 4 N-1 N I
"""
N = int(N)
x = np.linspace(0.0,1.0,N+1)
xgrid = np.linspace(dx,1.0,N) - (dx/2)
Pr = np.zeros((1,len(xgrid)))
rho = np.zeros((1,len(xgrid)))
u = np.zeros((1,len(xgrid)))
for i in range (0, N, 1):
if xgrid[i] < 0.5 : Pr[0,i] = PrL; rho[0,i] = rhoL; u[0,i] = uL
else: Pr[0,i] = PrR; rho[0,i] = rhoR; u[0,i] = uR
eI = (gammaB*Pr)/rho # specific (= per unit mass) internal energy
eT = gammaB*Pr # Thermal energy
M = u*rho # Momntum rho*u
Et = eT + 0.5*M* u # Total energy
EtL = Et[0,0] ; EtR = Et[0,N-1]
Ht = gamma*eI + 0.5*u*u # Total enthalpy
# New cell centre Variables
mach = np.zeros((1,N))
rho_n = np.zeros((1,N))
M_n = np.zeros((1,N))
Et_n = np.zeros((1,N))
A_n = np.zeros((1,N))
# Roe Fluxes
roeF1 = np.zeros((1,N))
roeF2 = np.zeros((1,N))
roeF3 = np.zeros((1,N))
# Roe Averages
Hav = np.zeros((1,N))
uav = np.zeros((1,N))
Aav = np.zeros((1,N))
dd = np.zeros((1,N))
# Flux Averages
F1av = np.zeros((1,N))
F2av = np.zeros((1,N))
F3av = np.zeros((1,N))
# State Vector Difference
delrho = np.zeros((1,N))
delM = np.zeros((1,N))
delEt = np.zeros((1,N))
# Eigenvalues
lamda1 = np.zeros((1,N))
lamda2 = np.zeros((1,N))
lamda3 = np.zeros((1,N))
#Coefficents
alpha1 = np.zeros((1,N))
alpha2 = np.zeros((1,N))
alpha3 = np.zeros((1,N))
t = 0
for i in range (0,n,1):
t = t + dt
for j in range(0,N-2,1):
dd[0,j] = np.sqrt(rho[0,j+1]/rho[0,j])
if np.isnan(dd[0,j]) == True:
dd[0,j] = dd[0,j-1]
Hav[0,j] = (Ht[0,j] + dd[0,j]*Ht[0,j+1])/(1+dd[0,j])
uav[0,j] = (u[0,j] + dd[0,j]*u[0,j+1])/(1+dd[0,j])
delrho[0,j] = rho[0,j+1] - rho[0,j]
delM[0,j] = M[0,j+1] - M[0,j]
delEt[0,j] = Et[0,j+1] - Et[0,j]
F1av[0,j] = 0.5*(M[0,j] + M[0,j+1])
F2av[0,j] = 0.5*((M[0,j]*M[0,j]/rho[0,j]) + Pr[0,j] +
(M[0,j+1]*M[0,j+1]/rho[0,j+1]) + Pr[0,j+1])
F3av[0,j] = 0.5*((M[0,j]*Ht[0,j]) + (M[0,j+1]*Ht[0,j+1]))
Aav = np.sqrt(gammaA*(Hav - 0.5*(uav*uav)))
Mav = uav/Aav
alpha1 = (0.25*Mav*(2+gammaA*Mav)*delrho -
0.5*(1+gammaA*Mav)*(delM/Aav) + 0.5*gammaA*(delEt/(Aav**2)))
alpha2 = ((1-0.5*gammaA*(Mav**2))*delrho + gammaA*(Mav/Aav)*delM -
gammaA*(delEt/(Aav**2)))
alpha3 = (-0.25*Mav*(2-gammaA*Mav)*delrho + 0.5*(1-gammaA*Mav)*(delM/Aav)
+ 0.5*gammaA*(delEt/(Aav**2)))
lamda1 = np.abs(uav - Aav); lamda2 = np.abs(uav);
lamda3 = np.abs(uav + Aav)
""" Harten’s sonic entropy fix """
Eps = 0.5
""" Eps = 0.0 No entropy fix """
for j in range (0,N-1):
if lamda1[0,j] < Eps :
lamda1[0,j] = 0.5*((Eps + lamda1[0,j]**2)/Eps)
if lamda3[0,j] < Eps:
lamda3[0,j] = 0.5*((Eps + lamda3[0,j]**2)/Eps)
roeF1 = F1av - 0.5*lamda1*alpha1 - 0.5*lamda2*alpha2 - 0.5*lamda3*alpha3
roeF2 = (F2av - 0.5*lamda1*alpha1*(uav-Aav) - 0.5*lamda2*alpha2*uav
- 0.5*lamda3*alpha3*(uav+Aav))
roeF3 = (F3av - 0.5*lamda1*alpha1*(Hav - uav*Aav) - 0.25*lamda2*
alpha2*uav*uav- 0.5*lamda3*alpha3*(Hav + uav*Aav))
rho_n[0,0] = rhoL; rho_n[0,N-1] = rhoR
M_n[0,0] = rhoL*uL; M_n[0,N-1] = rhoR*uR
Et_n[0,0] = EtL; Et_n[0,N-1] = EtR
for j in range(1, N-1):
rho_n[0,j] = rho[0,j] - mu*(roeF1[0,j] - roeF1[0,j-1])
M_n[0,j] = M[0,j] -mu*(roeF2[0,j] - roeF2[0,j-1])
Et_n[0,j] = Et[0,j] - mu*(roeF3[0,j] - roeF3[0,j-1])
u = M_n/rho_n
Pr = gammaA*(Et_n - 0.5*M_n*u)
eI = (gammaB*Pr)/rho_n
Ht = (Et_n + Pr)/rho_n
rho = rho_n
M = M_n
Et = Et_n
A_n = np.sqrt(gamma*gammaA*eI)
mach = u/A_n
for k in range(1,N):
if np.isnan(u[0,k]) == True:
u[0,k] = u[0,k-1]
if np.isnan(Pr[0,k]) == True:
Pr[0,k] = Pr[0,k-1]
if np.isnan(eI[0,k]) == True:
eI[0,k] = eI[0,k-1]
if np.isnan(Ht[0,k]) == True:
Ht[0,k] = Ht[0,k-1]
if np.isnan(rho[0,k]) == True:
rho[0,k] = rho[0,k-1]
if np.isnan(M[0,k]) == True:
M[0,k] = M[0,k-1]
if np.isnan(Et[0,k]) == True:
Et[0,k] = Et[0,k-1]
ent_ropy = np.log(Pr/(rho**gamma))
""" ---o---File Write Section---o--- """
file = open("roe_scheme.txt","w")
for i in range(0,xgrid.size):
(file.write(str("%.6f"%xgrid[0,i])+ +str("%.6f"%rho_n[0,i])+
+str("%.6f"%Pr_n[0,i])+ +str("%.6f"%u_nE[0,i])+
+str("%.6f"%machE[0,i])+ +str("%.6f"%entropy_E[0,i])))
file.write("\n")
file.close()

13.3 Code For Sod Shock Tube Problem By Python Code:

#!/usr/bin/env python
import numpy as np
from scipy.optimize import fsolve
#--------o--Input Section--o-------
# Sod Shock Tube Problem
PrL = 1.0; PrR = 0.1; rhoL = 1.0; rhoR = 0.125;
uL = 0.0; uR = 0.0; t_end = 0.2; mu = 0.35; # mu = dt/dx
#--------o--END Input Section--o-----------------
gamma = 1.4
gammaA = gamma - 1.0
gammaB = 1/gammaA
gammaC = gamma + 1.0
PRL = PrR/PrL
cR = np.sqrt(gamma * PrR/rhoR)
cL = np.sqrt(gamma * PrL/rhoL)
CRL = cR/cL
machL = (uL - uR)/cL
def func(p34):
wortel = np.sqrt(2 * gamma * (gammaA + gammaC * p34))
yy = (gammaA * CRL * (p34 - 1)) / wortel
yy = (1 + machL * gammaA/2 - yy)**(2 * gamma/gammaA)
y = yy/p34 - PRL
return y
p34 = fsolve(func,3.0) # p34 = p3/p4
print p34
p3 = p34 * PrR
alpha = gammaC/gammaA
rho3 = rhoR * (1 + alpha * p34)/(alpha + p34)
rho2 = rhoL * (p34 * PrR/PrL)**(1/gamma)
u2 = uL-uR+(2/gammaA)*cL*(1 - (p34 * PrR/PrL)**(gammaA/(2 * gamma)))
c2 = np.sqrt(gamma * p3/rho2)
spos = (0.5 + t_end* cR *np.sqrt(gammaA/(2 * gamma) +
gammaC/(2 * gamma) * p34) + t_end * uR) # Shock position
conpos = 0.5 + u2 * t_end + t_end * uR # Position of contact discontinuity
pos1 = 0.5 + (uL - cL) * t_end # Start of expansion fan
pos2 = 0.5 + (u2 + uR - c2) * t_end # End of expansion fan
xgrid = np.linspace(0,1,100)
PrE = np.zeros((1,len(xgrid)))
uE= np.zeros((1,len(xgrid)))
rhoE = np.zeros((1,len(xgrid)))
machE = np.zeros((1,len(xgrid)))
cE = np.zeros((1,len(xgrid)))
xgrid = np.matrix(xgrid)
for i in range (0,xgrid.size):
if xgrid[0,i] <= pos1:
PrE[0,i] = PrL
rhoE[0,i] = rhoL
uE[0,i] = uL
cE[0,i]= np.sqrt(gamma*PrE[0,i]/rhoE[0,i]);
machE[0,i]= uE[0,i]/cE[0,i];
elif xgrid[0,i] <= pos2:
PrE[0,i] = (PrL*(1 + (pos1 - xgrid[0,i])
/(cL * alpha * t_end))**(2 * gamma/gammaA))
rhoE[0,i] = (rhoL*(1+(pos1 - xgrid[0,i])
/(cL * alpha * t_end))**(2/gammaA))
uE[0,i] = uL + (2/gammaC)*(xgrid[0,i] - pos1)/t_end
cE[0,i] = np.sqrt(gamma * PrE[0,i]/rhoE[0,i])
machE[0,i] = uE[0,i]/cE[0,i]
elif xgrid[0,i] <= conpos:
PrE[0,i] = p3
rhoE[0,i] = rho2
uE[0,i] = u2 + uR;
cE[0,i]= np.sqrt(gamma * PrE[0,i]/rhoE[0,i]);
machE[0,i] = uE[0,i]/cE[0,i]
elif xgrid[0,i] <= spos:
PrE[0,i] = p3
rhoE[0,i] = rho3
uE[0,i] = u2+uR
cE[0,i] = np.sqrt(gamma * PrE[0,i]/rhoE[0,i])
machE[0,i] = uE[0,i]/cE[0,i]
else:
PrE[0,i] = PrR
rhoE[0,i] = rhoR;
uE[0,i] = uR
cE[0,i] = np.sqrt(gamma*PrE[0,i]/rhoE[0,i]);
machE[0,i] = uE[0,i]/cE[0,i];
entropy_E = np.log(PrE/rhoE**gamma);
""" ---o---File Write Section---o--- """
file = open("Riemann.txt","w")
for i in range(0,xgrid.size):
(file.write("%.6f"%str(xgrid[0,i])+ +str("%.6f"%rhoE[0,i])+
+str("%.6f"%PrE[0,i])+ +str("%.6f"%uE[0,i])+
+str("%.6f"%machE[0,i])+ +str("%.6f"%entropy_E[0,i])))
file.write("\n")
file.close()