% $Id: numerics_bc.tex 1226 2013-09-18 13:19:19Z gronemeier $
\input{header_tmp.tex}
%\input{header_lectures.tex}

\usepackage[utf8]{inputenc}
\usepackage{ngerman}
\usepackage{pgf}
\usetheme{Dresden}
\usepackage{subfigure}
\usepackage{units}
\usepackage{multimedia}
\usepackage{hyperref}
\newcommand{\event}[1]{\newcommand{\eventname}{#1}}
\usepackage{xmpmulti}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\def\Tiny{\fontsize{4pt}{4pt}\selectfont}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage{pdfcomment}

\institute{Institut für Meteorologie und Klimatologie, Leibniz Universität Hannover}
\date{last update: \today}
\event{PALM Seminar}
\setbeamertemplate{navigation symbols}{}

\setbeamertemplate{footline}
  {
    \begin{beamercolorbox}[rightskip=-0.1cm]&
     {\includegraphics[height=0.65cm]{imuk_logo.pdf}\hfill \includegraphics[height=0.65cm]{luh_logo.pdf}}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,
      leftskip=.3cm,rightskip=0.3cm plus1fil]{title in head/foot}
      {\leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor} \hfill \eventname \hfill \insertframenumber \; / \inserttotalframenumber}
    \end{beamercolorbox}
    \begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot}
    \end{beamercolorbox}
  }
%\logo{\includegraphics[width=0.3\textwidth]{luhimuk_logo.pdf}}

\title[Numerics and Boundary Conditions]{Numerics and Boundary Conditions\\
(used in PALM)
}
\author{Siegfried Raasch}

\begin{document}

% Folie 1
\begin{frame}
\titlepage
\end{frame}

% Folie 2
\begin{frame}
   \frametitle{Overview}
   \scriptsize PALM is (almost) using simple, standard and fast numerical schemes:
   \begin{itemize}
      \scriptsize
      \item<2-> \textbf{Spatial and temporal discretization by finite differences}\\
      \item<3-> \textbf{Explicit timestep methods:}\\
         - Euler\\
         - \underline{Runge-Kutta}, second or \underline{third order}
      \item<4-> \textbf{Advection method}\\
         - Upstream\\
         - Piacsek-Williams (second order central finite differences)\\
         - Bott-Chlond-scheme (monotone, positiv definit, for scalars only)\\
         - \underline{5th-order scheme of Wicker and Skamarock}, (as used in WRF model)
      \item<5-> \textbf{Poisson-equation for pressure}\\
         - \underline{Direct FFT-method}\\
         - Multigrid-method
      \item<6-> \textbf{Lagrangian particle model included}
      \item<7-> \textbf{Boundary conditions:}\\
         - \underline{Cyclic} and non-cyclic horizontal boundary conditions\\
         - Surface layer with Monin-Obukhov similarity\\
         - Topography\\
         - Turbulent inflow (for non-cyclic horizontal boundary conditions)
         
   \end{itemize}
\end{frame}


\section{Numerics}
\subsection{Numerics}

% Folie 3
\begin{frame}
   \frametitle{Numerical Grid}
   \footnotesize
   \vspace{2mm}
   \includegraphics[width=\textwidth]{numerics_bc_figures/numerical_grid.png}
   \begin{itemize}
      \item<1->Equations are spatially discretized on an Arakawa-C grid.
      \item<2->All scalar variables s (e.g. , $p^*$, $e$, $K_{\mathrm{m}}$, 
               $K_{\mathrm{h}}$) are defined at the cell centers.
      \item<3->Velocity components ($u$, $v$, $w$) are shifted by half of the grid spacing.
      \item<4->Spacings are equidistant, stretching along $z$ is possible.
   \end{itemize}

   \tikzstyle{plain} = [rectangle, draw, fill=white!20, text width=0.33\textwidth, font=\small]
   \begin{tikzpicture}[remember picture, overlay]
      \node at (current page.north west){%
      \begin{tikzpicture}[overlay]
         \node[plain, draw,anchor=west] at (88mm,-55mm) {
         \noindent \scriptsize general definition (cylic):\\
         $\Psi$(0:nz+1,-1:ny+1,-1:nx+1)\\
         $\Psi$(:,-1,:) $=\Psi$(:,ny,:)\\
         $\Psi$(:,ny+1,:) $=\Psi$(:,0,:)

         };
      \end{tikzpicture}
      };
   \end{tikzpicture}
\end{frame}

% Folie 4
\begin{frame}
   \frametitle{Timestep Methods (I)}
   \footnotesize
   \begin{itemize}
      \item<1->\textbf{Euler}\\
      \vspace{3mm}
      $\dfrac{\partial \psi(t)}{\partial t} = F (\psi(t)) \rightarrow 
      \dfrac{\psi(t + \Delta t) - \psi(t)}{\Delta t} 
      \approx F (\psi(t))$ \hspace{8mm} 
      \onslide<2-> $u\dfrac{\Delta t}{\Delta x}=C<1$\\
      \begin{flushright}
         for stability
      \end{flushright}

      \onslide<1->$\psi (t+\Delta t) = \psi(t) 
      + \Delta t \cdot F(\psi(t)) \hspace{28mm} \mathcal{O}(\Delta t)$\\
      (used for SGS-TKE in special cases)
         
      \vspace{3mm}
      \item<3-> \textbf{Runge-Kutta, third-order}\\
      \vspace{2mm}
      $k_1=F(\psi(t))$\\
      \vspace{1mm}
      $k_2=F \left( \psi(t) + \frac{1}{3} \Delta t \cdot k_1 \right)$\\
      \vspace{1mm}
      $k_3=F \left( \psi(t) - \frac{3}{16} \Delta t \cdot k_1 
      + \frac{15}{16} \Delta t \cdot k_2 \right)$\\
      \vspace{1mm}
      $\psi(t + \Delta t) = \psi(t) + \frac{1}{30}\Delta t (5 k_1 + 9 k_2 + 16 k_3)$ 
      \hspace{12mm} $\mathcal{O}(\Delta t^2)$ \hspace{3mm} $C \le 0.9$\\
   \end{itemize}
\end{frame}

% Folie 5
\begin{frame}
   \frametitle{Timestep Methods (II)}
   \footnotesize
   \onslide<1->In the PALM code, the different timestep schemes are treated by one 
   equation using switches:
   $\psi (t + \Delta t ) = (1 - c_1) \cdot \psi (t - \Delta t ) + c_1 \cdot \psi (t) 
   + \Delta t \cdot \left[ c_2 \cdot F (\psi (t) ) + c_3 \cdot F (\psi (t -  
   \Delta t ) ) \right]$
   \vspace{1mm}

   \onslide<2->
   \begin{centering}
      \begin{table}
         \begin{tabular}{cccc}
            \bf{Scheme} & \bf{c$_1$} & \bf{c$_2$} & \bf{c$_3$}\\
            Euler & 1 & 1 & 0\\
            RK (1st step) & 1 & 1/3 & 0\\
            RK (2nd step) & 1 & 15/16 & -25/48\\
            RK (3rd step) & 1 & 8/15 & 1/15\\
         \end{tabular}
      \end{table}
   \end{centering}

   \onslide<3->
   \begin{align*}
      \psi (t - \Delta t) &= \psi (t) \hspace{15mm} \textbf{after each RK substep}\\
      \psi (t) &= \psi (t + \Delta t)
   \end{align*}
\end{frame}

% Folie 6
\begin{frame}
   \frametitle{Advection Methods (I)}
   \small
   \begin{itemize}
      \item<1-> Piacsek Williams C3 (1970, J. Comput. Phy., 6, 392).
      \item<2-> Scheme of 2nd order accuracy.
      \item<3-> Conserves integrals of linear and quadratic quantities.
      \item<4-> Requires incompressibility $\rightarrow$ flux form of advection term.
                \onslide<4-> \includegraphics[width=0.8\textwidth]{numerics_bc_figures/advection_methods.png}
   \end{itemize}
   $$\left.\frac{\partial (u \psi)}{\partial x}\right\vert_i = \frac{1}{2 \Delta x} 
   \left( u_{i+\frac{1}{2}} \psi_{i+1} - u_{i-\frac{1}{2}} \psi_{i-1} \right)$$
   \begin{itemize}
      \item<5-> In case of momentum advection (e.g. $\psi=u$), $u_{i-1}$ and 
                $u_{i+1}$ have to be obtained by linear interpolation.
      \item<5-> May cause $2 \Delta x$ wiggles in case of sharp gradients.
   \end{itemize}
\end{frame}

% Folie 7
\begin{frame}
   \frametitle{Advection Methods (II)}
   \begin{itemize}
   
      \item<1-> \small Bott-Chlond\\ \scriptsize
         \onslide<1-> - Chlond (1994)\\
         \onslide<2-> - Monotone, positive definit. Can only be used for scalars\\
         \onslide<3-> - Conserves sharp gradients\\
         \onslide<4-> - Numerically expensive\\
         \onslide<5-> - Not optimized for use on cache-based machines.
      \par\bigskip
      \item<6-> \small Default: Wicker and Skamarock scheme (5th order)\\ \scriptsize
         \onslide<6-> - Much better accuracy than Piacsek Williams\\
         \onslide<7-> - Much simpler algorithm than Bott-Chlond\\
         \onslide<8-> - Requires additional ghost layers\\
         \onslide<9-> - Adds additional numerical dissipation
         
   \end{itemize}
\end{frame}

% Folie 8
\begin{frame}
   \frametitle{Advection Methods – Wicker/Skamarock (I)}
   \footnotesize
   \begin{itemize}
      \item Wicker and Skamarock (2002, Mon. Wea. Rev. 130, 2088 – 2097).
      \item Based on flux form of advection term
      \item Difference of fluxes at the edge of the grid cell is used to 
      discretise advection term
   \end{itemize}

   \begin{columns}[T]
      \begin{column}{0.55\textwidth}
         \hspace{8mm}\includegraphics[width=0.8\textwidth]{numerics_bc_figures/numerical_grid_small.png}
      \end{column}
      \begin{column}{0.45\textwidth}
         $\frac{ \partial \psi}{\partial t} = - \nabla (u_i \psi) \approx 
         - \frac{F_{i+\frac{1}{2}} - F_{i-\frac{1}{2}}}{\Delta x}$
      \end{column}
   \end{columns}

   \tikzstyle{plain} = [rectangle, text width=0.1\textwidth, font=\small]
   \begin{tikzpicture}[remember picture, overlay]
      \node at (current page.north west){%

      \begin{tikzpicture}[overlay]
         \node[plain, anchor=west] at (2mm,-68mm) {
         \tikz 
         {
         \draw[blue, -latex', line width=5pt] (1,0) -- (2,0);
         }

         $F_{i-\frac{1}{2}}$
         };
      \end{tikzpicture}

      \begin{tikzpicture}[overlay]
         \node[plain, anchor=west] at (62mm,-68mm) {
         \tikz 
         {
         \draw[blue, -latex', line width=5pt] (,0) -- (2,0);
         }
         $F_{i+\frac{1}{2}}$
         };
      \end{tikzpicture}

      };
   \end{tikzpicture}
\end{frame}

% Folie 9
\begin{frame}
   \frametitle{Advection Methods – Wicker/Skamarock (II)}
   


   \textbf{Finite difference approximation of 6$^{\text{th}}$ order}
   \begin{tikzpicture}[scale=2]
      \tikzstyle{ann} = [draw=none,fill=none,right]
      \matrix[nodes={draw, thick, fill=blue!20}, row sep=0.3cm,column sep=0.5cm]{
      \node[rectangle, rounded corners]{
      $F^{\text{6th}}_{i-\frac{1}{2}} = \frac{1}{60} u_{i-\frac{1}{2}} \left( 37 
      (\Psi_i + \Psi_{i-1}) - 8 (\Psi_{i+1} + \Psi_{i-2}) + (\Psi_{i+2} 
      + \Psi_{i-3}) \right)$ 
       };\\
       };
   \end{tikzpicture}
   
   \vspace{5mm}
   
   \textbf{Artificially added numerical dissipation term}
   \begin{tikzpicture}[scale=2]
      \tikzstyle{ann} = [draw=none,fill=none,right]
      \matrix[nodes={draw, thick, fill=blue!40}, row sep=0.3cm,column sep=0.5cm]{
      \node[rectangle, rounded corners]{
      $-\frac{1}{60} \left| u_{i-\frac{1}{2}} \right| \left( 10 (\Psi_i - 
      \Psi_{i-1}) - 5 (\Psi_{i+1} - \Psi_{i-2}) + (\Psi_{i+2} - \Psi_{i-3}) \right)$ 
       };\\
       };
   \end{tikzpicture}
\end{frame}

% Folie 10
\begin{frame}
   \frametitle{Advection Methods – Wicker/Skamarock (III)}
   
   \begin{tikzpicture}[scale=2]
      \tikzstyle{ann} = [draw=none,fill=none,right]
      \matrix[nodes={draw, thick, fill=blue!20}, row sep=0.3cm,column sep=0.5cm]{
      \node[rectangle, rounded corners]{
      $F^{\text{6th}}_{i-\frac{1}{2}} = \frac{1}{60} u_{i-\frac{1}{2}} 
      \left( 37 (\Psi_i + \Psi_{i-1}) - 8 (\Psi_{i+1} + \Psi_{i-2}) + (\Psi_{i+2} + 
      \Psi_{i-3}) \right)$ 
       };\\
       };
   \end{tikzpicture}
   
   \begin{columns}[T]
      \begin{column}{0.7\textwidth}
         \includegraphics[width=1\textwidth]{numerics_bc_figures/numerical_oscillations.png}
      \end{column}
      \begin{column}{0.3\textwidth}
         Centered Finite Differences produces numerical oscillations (''wiggles'') 
         near sharp gradients.
      \end{column}
   \end{columns}
\end{frame}

% Folie 11
\begin{frame}
   \frametitle{Advection Methods – Wicker/Skamarock (IV)}
   \footnotesize   

   \begin{tikzpicture}[scale=2]
      \tikzstyle{ann} = [draw=none,fill=none,right]
      \matrix[nodes={draw, thick, fill=blue!40}, row sep=0.3cm,column sep=0.5cm]{
      \node[rectangle, rounded corners]{
      $F^{\text{5th}}_{i-\frac{1}{2}} = F^{\text{6th}}_{i-\frac{1}{2}}
         - \frac{1}{60} \left| u_{i-\frac{1}{2}} \right| \left( 10 (\Psi_i - \Psi_{i-1}) - 
            5 (\Psi_{i+1} - \Psi_{i-2}) + (\Psi_{i+2} - \Psi_{i-3}) \right)$ 
       };\\
       };
   \end{tikzpicture}
   
   \begin{columns}[T]
      \begin{column}{0.7\textwidth}
         \includegraphics[width=1\textwidth]{numerics_bc_figures/numerical_oscillations_2.png}
      \end{column}
      \begin{column}{0.3\textwidth}
         \vspace{3mm}
         \underline{Advantage}\\
         Numerical Dissipation damps small scale oscillations.\\
         \vspace{3mm}
         \underline{Disadvantage}\\
         In a turbulent flow numerical dissipation removes energy from small scales.

      \end{column}
   \end{columns}
\end{frame}

% Folie 12
\begin{frame}
   \frametitle{Advection Methods – Wicker/Skamarock (V)}
    
    \begin{columns}[T]
      \begin{column}{0.6\textwidth}
         \includegraphics[width=1\textwidth]{numerics_bc_figures/numerical_properties.png}
      \end{column}
      \begin{column}{0.4\textwidth}
         \includegraphics[width=1\textwidth]{numerics_bc_figures/pw_ws.png}
      \end{column}
   \end{columns}
    
   \begin{itemize}
      \item Better resolution of larger scales $(> 8\,\Delta x)$ and hence less 
      numerical energy transfer from larger to smaller scales compared to lower 
      order schemes.
      \item Less spectral energy at smaller scales.
   \end{itemize}
   
\end{frame}

% Folie 13
\begin{frame}
   \frametitle{Pressure Solver (I)}
   \footnotesize
   \begin{itemize}
      \item<1-> Governing equations of PALM require incompressibility
      \item<2-> Incompressibility is reached by a predictor-corrector method\\
            \scriptsize
            1. Momentum equations are solved without the pressure term giving a
            provisional velocity field which is not free of divergence.\\
            \vspace{2mm}
            $\overline{u}^{t+\Delta t}_{i_{\mathrm{prov}}} = \overline{u}^t_i +
            \Delta t \left( - \frac{\partial}{\partial x_k} \overline{u}^t_k
            \overline{u}^t_i - (\varepsilon_{ijk} f_j \overline{u}^t_k 
            - \varepsilon_{i3k} f_3 u_{\mathrm{g}_k}) 
            + g \frac{\overline{\theta^*}^t}{\theta_0} \delta_{i3} 
            - \frac{\partial}{\partial x_k} \overline{u'_k u'_i}^t \right)$\\
            \vspace{2mm}
            \onslide<3-> 2. Assign all remaining divergences to the (perturbation)
            pressure $p^*$ so that the new corrected velocity field is the sum of the
            provisional, divergent field and the perturbation pressure term.\\
            \vspace{2mm}
            $\overline{u}^{t+\Delta t}_{i} = 
            \overline{u}^{t+\Delta t}_{i_{\mathrm{prov}}} + 
            \Delta t \left(-\frac{1}{\rho_0} \frac{\partial \overline{p^*}^t}{\partial x_i} \right)$\\
            \vspace{2mm}
            \onslide<4-> 3. The divergence operator is applied to this equation.
            Demanding a corrected velocity field free of divergence, this leads to a
            Poisson equation for the perturbation pressure.\\
            \vspace{2mm}
            $\frac{\partial^2 \overline{p^*}^t}{\partial x_i^2} = \frac{\rho_0}
            {\Delta t} \frac{\partial \overline{u}_{i_{\mathrm{prov}}}^{t + \Delta t}}
            {\partial x_i}$\\
            \vspace{2mm}
            \onslide<5-> 4. After solving the Poisson equation, the final velocity field
            is \\
            calculated as given in step 2.\\

   \end{itemize}
\end{frame}

% Folie 14
\begin{frame}
   \frametitle{Pressure Solver (II)}
   \small
   
   \begin{itemize}
      \item FFT-solver\\
      \onslide<1-> 1. Discretization of the Poisson-equation by central differences\\
      \onslide<2-> 2. 2D discrete FFT in both horizontal directions\\
      \onslide<3-> 3. Solving the resulting tridiagonal set of linear equations\\
      \onslide<4-> 4. Inverse 2D discrete FFT in both horizontal directions leading 
      to the perturbation pressure

      \begin{itemize}
         \item<5-> Very fast and accurate, $\mathcal{O}(n \log n)$, $n$: 
         number of gridpoints
         \item<6-> CPU requirement $<$ 50\% of total CPU time
         \item<7-> Due to non-locality of the FFT, transpositions are required 
         on parallel computers
         \item<8-> Requires periodic boundary conditions and uniform grids 
         along $x$ and $y$
      \end{itemize}
   \end{itemize}
\end{frame}

% Folie 15
\begin{frame}
   \frametitle{Pressure Solver (III)}
   \scriptsize   
   \begin{columns}
      \begin{column}{1.03\textwidth}
         \begin{itemize}
            \item<1-> Multigrid-method\\
            \begin{itemize}\scriptsize  
               \item Iterative solver\\
               \scriptsize
               basic idea: Poisson equation is transformed to a fixed point problem:\\
               $\vec{p}^{k+1} = T \cdot \vec{p}^k + \vec{c}^k$\\
               \vspace{1mm}
               \onslide<2-> starting from a first guess, the solution will be 
               improved by repeated execution of the fixed point problem:\\
               $\begin{array}{rcl}
               \vec{p}^{1} &=&T \cdot \vec{p}^0 + \vec{c}^0\\
               \vec{p}^{2} &=&T \cdot \vec{p}^1 + \vec{c}^1
               \vspace{-2mm}\\
               
               &\vdots&
               \vspace{-1.5mm}\\
               
               \vec{p}^{k} &=&T \cdot \vec{p}^{k-1} + \vec{c}^{k-1}\\
               \vec{p}^{k+1} &=&T \cdot \vec{p}^k + \vec{c}^k\\
               \end{array}$\\
               \vspace{1mm}
               \onslide<3-> Depending on the structure of the matrix $T$ and vector 
               $c$ different iterative solvers can be defined, e.g.: Jacobi-scheme 
               (here on 2D-uniform grid):\\
               $p^{k+1}_{i,j} = \frac{1}{4} \cdot \left( p^k_{i-1,j} + p^k_{i+1,j} 
               + p^k_{i,j-1} + p^k_{i,j+1} - \Delta x^2 f(i,j,k) \right)$\\
               \scriptsize \vspace{2mm}
               \item<4-> With each iteration step $k$ the improved solution converges towards 
               the exact solution.
               \item<5-> Iterative schemes are 'local schemes' $\rightarrow$ information 
               is needed \\ only from neighboring grid-points.
               \item<6-> Very low convergence: $\mathcal{O}(n^2)$.
           \end{itemize}
         \end{itemize}
      \end{column}
   \end{columns}
\end{frame}
   
% Folie 16
\begin{frame}
   \frametitle{Pressure Solver (IV)} 
   \begin{itemize}
      \item<1-> Multigrid-method\\
      \begin{itemize}
         \item Due to their locality, iterative solvers show a frequency-dependent
            reduction of the residual: low frequencies are reduced slower than high
            frequencies.
         \item<2-> The main idea of the multigrid method is to reduce errors of different
         frequencies on grids with different grid spacing:
         \begin{itemize}
            \item errors of high frequency are reduced on fine grids
            \item errors of low frequency are reduced on coarse grids.
         \end{itemize}
      \end{itemize}
   \end{itemize}
   \onslide<2->
   \begin{figure}[htp]
      \centering
      \includegraphics[scale=0.35]{numerics_bc_figures/errors.png}
   \end{figure}
\end{frame}

% Folie 17
\begin{frame}
   \frametitle{Pressure Solver (V)} 
   
   \begin{columns}[T]
      \begin{column}{0.65\textwidth}
         \begin{itemize}
            \item<1-> Multigrid-method\\
            \begin{itemize}
               \footnotesize
               \item On each grid-level an approximate solution of the fixed point 
                  equation is obtained performing a few iterations.
               \item<2-> The solution is transmitted to the next coarser grid-level
                  where it is used as the first guess to solve the fixed point problem.
               \item<3-> This procedure is performed up to the coarsest grid-level
                  containing two grid-points in each direction.
               \item<4-> From the coarsest grid-level the procedure is passed in 
                  backward order to get the final solution.
               \item<5-> For large grids faster than FFT method.
               \item<6-> V- and W-cycles are implemented.
            \end{itemize}
      \end{itemize}
      \end{column}
      \begin{column}{0.5\textwidth}
         \onslide<2->
         \includegraphics[width=1\textwidth]{numerics_bc_figures/multigrid.png}
      \end{column}
   \end{columns}
\end{frame}



\section{Boundary Conditions}
\subsection{Boundary Conditions}

% Folie 18
\begin{frame}
   \frametitle{Boundary Conditions (I)}
   
   \begin{itemize}
      \item<1-> Lateral $(xy)$ boundary conditions:\\
      \begin{itemize}
         \item Cyclic by default, allowing undisturbed evolution / advection of turbulence.
            \begin{columns}[T]
               \begin{column}{0.2\textwidth}
                  %leer
               \end{column}
               \begin{column}{0.5\textwidth}
                  \includegraphics[width=1\textwidth]{numerics_bc_figures/lateral_bc.png}\\
                  \vspace{2mm}
               \end{column}
               \begin{column}{0.4\textwidth}
                  $\begin{array}{rcl}
                     \Psi(-1) &=& \Psi(n)\\
                     \Psi(n+1) &=& \Psi(0)\\
                  \end{array}$
               \end{column}
            \end{columns}
   
         \item<2-> Dirichlet (inflow) and radiation (outflow) conditions are allowed along
            either $x$- or $y$-direction.

         \item<3-> In case of a Dirichlet condition, the inflow is laminar (by default) and 
            the domain has to be extended to allow for the development of a turbulent
            state, if neccessary.
         \item<4->  Non-cyclic lateral conditions require the use of the multigrid-method 
            for solving the Poisson-equation.
            
      \end{itemize}
   \end{itemize}
\end{frame}

% Folie 19
\begin{frame}
   \frametitle{Boundary Conditions (II)}
   
   \begin{columns}[T]
      \begin{column}{0.7\textwidth}
         \scriptsize
         \begin{itemize}
            \item<1-> Surface boundary condition:
            \begin{itemize}
               \scriptsize
               \item<1-> Monin-Obukhov-similarity is used by default, i.e. a Prandtl-layer is 
                  assumed between the surface and the first grid layer.\\
                  $\frac{\partial \overline{u}}{\partial z} = \frac{u_{*}}{\kappa z} 
                  \Phi_{\mathrm{m}}$; \hspace{3mm} $u_{*} = \sqrt{- \overline{w' u'_0}} 
                  = \sqrt{\frac{\tau_0}{\overline{\rho}}}$\\
                  $\frac{\partial \overline{\theta}}{\partial z} = \frac{\vartheta_{*}}
                  {\kappa z} \Phi_{\mathrm{h}}$; \hspace{3mm} $\vartheta_{*} = 
                  \frac{\overline{w' \theta'_0}}{u_{*}}$\\
               \vspace{2mm}
               \item<2-> Integration between $z=z_0$ (roughness height) and $z=z_{\mathrm{p}}$
                  (top of Prandtl-layer, $k=1$) gives the only unknowns $u_{*}$ and
                  $\theta_{*}$ which then define the surface momentum and heat flux,
                  used as the real boundary conditions.\\
               \vspace{2mm}
               \item<3-> $\Phi_{\mathrm{m}}$, $\Phi_{\mathrm{h}}$: Dyer-Businger functions\\
               \onslide<4->$\Phi_{\mathrm{m}} = \left\{ \begin{array}{cc}
                     1+5\,\mathrm{Rif} & \text{stable}\\
                     1 & \text{neutral}\\
                     (1-16\,\mathrm{Rif})^{-1/4} & \text{unstable}\\
                  \end{array} \right. $

            \end{itemize}
         \end{itemize}
      \end{column}
      \begin{column}{0.3\textwidth}
         \onslide<1->
         \includegraphics[width=1\textwidth]{numerics_bc_figures/surface_bc.png}\\
         \vspace{-2mm}
         Prandtl-layer\\
         \vspace{8mm}
         \onslide<5->
         $\mathrm{Rif} = \frac{\frac{g}{\tilde{\theta}} 
         \overline{w' \theta'_0}}{\overline{w' u'} 
         \frac{\partial \overline{u}}{\partial z}}$\\
         \scriptsize Richardson flux number
      \end{column}
   \end{columns}
\end{frame}

% Folie 20
\begin{frame}
   \frametitle{Boundary Conditions (III)}

   \begin{itemize}
      \item<1-> Surface boundary condition:
      \begin{itemize}
         \footnotesize
         \item<1-> Monin-Obukhov-similarity is only valid for a 
            horizontal surface with homogeneous conditions.
         \item<2-> The surface temperature has to be prescribed.
            Alternatively, the surface heat flux can be prescribed.
         \item<3-> Instead of MO-similarity, no-slip conditions or
            free-slip conditions can be used
            \begin{equation*}
               u(z=0) = 0, \quad v(z=0)=0 \hspace{15mm}
               \frac{\partial u}{\partial z} = 0, \quad 
               \frac{\partial v}{\partial z} = 0 \qquad
            \end{equation*}
            realized by 
            \begin{flalign*}
               u(k=0)=-u(k=1) \hspace{18mm} u(k=0)=u(k=1)\\
               v(k=0)=-v(k=1) \hspace{18mm} v(k=0)=v(k=1)
            \end{flalign*}
         \item<4-> Pressure boundary condition: 
            $\dfrac{\partial p}{\partial z} = 0$ 
            in order to guarantee $w(z=0)=0$
         \item<5-> SGS-TKE condition $\dfrac{\partial e}{\partial z}=0$
      \end{itemize}
   \end{itemize}
\end{frame}

% Folie 21
\begin{frame}
   \frametitle{Boundary Conditions (IV)}

   \begin{itemize}
      \item<1-> Boundary conditions at the top (default)
      \begin{itemize}
         \item<1-> Dirichlet conditions for velocities: $u=u_{\mathrm{g}}, 
            \quad v=v_{\mathrm{g}}, \quad w=0$
         \item<2-> Neumann conditions (temporal constant gradients) for scalars:
            $$\frac{\partial \theta}{\partial z} = 
            \left. \frac{\partial \theta}{\partial z} \right\vert_{t=0}$$
         \item<3-> Pressure: Dirichlet $p=0$ 
            or Neumann $\dfrac{\partial p}{\partial z} = 0$
         \item<4-> SGS-TKE: Neumann $\dfrac{\partial e}{\partial z} = 0$
         \item<5-> A damping layer can be switched on in order to absorb 
            gravity waves.
      \end{itemize}
   \end{itemize}
\end{frame}

% Folie 22
\begin{frame}
   \frametitle{Initial Conditions}

   All 3D-arrays are initialized with vertical profiles (horizontally homogeneous).\\
   \quad \\
   Two different profiles can be chosen:
   \begin{itemize}
      \item<2-> \textbf{constant (piecewise linear) profiles}
         \begin{itemize}
            \footnotesize
            \item \textbf{e.g.} $u=0, v=0, \dfrac{\partial \theta}{\partial z}=0$ 
               \textbf{up to} $z=\unit[1000]{m}$, 
               $\dfrac{\partial \theta}{\partial z}=+1.0$ \textbf{up to top}
         \end{itemize}
      \item<3-> \textbf{velocity profiles calculated by a 1D-model (which is a part of PALM)}
         \begin{itemize}
            \footnotesize
            \item  \textbf{constant (piecewise linear) temperature profile is used 
               for the 1D-model}
         \end{itemize}
   \end{itemize}
   \onslide<4->
   \underline{Under horizontally homogeneous initial conditions, random}\\ 
   \underline{fluctuations have to be added in order to generate turbulence!}
\end{frame}

\end{document}