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

Adding Cloudy tendencies #159

Merged
merged 21 commits into from
May 23, 2024
Merged

Adding Cloudy tendencies #159

merged 21 commits into from
May 23, 2024

Conversation

edejong-caltech
Copy link
Member

Purpose

To-do

Content


  • I have read and checked the items on the review checklist.

Add to-do-list

updates

Update CloudyMoisture

Add cloudy params + activation

WIP on advection

Fixing advection with dolla-dolla-i

final touches

now it's unstable with activation

fix the activation issue

making the results work...

Setup the col-sed only case

final touches on col_sed + plots

working on making it stable

fix the activation source term

updates to plotting
arg_type = String
default = "NonEquilibriumMoisture"
"--prognostic_vars"
Copy link
Member

Choose a reason for hiding this comment

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

I'm very happy to commit to one prognostic variable choice. Do you have a preference for theta or T? We should delete the other from CI and tendency options too

Copy link
Member

Choose a reason for hiding this comment

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

I prefer T, because in PySDM KiD and also in Shipway and Hill T is fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed on T

Copy link
Member Author

@edejong-caltech edejong-caltech left a comment

Choose a reason for hiding this comment

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

Sajjad, this all looks fantastic -- thank you for merging my commits with the new KiD structure!

@edejong-caltech edejong-caltech changed the title WIP adding Cloudy tendencies Adding Cloudy tendencies May 20, 2024
@@ -85,4 +86,36 @@ function create_kid_parameters(toml_dict)
return kid_params
end
Base.broadcastable(x::KID.Parameters.KinematicDriverParameters) = Ref(x)

function create_cloudy_parameters(NM, FT)
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some docstring explaining what is happening here? Or link to Cloudy documentation if it's explained there? I'm asking about NM / 3, 1e6 and 1e-9 in norms, 5e0 in kernel_func, 5e-10 1e-6 in KernelTensors and CoalescenceData and vel, etc.

@. q_rai = q_(Y.moments.:($$rain_mass_ind), ρ)
@. moments = Y.moments

tmp = @. cloudy_precompute_aux_precip_helper(cloudy_params, moments, pdists)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not very good at this, but I think that the way the Cloudy tendencies are added, both here and in 1D model, is allocating. Maybe instead we could create additional variables that we need for Cloudy and put them in scratch for temporary things that need to be stored during computations (like supersaturation, maybe pdists?) and in aux for the ones that need to be precomputed for tendencies.

I was trying to write all the other tendencies like

@inline function precompute_aux_important_sources!
    source_term = aux.scratch.tmp
    (; stored_variable) = aux.microph_variables
 
    @. source_term = some_micro_foo(stored_variable)
    @. aux.important_sources = to_sources(-source_term, source_term)
end

@inline function important_sources_tendency!

    precompute_aux_important_sources!
    
    @. dY.ρq_tot += aux.thermo_variables.ρ * aux.important_sources.q_tot
end

It is more complicated for Cloudy than the other microphysics models. There are software office hours on Wednesday. If we can't figure it out by then, maybe we could submit it as a request to help then?

@sajjadazimi
Copy link
Member

Sajjad, this all looks fantastic -- thank you for merging my commits with the new KiD structure!

Thank you for adding Cloudy to KiD!

Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 11.95652% with 162 lines in your changes are missing coverage. Please review.

Project coverage is 72.34%. Comparing base (de22bbe) to head (5a9bccf).
Report is 26 commits behind head on main.

Current head 5a9bccf differs from pull request most recent head 49e1185

Please upload reports for the commit 49e1185 to get more accurate results.

Files Patch % Lines
src/Common/tendency.jl 6.32% 74 Missing ⚠️
src/K1DModel/tendency.jl 1.88% 52 Missing ⚠️
src/Common/initial_condition.jl 16.66% 15 Missing ⚠️
src/Common/ode_utils.jl 40.00% 12 Missing ⚠️
src/Common/parameters.jl 0.00% 5 Missing ⚠️
src/Common/equation_types.jl 33.33% 2 Missing ⚠️
src/Common/helper_functions.jl 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
- Coverage   81.13%   72.34%   -8.79%     
==========================================
  Files          28       28              
  Lines        1834     1884      +50     
==========================================
- Hits         1488     1363     -125     
- Misses        346      521     +175     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


aerosol_distribution =
CMAM.AerosolDistribution((CMAM.Mode_κ(r_dry, std_dry, N_aer, (FT(1),), (FT(1),), (FT(0),), (κ,)),))
N_act = CMAA.N_activated_per_mode(activation_params, aerosol_distribution, air_params, thermo_params, T, p, w, q)[1]
Copy link
Member

Choose a reason for hiding this comment

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

This is out of date with the aerosol activation PR that I merged, apologies!

Copy link
Member

Choose a reason for hiding this comment

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

Can we use this one: CMAA.total_N_activated ? Or does it have to be only one aerosol mode for Cloudy right now?

@trontrytel trontrytel self-requested a review May 22, 2024 18:24
Copy link
Member

@trontrytel trontrytel left a comment

Choose a reason for hiding this comment

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

Thank you for adding more meaningful tests and Cloudy!

I think the aerosol activation needs to be updated with what I merged. IS everything else good to be merged?

@sajjadazimi sajjadazimi merged commit 9cdd0e6 into main May 23, 2024
7 checks passed
@sajjadazimi sajjadazimi deleted the ej/add_cloudy branch May 23, 2024 18:30
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.

None yet

3 participants