Skip to content

Commit

Permalink
Merge pull request #420 from CliMA/sa/bugfix_sb2006_evaporation_nan
Browse files Browse the repository at this point in the history
Bugfix SB2006 evaporation; return 0 instead of NaN for xr = 0
  • Loading branch information
trontrytel committed Jul 5, 2024
2 parents bfd7d26 + c901b71 commit f30e789
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ main
------
<!--- # Add changes since the most recent release here --->

- Bugfix; fixed the evaporation scheme of SB2006 to prevent returning NaN values when limiters are not applied. ([#420](https://github.com/CliMA/CloudMicrophysics.jl/pull/415))

v0.20.0
------
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CloudMicrophysics"
uuid = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
authors = ["Climate Modeling Alliance"]
version = "0.22.0"
version = "0.22.1"

[deps]
ClimaParams = "5c42b081-d73a-476f-9059-fd94b934656c"
Expand Down
5 changes: 4 additions & 1 deletion src/Microphysics2M.jl
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,10 @@ function rain_evaporation(
evap_rate_0 = min(FT(0), FT(2) * FT(π) * G * S * N_rai * Dr * Fv0 / xr)
evap_rate_1 = min(FT(0), FT(2) * FT(π) * G * S * N_rai * Dr * Fv1 / ρ)

evap_rate_0 = N_rai < eps(FT) ? FT(0) : evap_rate_0
# When xr = 0 evap_rate_0 becomes NaN. We replace NaN with 0 which is the limit of
# evap_rate_0 for xr -> 0.
evap_rate_0 =
N_rai < eps(FT) || xr / x_star < eps(FT) ? FT(0) : evap_rate_0
evap_rate_1 = q_rai < eps(FT) ? FT(0) : evap_rate_1
end

Expand Down
13 changes: 13 additions & 0 deletions test/microphysics2M_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,19 @@ function test_microphysics2M(FT)
T,
).evap_rate_1 0 atol = eps(FT)
end

# test limit case: xr = 0 for SB with no limiters
TT.@test CM2.rain_evaporation(
SB2006_no_limiters,
aps,
tps,
q,
FT(0),
ρ,
N_rai,
T,
).evap_rate_0 0 atol = eps(FT)

end

TT.@testset "2M_microphysics - Seifert and Beheng 2006 effective radius and reflectivity" begin
Expand Down

2 comments on commit f30e789

@trontrytel
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/110520

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.22.1 -m "<description of version>" f30e78936b47dc375ceabbfe95202bcc1526b6dc
git push origin v0.22.1

Please sign in to comment.