|
1 | 1 | # Examples |
2 | 2 |
|
3 | | -### Advection |
| 3 | +## 1D Column examples |
4 | 4 |
|
5 | | -The 1D Column advection example in [`examples/column/advect.jl`](https://github.com/CliMA/ClimaCore.jl/blob/main/examples/column/advect.jl). |
| 5 | +### Heat equation |
6 | 6 |
|
7 | | -#### Equations and Discretizations |
| 7 | +The 1D Column heat example in [`examples/column/heat.jl`](https://github.com/CliMA/ClimaCore.jl/blob/main/examples/column/heat.jl). |
8 | 8 |
|
9 | | -Follows the advection equation |
| 9 | +#### Equations and discretizations |
| 10 | + |
| 11 | +Follows the heat equation |
10 | 12 |
|
11 | 13 | ```math |
12 | 14 | \begin{equation} |
13 | | - \frac{\partial \theta}{\partial t} = -\frac{\partial (v \theta)}{\partial z} |
14 | | -\label{eq:1d-column-advection-continuity} |
| 15 | + \frac{\partial T}{\partial t} = \alpha \cdot \nabla^2 T. |
| 16 | +\label{eq:1d-column-heat-continuity} |
15 | 17 | \end{equation} |
16 | 18 | ``` |
| 19 | + |
17 | 20 | This is discretized using the following |
18 | 21 |
|
19 | 22 | ```math |
20 | 23 | \begin{equation} |
21 | | - \frac{\partial \theta}{\partial t} \approx - D(v, \theta) |
22 | | -\label{eq:1d-column-advection-discrete} |
| 24 | + \frac{\partial T}{\partial t} \approx \alpha \cdot D(G(T)). |
| 25 | +\label{eq:1d-column-heat-discrete} |
23 | 26 | \end{equation} |
24 | 27 | ``` |
25 | 28 |
|
26 | 29 | #### Prognostic Variables |
27 | 30 |
|
28 | | -* ``\theta``: the scalar field |
29 | | -* ``v``: the velocity field |
30 | | - |
31 | | -#### Tendencies |
| 31 | +* ``\alpha``: thermal diffusivity measured in $\frac{m^2}{s}$ |
| 32 | +* ``T``: temperature |
32 | 33 |
|
33 | | -The example code solves the equation for 4 different tendencies with the following discretizations: |
| 34 | +#### Differentiation Operators |
34 | 35 |
|
35 | | -* Tendency 1: ``D = \partial(UB)``, where ``\partial`` is the [`face-to-center divergence`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.DivergenceF2C) and $UB$ is the [`center-to-face upwind biased product`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.UpwindBiasedProductC2F) operator. |
36 | | -* Tendency 2: Follows tendency 1, where ``D = \partial(UB)``. Similarly, ``\partial`` is the [`face-to-center divergence`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.DivergenceF2C) and $UB$ is the [`center-to-face upwind biased product`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.UpwindBiasedProductC2F) operator. Tendency 2 also includes the [`center-to-center flux correction`](https://github.com/CliMA/ClimaCore.jl/blob/main/src/Operators/finitedifference.jl#L2617), `fcc`. |
37 | | -* Tendency 3: $D = A$, where $A$ is the [`center-to-center vertical advection`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.AdvectionC2C) operator. |
38 | | -* Tendency 4: Follows tendency 3, where $D = A$, the [`center-to-center vertical advection`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.AdvectionC2C). Tendency 4 also includes the [`center-to-center flux correction`](https://github.com/CliMA/ClimaCore.jl/blob/main/src/Operators/finitedifference.jl#L2617), `fcc`. |
| 36 | + * ``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 |
| 37 | + * ``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 |
39 | 38 |
|
40 | 39 | #### Set Up |
41 | 40 |
|
42 | | -This test case is set up in a 1D column domain ``z \in [0, 4\pi]``, discretized into a mesh of 128 elements. The velocity field is defined as a sinusoidal wave. The boundary conditions are operator dependent, so they depend on the tendency. |
43 | | -* 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. |
44 | | -* 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. |
| 41 | +This test case is set up in a 1D column domain ``z \in [0, 1]`` and discretized into a mesh of 10 elements. A homogeneous Dirichlet boundary condition is set at the bottom boundary, `bcs_bottom`, setting the temperature to 0. A Neumann boundary condition is applied to the top boundary, `bcs_top`, setting the temperature gradient to 1. |
45 | 42 |
|
46 | | -### Heat |
| 43 | +### Advection equation |
47 | 44 |
|
48 | | -The 1D Column heat example in [`examples/column/heat.jl`](https://github.com/CliMA/ClimaCore.jl/blob/main/examples/column/heat.jl). |
| 45 | +The 1D Column advection example in [`examples/column/advect.jl`](https://github.com/CliMA/ClimaCore.jl/blob/main/examples/column/advect.jl). |
49 | 46 |
|
50 | | -#### Equations and discretizations |
| 47 | +#### Equations and Discretizations |
51 | 48 |
|
52 | | -Follows the heat equation |
| 49 | +Follows the advection equation |
53 | 50 |
|
54 | 51 | ```math |
55 | 52 | \begin{equation} |
56 | | - \frac{\partial T}{\partial t} = \alpha \cdot \nabla^2 T. |
57 | | -\label{eq:1d-column-heat-continuity} |
| 53 | + \frac{\partial \theta}{\partial t} = -\frac{\partial (v \theta)}{\partial z} . |
| 54 | +\label{eq:1d-column-advection-continuity} |
58 | 55 | \end{equation} |
59 | 56 | ``` |
60 | | - |
61 | 57 | This is discretized using the following |
62 | 58 |
|
63 | 59 | ```math |
64 | 60 | \begin{equation} |
65 | | - \frac{\partial T}{\partial t} \approx \alpha \cdot D(G(T)). |
66 | | -\label{eq:1d-column-heat-discrete} |
| 61 | + \frac{\partial \theta}{\partial t} \approx - D(v, \theta) . |
| 62 | +\label{eq:1d-column-advection-discrete} |
67 | 63 | \end{equation} |
68 | 64 | ``` |
69 | 65 |
|
70 | 66 | #### Prognostic Variables |
71 | 67 |
|
72 | | -* ``\alpha``: thermal diffusivity measured in $\frac{m^2}{s}$ |
73 | | -* ``T``: temperature |
| 68 | +* ``\theta``: the scalar field |
| 69 | +* ``v``: the velocity field |
74 | 70 |
|
75 | | -#### Differentiation Operators |
| 71 | +#### Tendencies |
76 | 72 |
|
77 | | - * ``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 |
78 | | - * ``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 |
| 73 | +The example code solves the equation for 4 different tendencies with the following discretizations: |
| 74 | + |
| 75 | +- Tendency 1: |
| 76 | + |
| 77 | + $$D = \partial(UB),$$ |
| 78 | + |
| 79 | + where ``\partial`` is the [`face-to-center divergence`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.DivergenceF2C) and $UB$ is the [`center-to-face upwind biased product`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.UpwindBiasedProductC2F) operator. |
| 80 | +- Tendency 2: |
| 81 | + |
| 82 | + $$D = \partial(UB) + \textrm{fcc}(v, \theta),$$ |
| 83 | + |
| 84 | + where $\textrm{fcc}(v, \theta)$ is the [`center-to-center flux correction`](https://github.com/CliMA/ClimaCore.jl/blob/main/src/Operators/finitedifference.jl#L2617) operator. |
| 85 | +- Tendency 3: |
| 86 | + |
| 87 | + $$D = A,$$ |
| 88 | + |
| 89 | + where $A$ is the [`center-to-center vertical advection`](https://clima.github.io/ClimaCore.jl/dev/operators/#ClimaCore.Operators.AdvectionC2C) operator. |
| 90 | +- Tendency 4: |
| 91 | + |
| 92 | + $$D = A + \textrm{fcc}(v, \theta),$$ |
| 93 | + |
| 94 | + where $\textrm{fcc}(v, \theta)$ is the [`center-to-center flux correction`](https://github.com/CliMA/ClimaCore.jl/blob/main/src/Operators/finitedifference.jl#L2617) operator. |
79 | 95 |
|
80 | 96 | #### Set Up |
81 | 97 |
|
82 | | -This test case is set up in a 1D column domain ``z \in [0, 1]`` and discretized into a mesh of 10 elements. A homogeneous Dirichlet boundary condition is set at the bottom boundary, `bcs_bottom`, setting the temperature to 0. A Neumann boundary condition is applied to the top boundary, `bcs_top`, setting the temperature gradient to 1. |
| 98 | +This test case is set up in a 1D column domain ``z \in [0, 4\pi]``, discretized into a mesh of 128 elements. The velocity field is defined as a sinusoidal wave. The boundary conditions are operator dependent, so they depend on the tendency. |
| 99 | +* 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. |
| 100 | +* 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. |
83 | 101 |
|
84 | 102 | ## 2D Cartesian examples |
85 | 103 |
|
|
0 commit comments