You are on page 1of 6

Ao Xu Homepage: http://home.ustc.edu.

cn/~xuaoxiqi

AUSM Flux Vector Splitting Scheme for


Sod Shock Tube Problem

1. Problem
i

Initial condition:
Density_left = 1.0 Density_right = 0.125
Pressure_left = 1.0 Pressure_right = 0.1
Velocity_left = 0.0 Velocity_right = 0.0

2. Numerical scheme

1D Euler Equation in conservation law form is

Where .

Splitting the flux vector F into convective component and pressure component,

Where the convective flux component is

The cell-interface Mach number is given by the splitting,

The splitting of the pressure flux component


Ao Xu Homepage: http://home.ustc.edu.cn/~xuaoxiqi

Splitting of the Mach number,

Splitting of the pressure,

( An alternative choice is )

3. Source codes:
4.
5. !!! This program solves Riemann problem for the Euler equations using AUSM first-order
upwind methods
6. !!! This work is licensed under the Creative Commons Attribution-NonCommercial 3.0
Unported License.
7. !!! Ao Xu, Profiles: <http://www.linkedin.com/pub/ao-xu/30/a72/a29>
8.
9. !!!
10. !!! Shock Tube
11. !!! -------------------------|-------------------------
12. !!! | | |
13. !!! | | |
14. !!! | | |
15. !!! -------------------------|-------------------------
16. !!! Contact Discontinuity
17. !!!
18.
19. !!! x1,x1----------------Left/Right side
20. !!! diaph----------------Initial discontinuity
21. !!! pl,pr----------------Left/Right side pressure
22. !!! rhol,rhor------------Left/Right side density
23. !!! ul,ur----------------Left/Right side velocity
24. !!! al,ar----------------Left/Right side local speed of sound
25.
26. program main
27. implicit none
28. integer, parameter :: N=1000
29. integer :: i, itert, itc
30. real(8), parameter :: gamma=1.4d0, R=287.14d0
31. real(8) :: X(0:N+2), p(0:N+2), a(0:N+2), u(0:N+2), u1(0:N+2),
u2(0:N+2), u3(0:N+2), f1(0:N+1), f2(0:N+1), f3(0:N+1)
Ao Xu Homepage: http://home.ustc.edu.cn/~xuaoxiqi

32. real(8) :: x1, x2, dx, t, dt, lambda, diaph


33. real(8) :: pl, pr, ul, ur, al, ar, rul, rur, retl, retr,rhol, rhor
34.
35. !!! input initial data
36. x1 = 0.0d0
37. x2 = 1.0d0
38. dx = (x2-x1)/float(N)
39. t = 0.25d0
40. dt = 1e-4
41. itert = NINT(t/dt)
42. lambda = dt/dx
43. diaph = 0.5d0
44. itc = 0
45. pl = 1.0d0
46. pr = 0.1d0
47. rhol = 1.0d0
48. rhor =0.125d0
49. ul = 0.0d0
50. ur = 0.0d0
51. al = SQRT(gamma*pl/rhol)
52. ar = SQRT(gamma*pr/rhor)
53.
54. !!! convert primitive variables to conservative variables
55. !!! rul,rur--------------Left/Right side rho*u
56. !!! retl,retr------------Left/Right side rho*E = rho*(e+0.5*u^2)=
rho*(p/rho/(gamma-1)+0.5*u^2) = p/(gamma-1)+0.5*u^2*rho
57. !!! E = e+0.5*u^2 e = p/rho/(gamma-1)
58. rul = rhol*ul
59. rur = rhor*ur
60. retl = 0.5d0*rul*ul+pl/(gamma-1.0d0)
61. retr = 0.5d0*rur*ur+pr/(gamma-1.0d0)
62.
63. !!! construct initial conditions
64. call initial(N,X,dx,diaph,rhol,rhor,rul,rur,retl,retr,u1,u2,u3)
65. t=0
66.
67. do itc=1,itert
68. !!! find conserative numerical fluxes
69. t = t + dt
70. do i=0,N+1
71. call
AUSM(gamma,u1(i),u2(i),u3(i),u1(i+1),u2(i+1),u3(i+1),f1(i),f2(i),f3(i))
72. enddo
73.
Ao Xu Homepage: http://home.ustc.edu.cn/~xuaoxiqi

74. !!! update conserved variables


75. do i=1,N+1
76. u1(i) = u1(i)-lambda*(f1(i)-f1(i-1))
77. u2(i) = u2(i)-lambda*(f2(i)-f2(i-1))
78. u3(i) = u3(i)-lambda*(f3(i)-f3(i-1))
79. u(i) = u2(i)/u1(i)
80. p(i) = (gamma-1.0)*(u3(i)-0.5*u2(i)*u2(i)/u1(i))
81. a(i) = SQRT(gamma*p(i)/u1(i))
82. enddo
83. enddo
84.
85. write(*,*) 'AUSM first-order upwind methods'
86. write(*,*) 'dt=',dt
87. write(*,*) 'dx=',dx
88. write(*,*) 'Final time = ',t
89.
90. open(unit=02,file='./shock_tube_AUSM.dat',status='unknown')
91. write(02,101)
92. write(02,102)
93. write(02,103) N
94. do i = 1,N+1
95. p(i) =
(gamma-1.0d0)*(u3(i)-0.5d0*u2(i)*u2(i)/u1(i))
96. a(i) = SQRT(gamma*p(i)/u1(i))
97. u(i) = u2(i)/u1(i)
98. write(02,100) X(i), u1(i), p(i) ,u(i)
99. enddo
100.
101. 100 format(2x,10(e12.6,' '))
102. 101 format('Title="Sod Shock Tube"')
103. 102 format('Variables=x,rho,p,u')
104. 103 format('zone',1x,'i=',1x,i5,2x,'f=point')
105.
106. close(02)
107. write(*,*) 'Data export to ./shock_tube_AUSM.dat file!'
108.
109. stop
110. end program main
111.
112.
113.
114. subroutine initial(N,X,dx,diaph,rhol,rhor,rul,rur,retl,retr,u1,u2,u3)
115. implicit none
116. integer :: i, N
Ao Xu Homepage: http://home.ustc.edu.cn/~xuaoxiqi

117. real(8) :: dx, diaph, rhol, rhor, rul, rur, retl, retr
118. real(8) :: X(0:N+2),u1(0:N+2), u2(0:N+2), u3(0:N+2)
119.
120. do i = 0,N+2
121. X(i) = i*dx
122. if(X(i).LT.diaph) then
123. u1(i) = rhol
124. u2(i) = rul
125. u3(i) = retl
126. elseif(X(i).GE.diaph) then
127. u1(i) = rhor
128. u2(i) = rur
129. u3(i) = retr
130. endif
131. enddo
132.
133. end subroutine initial
134.
135.
136.
137. subroutine AUSM(gamma,rl,rul,retl,rr,rur,retr,f1,f2,f3)
138. implicit none
139. real(8) :: gamma, rl, rul, retl, rr, rur, retr, f1, f2, f3
140. real(8) :: rhol, rhor, ul, ur, pl, pr, hl, hr, al, ar, Ml, Mr
141. real(8) :: Mp, pp, Mm, pm, Mpm
142.
143. !!! Convert conservative variables to primitive variables.
144. rhol = rl
145. rhor = rr
146. ul = rul/rhol
147. ur = rur/rhor
148. pl = (gamma-1.0d0)*(retl - 0.5d0*rul*rul/rhol)
149. pr = (gamma-1.0d0)*(retr - 0.5d0*rur*rur/rhor)
150. hl = (retl+pl)/rhol
151. hr = (retr+pr)/rhor
152. al = sqrt(gamma*pl/rhol)
153. ar = sqrt(gamma*pr/rhor)
154. Ml = ul/al
155. Mr = ur/ar
156.
157. !!! Compute positive splitting of M and p.
158. if(Ml.LE.-1.0d0) then
159. Mp = 0.0d0
160. pp = 0.0d0
Ao Xu Homepage: http://home.ustc.edu.cn/~xuaoxiqi

161. elseif(Ml.lt.1.0d0) then


162. Mp = 0.25d0*(Ml+1.0d0)*(Ml+1.0d0)
163. pp = 0.5d0*(1.0d0+Ml)*pl !Choice One
164. ! pp = 0.25*pl*(1.0+Ml)*(1.0+Ml)*(2.0-Ml) !Choice Two
165. else
166. Mp = Ml
167. pp = pl
168. endif
169.
170. !!! Compute negative splitting of M and p.
171. if(Mr.LE.-1.0d0) then
172. Mm = Mr
173. pm = pr
174. elseif(Mr.LT.1.0d0) then
175. Mm = -0.25d0*(Mr-1.0d0)*(Mr-1.0d0)
176. pm = 0.5d0*(1.0d0-Mr)*pr !Choice One
177. ! pm = 0.25*pr*(1.0-Mr)*(1.0-Mr)*(2.0+Mr) !Choice Two
178. else
179. Mm = 0.0d0
180. pm = 0.0d0
181. endif
182.
183. Mpm = Mp + Mm
184.
185. !!! Compute conserative numerical fluxes.
186. !!! Splitting the flux vector F into a convective component F^(c) and a pressure
component F^(p)
187. f1 = MAX(0.0d0,Mpm)*rhol*al + MIN(0.0d0,Mpm)*rhor*ar
188. f2 = MAX(0.0d0,Mpm)*rul*al + MIN(0.0d0,Mpm)*rur*ar + pp +
pm
189. f3 = MAX(0.0d0,Mpm)*rhol*hl*al + MIN(0.0d0,Mpm)*rhor*hr*ar
190.
191. return
192. end subroutine AUSM

You might also like