Skip to content

Commit

Permalink
Implement the complete equation for R11-24.
Browse files Browse the repository at this point in the history
Implement Z, pKwG and pKw for computing the ionization constant.
  • Loading branch information
MilanSkocic committed Jan 16, 2025
1 parent 677caa2 commit 5921ec2
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/iapws_r1124.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module iapws__g704
module iapws__r1124
!! Module for IAPWS R11-24.
use iapws__common
implicit none
Expand All @@ -15,17 +15,49 @@ module iapws__g704

contains

pure elemental Z(T, rhow)result(res)
pure elemental function Z(T, rhow)result(res)
!! Empirical function in Bandura–Lvov model, g.cm^{-3}

!! Arguments
! Arguments
real(dp), intent(in) :: T !! Temperature in K.
real(dp), intent(in) :: rhow !! Mass density, g.cm^{-3}

!! Returns
! Returns
real(dp) :: res !! Empirical value of temperature and water density

Z = rhow * exp(a0 + a1/T + a2/T**2.0_dp*rhow**(2.0_dp/3.0_dp))
end function

pure elemental function pKwG(T)result(res)
!! Equilibrium constant of the ionization reaction in the ideal-gas state.

! Arguments
real(dp), intent(in) :: T !! Temperature in K.

! Returns
real(dp) :: res
res = 0.61415 + 48251.33/T + 67707.93/T**2.0_dp + 10102100.0_dp/T**3.0_dp

end function

pure elemental function pKw(T, rhow)result(res)
!! Ionization constant of water.
!! Validity range 273.13 K <= T <= 1273.15 K and 0 <= p <= 1000 MPa.

! Arguments
real(dp), intent(in) :: T !! Temperature in K.
real(dp), intent(in) :: rhow !! Mass density in g.cm^{-3}.

! Returns
real(dp) :: res

res = ieee_value(1.0_dp, ieee_quiet_nan)

if(T>=Tlim1) .and. (T<=Tlim2)then
res = -2*n* ( &
log10(1+Z(T, rhow)) - Z(T, rhow)/(Z(T, rhow)+1) * rhow *(b0+b1/T+b2*rhow) &
) + pKwG(T) + 2*log10(Mw/1000.0_dp)
endif
end function

end module iapws__r1124

0 comments on commit 5921ec2

Please sign in to comment.