12 function to created the relativistic hydrodynamic kernel in the conserved formulation
13 We treat the primitive variables and spacetime variables as auxiliary variables
16 for now the default order of the file is following the FV solvers persepective (thus require adjust data arrangement)
17 if we only have current infrastructure, the order here have to be adjusted. We can have
18 {Q_spacetime, Q_hydro_evo}
20 Reconstruction of primitive variables:
21 For RK1 we can naturally insert the reconstruction into the preprocess stage.
22 It becomes tricky when we do higher RK where we need reconstruction for every RK stage
23 (still working but find a better place to insert)
24 The reconstruction function would be (tilde{gamma}_ij, phi, Q_hydro_evo) -> Q_hydro_primitive
27 hydro_pde= exahype2.symhype.FirstOrderConservativePDEFormulation(
28 unknowns=5, auxiliary_variables=5+51+1, dimensions=3)
31 tildeD = hydro_pde.name_Q_entry(0,
"tildeD")
32 tildeS1 = hydro_pde.name_Q_entry(1,
"tildeS1")
33 tildeS2 = hydro_pde.name_Q_entry(2,
"tildeS2")
34 tildeS3 = hydro_pde.name_Q_entry(3,
"tildeS3")
35 tildetau= hydro_pde.name_Q_entry(4,
"tildetau")
38 rho0 = hydro_pde.name_auxiliary_variable(0,
"rho0")
39 v1 = hydro_pde.name_auxiliary_variable(1,
"v1")
40 v2 = hydro_pde.name_auxiliary_variable(2,
"v2")
41 v3 = hydro_pde.name_auxiliary_variable(3,
"v3")
42 epsilon = hydro_pde.name_auxiliary_variable(4,
"epsilon")
43 W = hydro_pde.name_auxiliary_variable(56,
"W")
46 tg11 = hydro_pde.name_auxiliary_variable(5,
"tg11"); tg12 = hydro_pde.name_auxiliary_variable(6,
"tg12")
47 tg13 = hydro_pde.name_auxiliary_variable(7,
"tg13"); tg22 = hydro_pde.name_auxiliary_variable(8,
"tg22")
48 tg23 = hydro_pde.name_auxiliary_variable(9,
"tg23"); tg33 = hydro_pde.name_auxiliary_variable(10,
"tg33")
50 tA11 = hydro_pde.name_auxiliary_variable(11,
"tA11"); tA12 = hydro_pde.name_auxiliary_variable(12,
"tA12")
51 tA13 = hydro_pde.name_auxiliary_variable(13,
"tA13"); tA22 = hydro_pde.name_auxiliary_variable(14,
"tA22")
52 tA23 = hydro_pde.name_auxiliary_variable(15,
"tA23"); tA33 = hydro_pde.name_auxiliary_variable(16,
"tA33")
54 alpha = hydro_pde.name_auxiliary_variable(17,
"alpha")
55 beta1 = hydro_pde.name_auxiliary_variable(18,
"beta1")
56 beta2 = hydro_pde.name_auxiliary_variable(19,
"beta2")
57 beta3 = hydro_pde.name_auxiliary_variable(20,
"beta3")
59 A1 = hydro_pde.name_auxiliary_variable(21,
"A1")
60 A2 = hydro_pde.name_auxiliary_variable(22,
"A2")
61 A3 = hydro_pde.name_auxiliary_variable(23,
"A3")
63 B11 = hydro_pde.name_auxiliary_variable(24,
"B11")
64 B12 = hydro_pde.name_auxiliary_variable(25,
"B12")
65 B13 = hydro_pde.name_auxiliary_variable(26,
"B13")
66 B21 = hydro_pde.name_auxiliary_variable(27,
"B21")
67 B22 = hydro_pde.name_auxiliary_variable(28,
"B22")
68 B23 = hydro_pde.name_auxiliary_variable(29,
"B23")
69 B31 = hydro_pde.name_auxiliary_variable(30,
"B31")
70 B32 = hydro_pde.name_auxiliary_variable(31,
"B32")
71 B33 = hydro_pde.name_auxiliary_variable(32,
"B33")
73 D111 = hydro_pde.name_auxiliary_variable(33,
"D111"); D112 = hydro_pde.name_auxiliary_variable(34,
"D112"); D113 = hydro_pde.name_auxiliary_variable(35,
"D113");
74 D122 = hydro_pde.name_auxiliary_variable(36,
"D122"); D123 = hydro_pde.name_auxiliary_variable(37,
"D123"); D133 = hydro_pde.name_auxiliary_variable(38,
"D133");
75 D211 = hydro_pde.name_auxiliary_variable(39,
"D211"); D212 = hydro_pde.name_auxiliary_variable(40,
"D212"); D213 = hydro_pde.name_auxiliary_variable(41,
"D213");
76 D222 = hydro_pde.name_auxiliary_variable(42,
"D222"); D223 = hydro_pde.name_auxiliary_variable(43,
"D223"); D233 = hydro_pde.name_auxiliary_variable(44,
"D233");
77 D311 = hydro_pde.name_auxiliary_variable(45,
"D311"); D312 = hydro_pde.name_auxiliary_variable(46,
"D312"); D313 = hydro_pde.name_auxiliary_variable(47,
"D313");
78 D322 = hydro_pde.name_auxiliary_variable(48,
"D322"); D323 = hydro_pde.name_auxiliary_variable(49,
"D323"); D333 = hydro_pde.name_auxiliary_variable(50,
"D333");
80 K = hydro_pde.name_auxiliary_variable(51,
"K")
81 phi = hydro_pde.name_auxiliary_variable(52,
"phi")
82 P1 = hydro_pde.name_auxiliary_variable(53,
"P1")
83 P2 = hydro_pde.name_auxiliary_variable(54,
"P2")
84 P3 = hydro_pde.name_auxiliary_variable(55,
"P3")
87 tildeS = Array([tildeS1, tildeS2, tildeS3])
88 v = Array([v1, v2, v3])
89 tg = Array([[tg11, tg12, tg13],
92 tA = Array([[tA11, tA12, tA13],
95 beta = Array([beta1, beta2, beta3])
96 A = Array([A1, A2, A3])
97 B = Array([[B11, B12, B13],
100 Dijk = Array([[[D111, D112, D113], [D112, D122, D123], [D113, D123, D133]],
101 [[D211, D212, D213], [D212, D222, D223], [D213, D223, D233]],
102 [[D311, D312, D313], [D312, D322, D323], [D313, D323, D333]]])
103 P = Array([P1, P2, P3])
109 detg = Matrix(g).det()
110 g_up = Array(Matrix(g).inv().tolist())
111 tg_up = Array(Matrix(tg).inv().tolist())
113 p = (Gamma_index-1)*rho0*epsilon
115 V = alpha*tensorcontraction(tensorproduct(g_up, v), (1,2)) - beta
116 v_up = tensorcontraction(tensorproduct(g_up, v), (1,2))
123 Sij = tensorproduct(S, S)/(rho0*h*W**2) + p*g
125 Kij = tA/(phi*phi) + (1/3)*K*g
126 Kij_up = tensorcontraction(tensorproduct(g_up, g_up, Kij), (1,4), (3,5))
127 dg_up = 2*phi*tensorproduct(P, tg_up)-2*phi**2*tensorcontraction(tensorproduct(tg_up, tg_up, Dijk), (1, 5), (3, 6))
130 S_source = -E*A + tensorcontraction(tensorproduct(S, B), (0,2)) - 0.5*alpha*tensorcontraction(tensorproduct(Sij, dg_up), (0, 3), (1, 4))
133 tau_source = alpha*tensorcontraction(tensorproduct(Sij, Kij_up), (0, 2), (1, 3)) - tensorcontraction(tensorproduct(g_up, S, A), (0, 3), (1, 2))
137 hydro_pde.F[0,i] = detg*D*V[i]
138 hydro_pde.F[4,i] = tau*V[i] + alpha*p*v_up[i]
140 hydro_pde.F[1,0] = detg *(S[0]*V[0]+alpha*p)
141 hydro_pde.F[1,1] = detg * S[0]*V[1]
142 hydro_pde.F[1,2] = detg * S[0]*V[2]
143 hydro_pde.F[2,0] = detg * S[1]*V[0]
144 hydro_pde.F[2,1] = detg *(S[1]*V[1]+alpha*p)
145 hydro_pde.F[2,2] = detg * S[1]*V[2]
146 hydro_pde.F[3,0] = detg * S[2]*V[0]
147 hydro_pde.F[3,1] = detg * S[2]*V[1]
148 hydro_pde.F[3,2] = detg *(S[2]*V[2]+alpha*p)
151 hydro_pde.sources[0] = 0
152 hydro_pde.sources[1] = S_source[0]
153 hydro_pde.sources[2] = S_source[1]
154 hydro_pde.sources[3] = S_source[2]
155 hydro_pde.sources[4] = tau_source
158 c_s_2 = Gamma_index*(Gamma_index-1)*epsilon/(1+Gamma_index*epsilon)
163 hydro_pde.eigenvalues[0, i]= -beta[i]+ alpha/(1-c_s_2*v_mag_2) * ( v[i]*(1-c_s_2) + (c_s_2*(1-v_mag_2)*(g[i][i]*(1-c_s_2*v_mag_2)-v_up[i]*v_up[i]*(1-c_s_2)))**0.5 )
165 hydro_pde.eigenvalues[4, i]= -beta[i]+ alpha/(1-c_s_2*v_mag_2) * ( v[i]*(1-c_s_2) - (c_s_2*(1-v_mag_2)*(g[i][i]*(1-c_s_2*v_mag_2)-v_up[i]*v_up[i]*(1-c_s_2)))**0.5 )
167 hydro_pde.eigenvalues[1, i]= V[i]
168 hydro_pde.eigenvalues[2, i]= V[i]
169 hydro_pde.eigenvalues[3, i]= V[i]
174 print(hydro_pde.implementation_of_flux())