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

Add "Flexible Microphysics" option, based on Cloudy.jl #333

Merged
merged 17 commits into from
Mar 13, 2024

Conversation

edejong-caltech
Copy link
Member

@edejong-caltech edejong-caltech commented Feb 22, 2024

Purpose

Creates a flexible many-moment microphysics option based on the computational framework of Cloudy.jl.

To-do

  • Make Cloudy dependency an extension
  • Add physical default parameters (see Cloudy.jl issue )
  • Test condensation in parcel model
  • Refactor the sedimentation to return a moment_weighted terminal velocity

Next steps:

  • Test coalescence in box model (maybe)
  • Test condensation + coalescence + sedimentation in (KiD or CliMA Atmos single column)

Content

  • Link existing dynamics in a new module
  • Write unit tests for new Cloudy dynamics

Note: GPU and performance tests are not and will not be included in the initial integration.


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

@trontrytel trontrytel added enhancement New feature or request work-in-progress labels Feb 24, 2024
@edejong-caltech edejong-caltech marked this pull request as ready for review March 11, 2024 21:15
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

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

Project coverage is 96.16%. Comparing base (d38910d) to head (699496d).
Report is 2 commits behind head on main.

Files Patch % Lines
ext/CloudyExt.jl 0.00% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
- Coverage   98.11%   96.16%   -1.95%     
==========================================
  Files          35       36       +1     
  Lines        1165     1225      +60     
==========================================
+ Hits         1143     1178      +35     
- Misses         22       47      +25     

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

@@ -0,0 +1,39 @@
# Microphysics Flexible

Copy link
Member

Choose a reason for hiding this comment

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

You should also add the docs page you are creating to the docs make file. Maybe somewhere here:

"Non-equilibrium cloud formation" => "MicrophysicsNonEq.md",

Copy link
Member Author

Choose a reason for hiding this comment

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

👍


The `MicrophysicsFlexible.jl` module relies on the extension defined in `ext/CloudyExt.jl`, based on a flexible N-moment microphysics scheme built in the external package `Cloudy.jl`. This option currently handles warm-rain processes including coalescence, condensation/evaporation, and sedimentation (terminal velocity). Unlike typical moment-based schemes which distinguish between categories such as rain and cloud, and which determine rates of conversion between categories (the canonical autoconversion, accretion, and self-collection), this option gives the user the flexibility to define as many or as few moments as they please, with these coalescence-based processes being solved directly without relying on conversion rates. Likewise, the rate of condensation/evaporation is defined through the rate of diffusion of water vapor to/from the surface of droplets defined by the subdistributions which underpin the method. The user has not only the flexibility to specify the number of moments (and therefore the complexity/accuracy) to use, but also the assumed size distributions corresponding to these moments. For instance, one might define a 5-moment implementation using an Exponential mode for smaller cloud droplets, plus a Gamma mode for larger rain droplets. Or, more creatively, perhaps a 12-moment implementation comprised of four Gamma modes.

Options for dynamics and size distributions are under continuous development in the `Cloudy.jl` package, thus only the default and suggested use cases are described in detail here.
Copy link
Member

@trontrytel trontrytel Mar 11, 2024

Choose a reason for hiding this comment

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

Maybe it would be good to add a link to Cloudy documentation, paper or repo somewhere? Especially since w don't want to explain the details of how the collisions or condensation are handled

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

|---------------------|------------------------------------------|----------------------------|
| ``pdists`` | Vector of subdistributions corresponding | ``[Exponential, Gamma]`` |
| | to the moments | |
| ``mom`` | Prognostic moments, in the same order as | ``[0, 0, 0, 0, 0]`` |
Copy link
Member

Choose a reason for hiding this comment

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

Does it mean that by default I have two distributions - one Exponential and one Gamma? Which sizes do they refer to? And why by default do I have the 0 moment 5 times? (It probably just shows I should read Cloudy docs...

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually these have changed, and the Cloudy docs aren't helpful... I"ll try to make it more self explanatory

weighted_vt(clinfo)

- `clinfo` - kwarg structure containing pdists, moments, and coalescence parameters
Returns the integrated fall speeds corresponding to the rate of change of prognostic moments
Copy link
Member

Choose a reason for hiding this comment

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

Would it be correct to say moment-weighted terminal velocities?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes!

| ``KernelFunc`` | Form of the coalescence kernel function | ``LongKernelFunction`` |
| ``mass_thresholds`` | Particle size thresholds for coalescence | ``[10.0, Inf]`` |
| | integration | |
| ``kernel order`` | Polynomial order for the approx. kernel | ``1`` |
Copy link
Member

Choose a reason for hiding this comment

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

The CLSetup has more fields than what the table shows? Are they not meant to be changed by the user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, unless the user really knows what they're doing ;)

TT.@test length(clinfo.mom) == 5
TT.@test length(clinfo.NProgMoms) == 2

# Test coalescence
Copy link
Member

Choose a reason for hiding this comment

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

Should the mass be conserved in this approach when doing collisions? Could we test that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but these tests are already covered in Cloudy.jl so I think it would be redundant here

Copy link
Member Author

Choose a reason for hiding this comment

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

These tests are only to check that the new features/structs that are created in CM.jl work. But, if you think it would be useful to create some redundant tests, I can absolutely do so! Let's open an issue if so.

Copy link
Member

Choose a reason for hiding this comment

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

It's fine. Lets add as many tests as is necessary to test that Cloudy can be used in CM.

"""
ODE problem definitions
"""
function parcel_model_cloudy(dY, Y, p, t)
Copy link
Member

Choose a reason for hiding this comment

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

I'll think about how to unify the OG parcel model with the Cloudy parcel model. But it's ok to have two separate ones for now. My only concern is that we won't see anywhere if this example stops working. So you could add the plot to the docs somewhere (then the docs will break if things break). Or move it to tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's address in this in a future PR, where I will also add a box model test case and such "smoke tests". I'll open an issue.

@edejong-caltech edejong-caltech merged commit 3fcd6ef into main Mar 13, 2024
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved 🍀 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants