|
1 | 1 | # Examples
|
2 | 2 |
|
3 | 3 | ## 1D Column examples
|
| 4 | +### Ekman Layer |
| 5 | + |
| 6 | +The 1D vertical Ekman layer simulation in [`examples/column/ekman.jl`](https://github.com/CliMA/ClimaCore.jl/blob/main/examples/column/ekman.jl) demonstrates the simulation of atmospheric boundary layer dynamics, specifically the Ekman spiral phenomenon resulting from the balance between Coriolis force and vertical diffusion. |
| 7 | + |
| 8 | +#### Equations and discretizations |
| 9 | + |
| 10 | +#### Momentum |
| 11 | + |
| 12 | +Follows the momentum equations with vertical diffusion and Coriolis force: |
| 13 | +```math |
| 14 | +\begin{align} |
| 15 | +\frac{\partial u}{\partial t} &= \frac{\partial}{\partial z}\left(\nu \frac{\partial u}{\partial z}\right) + f(v - v_g) - w\frac{\partial u}{\partial z} \\ |
| 16 | +\frac{\partial v}{\partial t} &= \frac{\partial}{\partial z}\left(\nu \frac{\partial v}{\partial z}\right) - f(u - u_g) - w\frac{\partial v}{\partial z} |
| 17 | +\end{align} |
| 18 | +``` |
| 19 | + |
| 20 | +These are discretized using the following: |
| 21 | +```math |
| 22 | +\begin{align} |
| 23 | +\frac{\partial u}{\partial t} &\approx D_{f2c}\left(\nu G_{c2f}(u)\right) + f(v - v_g) - A(w, u) \\ |
| 24 | +\frac{\partial v}{\partial t} &\approx D_{f2c}\left(\nu G_{c2f}(v)\right) - f(u - u_g) - A(w, v) |
| 25 | +\end{align} |
| 26 | +``` |
| 27 | + |
| 28 | +#### Prognostic variables |
| 29 | + |
| 30 | +* `u`: _horizontal velocity (zonal or east-west component)_ measured in m/s. |
| 31 | +* `v`: _horizontal velocity (meridional or north-south component)_ measured in m/s. |
| 32 | +* `w`: _vertical velocity_ measured in m/s (manually set to zero in this example to disable vertical advection effects). |
| 33 | + |
| 34 | +#### Differentiation operators |
| 35 | + |
| 36 | +Because this is a 1D vertical problem, we utilize the staggered vertical grid with: |
| 37 | + |
| 38 | +- `G_{c2f}` is the [gradient operator from cell centers to faces](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.GradientC2F), called `gradc2f` in the example code. |
| 39 | +- `D_{f2c}` is the [divergence operator from faces to centers](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.DivergenceF2C), called `divf2c` in the example code. |
| 40 | +- `A` is the [advection operator](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.AdvectionC2C), called `A` in the example code. |
| 41 | + |
| 42 | +#### Problem flow and set-up |
| 43 | + |
| 44 | +This test case is set up in a vertical column domain $[0, L]$ with height $L = 200\,\mathrm{m}$. The Coriolis parameter is set to $f = 5 \times 10^{-5}\,\mathrm{s}^{-1}$, the viscosity coefficient to $\nu = 0.01\,\mathrm{m}^2/\mathrm{s}$, and the geostrophic wind to $(u_g, v_g) = (1.0, 0.0)\,\mathrm{m/s}$. |
| 45 | + |
| 46 | +The Ekman depth parameter is calculated as |
| 47 | +$d = \sqrt{\dfrac{2\nu}{f}}$, |
| 48 | +which determines the characteristic depth of the boundary layer. |
| 49 | + |
| 50 | +The initial condition is set to a uniform wind profile equal to the geostrophic wind throughout the vertical column. The simulation is run for 50 hours to allow the boundary layer to develop fully. |
| 51 | + |
| 52 | +Boundary conditions are applied as follows: |
| 53 | +- At the top boundary: wind velocity equals the geostrophic wind $(u_g, v_g)$ |
| 54 | +- At the bottom boundary: drag condition proportional to the wind speed, where the surface stress is |
| 55 | + $C_d \, |\mathbf{U}| \, u$ and $C_d \, |\mathbf{U}| \, v$ |
| 56 | + |
| 57 | +#### Application of boundary conditions |
| 58 | + |
| 59 | +The application of boundary conditions is implemented through the operators: |
| 60 | + |
| 61 | +1. For the u-momentum equation: |
| 62 | + - Top boundary: `Operators.SetValue(FT(ug))` sets u to the geostrophic value |
| 63 | + - Bottom boundary: `Operators.SetValue(Geometry.WVector(Cd * u_wind * u_1))` applies the drag condition |
| 64 | + |
| 65 | +2. For the v-momentum equation: |
| 66 | + - Top boundary: `Operators.SetValue(FT(vg))` sets v to the geostrophic value |
| 67 | + - Bottom boundary: `Operators.SetValue(Geometry.WVector(Cd * u_wind * v_1))` applies the drag condition |
| 68 | + |
| 69 | +3. DSS (Direct Stiffness Summation) is applied implicitly through the operators to ensure continuity of the solution at element boundaries and reduction of unnecessary multiplicity |
| 70 | + |
| 71 | +The example verifies the numerical solution by comparing it to the analytical solution: |
| 72 | +```math |
| 73 | +\begin{align} |
| 74 | +u(z) &= u_g - e^{-z/d}(u_g\cos(z/d) + v_g\sin(z/d)) \\ |
| 75 | +v(z) &= v_g + e^{-z/d}(u_g\sin(z/d) - v_g\cos(z/d)) |
| 76 | +\end{align} |
| 77 | +``` |
| 78 | + |
| 79 | +The results demonstrate accurate capture of the characteristic Ekman spiral, where wind speed increases with height and wind direction rotates with increasing height until it aligns with the geostrophic wind. |
| 80 | + |
| 81 | + |
| 82 | +### Hydrostatic Balance |
| 83 | + |
| 84 | +The 1D Column hydrostatic balance example in [`examples/column/hydrostatic.jl`](https://github.com/CliMA/ClimaCore.jl/blob/main/examples/column/hydrostatic.jl) demonstrates the setup and maintenance of hydrostatic balance in a single vertical column using a finite difference discretization. |
| 85 | + |
| 86 | +#### Equations and discretizations |
| 87 | + |
| 88 | +##### Mass and Potential Temperature |
| 89 | + |
| 90 | +The system maintains hydrostatic balance while solving the continuity equations for density and potential temperature density: |
| 91 | + |
| 92 | +```math |
| 93 | +\begin{equation} |
| 94 | + \frac{\partial \rho}{\partial t} = - \nabla \cdot(\rho \boldsymbol{w}) |
| 95 | +\label{eq:1d-column-continuity} |
| 96 | +\end{equation} |
| 97 | +``` |
| 98 | + |
| 99 | +```math |
| 100 | +\begin{equation} |
| 101 | + \frac{\partial \rho\theta}{\partial t} = - \nabla \cdot(\rho\theta \boldsymbol{w}) |
| 102 | +\label{eq:1d-column-theta} |
| 103 | +\end{equation} |
| 104 | +``` |
| 105 | + |
| 106 | +These are discretized using the following: |
| 107 | + |
| 108 | +```math |
| 109 | +\begin{equation} |
| 110 | + \frac{\partial \rho}{\partial t} \approx - D^c_v[I^f(\rho) \boldsymbol{w}] |
| 111 | +\label{eq:1d-column-discrete-continuity} |
| 112 | +\end{equation} |
| 113 | +``` |
| 114 | + |
| 115 | +```math |
| 116 | +\begin{equation} |
| 117 | + \frac{\partial \rho\theta}{\partial t} \approx - D^c_v[I^f(\rho\theta) \boldsymbol{w}] |
| 118 | +\label{eq:1d-column-discrete-theta} |
| 119 | +\end{equation} |
| 120 | +``` |
| 121 | + |
| 122 | +#### Vertical Momentum |
| 123 | + |
| 124 | +The vertical momentum follows: |
| 125 | + |
| 126 | +```math |
| 127 | +\begin{equation} |
| 128 | + \frac{\partial \boldsymbol{w}}{\partial t} = -I^f\left(\frac{\rho\theta}{\rho}\right) \nabla^f_v \Pi(\rho\theta) - \nabla^f_v \Phi(z) |
| 129 | +\label{eq:1d-column-momentum} |
| 130 | +\end{equation} |
| 131 | +``` |
| 132 | + |
| 133 | +Where: |
| 134 | +- $\Pi(\rho\theta) = C_p \left(\frac{R_d \rho\theta}{p_0}\right)^{\frac{R_m}{C_v}}$ is the Exner function |
| 135 | +- $\Phi(z) = gz$ is the geopotential |
| 136 | + |
| 137 | +This is discretized using the following: |
| 138 | + |
| 139 | +```math |
| 140 | +\begin{equation} |
| 141 | + \frac{\partial \boldsymbol{w}}{\partial t} \approx B\left(-I^f\left(\frac{\rho\theta}{\rho}\right) \nabla^f_v \Pi(\rho\theta) - \nabla^f_v \Phi(z)\right) |
| 142 | +\label{eq:1d-column-discrete-momentum} |
| 143 | +\end{equation} |
| 144 | +``` |
| 145 | + |
| 146 | +Where $B$ applies boundary conditions to enforce $\boldsymbol{w} = 0$ at the domain boundaries. |
| 147 | + |
| 148 | +### Prognostic variables |
| 149 | + |
| 150 | +* $\rho$: _density_ measured in kg/m³, discretized at cell centers. |
| 151 | +* $\rho\theta$: _potential temperature density_ measured in K·kg/m³, discretized at cell centers. |
| 152 | +* $\boldsymbol{w}$: _vertical velocity_ measured in m/s, discretized at cell faces. |
| 153 | + |
| 154 | +### Operators |
| 155 | + |
| 156 | +#### Reconstructions |
| 157 | + |
| 158 | +* $I^f$ is the [center-to-face reconstruction operator](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.InterpolateC2F), called `If` in the example code. |
| 159 | + - Currently this is implemented as the arithmetic mean. |
| 160 | + |
| 161 | +#### Differentiation operators |
| 162 | + |
| 163 | +* $D^c_v$ is the [face-to-center vertical divergence](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.DivergenceF2C), called `∂` in the example code. |
| 164 | + - This example uses zero vertical velocity at the top and bottom boundaries. |
| 165 | +* $\nabla^f_v$ is the [center-to-face vertical gradient](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.GradientC2F), called `∂f` in the example code. |
| 166 | +* $B$ is the [boundary operator](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.SetBoundaryOperator), called `B` in the example code. |
| 167 | + - This enforces zero vertical velocity at domain boundaries. |
| 168 | + |
| 169 | +### Problem flow and set-up |
| 170 | + |
| 171 | +This test case is set up in a vertical column domain from $z=0$ m to $z=30$ km with 30 vertical elements. The column is initialized with a decaying temperature profile, where: |
| 172 | + |
| 173 | +- The virtual temperature starts at $T_{virt\_surf} = 280$ K at the surface |
| 174 | +- It asymptotically approaches $T_{min\_ref} = 230$ K with height |
| 175 | +- The profile follows a hyperbolic tangent function with height |
| 176 | +- The pressure follows a hydrostatic balance equation |
| 177 | +- Density is calculated from the equation of state using virtual temperature and pressure |
| 178 | + |
| 179 | +The initial vertical velocity is set to zero everywhere. To maintain hydrostatic balance, the discrete form computes iteratively the values of density that ensure the vertical pressure gradient balances gravity. |
| 180 | + |
| 181 | +The simulation is run for 10 days to verify that the hydrostatic balance is maintained over time. Results are plotted showing density ($\rho$), vertical velocity ($\boldsymbol{w}$), and potential temperature density ($\rho\theta$) profiles. |
4 | 182 |
|
5 | 183 | ## 2D Cartesian examples
|
6 | 184 |
|
|
0 commit comments