@@ -752,6 +752,7 @@ contains
752752 real (wp) :: rho
753753 real (wp) :: gamma
754754 real (wp) :: pi_inf
755+ real (wp) :: pres_i, alpha_i, alpha_rho_i, e_i
755756 real (wp) :: qv
756757 real (wp) :: dyn_pres
757758 real (wp) :: nbub, R3tmp
@@ -894,10 +895,11 @@ contains
894895 ! Six- equation model (Saurel et al. JCP 2009 ): compute per- phase internal energies
895896 if (model_eqns == model_eqns_6eq) then
896897 do i = 1 , num_fluids
897- call s_phase_internal_energy(q_prim_vf(eqn_idx%E)%sf(j, k, l), &
898- & q_cons_vf(i + eqn_idx%adv%beg - 1 )%sf(j, k, l), &
899- & q_cons_vf(i + eqn_idx%cont%beg - 1 )%sf(j, k, l), i, &
900- & q_cons_vf(i + eqn_idx%int_en%beg - 1 )%sf(j, k, l))
898+ pres_i = q_prim_vf(eqn_idx%E)%sf(j, k, l)
899+ alpha_i = q_cons_vf(i + eqn_idx%adv%beg - 1 )%sf(j, k, l)
900+ alpha_rho_i = q_cons_vf(i + eqn_idx%cont%beg - 1 )%sf(j, k, l)
901+ call s_phase_internal_energy(pres_i, alpha_i, alpha_rho_i, i, e_i)
902+ q_cons_vf(i + eqn_idx%int_en%beg - 1 )%sf(j, k, l) = e_i
901903 end do
902904 end if
903905
@@ -1241,7 +1243,7 @@ contains
12411243 #:endif
12421244 real(wp), intent(out) :: rho_K, gamma_K, pi_inf_K, qv_K
12431245 real(wp) :: gamma_i, pi_inf_i, dpi_i, dgamma_i
1244- real(wp) :: rho_i
1246+ real(wp) :: rho_i, alpha_i, alpha_rho_i
12451247 integer :: i !< Loop iterator over fluids
12461248
12471249 ! The bubbly closure is written for one carrier liquid, which keeps its own coefficients
@@ -1263,7 +1265,9 @@ contains
12631265 $:GPU_LOOP(parallelism=' [seq]' )
12641266 do i = 1, num_fluids
12651267 rho_K = rho_K + alpha_rho_K(i)
1266- call s_phase_coefficients(alpha_rho_K(i), alpha_K(i), i, rho_i, gamma_i, pi_inf_i, dpi_i, dgamma_i)
1268+ alpha_rho_i = alpha_rho_K(i)
1269+ alpha_i = alpha_K(i)
1270+ call s_phase_coefficients(alpha_rho_i, alpha_i, i, rho_i, gamma_i, pi_inf_i, dpi_i, dgamma_i)
12671271 gamma_K = gamma_K + alpha_K(i)*gamma_i
12681272 pi_inf_K = pi_inf_K + alpha_K(i)*pi_inf_i
12691273 qv_K = qv_K + alpha_rho_K(i)*qvs(i)
@@ -1283,7 +1287,7 @@ contains
12831287 real(wp), dimension(num_fluids), intent(in) :: dalpha_rho_dt, dadv_dt, alpha_rho, adv
12841288 #:endif
12851289 real(wp), intent(out) :: drho_dt, dgamma_dt, dpi_inf_dt, dqv_dt
1286- real(wp) :: rho_i, gamma_i, pi_inf_i, dpi_i, dgamma_i
1290+ real(wp) :: rho_i, gamma_i, pi_inf_i, dpi_i, dgamma_i, alpha_i, alpha_rho_i
12871291 integer :: i !< Loop iterator over fluids
12881292
12891293 dgamma_dt = 0._wp
@@ -1299,7 +1303,9 @@ contains
12991303 $:GPU_LOOP(parallelism= ' [seq]' )
13001304 do i = 1 , num_fluids
13011305 drho_dt = drho_dt + dalpha_rho_dt(i)
1302- call s_phase_coefficients(alpha_rho(i), adv(i), i, rho_i, gamma_i, pi_inf_i, dpi_i, dgamma_i)
1306+ alpha_rho_i = alpha_rho(i)
1307+ alpha_i = adv(i)
1308+ call s_phase_coefficients(alpha_rho_i, alpha_i, i, rho_i, gamma_i, pi_inf_i, dpi_i, dgamma_i)
13031309 ! d(alpha X(rho_i))/ dt with rho_i = alpha_rho/ alpha; the alpha in dX/ dt cancels
13041310 dgamma_dt = dgamma_dt + dadv_dt(i)* gamma_i + dgamma_i* (dalpha_rho_dt(i) - rho_i* dadv_dt(i))
13051311 dpi_inf_dt = dpi_inf_dt + dadv_dt(i)* pi_inf_i + dpi_i* (dalpha_rho_dt(i) - rho_i* dadv_dt(i))
@@ -1599,11 +1605,12 @@ contains
15991605 real(wp), intent(in) :: rho, pres
16001606 integer, intent(in) :: i
16011607 real(wp), intent(out) :: T
1602- real(wp) :: p_ref, e_ref, dp_drho, de_drho, G0, dG0, T_ref
1608+ real(wp) :: p_ref, e_ref, dp_drho, de_drho, G0, dG0, T0, T_ref
16031609
16041610 if (f_is_state_dependent(i)) then
16051611 call s_reference_curve(rho, i, p_ref, e_ref, dp_drho, de_drho, G0, dG0)
1606- call s_rk4(ode_reference_temperature, i, 1._wp/rho0s(i), t0s(i), 1._wp/rho, T_ref)
1612+ T0 = t0s(i)
1613+ call s_rk4(ode_reference_temperature, i, 1._wp/rho0s(i), T0, 1._wp/rho, T_ref)
16071614 T = T_ref + (pres - p_ref)/(rho*G0*cvs(i))
16081615 else
16091616 T = (pres + isentrope_B(i))/((isentrope_n(i) - 1._wp)*cvs(i)*rho)
@@ -1758,7 +1765,7 @@ contains
17581765 real(wp), dimension(num_fluids), intent(in), optional :: alpha_rho
17591766 #:endif
17601767 real(wp) :: alf !< Subgrid void fraction; dilute by construction
1761- real(wp) :: blkmod_q
1768+ real(wp) :: blkmod_q, alpha_q, alpha_rho_q, gamma_q, pi_inf_q
17621769 integer :: q
17631770
17641771 if (chemistry) then ! Reacting mixture sound speed
@@ -1772,7 +1779,9 @@ contains
17721779 c = 0._wp
17731780 $:GPU_LOOP(parallelism= ' [seq]' )
17741781 do q = 1 , num_fluids
1775- call s_phase_bulk_modulus(pres, adv(q), alpha_rho(q), q, blkmod_q)
1782+ alpha_q = adv(q)
1783+ alpha_rho_q = alpha_rho(q)
1784+ call s_phase_bulk_modulus(pres, alpha_q, alpha_rho_q, q, blkmod_q)
17761785 if (alt_soundspeed) then
17771786 c = c + adv(q)/ blkmod_q
17781787 else
@@ -1788,14 +1797,18 @@ contains
17881797 c = 0._wp
17891798 $:GPU_LOOP(parallelism=' [seq]' )
17901799 do q = 1, num_fluids
1791- c = c + adv(q)/f_bulk_modulus(pres, gammas(q), pi_infs(q))
1800+ gamma_q = gammas(q)
1801+ pi_inf_q = pi_infs(q)
1802+ c = c + adv(q)/f_bulk_modulus(pres, gamma_q, pi_inf_q)
17921803 end do
17931804 c = 1._wp/(rho*c)
17941805 else if (model_eqns == model_eqns_6eq) then ! volume-weighted arithmetic mean
17951806 c = 0._wp
17961807 $:GPU_LOOP(parallelism=' [seq]' )
17971808 do q = 1, num_fluids
1798- c = c + adv(q)*f_bulk_modulus(pres, gammas(q), pi_infs(q))
1809+ gamma_q = gammas(q)
1810+ pi_inf_q = pi_infs(q)
1811+ c = c + adv(q)*f_bulk_modulus(pres, gamma_q, pi_inf_q)
17991812 end do
18001813 c = c/rho
18011814 else ! the mixture coefficients already carry the mixing
0 commit comments