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

Bug fix in buoyancy diagnostic function #1430

Merged
merged 9 commits into from
Mar 22, 2021

Conversation

zhixiaozhang
Copy link
Contributor

@zhixiaozhang zhixiaozhang commented Mar 11, 2021

Correct MU layer and PWAT, refine CAPE, CIN, LFC

TYPE: bug fix, enhancement

KEYWORDS: Most unstable layer, Precipitable water, CAPE, CIN, LFC

SOURCE: Zhixiao Zhang (University of Utah), Adam Varble (PNNL and University of Utah), and Katelyn Barber (PNNL)

DESCRIPTION OF CHANGES:
Problem:
The most unstable (MU) layer and precipitable water(PWAT) are inconsistent with the conventional definitions in
meteorological communities. LFC, CAPE and CIN calculations do not work well while dealing with multiple inversion
layers. The vertical buoyancy integration for calculating CAPE is unexpectedly stopped when the lifted parcel is colder than 253.15 K.

Solution:

  1. Correct the MU layer definition from the max water vapor mixing ratio (w) level to the max equivalent potential
    temperature (Theta-e) level. Because it is the theta-e rather than mixing ratio conserved during the dry/moist
    adiabatic lifting processes.
  2. Correct PWAT definition from column accumulated total mass of water vapor and cloud water to only water vapor.
    This is based on the AMS glossary https://glossary.ametsoc.org/wiki/Precipitable_water.
  3. Calculate MUCAPE, MUCIN and LFC by refined definitions: MUCAPE and MUCIN are defined as the vertically
    integrated positive and negative buoyant energy between LCL and EL with the air parcel lifted from MU layer. LFC
    is defined as the highest separation level when buoyancy turns from negative to positive.

LIST OF MODIFIED FILES:
phys/module_diag_functions.F

TESTS CONDUCTED:

  1. The modified code has been complied successfully and applied on regional climate simulations for CACTI field
    campaign.
  2. Jenkins testing is all PASS.

OTHER NOTES: The modification is based on WRF 4.1.1. The relevant AFWA module, diagnostic driver and registry require to be consistently modified in the latest source code by maintainers.

RELEASE NOTE: A few updates to the diagnostic schemes were added. The most unstable (MU) layer and precipitable water(PWAT) were inconsistent with the conventional definitions used by the meteorological communities. LFC, CAPE and CIN calculations previously did not work well while dealing with multiple inversion layers.

1. Correct the most unstable (MU) layer definition from the max water vapor mixing ratio (w) level to the max equivalent potential temperature (Theta-e) level. Because it is the theta-e rather than mixing ratio that is conserved during the dry/moist adiabatic lifting processes.
2. Correct precipitable water (Pwat) definition from column accumulated mass of water vapor and cloud water to only water vapor. This is based on the AMS glossary https://glossary.ametsoc.org/wiki/Precipitable_water.
3. Supplement equilibrium level (EL) calculation, which is the highest model level when buoyancy turns from positive to negative.
Save corrected MU layer height, LCL, EL as output variables.
4. Compute and save MUCAPE, MUCIN and LFC by refined definitions: MUCAPE and MUCIN are defined as the vertically integrated positive and negative buoyant energy between LCL and EL with the air parcel lifted from MU layer. LFC is defined as the highest separation level when buoyancy turns from negative to positive.
@zhixiaozhang zhixiaozhang requested a review from a team as a code owner March 11, 2021 05:37
@davegill davegill changed the base branch from master to develop March 11, 2021 05:47
@davegill
Copy link
Contributor

@zhixiaozhang
It looks like all of the ARW tests are failing to build. Maybe pull this branch locally and try a configure/compile.

Please find result of the WRF regression test cases in the attachment. This build is for Commit ID: 20fc1d0c4c454fb3132187f62dfd00f6d1a9129b, requested by: zhixiaozhang for PR: https://github.com/wrf-model/WRF/pull/1430. For any query please send e-mail to David Gill.

    Test Type              | Expected  | Received |  Failed
    = = = = = = = = = = = = = = = = = = = = = = = =  = = = =
    Number of Tests        : 19           18
    Number of Builds       : 48           46
    Number of Simulations  : 163           161         158
    Number of Comparisons  : 103           0         0

    Failed Simulations are: 
    output_1:2 = STATUS test_001s em em_real 32 3dtke
output_1:2 = STATUS test_001s em em_real 32 conus
output_1:2 = STATUS test_001s em em_real 32 rap
output_1:2 = STATUS test_001s em em_real 32 tropical
output_1:2 = STATUS test_001o em em_real 33 3dtke
output_1:2 = STATUS test_001o em em_real 33 conus
output_1:2 = STATUS test_001o em em_real 33 rap
output_1:2 = STATUS test_001o em em_real 33 tropical
output_1:2 = STATUS test_001m em em_real 34 3dtke
output_1:2 = STATUS test_001m em em_real 34 conus
output_1:2 = STATUS test_001m em em_real 34 rap
output_1:2 = STATUS test_001m em em_real 34 tropical
output_10:2 = STATUS test_010s hill em_hill2d_x 32 01
output_11:2 = STATUS test_011s em em_real 32 03
output_11:2 = STATUS test_011s em em_real 32 03DF
output_11:2 = STATUS test_011s em em_real 32 03FD
output_11:2 = STATUS test_011s em em_real 32 06
output_11:2 = STATUS test_011s em em_real 32 07NE
output_11:2 = STATUS test_011o em em_real 33 03
output_11:2 = STATUS test_011o em em_real 33 03DF
output_11:2 = STATUS test_011o em em_real 33 03FD
output_11:2 = STATUS test_011o em em_real 33 06
output_11:2 = STATUS test_011o em em_real 33 07NE
output_11:2 = STATUS test_011m em em_real 34 03
output_11:2 = STATUS test_011m em em_real 34 03DF
output_11:2 = STATUS test_011m em em_real 34 03FD
output_11:2 = STATUS test_011m em em_real 34 06
output_11:2 = STATUS test_011m em em_real 34 07NE
output_12:2 = STATUS test_012s em em_real 32 10
output_12:2 = STATUS test_012s em em_real 32 11
output_12:2 = STATUS test_012s em em_real 32 14
output_12:2 = STATUS test_012s em em_real 32 16
output_12:2 = STATUS test_012o em em_real 33 10
output_12:2 = STATUS test_012o em em_real 33 11
output_12:2 = STATUS test_012o em em_real 33 14
output_12:2 = STATUS test_012o em em_real 33 16
output_12:2 = STATUS test_012m em em_real 34 10
output_12:2 = STATUS test_012m em em_real 34 11
output_12:2 = STATUS test_012m em em_real 34 14
output_12:2 = STATUS test_012m em em_real 34 16
output_13:2 = STATUS test_013s em em_real 32 17
output_13:2 = STATUS test_013s em em_real 32 17AD
output_13:2 = STATUS test_013s em em_real 32 18
output_13:2 = STATUS test_013s em em_real 32 20
output_13:2 = STATUS test_013s em em_real 32 20NE
output_13:2 = STATUS test_013o em em_real 33 17
output_13:2 = STATUS test_013o em em_real 33 17AD
output_13:2 = STATUS test_013o em em_real 33 18
output_13:2 = STATUS test_013o em em_real 33 20
output_13:2 = STATUS test_013o em em_real 33 20NE
output_13:2 = STATUS test_013m em em_real 34 17
output_13:2 = STATUS test_013m em em_real 34 17AD
output_13:2 = STATUS test_013m em em_real 34 18
output_13:2 = STATUS test_013m em em_real 34 20
output_13:2 = STATUS test_013m em em_real 34 20NE
output_14:2 = STATUS test_014s em em_real 32 38
output_14:2 = STATUS test_014s em em_real 32 48
output_14:2 = STATUS test_014s em em_real 32 49
output_14:2 = STATUS test_014s em em_real 32 50
output_14:2 = STATUS test_014s em em_real 32 51
output_14:2 = STATUS test_014o em em_real 33 38
output_14:2 = STATUS test_014o em em_real 33 48
output_14:2 = STATUS test_014o em em_real 33 49
output_14:2 = STATUS test_014o em em_real 33 50
output_14:2 = STATUS test_014o em em_real 33 51
output_14:2 = STATUS test_014m em em_real 34 38
output_14:2 = STATUS test_014m em em_real 34 48
output_14:2 = STATUS test_014m em em_real 34 49
output_14:2 = STATUS test_014m em em_real 34 50
output_14:2 = STATUS test_014m em em_real 34 51
output_15:2 = STATUS test_015s em em_real 32 52
output_15:2 = STATUS test_015s em em_real 32 52DF
output_15:2 = STATUS test_015s em em_real 32 52FD
output_15:2 = STATUS test_015s em em_real 32 60
output_15:2 = STATUS test_015s em em_real 32 60NE
output_15:2 = STATUS test_015o em em_real 33 52
output_15:2 = STATUS test_015o em em_real 33 52DF
output_15:2 = STATUS test_015o em em_real 33 52FD
output_15:2 = STATUS test_015o em em_real 33 60
output_15:2 = STATUS test_015o em em_real 33 60NE
output_15:2 = STATUS test_015m em em_real 34 52
output_15:2 = STATUS test_015m em em_real 34 52DF
output_15:2 = STATUS test_015m em em_real 34 52FD
output_15:2 = STATUS test_015m em em_real 34 60
output_15:2 = STATUS test_015m em em_real 34 60NE
output_16:2 = STATUS test_016s em em_real 32 65DF
output_16:2 = STATUS test_016s em em_real 32 66FD
output_16:2 = STATUS test_016s em em_real 32 71
output_16:2 = STATUS test_016s em em_real 32 78
output_16:2 = STATUS test_016s em em_real 32 79
output_16:2 = STATUS test_016o em em_real 33 65DF
output_16:2 = STATUS test_016o em em_real 33 66FD
output_16:2 = STATUS test_016o em em_real 33 71
output_16:2 = STATUS test_016o em em_real 33 78
output_16:2 = STATUS test_016o em em_real 33 79
output_16:2 = STATUS test_016m em em_real 34 65DF
output_16:2 = STATUS test_016m em em_real 34 66FD
output_16:2 = STATUS test_016m em em_real 34 71
output_16:2 = STATUS test_016m em em_real 34 78
output_16:2 = STATUS test_016m em em_real 34 79
output_17:2 = STATUS test_017s em em_real 32 kiaps1NE
output_17:2 = STATUS test_017s em em_real 32 kiaps2
output_17:2 = STATUS test_017o em em_real 33 kiaps1NE
output_17:2 = STATUS test_017o em em_real 33 kiaps2
output_17:2 = STATUS test_017m em em_real 34 kiaps1NE
output_17:2 = STATUS test_017m em em_real 34 kiaps2
output_18:2 = STATUS test_018s em em_real 32 cmt
output_18:2 = STATUS test_018s em em_real 32 solaraNE
output_18:2 = STATUS test_018s em em_real 32 urb3bNE
output_18:2 = STATUS test_018m em em_real 34 cmt
output_18:2 = STATUS test_018m em em_real 34 solaraNE
output_18:2 = STATUS test_018m em em_real 34 urb3bNE
output_3:2 = STATUS test_003s chem em_real 32 1
output_3:2 = STATUS test_003s chem em_real 32 2
output_3:2 = STATUS test_003s chem em_real 32 5
output_3:2 = STATUS test_003m chem em_real 34 1
output_3:2 = STATUS test_003m chem em_real 34 2
output_3:2 = STATUS test_003m chem em_real 34 5
output_4:2 = STATUS test_004s qss em_quarter_ss 32 02NE
output_4:2 = STATUS test_004s qss em_quarter_ss 32 03
output_4:2 = STATUS test_004s qss em_quarter_ss 32 03NE
output_4:2 = STATUS test_004s qss em_quarter_ss 32 04
output_4:2 = STATUS test_004o qss em_quarter_ss 33 02NE
output_4:2 = STATUS test_004o qss em_quarter_ss 33 03
output_4:2 = STATUS test_004o qss em_quarter_ss 33 03NE
output_4:2 = STATUS test_004o qss em_quarter_ss 33 04
output_4:2 = STATUS test_004m qss em_quarter_ss 34 02NE
output_4:2 = STATUS test_004m qss em_quarter_ss 34 03
output_4:2 = STATUS test_004m qss em_quarter_ss 34 03NE
output_4:2 = STATUS test_004m qss em_quarter_ss 34 04
output_5:2 = STATUS test_005s bwave em_b_wave 32 1NE
output_5:2 = STATUS test_005s bwave em_b_wave 32 2
output_5:2 = STATUS test_005s bwave em_b_wave 32 2NE
output_5:2 = STATUS test_005s bwave em_b_wave 32 3
output_5:2 = STATUS test_005o bwave em_b_wave 33 1NE
output_5:2 = STATUS test_005o bwave em_b_wave 33 2
output_5:2 = STATUS test_005o bwave em_b_wave 33 2NE
output_5:2 = STATUS test_005o bwave em_b_wave 33 3
output_5:2 = STATUS test_005m bwave em_b_wave 34 1NE
output_5:2 = STATUS test_005m bwave em_b_wave 34 2
output_5:2 = STATUS test_005m bwave em_b_wave 34 2NE
output_5:2 = STATUS test_005m bwave em_b_wave 34 3
output_6:2 = STATUS test_006s real8 em_real 32 14
output_6:2 = STATUS test_006s real8 em_real 32 17AD
output_6:2 = STATUS test_006o real8 em_real 33 14
output_6:2 = STATUS test_006o real8 em_real 33 17AD
output_6:2 = STATUS test_006m real8 em_real 34 14
output_6:2 = STATUS test_006m real8 em_real 34 17AD
output_7:2 = STATUS test_007s qss8 em_quarter_ss 32 08
output_7:2 = STATUS test_007s qss8 em_quarter_ss 32 09
output_7:2 = STATUS test_007o qss8 em_quarter_ss 33 08
output_7:2 = STATUS test_007o qss8 em_quarter_ss 33 09
output_7:2 = STATUS test_007m qss8 em_quarter_ss 34 08
output_7:2 = STATUS test_007m qss8 em_quarter_ss 34 09
output_8:2 = STATUS test_008m move em_real 34 01
output_9:2 = STATUS test_009s fire em_fire 32 01
output_9:2 = STATUS test_009o fire em_fire 33 01
output_9:2 = STATUS test_009m fire em_fire 34 01
    Which comparisons are not bit-for-bit: 
    None

FUNCTION Buoyancy ( nz, tk, rh, p, hgt, sfc, cape, cin, zlfc, plfc, lidx, &
parcel ) result (ostat)
FUNCTION Buoyancy ( nz, tk, rh, p, hgt, sfc, cape, cin, zlcl, zlfc, zel, zmu, &
parcel ) result (ostat) !Add declaration of lcl, el, and MU layer. Modified by Zhixiao.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see the arguments changed but not the function call

Copy link
Contributor Author

@zhixiaozhang zhixiaozhang Mar 11, 2021

Choose a reason for hiding this comment

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

@davegill @dudhia Yeah, phys/module_diag_afwa.F and Registry/registry.afwa are recommended to be consistently modified based on this argument changes in buoyancy function. Despite this, we made other frame changes that are specialized for our simulation, but can not be generalized for public use. To less confuse the public, I try to avoid comprehensive frame modifications here and only uploaded the module_diag_functions.F.

Copy link

Choose a reason for hiding this comment

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

@davegill @dudhia @zhixiaozhang To clarify, I believe Zhixiao uploaded all of his code changes to module_diag_functions.F but these require changes to the driver and registry files because of new variables (height of most unstable layer (zmu), equilibrium level (zel), and LCL (zlcl). Those new variables are not a bug fix though and are an add on that may or may not be useful. I don't know if those go through a different process to implement added diagnostics. If the bug fixes alone are to be implemented (the most unstable (MU) layer definition and the calculation of precipitable water), then all of the other code related to new variables needs to be removed, and then the file should work. if that is what is wanted, I believe Zhixiao can do that without too much work. If instead, the added variables are also wanted, then Zhixiao can supply the other modified driver and registry files.

@dudhia
Copy link
Collaborator

dudhia commented Mar 11, 2021 via email

@dudhia
Copy link
Collaborator

dudhia commented Mar 12, 2021

Since the outputting of extra diagnostics is now removed, I would prefer that related code for these is also removed so that we can see the MU CAPE change by itself in this PR. We may want to have these additional diagnostics in the future, but that should be a separate PR at a later stage.

@zhixiaozhang
Copy link
Contributor Author

zhixiaozhang commented Mar 12, 2021

@davegill @dudhia @avarble Thanks for these comments. The code has been updated on all of your suggestions.

@dudhia
Copy link
Collaborator

dudhia commented Mar 17, 2021

Might be good to show an example of how this improves MUCAPE for a given sounding.

@weiwangncar
Copy link
Collaborator

@zhixiaozhang It may be good to add a comment about how much the variables change (and in which direction) because of the modification. Thanks.

@avarble
Copy link

avarble commented Mar 17, 2021

We never ran WRF with the original code since we saw that it was wrong so we only have output with the bug fix applied. MUCAPE either stays the same or increases (the MU parcel always is the highest possible CAPE in the column, but before, this wasn't selected properly). Because of this, MUCIN tends to go down. We have a colleague that had run the original diagnostics for a simulation over the Amazon and was then going to implement the bug fix because the CIN values were unreasonably high, likely from this error. Zhixiao will check to see if she has output from both that can be compared although how large the differences are depends upon meteorological regime.

In elevated deep convection regimes when the highest water vapor mixing ratios are still at low levels but the most unstable parcel is at a higher altitude, the differences can be large. An example of such a sounding is attached. The original diagnostic would choose a parcel starting at the surface where the highest water vapor mixing ratio exists. That parcel has no CAPE and obviously a lot of CIN. The most unstable parcel with the highest theta-e (you can find this using the highest dashed green moist adiabat value) is just above the 700-mb level which is a parcel with CAPE and very little CIN.
upperair DOE_M1_sonde 201811121200 skewT

@zhixiaozhang
Copy link
Contributor Author

zhixiaozhang commented Mar 17, 2021

@weiwangncar @dudhia Thanks for the comments. As the sounding example shown by Adam, the max water vapor mixing ratio in original code can not indicate the parcel lifting level with the maximum CAPE. Compared to original code, our modifications define the MU layer as the max theta-e level and refine the MUCAPE and MUCIN definition as the integrated energy between LCL and EL, which will increase MUCAPE, decrease MUCIN, and slightly elevate LFC in specific scenarios. We have contacted our colleague Katelyn to supplement more analysis. We will update her findings later.

@davegill davegill merged commit 3f0aae4 into wrf-model:develop Mar 22, 2021
@zhixiaozhang
Copy link
Contributor Author

zhixiaozhang commented May 14, 2021

Here are some supplemental tests to show the MUCAPE and MU layer changes after the modification:

As shown in the Nov 12 sounding, the previous AFWA module took the surface as the MU layer without obtaining any MUCAPE, but the modified module can capture the elevated unstable layer (2.9 km) and get a relatively reasonable MUCAPE (238.6 J kg^-1).
20181112-120000-Regridded-to-WRF-Levels

Despite this, in Nov 10 sounding, the previous AFWA underestimated MUCAPE because it stopped vertical buoyancy integration when the lifted parcel was colder than 253.15 K. After the modification, the integration stopped until the air parcel exceeding the equilibrium level. The module obtains the complete MUCAPE, increasing the value from 576.9 to 2345.0 J kg^-1.
20181110-150000-Regridded-to-WRF-Levels

@weiwangncar
Copy link
Collaborator

@zhixiaozhang Thanks for providing more test results.

vlakshmanan-scala pushed a commit to scala-computing/WRF that referenced this pull request Apr 4, 2024
Correct MU layer and PWAT, refine CAPE, CIN, LFC

TYPE: bug fix, enhancement

KEYWORDS: Most unstable layer, Precipitable water, CAPE, CIN, LFC

SOURCE: Zhixiao Zhang (University of Utah), Adam Varble (PNNL and University of Utah), and Katelyn Barber (PNNL)

DESCRIPTION OF CHANGES:
Problem:
The most unstable (MU) layer and precipitable water(PWAT) are inconsistent with the conventional definitions in 
meteorological communities. LFC, CAPE and CIN calculations do not work well while dealing with multiple inversion 
layers.

Solution:
1. Correct the MU layer definition from the max water vapor mixing ratio (w) level to the max equivalent potential 
temperature (Theta-e) level. Because it is the theta-e rather than mixing ratio conserved during the dry/moist 
adiabatic lifting processes.
2. Correct PWAT definition from column accumulated total mass of water vapor and cloud water to only water vapor. 
This is based on the AMS glossary https://glossary.ametsoc.org/wiki/Precipitable_water.
3. Calculate MUCAPE, MUCIN and LFC by refined definitions: MUCAPE and MUCIN are defined as the vertically 
integrated positive and negative buoyant energy between LCL and EL with the air parcel lifted from MU layer. LFC 
is defined as the highest separation level when buoyancy turns from negative to positive.

LIST OF MODIFIED FILES:
phys/module_diag_functions.F

TESTS CONDUCTED: 
1. The modified code has been complied successfully and applied on regional climate simulations for CACTI field 
campaign.

2. In elevated deep convection regimes when the highest water vapor mixing ratios are still at low levels but the 
most unstable parcel is at a higher altitude, the differences can be large. An example of such a sounding is 
attached. The original diagnostic would choose a parcel starting at the surface where the highest water vapor 
mixing ratio exists. That parcel has no CAPE and obviously a lot of CIN. The most unstable parcel with the 
highest theta-e (you can find this using the highest dashed green moist adiabat value) is just above the 700-mb 
level which is a parcel with CAPE and very little CIN.
![upperair DOE_M1_sonde 201811121200 skewT](https://user-images.githubusercontent.com/17436975/111506933-5ffeff80-8707-11eb-89ff-a24590d419c2.png)

3. Jenkins testing is all PASS.

OTHER NOTES: The modification is based on WRF 4.1.1. The relevant AFWA module, diagnostic driver and registry require to be consistently modified in the latest source code by maintainers.

RELEASE NOTE: A few updates to the diagnostic schemes were added. The most unstable (MU) layer and precipitable water(PWAT) were inconsistent with the conventional definitions used by the meteorological communities. LFC, CAPE and CIN calculations previously did not work well while dealing with multiple inversion layers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants