Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set gas-species profiles in TUV-x prior to calculating rate constants #174

Draft
wants to merge 15 commits into
base: development
Choose a base branch
from

Conversation

boulderdaze
Copy link
Collaborator

@boulderdaze boulderdaze commented Dec 6, 2024

Currently in draft for questions and discussions

@boulderdaze boulderdaze self-assigned this Dec 6, 2024
air_pressure_thickness, rate_parameters, &
errmsg, errcode)

! TODO(jiwon) this might not be correct because it doesn't know the index
Copy link
Collaborator Author

@boulderdaze boulderdaze Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @peverwhee, is this code still valid (line 116 - 122)? We discussed that the sequence of the constituents array is not guaranteed. Do we now need to search for the index of the MICM constituents before attempting to retrieve the molar mass?

    do i_elem = 1, size(molar_mass_arr)
      call constituent_props(i_elem)%molar_mass(molar_mass_arr(i_elem), errcode, errmsg)
      if (errcode /= 0) then
        errmsg = "[MUSICA Error] Unable to get molar mass."
        return
      end if
    end do

Comment on lines +15 to +17
!> Molar mass value of dry air is obtained from 'CAM-SIMA/src/utils/std_atm_profile.F90'
! TODO(jiwon)
real(kind_phys), parameter, public :: MOLAR_MASS_DRY_AIR = 0.0289644_kind_phys ! kg mol-1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mattldawson and @nusbaume, I get the molar mass value of dry air from CAM-SIMA/src/utils/std_atm_profile.F90. Is it okay to define it here? We discussed about passing parameters from CAM-SIMA, but I'm still unsure about the approach we're going to take.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @boulderdaze, you should be able to read in the molar mass of dry air as an input argument with the standard name molecular_weight_of_dry_air, which will be in units of g mol-1. There is also a composition-dependent version as well, but that is only used in WACCM and WACCM-X configurations (although if you would like to use that quantity instead just let me know).

The reason we generally suggest passing this value in as an argument is because some host models and host model configurations might have slightly different values for the dry air molar mass, especially if they are configured for high-top, paleoclimate, or exoplanet simulations, and so by bringing it in as an argument we won't have to worry about molar mass value mismatches.

Anyways, hopefully that helps? If for some reason that method does not work for your particular setup here just let me know. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense, thank you for the additional details! I will use molecular_weight_of_dry_air as an input.

Comment on lines 53 to 91
!> Configures gas species.
! Note: The user can customize this function to configure gas species in the system
! This function allocates memory for the gas species that is needed in tuvx_init and tuvx_run.
! The user is responsible for deallocating the memory.
subroutine configure_gas_species(constituent_props, gas_species_group, errmsg, errcode)
use ccpp_const_utils, only: ccpp_const_get_idx
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t

type(ccpp_constituent_prop_ptr_t), intent(in) :: constituent_props(:)
type(gas_species_t), allocatable, intent(out) :: gas_species_group(:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errcode

! local variable
integer :: num_gas_species = 3
real(kind_phys), parameter :: SCALE_HEIGHT_DRY_AIR = 8.01_kind_phys ! km
real(kind_phys), parameter :: SCALE_HEIGHT_O2 = 7.0_kind_phys ! km
real(kind_phys), parameter :: SCALE_HEIGHT_O3 = 7.0_kind_phys ! km
real(kind_phys) :: molar_mass_O2 ! kg mol-1
real(kind_phys) :: molar_mass_O3 ! kg mol-1
integer, parameter :: INDEX_NOT_KNOWN = -9999
integer :: index_air, index_O2, index_O3

allocate(gas_species_group(num_gas_species)) ! need to deallocate

! TODO(jiwon) - I commented out this block of code that searches for the molar mass
! of air and instead hard-coded it using the value imported from CAM-SIMA.
! Should we register air in the register phase like cloud liquid water content,
! or should we include it in the configuration file, or is it good as it is?

! Air
! Find the index of the species and create a 'gas_species_t' for it
! call ccpp_const_get_idx(constituent_props, "air", index_air, errmsg, errcode)
! write(*,*) "air index: ", index_air
! if (errcode /= 0) return

! call constituent_props(index_air)%molar_mass(molar_mass_air, errcode, errmsg)
! if (errcode /= 0) return

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mattldawson, I was trying to make the gas species configurable, allowing the user to provide their own species and define a function. Do you have any feedback on this implementation? Also, air is not included in the species.json, so it ends up being hard-coded. Could you share your thoughts on that in my comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants