Skip to content

Commit 576ac23

Browse files
authored
Merge pull request #4037 from CliMA/aj/double_sided_limiters
Implementing double-sided limiters
2 parents 237e9a4 + a48929f commit 576ac23

File tree

9 files changed

+282
-176
lines changed

9 files changed

+282
-176
lines changed

docs/bibliography.bib

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# The citation keys have been formatted as:
22
# Last author name (titlecase), followed by
33
# (no characters in-between) the year.
4+
@article{Akbar2016,
5+
title = {Minimum-dissipation scalar transport model for large-eddy simulation of turbulent flows},
6+
author = {Abkar, Mahdi and Bae, Hyun J. and Moin, Parviz},
7+
journal = {Phys. Rev. Fluids},
8+
volume = {1},
9+
issue = {4},
10+
pages = {041701},
11+
year = {2016},
12+
doi = {10.1103/PhysRevFluids.1.041701}
13+
}
14+
415
@article{alexander1999,
516
title={A spectral parameterization of mean-flow forcing due to breaking gravity waves},
617
author={Alexander, Joan M and Dunkerton, Timothy J},
@@ -53,6 +64,18 @@ @article{Shen2022
5364
publisher={Wiley Online Library}
5465
}
5566

67+
@article{Sridhar2022,
68+
title = {Large-eddy simulations with ClimateMachine v0.2.0: a new open-source code for atmospheric simulations on GPUs and CPUs},
69+
author = {Sridhar, A. and Tissaoui, Y. and Marras, S. and Shen, Z. and Kawczynski, C. and Byrne, S.
70+
and Pamnany, K. and Waruszewski, M. and Gibson, T. H. and Kozdon, J. E. and Churavy, V. and Wilcox, L. C. and Giraldo, F. X. and Schneider, T.},
71+
journal = {Geosci. Model Dev.},
72+
volume = {15},
73+
year = {2022},
74+
number = {15},
75+
pages = {6259--6284},
76+
doi = {10.5194/gmd-15-6259-2022}
77+
}
78+
5679
@article{Lopez2020,
5780
title={A generalized mixing length closure for eddy-diffusivity mass-flux schemes of turbulence and convection},
5881
author={Lopez-Gomez, Ignacio and Cohen, Yair and He, Jia and Jaruga, Anna and Schneider, Tapio},

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ makedocs(;
2727
"Installation instructions" => "installation_instructions.md",
2828
"Contributor Guide" => "contributor_guide.md",
2929
"Equations" => "equations.md",
30+
"Microphysics" => "microphysics.md",
3031
"EDMF Equations" => "edmf_equations.md",
3132
"Diagnostics" => "diagnostics.md",
3233
"Available Diagnostics" => "available_diagnostics.md",

docs/src/equations.md

Lines changed: 4 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ term treated implicitly (check this)
122122

123123
Uses the advective form equation
124124
```math
125-
\frac{\partial}{\partial t} \boldsymbol{u} = - (2 \boldsymbol{\Omega} + \nabla \times \boldsymbol{u}) \times \boldsymbol{u} - c_{pd} (\theta_v - \theta_{v, r}) \nabla_h \Pi - \nabla_h [(\Phi - \Phi_r) + K].
125+
\frac{\partial}{\partial t} \boldsymbol{u} = - (2 \boldsymbol{\Omega} + \nabla \times \boldsymbol{u}) \times \boldsymbol{u} - c_{pd} (\theta_v - \theta_{v, r}) \nabla_h \Pi - \nabla_h [(\Phi - \Phi_r) + K].
126126
```
127127
Here, we use the Exner function to compute pressure gradients and are subtracting a hydrostatic reference state
128128
```math
129129
- \frac{1}{\rho} \nabla p = - c_{pd} \theta_v \Pi
130130
```
131-
where ``\theta_v`` is the virtual potential temperature. ``\theta_{v,r} = T_r / \Pi`` is a reference virtual potential temperature (with reference temperature ``T_r``), and
131+
where ``\theta_v`` is the virtual potential temperature. ``\theta_{v,r} = T_r / \Pi`` is a reference virtual potential temperature (with reference temperature ``T_r``), and
132132
```math
133133
\Phi_r = -c_{pd} \left[ T_\text{min} \log(\Pi) + \frac{(T_\text{sfc} - T_\text{min})}{n_s} (\Pi^{n_s} - 1) \right],
134134
```
@@ -137,14 +137,14 @@ We use the reference temperature profile ``T_r = T_\text{min} + (T_\text{sfc} -
137137

138138
#### Horizontal momentum
139139

140-
By breaking the curl and cross product terms into horizontal and vertical contributions, and removing zero terms (e.g. ``\nabla_v \times \boldsymbol{u}_v = 0``), we obtain
140+
By breaking the curl and cross product terms into horizontal and vertical contributions, and removing zero terms (e.g. ``\nabla_v \times \boldsymbol{u}_v = 0``), we obtain
141141
```math
142142
\frac{\partial}{\partial t} \boldsymbol{u}_h =
143143
- (2 \boldsymbol{\Omega}^h + \nabla_v \times \boldsymbol{u}_h + \nabla_h \times \boldsymbol{u}_v) \times \boldsymbol{u}^v
144144
- (2 \boldsymbol{\Omega}^v + \nabla_h \times \boldsymbol{u}_h) \times \boldsymbol{u}^h
145145
- c_{pd} (\theta_v - \theta_{v, r}) \nabla_h \Pi - \nabla_h [(\Phi - \Phi_r) + K],
146146
```
147-
where ``\boldsymbol{u}^h`` and ``\boldsymbol{u}^v`` are the horizontal and vertical _contravariant_ vectors.
147+
where ``\boldsymbol{u}^h`` and ``\boldsymbol{u}^v`` are the horizontal and vertical _contravariant_ vectors.
148148

149149
The effect of topography is accounted for through the computation of the contravariant velocity components (projections from the covariant velocity representation) prior to computing the cross-product contributions.
150150

@@ -284,155 +284,3 @@ is treated implicitly.
284284
- \mathcal{D}^c_v\left[WI^f(J, \rho) U^f\left(I^f(\boldsymbol{u}_h) + \boldsymbol{u}_v, \frac{\rho \chi}{\rho} \right) \right]
285285
```
286286
is treated implicitly.
287-
288-
## Microphysics source terms
289-
290-
Sources from cloud microphysics ``\mathcal{S}`` represent the transfer of mass
291-
between the working fluid (dry air, water vapor cloud liquid and cloud ice)
292-
and precipitation (rain and snow),
293-
as well as the latent heat release due to phase changes.
294-
295-
The scalars ``\rho q_{rai}`` and ``\rho q_{sno}`` are part of the state vector
296-
when running simulations with 1-moment microphysics scheme,
297-
and represent the specific humidity of liquid and solid precipitation
298-
(i.e. rain and snow).
299-
300-
```math
301-
q_{rai} := \frac{m_{rai}}{m_{dry} + m_{vap} + m_{liq} + m_{ice}}\; ,
302-
\;\;\;\;
303-
q_{sno} := \frac{m_{sno}}{m_{dry} + m_{vap} + m_{liq} + m_{ice}}
304-
```
305-
306-
The different source terms are provided by
307-
[CloudMicrophysics.jl](https://github.com/CliMA/CloudMicrophysics.jl) library
308-
and are defined as the change of mass of one of the cloud condensate or
309-
precipitation species normalised by the mass of the working fluid.
310-
See the [CloudMicrophysics.jl docs](https://clima.github.io/CloudMicrophysics.jl/dev/)
311-
for more details.
312-
313-
!!! todo
314-
Throughout the rest of the derivations we are assuming that the volume
315-
of the working fluid is constant (not the pressure).
316-
This is strange for phase changes and needs more thinking.
317-
318-
### Case 1: Mass of the working fluid is changed
319-
320-
When the phase change is happening within the working fluid
321-
(for example condensation from water vapor to liquid water),
322-
there is no change to any of the state variables.
323-
Considering the transition from
324-
``x \rightarrow y`` where ``x`` is either
325-
water vapor, cloud liquid water or cloud ice and
326-
``y`` is either rain or snow
327-
```math
328-
\mathcal{S}_{x \rightarrow y} := \frac{\frac{dm_x}{dt}}{m_{dry} + m_{vap} + m_{liq} + m_{ice}}
329-
```
330-
```math
331-
\frac{d}{dt} \rho =
332-
\frac{d}{dt} \rho q_{tot} =
333-
\rho \mathcal{S}_{x \rightarrow y} =
334-
- \frac{d}{dt} \rho q_y
335-
```
336-
```math
337-
\frac{d}{dt} \rho e = \rho \mathcal{S}_{x \rightarrow y} (I_{y} + \Phi)
338-
```
339-
where ``I_{y}`` is the internal energy of the ``y`` phase.
340-
This formula applies to the majority of microphysics processes.
341-
Namely, it is valid for processes where ``T=const`` such as
342-
autoconversion and accretion between species of the same phase.
343-
It is also valid for rain evaporation, deposition/sublimation, and
344-
accretion of cloud water and snow in temperatures below freezing
345-
(which result in snow).
346-
347-
### Case 2: Phase change outside of the working fluid
348-
349-
For cases where both ``x`` and ``y`` are not part of the working fluid
350-
(melting of snow, freezing of rain)
351-
```math
352-
\mathcal{S}_{x \rightarrow y} := \frac{\frac{dm_{x}}{dt}}{m_{dry} + m_{vap} + m_{liq} + m_{ice}}
353-
```
354-
```math
355-
\frac{d}{dt} \rho q_{x} =
356-
- \frac{d}{dt} \rho q_{y} =
357-
\rho \mathcal{S}_{x \rightarrow y}
358-
```
359-
```math
360-
\frac{d}{dt} \rho = \frac{d}{dt} \rho q_{tot} = 0
361-
```
362-
```math
363-
\frac{d}{dt} \rho e = - \rho \mathcal{S}_{x \rightarrow y} L_{f}
364-
```
365-
where ``L_f`` is the latent heat of fusion.
366-
The sign in the last equation assumes ``x`` stands for rain and ``y`` for snow.
367-
368-
### Additional cases
369-
370-
Accretion of cloud ice by rain results in snow.
371-
This process combines the effects from the loss of working fluid ``q_{ice}``
372-
(described by case 1)
373-
and the phase change from rain to snow
374-
(described by case 2).
375-
376-
Accretion of cloud liquid by snow in temperatures above freezing results in rain.
377-
It is assummed that some fraction ``\alpha`` of snow is melted during the process
378-
and both cloud liquid and melted snow are turned into rain.
379-
380-
```math
381-
\mathcal{S}_{acc} := \frac{\frac{dm_{liq}}{dt}}{m_{dry} + m_{vap} + m_{liq} + m_{ice}}
382-
```
383-
```math
384-
\frac{d}{dt} \rho = \frac{d}{dt} \rho q_{tot} = \rho S_{acc}
385-
```
386-
```math
387-
\frac{d}{dt} \rho q_{sno} = \rho \alpha S_{acc}
388-
```
389-
```math
390-
\frac{d}{dt} \rho q_{rai} = - \rho (1 + \alpha) S_{acc}
391-
```
392-
```math
393-
\frac{d}{dt} \rho e = \rho \mathcal{S}_{acc} ((1+\alpha) I_{liq} - \alpha I_{ice} + \Phi)
394-
```
395-
396-
### Precipitation temperature
397-
398-
Precipitation is assumed to have the same temperature as the surrounding air ``T_a``.
399-
The corresponding energy sink associated with heat transfer
400-
between air and precipitating species can be written as
401-
402-
```math
403-
\frac{d}{dt} \rho e = - \rho q_p (\boldsymbol{u} - v_p) c_p \nabla T_a
404-
```
405-
where ``q_p``, ``\boldsymbol{u}``, ``v_p``, ``c_p `` are the precipitation specific humidity,
406-
air velocity, precipitation terminal velocity assumed to be along the gravity axis,
407-
specific heat of precipitating species.
408-
409-
!!! todo
410-
We should consider replacing ``T_a`` with
411-
some approximation of wet bulb temperature.
412-
413-
### Stability and positivity
414-
415-
All source terms are individually limited such that they don't exceed the
416-
available tracer specific humidity divided by a coefficient ``a``.
417-
```math
418-
\mathcal{S}_{x \rightarrow y} = min(\mathcal{S}_{x \rightarrow y}, \frac{q_{x}}{a \; dt})
419-
```
420-
This will not ensure positivity because the sum of all source terms,
421-
combined with the advection tendency,
422-
could still drive the solution to negative numbers.
423-
It should however help mitigate some of the problems.
424-
The source terms functions treat negative specific humidities as zeros,
425-
so the simulations should be stable even with small negative numbers.
426-
427-
We do not apply hyperdiffusion for precipitation tracers.
428-
429-
### Aerosol Activation for 2-Moment Microphysics
430-
431-
Aerosol activation uses functions from the [CloudMicrophysics.jl](https://github.com/CliMA/CloudMicrophysics.jl) library, based on the Abdul-Razzak and Ghan (ARG) parameterization. ARG predicts the number of activated cloud droplets assuming a parcel of clear air rising adiabatically. This formulation is traditionally applied only at cloud base, where the maximum supersaturation typically occurs.
432-
433-
To enable ARG to be used locally (i.e., without explicitly identifying cloud base), CloudMicrophysics.jl implements a modified equation for the maximum supersaturation that accounts for the presence of pre-existing liquid and ice particles. This allows activation to be applied inside clouds. To ensure that activation occurs only where physically appropriate, we apply additional clipping logic:
434-
435-
- If the predicted maximum supersaturation is less than the local supersaturation (i.e., supersaturation is decreasing), aerosol activation is not applied.
436-
- If the predicted number of activated droplets is less than the existing local cloud droplet number concentration, activation is also suppressed.
437-
438-
This ensures that droplet activation occurs only in physically meaningful regions—typically near cloud base—even though the activation routine can be applied throughout the domain.

docs/src/limiter_plots.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import ClimaAtmos as CA
2+
import CairoMakie as MK
3+
4+
FT = Float32
5+
6+
# Two example forces
7+
force1(q) = q
8+
force2(q) = -q
9+
10+
# Max allowed source amount
11+
max_q1 = FT(5)
12+
max_q2 = FT(2)
13+
14+
# tracer range
15+
q_range = range(FT(-20), FT(20), 100)
16+
17+
#Plotting
18+
fig = MK.Figure()
19+
ax = MK.Axis(
20+
fig[1, 1];
21+
xlabel = "tracer specific humidity [-]",
22+
ylabel = "limited source term [1/s]",
23+
)
24+
25+
MK.lines!(
26+
q_range,
27+
CA.triangle_inequality_limiter.(force1.(q_range), max_q1, max_q2),
28+
label = "Positive force",
29+
)
30+
MK.lines!(
31+
q_range,
32+
CA.triangle_inequality_limiter.(force2.(q_range), max_q1, max_q2),
33+
label = "Negative force",
34+
)
35+
MK.hlines!([max_q1, -max_q2], label = "Allowed tracer sources")
36+
37+
MK.axislegend(ax; position = :lc)
38+
MK.save("assets/limiters_plot.png", fig) # hide

0 commit comments

Comments
 (0)