= Non-cyclic lateral boundary conditions = Figure 1 shows the grid structure for non-cyclic boundary conditions at the left/right boundary '''LB/RB''' ([../../app/inipar/#bc_lr bc_lr]) and figure 2 for non-cyclic boundary conditions at the north/south boundary '''NB/SB''' ([../../app/inipar/#bc_ns bc_ns]). The indices (i,j,k) represent the directions (x,y,z). The model domain extends from -1:nx+1 in the x-direction, from -1:ny+1 in the y-direction and from 0:nzt+1 in the z-direction. For the advection scheme of Wicker and Skamarock, two more grid points are added at the lateral boundaries which are not needed for non-cyclic boundary conditions. The figures display the grid layer of the horizontal velocity components u and v, and scalar s. The grid points of the vertical velocity w are defined at the scalar position but shifted by one half grid spacing in vertical direction (not shown, detailed information about the grid structure in PALM can be found [http://palm.muk.uni-hannover.de/wiki/doc/tut/the/numerics here]). The prognostic equations are solved at all inner grid points which are marked black. The grid points at the respective non-cyclic boundaries (blue) are treated as follows. \\\\ [[Image(grid_lr.png, 700px, border=1)]] \\ Figure 1: Grid structure at the lateral boundaries with non-cyclic lateral boundary conditions along the left-right direction. \\\\\\ [[Image(grid_ns.png, 700px, border=1)]] \\ Figure 2: Grid structure of the lateral boundaries with non-cyclic lateral boundary conditions along the north-south direction. \\\\\\ LB is defined at i = -1 for v, w, s and at i = 0 for u. SB is defined at j = -1 for u, w, s and at j = 0 for v. RB is defined at i = nx + 1 and NB at j = ny + 1 for all quantities. LB and SB are treated this way so that the order and number of grid points for the streamwise velocity component and scalars is the same, independent of the flow direction. \\ For technical reasons, the prognostic equations are first solved for u at i = 0 (v at j = 0), since these grid points technically belong to the inner grid, but afterwards, these results at i = 0 (j = 0) are replaced by the respective boundary condition in routine ''boundary_conds.f90''. In case of a Dirichlet condition, the values at i = 0 (j = 0) are taken from i = -1 (j = -1). In case of a radiation boundary condition, the solution of the Sommerfeld equation overwrites the prognostic values at i = 0 (j = 0). \\ For non-cyclic lateral boundary conditions, the parameter [../../app/inipar/#psolver psolver] has to be set to '' 'multigrid' '' because the default FFT-solver can only be applied for cyclic boundary conditions. \\\\ === Inflow boundary === At the inflow boundary, Dirichlet conditions are used for the three velocity components ψ = {u,v,w} as well as for all scalar quantities s and are implemented as follows (here e.g. for s and a flow in positive x direction): {{{ #!Latex s^{t + \Delta t}(k,j,-1) = s_{init}(k) \; . \quad(1) }}} t denotes the time, Δt the time step and s,,init,, the initialization profile of the scalar quantities which is constant in time. The quantities at the inflow are set by the initial vertical profiles (see [../../app/inipar/#initializing_actions initializing_actions]). A Neumann condition is used for the subgrid-scale turbulent kinetic energy e (here e.g. for a left-right flow): {{{ #!Latex e^{t + \Delta t}(k,j,-1) = e^{t + \Delta t}(k,j,0) \; . \quad(2) }}} To prevent gravity waves from being reflected at the inflow, a relaxation term can be added to the prognostic equations for the potential temperature θ (Davies, 1976): {{{ #!Latex \theta^{t+1}(d) = ... - \Delta t \cdot K(d) \cdot \left( \theta^{t}(d) - \theta_{init} \right) \; . \quad(3) }}} Here, d is the distance normal to the wall and θ,,init,, the initial value of the potential temperature, which corresponds to the value at the inflow boundary. The damping or relaxation function K depends only on the distance d to the inflow. K is calculated by {{{ #!Latex K(d) = \begin{cases} d_f \sin^2\left( \frac{\pi}{2} \frac{d_w - d}{d_w} \right) , \text{for } d < d_w \\ \qquad\quad 0 \qquad \quad \;\;\; , \text{for } d \ge d_w \end{cases} . \quad (4) }}} d,,f,, is a damping factor to control the damping intensity, and d,,w,, is the width of the relaxation region extending from the inflow. Quantities d,,f,, and d,,w,, can be set with parameters [../../app/inipar/#pt_damping_factor pt_damping_factor] and [../../app/inipar/#pt_damping_width pt_damping_width], respectively. Both parameters have to be set by the user and must be adjusted case-by-case, because both parameters depend on the numerical and physical conditions, so that application of universal default values is not possible. So far, we have experience with gravity waves in case of cold air outbreaks, which grow in amplitude up to quite extreme values, if no damping is applied. In the respective simulations, we used typical values for [../../app/inipar/#pt_damping_factor pt_damping_factor] of 0.05 and for [../../app/inipar/#pt_damping_width pt_damping_width] of 25 km in order to prevent the gravity waves from growing. === Outflow boundary === At the outflow, an open boundary condition is needed to ensure that disturbances of the mean flow can exit the model domain without effecting the flow upstream. For the scalar quantities, Neumann boundary conditions are used at the outflow boundary which is the simplest way. For the velocity components, a Neumann condition would require to be considered in the solution of the Poisson equation for perturbation pressure, which has not been realized so far, because it requires some technical effort. Instead, PALM offers two types of radiation boundary conditions for the velocity components, which are not in conflict with the pressure solver (see [../../app/inipar/#bc_lr bc_lr] and [../../app/inipar/#bc_ns bc_ns]). For the radiation condition, the Sommerfeld radiation equation is solved at the outflow {{{ #!Latex \partial_t \psi + c_{\psi} \partial_n \psi = 0 \; , \quad (5) }}} which considers flow disturbances propagating with the mean flow and by waves. Here ψ is the transported quantity and $\partial_n$ is the derivative normal to the outflow boundary. In PALM, based on 5, the radiation boundary condition is realized in two ways as follows.