Compute the density for an ideal calorically perfect gas.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R_P), | intent(in) | :: | p | Pressure. |
||
real(kind=R_P), | intent(in) | :: | a | Speed of sound. |
||
real(kind=R_P), | intent(in) | :: | g | Specific heats ratio \(\frac{{c_p}}{{c_v}}\). |
Density.
pure function fluxes(p, r, u, g) result(Fc)
!-------------------------------------------------------------------------------------------------------------------------------
!< 1D Euler fluxes from primitive variables.
!-------------------------------------------------------------------------------------------------------------------------------
real(R_P), intent(IN) :: p !< Pressure.
real(R_P), intent(IN) :: r !< Density.
real(R_P), intent(IN) :: u !< Velocity.
real(R_P), intent(IN) :: g !< Specific heats ratio.
real(R_P) :: Fc(1:3) !< State fluxes.
!-------------------------------------------------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------------------------------------------------
Fc(1) = r*u
Fc(2) = Fc(1)*u + p
Fc(3) = Fc(1)*H(p=p, r=r, u=u, g=g)
return
!-------------------------------------------------------------------------------------------------------------------------------
endfunction fluxes
endsubroutine riemann_solver
! non type-bound procedures
pure subroutine compute_inter_states(r1, p1, u1, g1, r4, p4, u4, g4, p, S, S1, S4)
!------------------------------------------------------------------------------------------------------------------------------
!< Compute inter states (23*-states) from state1 and state4.
!------------------------------------------------------------------------------------------------------------------------------
real(R_P), intent(IN) :: r1 !< Density of state 1.
real(R_P), intent(IN) :: p1 !< Pressure of state 1.
real(R_P), intent(IN) :: u1 !< Velocity of state 1.
real(R_P), intent(IN) :: g1 !< Specific heat ratio of state 1.
real(R_P), intent(IN) :: r4 !< Density of state 4.
real(R_P), intent(IN) :: p4 !< Pressure of state 4.
real(R_P), intent(IN) :: u4 !< Velocity of state 4.
real(R_P), intent(IN) :: g4 !< Specific heat ratio of state 4.
real(R_P), intent(OUT) :: p !< Pressure of the intermediate states.
real(R_P), intent(OUT) :: S !< Contact discontinuity signal velocity.
real(R_P), intent(OUT) :: S1 !< Left fastest signal velocity.
real(R_P), intent(OUT) :: S4 !< Right fastest signal velocity.
real(R_P) :: a1 !< Speed of sound of state 1.
real(R_P) :: a4 !< Speed of sound of state 4.
real(R_P) :: ram !< Mean value of rho*a.
real(R_P), parameter :: toll=1e-10_R_P !< Tollerance.
!------------------------------------------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------------------------------------------
! evaluation of the intermediate states pressure and velocity
a1 = sqrt(g1 * p1 / r1) ! left speed of sound
a4 = sqrt(g4 * p4 / r4) ! right speed of sound
ram = 0.5_R_P * (r1 + r4) * 0.5_R_P * (a1 + a4) ! product of mean density for mean speed of sound
S = 0.5_R_P * (u1 + u4) - 0.5_R_P * (p4 - p1) / ram ! evaluation of the contact wave speed (velocity of intermediate states)
p = 0.5_R_P * (p1 + p4) - 0.5_R_P * (u4 - u1) * ram ! evaluation of the pressure of the intermediate states
! evaluation of the left wave speeds
if (p<=p1*(1._R_P + toll)) then
! rarefaction
S1 = u1 - a1
else
! shock
S1 = u1 - a1 * sqrt(1._R_P + (g1 + 1._R_P) / (2._R_P * g1) * (p / p1 - 1._R_P))
endif
! evaluation of the right wave speeds
if (p<=p4 * (1._R_P + toll)) then
! rarefaction
S4 = u4 + a4
else
! shock
S4 = u4 + a4 * sqrt(1._R_P + (g4 + 1._R_P) / (2._R_P * g4) * ( p / p4 - 1._R_P))
endif
return
!------------------------------------------------------------------------------------------------------------------------------
endsubroutine compute_inter_states
elemental function p(r, a, g) result(pressure)
!---------------------------------------------------------------------------------------------------------------------------------
!< Compute the pressure for an ideal calorically perfect gas.
!---------------------------------------------------------------------------------------------------------------------------------
real(R_P), intent(IN) :: r !< Density.
real(R_P), intent(IN) :: a !< Speed of sound.
real(R_P), intent(IN) :: g !< Specific heats ratio \(\frac{{c_p}}{{c_v}}\).
real(R_P) :: pressure !< Pressure.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
pressure = r*a*a/g
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction p
elemental function r(p, a, g) result(density)
!---------------------------------------------------------------------------------------------------------------------------------
!< Compute the density for an ideal calorically perfect gas.
!---------------------------------------------------------------------------------------------------------------------------------
real(R_P), intent(IN) :: p !< Pressure.
real(R_P), intent(IN) :: a !< Speed of sound.
real(R_P), intent(IN) :: g !< Specific heats ratio \(\frac{{c_p}}{{c_v}}\).
real(R_P) :: density !< Density.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
density = g*p/(a*a)
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction r