Compute the speed of sound 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) | :: | r | Density. |
||
real(kind=R_P), | intent(in) | :: | g | Specific heats ratio \(\frac{{c_p}}{{c_v}}\). |
Speed of sound.
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
elemental function a(p, r, g) result(ss)
!---------------------------------------------------------------------------------------------------------------------------------
!< Compute the speed of sound for an ideal calorically perfect gas.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
real(R_P), intent(IN) :: p !< Pressure.
real(R_P), intent(IN) :: r !< Density.
real(R_P), intent(IN) :: g !< Specific heats ratio \(\frac{{c_p}}{{c_v}}\).
real(R_P) :: ss !< Speed of sound.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
ss = sqrt(g*p/r)
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction a