@@ -55,41 +55,6 @@ contains
5555
5656 end subroutine s_finalize_chemistry_module
5757
58- #:for NORM_DIR, XYZ in [(1 , ' x' ), (2 , ' y' ), (3 , ' z' )]
59- subroutine s_compute_chemistry_rhs_ ${XYZ}$ (flux_n, rhs_vf, flux_src_vf, q_prim_vf)
60-
61- type(vector_field), dimension (:), intent (IN ) :: flux_n
62- type(scalar_field), dimension (sys_size), intent (INOUT ) :: rhs_vf, flux_src_vf, q_prim_vf
63- type(int_bounds_info) :: ix, iy, iz
64-
65- integer :: x, y, z
66- integer :: eqn
67-
68- integer , parameter :: mx = ${1 if NORM_DIR == 1 else 0 }$
69- integer , parameter :: my = ${1 if NORM_DIR == 2 else 0 }$
70- integer , parameter :: mz = ${1 if NORM_DIR == 3 else 0 }$
71-
72- !$acc parallel loop collapse(4 ) present (rhs_vf, flux_n)
73- do x = 0 , m
74- do y = 0 , n
75- do z = 0 , p
76-
77- do eqn = chemxb, chemxe
78-
79- ! \nabla \cdot (F)
80- rhs_vf(eqn)%sf(x, y, z) = rhs_vf(eqn)%sf(x, y, z) + &
81- (flux_n(${NORM_DIR}$)%vf(eqn)%sf(x - mx, y - my, z - mz) - &
82- flux_n(${NORM_DIR}$)%vf(eqn)%sf(x, y, z))/ d${XYZ}$ (${XYZ}$)
83-
84- end do
85-
86- end do
87- end do
88- end do
89-
90- end subroutine s_compute_chemistry_rhs_ ${XYZ}$
91- #:endfor
92-
9358 subroutine s_compute_chemistry_reaction_flux (rhs_vf , q_cons_qp , q_prim_qp )
9459
9560 type(scalar_field), dimension (sys_size), intent (INOUT ) :: rhs_vf, q_cons_qp, q_prim_qp
@@ -104,50 +69,47 @@ contains
10469 real (kind (0d0 )) :: dyn_pres
10570 real (kind (0d0 )) :: E
10671
107- real (kind (0d0 )) :: rho
108- real (kind (1.d0 )), dimension (num_species) :: Ys
109- real (kind (1.d0 )), dimension (num_species) :: omega
72+ real (kind (0d0 )) :: rho, omega_m, omega_T
73+ real (kind (0d0 )), dimension (num_species) :: Ys
74+ real (kind (0d0 )), dimension (num_species) :: omega
11075 real (kind (0d0 )), dimension (num_species) :: enthalpies
11176 real (kind (0d0 )) :: cp_mix
11277
11378 #:if chemistry
11479
115- !$acc parallel loop collapse(4 ) private(rho)
80+ !$acc parallel loop collapse(3 ) private(rho)
11681 do x = 0 , m
11782 do y = 0 , n
11883 do z = 0 , p
11984
120- ! Maybe use q_prim_vf instead?
12185 rho = 0d0
12286 do eqn = chemxb, chemxe
12387 rho = rho + q_cons_qp(eqn)%sf(x, y, z)
12488 end do
12589
12690 do eqn = chemxb, chemxe
127- Ys(eqn - chemxb + 1 ) = q_cons_qp (eqn)%sf(x, y, z)/ rho
91+ Ys(eqn - chemxb + 1 ) = q_prim_qp (eqn)%sf(x, y, z)
12892 end do
12993
13094 dyn_pres = 0d0
131-
13295 do i = momxb, momxe
133- dyn_pres = dyn_pres + rho * q_cons_qp(i)%sf(x, y, z)* &
134- q_cons_qp (i)%sf(x, y, z)/ 2d0
96+ dyn_pres = dyn_pres + q_cons_qp(i)%sf(x, y, z)* &
97+ q_prim_qp (i)%sf(x, y, z)/ 2d0
13598 end do
13699
137- call get_temperature(.true. , q_cons_qp(E_idx)%sf(x, y, z) - dyn_pres, &
138- & q_prim_qp(tempxb)%sf(x, y, z), Ys , T)
100+ call get_temperature(q_cons_qp(E_idx)%sf(x, y, z)/ rho - dyn_pres/ rho , &
101+ & 1200d0 , Ys, .true. , T)
139102
140103 call get_net_production_rates(rho, T, Ys, omega)
141104
142- q_cons_qp(tempxb)%sf(x, y, z) = T
143- q_prim_qp(tempxb)%sf(x, y, z) = T
144-
145- !print * , x, y, z, T, rho, Ys, omega, q_cons_qp(E_idx)%sf(x, y, z), dyn_pres
105+ call get_species_enthalpies_rt(T, enthalpies)
146106
147107 do eqn = chemxb, chemxe
148108
149- rhs_vf(eqn)%sf(x, y, z) = rhs_vf(eqn)%sf(x, y, z) + &
150- mol_weights(eqn - chemxb + 1 )* omega(eqn - chemxb + 1 )
109+ omega_m = mol_weights(eqn - chemxb + 1 )* omega(eqn - chemxb + 1 )
110+ omega_T = omega_m* enthalpies(eqn - chemxb + 1 )* gas_constant* T
111+
112+ rhs_vf(eqn)%sf(x, y, z) = rhs_vf(eqn)%sf(x, y, z) + omega_m
151113
152114 end do
153115
@@ -171,9 +133,9 @@ contains
171133 integer :: eqn
172134
173135 !$acc parallel loop collapse(4 )
174- do x = ix%beg, ix% end
175- do y = iy%beg, iy%end
176- do z = iz%beg, iz%end
136+ do x = 0 , m
137+ do y = 0 , n
138+ do z = 0 , p
177139
178140 do eqn = chemxb, chemxe
179141 q_cons_qp(eqn)%sf(x, y, z) = max (0d0 , q_cons_qp(eqn)%sf(x, y, z))
0 commit comments