Skip to content

Commit

Permalink
add function to convert rh to water vapor mixing ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed Oct 23, 2024
1 parent a51fa48 commit 4864270
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
22 changes: 22 additions & 0 deletions src/env_state.F90
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,28 @@ real(kind=dp) function env_state_air_molar_den(env_state)

end function env_state_air_molar_den

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Converts relative humidity (1) to water vapor mixing ratio (ppb).
!!
!! Uses equation (1.10) of Seinfeld and Pandis Atmospheric Chemistry and
!! Physics From Air Pollution to Climate Change Second Edition, 2006.
real(kind=dp) function env_state_rel_humid_to_mix_rat(env_state)

!> Environment state.
type(env_state_t), intent(in) :: env_state

real(kind=dp), parameter :: t_steam = 373.15 ! steam temperature (K)
real(kind=dp) :: a, water_vp

a = 1.0 - t_steam / env_state%temp
a = (((-0.1299 * a - 0.6445) * a - 1.976) * a + 13.3185) * a
water_vp = 101325.0 * exp(a) ! (Pa)
env_state_rel_humid_to_mix_rat = env_state%rel_humid * water_vp * 1.0e9 &
/ env_state%pressure ! (ppb)

end function env_state_rel_humid_to_mix_rat

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Condensation \f$A\f$ parameter.
Expand Down
21 changes: 6 additions & 15 deletions src/gas_state.F90
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,15 @@ subroutine gas_state_set_camp_conc(gas_state, camp_state, gas_data)
!> Gas data
type(gas_data_t), intent(in) :: gas_data

real(kind=dp), parameter :: t_steam = 373.15 ! steam temperature (K)
real(kind=dp) :: a, water_vp

camp_state%state_var(1:size(gas_state%mix_rat)) = gas_state%mix_rat(:) &
/ 1000.0d0

! Convert relative humidity (1) to [H2O] (ppm)
! From MOSAIC code - reference to Seinfeld & Pandis page 181
! TODO Figure out how to have consistent RH<->ppm conversions
! (There is only one environmental state for PartMC runs
call assert(590005048, associated(camp_state%env_states(1)%val))
a = 1.0 - t_steam / camp_state%env_states(1)%val%temp
a = (((-0.1299 * a - 0.6445) * a - 1.976) * a + 13.3185) * a
water_vp = 101325.0 * exp(a) ! (Pa)

! Convert relative humidity (1) to [H2O] (ppb)
camp_state%state_var(gas_data%i_camp_water) = &
camp_state%env_states(1)%val%rel_humid * water_vp * 1.0e6 &
/ camp_state%env_states(1)%val%pressure ! (ppm)
env_state_rel_humid_to_mix_rat(camp_state%env_states(1))

! Convert from ppb to ppm
camp_state%state_var(1:size(gas_state%mix_rat)) = gas_state%mix_rat(:) &
/ 1000.0d0

end subroutine gas_state_set_camp_conc

Expand Down
9 changes: 1 addition & 8 deletions src/tchem_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ subroutine tchem_from_partmc(aero_data, aero_state, gas_data, gas_state, &

real(kind=dp), allocatable :: stateVector(:)
integer :: stateVecDim
real(kind=dp), parameter :: t_steam = 373.15 ! steam temperature (K)
real(kind=dp) :: a, water_vp
integer :: i_part
integer :: i_water

Expand All @@ -239,12 +237,7 @@ subroutine tchem_from_partmc(aero_data, aero_state, gas_data, gas_state, &
! PartMC uses relative humidity and not H2O mixing ratio.
! Equation 1.10 from Seinfeld and Pandis - Second Edition.
i_water = gas_data_spec_by_name(gas_data, "H2O")
a = 1.0 - t_steam / env_state%temp
a = (((-0.1299 * a - 0.6445) * a - 1.976) * a + 13.3185) * a
water_vp = 101325.0 * exp(a) ! (Pa)
gas_state%mix_rat(i_water) = env_state%rel_humid * water_vp * 1.0e9 &
/ env_state%pressure ! (ppb)

gas_state%mix_rat(i_water) = env_state_rel_humid_to_mix_rat(env_state)
! Add gas species to state vector. Convert from ppb to ppm.
stateVector(4:gas_data_n_spec(gas_data)+3) = gas_state%mix_rat / 1000.d0

Expand Down

0 comments on commit 4864270

Please sign in to comment.