5.2.1. 示例 1: 一维Euler方程组
激波管问题是验证 CFD 黎曼求解器的常用测试算例。
(1) 离散方法
空间半离散形式 Eq.3.2.38, Roe 通量格式: Eq.3.2.45, 一阶重构: Eq.3.2.50。
时间推进的常微分方程 (Eq.3.1.20) 可写作:
(5.2.1)\[\frac{d \mathbf{U}_j}{d t} =
\mathbf{Q}_j (\mathbf{U}_{j-1}, \mathbf{U}_j, \mathbf{U}_{j+1})\]
有限体积方法
均匀结构网格
半离散方法
显式时间推进 (TVD 性质, 三阶精度)
二阶空间离散 (ROE 格式)
无边界条件
(2) 代码示例
以下为部分代码。 其中,调用的通量和重构格式参考 Eq.3.2.45, Eq.3.2.57 相关实现。
1def time_march_rhs(sol: np.ndarray, dx: float, dt: float) -> np.ndarray:
2 '''
3 Calculate the right hand side of the dU/dt=Q
4 '''
5 qq = np.zeros_like(sol)
6
7 for i in range(2, N_POINTS-1):
8
9 uUL, uUR = Reconstruction.Upwind1_TVD_eigen(
10 sol[i-2,:], sol[i-1,:], sol[i,:], sol[i+1,:],
11 limiter=Reconstruction.min_mod, roe_average=Roe.average,
12 dx=dx, dt=dt)
13
14 fFaceL = Roe.flux_face(uUL, uUR)
15
16 uUL, uUR = Reconstruction.Upwind1_TVD_eigen(
17 sol[i-1,:], sol[i,:], sol[i+1,:], sol[i+2,:],
18 limiter=Reconstruction.min_mod, roe_average=Roe.average,
19 dx=dx, dt=dt)
20
21 fFaceR = Roe.flux_face(uUL, uUR)
22
23 qq[i,:] = - (fFaceR - fFaceL)/dx
24
25 return qq
26
27
28def RungeKutta3(sol: np.ndarray, dx: float, time_remain: float) -> np.ndarray:
29
30 global_dt = time_step(sol, dx, CFL)
31
32 global_dt = min(global_dt, time_remain)
33
34 next_sol = sol.copy()
35
36 #* Step 1
37 qq = time_march_rhs(next_sol, dx, global_dt)
38 next_sol = sol + global_dt*qq
39
40 #* Step 2
41 qq = time_march_rhs(next_sol, dx, global_dt)
42 next_sol = 3/4*sol + 1/4*(next_sol + global_dt*qq)
43
44 #* Step 3
45 qq = time_march_rhs(next_sol, dx, global_dt)
46 next_sol = 1/3*sol + 2/3*(next_sol + global_dt*qq)
47
48 return next_sol, global_dt
49
50
51if __name__ == "__main__":
52
53 mesh, current_solution, DX = initialization()
54 CFL=1.2
55 t0=0
56 while t0<T0:
57 current_solution, global_dt = RungeKutta3(current_solution, DX, T0-t0)
58 t0 += global_dt
(3) 结果展示
图 5.2.1 AUSM 矢通量分解格式, ROE 格式与精确解的对比