Skip to content

Commit abd6700

Browse files
Snowdog85123valeriabarra
authored andcommitted
Add Documentation for Hydrostatic Balance and Ekman Layer 1D Column Examples
Hello, following up on the idea I previously shared in the issue, I've added documentation [docs/src/examples.md](https://github.com/CliMA/ClimaCore.jl/blob/main/docs/src/examples.md) for the two 1D column examples: the hydrostatic balance and the Ekman layer. Please let me know if this contribution aligns with your goals for the documentation or if any revisions are needed. I'd be happy to make changes!
1 parent a7bb4ec commit abd6700

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed

docs/src/examples.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,189 @@ This test case is set up in a 1D column domain ``z \in [0, 4\pi]``, discretized
9999
* For tendencies 1 and 2 where the upwind biased operator ``UB`` is used, the left boundary is defined as ``sin(a - t)``. The right boundary is ``sin(b - t)``. Here ``a`` and ``b`` are the left and right bounds of the domain.
100100
* For tendencies 3 and 4, where the advection operator ``A`` is used, the left boundary is defined as ``sin(-t)``. The right boundary is extrapolated, meaning its value is set to the closest interior point.
101101

102+
### Ekman Layer
103+
104+
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.
105+
106+
#### Equations and discretizations
107+
108+
#### Momentum
109+
110+
Follows the momentum equations with vertical diffusion and Coriolis force:
111+
```math
112+
\begin{align}
113+
\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} \\
114+
\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}
115+
\end{align}
116+
```
117+
118+
These are discretized using the following:
119+
```math
120+
\begin{align}
121+
\frac{\partial u}{\partial t} &\approx D \left(\nu G(u)\right) + f(v - v_g) - A(w, u) \\
122+
\frac{\partial v}{\partial t} &\approx D \left(\nu G(v)\right) - f(u - u_g) - A(w, v)
123+
\end{align}
124+
```
125+
126+
#### Prognostic variables
127+
128+
* `u`: _horizontal velocity (zonal or east-west component)_ measured in m/s.
129+
* `v`: _horizontal velocity (meridional or north-south component)_ measured in m/s.
130+
* `w`: _vertical velocity_ measured in m/s (manually set to zero in this example to disable vertical advection effects).
131+
132+
#### Differentiation operators
133+
134+
Because this is a 1D vertical problem, we utilize the staggered vertical grid with:
135+
136+
- ``D`` is the [face-to-center divergence](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.DivergenceF2C) operator, called `divf2c` in the example code
137+
- ``G`` is the [center-to-face gradient](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.GradientC2F) operator, called `gradc2f` in the example code
138+
- ``A`` is the [center-to-center vertical advection](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.AdvectionC2C) operator, called `A` in the example code.
139+
140+
#### Problem flow and set-up
141+
142+
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}$.
143+
144+
The Ekman depth parameter is calculated as
145+
$d = \sqrt{\dfrac{2\nu}{f}}$,
146+
which determines the characteristic depth of the boundary layer.
147+
148+
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.
149+
150+
Boundary conditions are applied as follows:
151+
- At the top boundary: wind velocity equals the geostrophic wind $(u_g, v_g)$
152+
- At the bottom boundary: drag condition proportional to the wind speed, where the surface stress is
153+
$C_d \, |\mathbf{U}| \, u$ and $C_d \, |\mathbf{U}| \, v$
154+
155+
#### Application of boundary conditions
156+
157+
The application of boundary conditions is implemented through the operators:
158+
159+
1. For the u-momentum equation:
160+
- Top boundary: `Operators.SetValue(FT(ug))` sets $u$ to the geostrophic value
161+
- Bottom boundary: `Operators.SetValue(Geometry.WVector(Cd * u_wind * u_1))` applies the drag condition
162+
163+
2. For the v-momentum equation:
164+
- Top boundary: `Operators.SetValue(FT(vg))` sets $v$ to the geostrophic value
165+
- Bottom boundary: `Operators.SetValue(Geometry.WVector(Cd * u_wind * v_1))` applies the drag condition
166+
167+
The example verifies the numerical solution by comparing it to the analytical solution:
168+
```math
169+
\begin{align}
170+
u(z) &= u_g - e^{-z/d}(u_g\cos(z/d) + v_g\sin(z/d)) \\
171+
v(z) &= v_g + e^{-z/d}(u_g\sin(z/d) - v_g\cos(z/d))
172+
\end{align}
173+
```
174+
175+
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.
176+
177+
178+
### Hydrostatic Balance
179+
180+
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.
181+
182+
#### Equations and discretizations
183+
184+
##### Mass and Potential Temperature
185+
186+
The system maintains hydrostatic balance while solving the continuity equations for density and potential temperature density:
187+
188+
```math
189+
\begin{equation}
190+
\frac{\partial \rho}{\partial t} = - \nabla \cdot(\rho \boldsymbol{w})
191+
\label{eq:1d-column-continuity}
192+
\end{equation}
193+
```
194+
195+
```math
196+
\begin{equation}
197+
\frac{\partial \rho\theta}{\partial t} = - \nabla \cdot(\rho\theta \boldsymbol{w})
198+
\label{eq:1d-column-theta}
199+
\end{equation}
200+
```
201+
202+
These are discretized using the following:
203+
204+
```math
205+
\begin{equation}
206+
\frac{\partial \rho}{\partial t} \approx - D^c_v[I^f(\rho) \boldsymbol{w}]
207+
\label{eq:1d-column-discrete-continuity}
208+
\end{equation}
209+
```
210+
211+
```math
212+
\begin{equation}
213+
\frac{\partial \rho\theta}{\partial t} \approx - D^c_v[I^f(\rho\theta) \boldsymbol{w}]
214+
\label{eq:1d-column-discrete-theta}
215+
\end{equation}
216+
```
217+
218+
#### Vertical Momentum
219+
220+
The vertical momentum follows:
221+
222+
```math
223+
\begin{equation}
224+
\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)
225+
\label{eq:1d-column-momentum}
226+
\end{equation}
227+
```
228+
229+
Where:
230+
- $\Pi(\rho\theta) = C_p \left(\frac{R_d \rho\theta}{p_0}\right)^{\frac{R_m}{C_v}}$ is the Exner function
231+
- $\Phi(z) = gz$ is the geopotential
232+
233+
This is discretized using the following:
234+
235+
```math
236+
\begin{equation}
237+
\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)
238+
\label{eq:1d-column-discrete-momentum}
239+
\end{equation}
240+
```
241+
242+
Where $B$ applies boundary conditions to enforce $\boldsymbol{w} = 0$ at the domain boundaries.
243+
244+
#### Prognostic variables
245+
246+
**$\rho$**: *Density*, measured in kg/m³, discretized at cell centers.
247+
248+
**$\rho\theta$**: *Potential temperature density*, measured in K·kg/m³, discretized at cell centers.
249+
250+
**$\boldsymbol{w}$**: *Vertical velocity*, measured in m/s, discretized at cell faces.
251+
252+
#### Operators
253+
254+
##### Reconstructions
255+
256+
**$I^f$** is the [center-to-face reconstruction](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.InterpolateC2F) operator, called `If` in the example code.
257+
Currently this is implemented as the arithmetic mean.
258+
259+
##### Differentiation operators
260+
261+
**$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.
262+
This example uses zero vertical velocity at the top and bottom boundaries.
263+
264+
**$\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.
265+
266+
**$B$** is the [boundary operator](https://clima.github.io/ClimaCore.jl/stable/operators/#ClimaCore.Operators.SetBoundaryOperator), called `B` in the example code.
267+
This enforces zero vertical velocity at domain boundaries.
268+
269+
270+
#### Problem flow and set-up
271+
272+
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:
273+
274+
- The virtual temperature starts at $T_{\textrm{virt}\_\textrm{surf}} = 280$ K at the surface
275+
- It asymptotically approaches $T_{\textrm{min}\_\textrm{ref}} = 230$ K with height
276+
- The profile follows a hyperbolic tangent function with height
277+
- The pressure follows a hydrostatic balance equation
278+
- Density is calculated from the equation of state using virtual temperature and pressure
279+
280+
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.
281+
282+
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.
283+
284+
102285
## 2D Cartesian examples
103286

104287
### Flux Limiters advection

0 commit comments

Comments
 (0)