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

use ts_dry in EDMF_env conditioned on cf<1 #392

Merged
merged 1 commit into from
Oct 14, 2021
Merged

use ts_dry in EDMF_env conditioned on cf<1 #392

merged 1 commit into from
Oct 14, 2021

Conversation

yairchn
Copy link
Member

@yairchn yairchn commented Oct 13, 2021

the correct use of TD in EDMF environment in the dry case requires the buoyancy gradient computation not to compute the gradients in the dry part if the cloud fraction is 1

@@ -10,8 +10,13 @@ function buoyancy_gradients(param_set, bg_model::Tan2018)
Π = TD.exner_given_pressure(param_set, bg_model.p0, phase_part)

∂b∂θv = g * (R_d / bg_model.alpha0 / bg_model.p0) * Π
∂b∂θl_dry = ∂b∂θv * (1 + (molmass_ratio - 1) * bg_model.qt_dry)
∂b∂qt_dry = ∂b∂θv * bg_model.th_dry * (molmass_ratio - 1)
if bg_model.en_cld_frac < 1.0
Copy link
Member

Choose a reason for hiding this comment

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

Why did this have to change as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

if 'bg_model.en_cld_frac = 1.0' there is no 'dry', so T_dry = qt_dry = 0

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary? The terms are already multiplied by bg_model.qt_dry and bg_model.th_dry.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok what is happening is that when cl_frc=1 T_dry is zero, and this leads to th_dry = Nan. The reason for that I think is the Thermodynamics.jl computes TD.dry_pottemp(ts_dry) going through density ~ p/T. The only places these values take place is in the buoyancy gradients so that my if else was avoiding this issue - but not in the right place in the code. I think it is better to place a conditional if else in EDMF environment instead. I will update the PR

Copy link
Member Author

Choose a reason for hiding this comment

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

@charleskawczynski could this be a bug in Thermodynamics.jl, that a zero T with non zero pressure returns Nan for potential temperature?

Copy link
Member

Choose a reason for hiding this comment

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

when cl_frc=1 T_dry is zero,

How does this make sense? I expect that many thermo relations do not hold for T = 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @charleskawczynski that this should not be changed in Thermodynamics.jl. Maybe having the if/else with a comment is the right thing to do after all.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. Let's just have a comment here. We shouldn't expect Thermodynamics to work with T=0

Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

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

I haven't looked close at the equations, but the code changes seem fine to me.

@yairchn yairchn force-pushed the yc/fix_dry_SA branch 2 times, most recently from 6475a8b to 1407cd5 Compare October 14, 2021 00:28
@ilopezgp
Copy link
Contributor

LGTM, but let's make sure @trontrytel agrees with the approach.

@yairchn yairchn force-pushed the yc/fix_dry_SA branch 2 times, most recently from 86c346c to 2e304f0 Compare October 14, 2021 16:58
@ilopezgp
Copy link
Contributor

BTW, could you update the PR name to reflect the new changes?

@yairchn yairchn changed the title use ts_dry in EDMF_env, condition dry buoy_grad on cf<1 use ts_dry in EDMF_env conditioned on cf<1 Oct 14, 2021
@trontrytel trontrytel self-requested a review October 14, 2021 17:47
@yairchn
Copy link
Member Author

yairchn commented Oct 14, 2021

Bors r+

@bors
Copy link
Contributor

bors bot commented Oct 14, 2021

Build succeeded:

@bors bors bot merged commit 90a5f13 into main Oct 14, 2021
@bors bors bot deleted the yc/fix_dry_SA branch October 14, 2021 18:10
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.

4 participants