@@ -1398,7 +1398,7 @@ contains
13981398 end subroutine s_finalize_variables_conversion_module
13991399
14001400#ifndef MFC_PRE_PROCESS
1401- subroutine s_compute_speed_of_sound (pres , rho , gamma , pi_inf , H , adv , vel_sum , c )
1401+ subroutine s_compute_speed_of_sound (pres , rho , gamma , pi_inf , H , adv , vel_sum , c , c_avggg )
14021402#ifdef CRAY_ACC_WAR
14031403 !DIR$ INLINEALWAYS s_compute_speed_of_sound
14041404#else
@@ -1412,44 +1412,57 @@ contains
14121412 real (kind (0d0 )), intent (out ) :: c
14131413
14141414 real (kind (0d0 )) :: blkmod1, blkmod2
1415-
1415+ real (kind (0d0 )) :: Tolerance, c_c
1416+ real (kind (0d0 )), optional, intent (in ) :: c_avggg
14161417 integer :: q
1418+ if (chemistry) then
1419+ if (present (c_avggg)) then
1420+ c_c = c_avggg
1421+ else
1422+ c_c = 0.0d0 ! Default value if ' b' is absent
1423+ end if
14171424
1418- if (alt_soundspeed) then
1419- blkmod1 = ((gammas(1 ) + 1d0 )* pres + &
1420- pi_infs(1 ))/ gammas(1 )
1421- blkmod2 = ((gammas(2 ) + 1d0 )* pres + &
1422- pi_infs(2 ))/ gammas(2 )
1423- c = (1d0 / (rho* (adv(1 )/ blkmod1 + adv(2 )/ blkmod2)))
1424- elseif (model_eqns == 3 ) then
1425- c = 0d0
1426- !$acc loop seq
1427- do q = 1 , num_fluids
1428- c = c + adv(q)* (1d0 / gammas(q) + 1d0 )* &
1429- (pres + pi_infs(q)/ (gammas(q) + 1d0 ))
1430- end do
1431- c = c/ rho
1432-
1433- elseif (((model_eqns == 4 ) .or. (model_eqns == 2 .and. bubbles))) then
1434- ! Sound speed for bubble mmixture to order O(\alpha)
1435-
1436- if (mpp_lim .and. (num_fluids > 1 )) then
1437- c = (1d0 / gamma + 1d0 )* &
1438- (pres + pi_inf/ (gamma + 1d0 ))/ rho
1425+ if (avg_state == 1 .and. abs (c_c) > Tolerance) then
1426+ c = sqrt (c_c - (gamma - 1.0d0 )* (vel_sum - H))
14391427 else
1440- c = &
1441- (1d0 / gamma + 1d0 )* &
1442- (pres + pi_inf/ (gamma + 1d0 ))/ &
1443- (rho* (1d0 - adv(num_fluids)))
1428+ c = sqrt ((1.0d0 + 1.0d0 / gamma)* pres/ rho)
14441429 end if
14451430 else
1446- c = ((H - 5d-1 * vel_sum)/ gamma)
1447- end if
1431+ if (alt_soundspeed) then
1432+ blkmod1 = ((gammas(1 ) + 1d0 )* pres + &
1433+ pi_infs(1 ))/ gammas(1 )
1434+ blkmod2 = ((gammas(2 ) + 1d0 )* pres + &
1435+ pi_infs(2 ))/ gammas(2 )
1436+ c = (1d0 / (rho* (adv(1 )/ blkmod1 + adv(2 )/ blkmod2)))
1437+ elseif (model_eqns == 3 ) then
1438+ c = 0d0
1439+ !$acc loop seq
1440+ do q = 1 , num_fluids
1441+ c = c + adv(q)* (1d0 / gammas(q) + 1d0 )* &
1442+ (pres + pi_infs(q)/ (gammas(q) + 1d0 ))
1443+ end do
1444+ c = c/ rho
1445+ elseif (((model_eqns == 4 ) .or. (model_eqns == 2 .and. bubbles))) then
1446+ ! Sound speed for bubble mmixture to order O(\alpha)
1447+
1448+ if (mpp_lim .and. (num_fluids > 1 )) then
1449+ c = (1d0 / gamma + 1d0 )* &
1450+ (pres + pi_inf/ (gamma + 1d0 ))/ rho
1451+ else
1452+ c = &
1453+ (1d0 / gamma + 1d0 )* &
1454+ (pres + pi_inf/ (gamma + 1d0 ))/ &
1455+ (rho* (1d0 - adv(num_fluids)))
1456+ end if
1457+ else
1458+ c = ((H - 5d-1 * vel_sum)/ gamma)
1459+ end if
14481460
1449- if (mixture_err .and. c < 0d0 ) then
1450- c = 100.d0 * sgm_eps
1451- else
1452- c = sqrt (c)
1461+ if (mixture_err .and. c < 0d0 ) then
1462+ c = 100.d0 * sgm_eps
1463+ else
1464+ c = sqrt (c)
1465+ end if
14531466 end if
14541467 end subroutine s_compute_speed_of_sound
14551468#endif
0 commit comments