-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
src/closures/buoyancy_gradients.jl
Outdated
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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.
6475a8b
to
1407cd5
Compare
LGTM, but let's make sure @trontrytel agrees with the approach. |
86c346c
to
2e304f0
Compare
BTW, could you update the PR name to reflect the new changes? |
2e304f0
to
ccd0aca
Compare
ccd0aca
to
e3ed8b6
Compare
Bors r+ |
Build succeeded: |
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