-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parametrization of Large-Scale Condensation (#82)
* Add humidity functions * Remove prematurely elaborate docstrings * Switch iteration order * Add inbounds block * Fix typo * Move params into struct * Add large-scale condensation parametrization * Make coefficient structs parametric * Remove @inbounds * Remove unreachable branch * Revert renaming of file * Fix include * Fix params unpacking * Add ParametrizationVariables struct * Add tests * Tidy up * Remove Distributions dependency * Don't export humidity coefficients * Rename variables * Add comments * Rename variables and add docstrings * Add comment * Parametrise k for large-scale condensation * Allocate lsc tendencies explicitly * Update docstring * Remove test-specific dependencies * Define and convert ratio outside loop * Fix NF in tests * Update docstring
- Loading branch information
1 parent
f360aed
commit 54ff1b0
Showing
12 changed files
with
289 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" | ||
Compute the saturation vapour pressure as a function of temperature using the | ||
August-Roche-Magnus formula, | ||
eᵢ(T) = e₀ * exp(Cᵢ * (T - T₀) / (T - Tᵢ)), | ||
where T is in Kelvin and i = 1,2 for saturation with respect to water and ice, | ||
respectively. | ||
""" | ||
function get_saturation_vapour_pressure!( | ||
sat_vap_pressure ::Array{NF,3}, | ||
temp_grid ::Array{NF,3}, | ||
model ::ModelSetup, | ||
) where {NF<:AbstractFloat} | ||
@unpack nlon, nlat, nlev = model.geospectral.geometry | ||
@unpack e₀, T₀, C₁, C₂, T₁, T₂ = model.parameters.magnus_coefs | ||
|
||
for k = 1:nlev, j = 1:nlat, i = 1:nlon | ||
if temp_grid[i, j, k] > T₀ | ||
# Saturation vapour pressure over water | ||
sat_vap_pressure[i, j, k] = e₀ * exp(C₁ * (temp_grid[i, j, k] - T₀) / (temp_grid[i, j, k] - T₁)) | ||
else | ||
# Saturation vapour pressure over ice | ||
sat_vap_pressure[i, j, k] = e₀ * exp(C₂ * (temp_grid[i, j, k] - T₀) / (temp_grid[i, j, k] - T₂)) | ||
end | ||
end | ||
|
||
return nothing | ||
end | ||
|
||
""" | ||
Compute the saturation specific humidity according to the formula, | ||
0.622 * e / (p - (1 - 0.622) * e), | ||
where e is the saturation vapour pressure, p is the pressure, and 0.622 is the ratio of | ||
the molecular weight of water to dry air. | ||
""" | ||
function get_saturation_specific_humidity!( | ||
sat_spec_humidity ::Array{NF,3}, | ||
sat_vap_pressure ::Array{NF,3}, | ||
temp_grid ::Array{NF,3}, | ||
pres ::Array{NF,2}, | ||
model ::ModelSetup, | ||
) where {NF<:AbstractFloat} | ||
@unpack nlon, nlat, nlev, σ_levels_full = model.geospectral.geometry | ||
|
||
mol_ratio = convert(NF, 0.622) | ||
one_minus_mol_ratio = convert(NF, 1 - mol_ratio) | ||
|
||
get_saturation_vapour_pressure!(sat_vap_pressure, temp_grid, model) | ||
|
||
for k = 1:nlev, j = 1:nlat, i = 1:nlon | ||
sat_spec_humidity[i, j, k] = mol_ratio * sat_vap_pressure[i, j, k] / | ||
(pres[i, j] * σ_levels_full[k] - one_minus_mol_ratio * sat_vap_pressure[i, j, k]) | ||
end | ||
|
||
return nothing | ||
end |
Oops, something went wrong.