Skip to content

Conversation

syha
Copy link
Contributor

@syha syha commented Nov 17, 2022

Description:

The HofX (e.g., observation operators) described in model_mod.f90 computes the pressure field based on the equation of state to find the vertical locations of observations at pressure levels (ex. radiosondes). Because the "rho" used in model_mod indicates dry air density (e.g., rho_d), not air density (= rho_d + rho_v), we need to add the second order term for water vapor mixing ratio (qv) to compute the full pressure accounting for the moisture effect correctly.
Also, a few parameters are updated based on MPAS/src/framework/mpas_constants.F.

Fixes issue

 pressure = rho * rgas * tk * (1.0_r8 + 1.61_r8 * qv_nonzero)

=> pressure = rho * rgas * tk * (1.0_r8 + rvord * qv_nonzero + rvordm1 * qv_nonzero**2)

fixes #251

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Documentation changes needed?

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.

Tests

Not tested with data yet, but compiled successfully (on cheyenne).

Checklist for merging

  • Updated changelog entry
  • Documentation updated
  • Update conf.py

Checklist for release

  • Merge into main
  • Create release from the main branch with appropriate tag
  • Delete feature-branch

@hkershaw-brown
Copy link
Member

Thanks for this Soyoung.

For the change in constants cv and cp does this apply to mpas versions 5.0 onwards?

@syha
Copy link
Contributor Author

syha commented Nov 17, 2022

Thanks for this Soyoung.

For the change in constants cv and cp does this apply to mpas versions 5.0 onwards?

It looks like MPAS Versions 5 through 7 have these new parameters.

@hkershaw-brown
Copy link
Member

great thanks!

@hkershaw-brown
Copy link
Member

waiting for science review on this.

! redefined here for consistency with the model (MPAS/src/framework/mpas_constants.F).
real(r8), parameter :: rgas = 287.0_r8 ! = R_d (Gas constant for dry air [J kg-1 K-1])
real(r8), parameter :: rv = 461.6_r8 ! = R_v (Gas constant for water varpor [J kg-1 K-1])
real(r8), parameter :: cp = 7.*rgas/2. ! = 1004.5
Copy link
Contributor

Choose a reason for hiding this comment

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

Another comment might be helpful here: "For an ideal diatomic gas, cp:cv:R is 7:5:2"


where (istatus == 0) ! We only take non-missing tk here
pressure = rho * rgas * tk * (1.0_r8 + 1.61_r8 * qv_nonzero)
! Soyoung (Nov-2022): The last term is added for full pressure P = (rho_d*R_d + rho_v*R_v)*tk
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see yet where the qv**2 term comes from.
From the ideal gas law, as written in the comment here,
P = rho_d*R_d*tk * [1 + (rho_v/rho_d)(R_v/R_d)]
Translating into the variables and parameters defined in this module:
P = rho *rgas*tk * [1 + qv_nonzero * rvord]
which is the unmodified code. It would be helpful to confirm that
MPAS uses mixing ratio (mass_v/mass_d),
not specific humidity (mass_v/mass_(v+d))?

Copy link
Contributor

@kdraeder kdraeder left a comment

Choose a reason for hiding this comment

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

I have one suggestion and one major sticking point.

@nancycollins
Copy link
Collaborator

just a note to say that i talked with soyoung about this today. she's sure the equation is correct; mpas uses mixing ratio and it is just the comment about the equation that needs to be clarified. at some point soon she is going to merge in the current main branch and update the code for this pull request.

@kdraeder
Copy link
Contributor

@nancycollins and @syha
which equation are you saying is correct?

  1. The ideal gas law that's in the new comment (which looks correct to me), or
  2. the equation that's in the updated code:
    pressure = rho * rgas * tk * (1.0_r8 + rvord * qv_nonzero + rvordm1 * qv_nonzero**2)?
    I can't derive 2) from 1). 1) has moisture in it, and when it's rewritten with the available fortran variables,
    it looks like the old code.
    Does qv_nonzero have a new definition which I'm not seeing, or was it used incorrectly before?
    There seems to be only one file changed, and qv_nonzero was not one of the changes.

@syha
Copy link
Contributor Author

syha commented Jul 27, 2023

@kdraeder, thanks for your examination with patience!
You are right. We should go with the original equation (1) for the full pressure.
Let me do a new PR for the constant updates only.

@syha syha closed this Jul 27, 2023
@hkershaw-brown hkershaw-brown added the mpas Model for Prediction Across Scales (MPAS) label Jul 28, 2023
@hkershaw-brown hkershaw-brown mentioned this pull request Jul 28, 2023
15 tasks
@nancycollins
Copy link
Collaborator

in the interest of putting this issue to bed - soyoung says that she was looking at how jedi handles computing pressure for mpas. they do a transform which requires a different equation (which includes the squared term). she says the original equation and comment are correct for the dart model_mod, and that is why this pull request is closed. the original code and comment should remain unchanged. the constants need to be updated and that's happening in a separate pull request (#521).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mpas Model for Prediction Across Scales (MPAS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Constants in the model_mod for MPAS

4 participants