Added the Grey Radiation Scheme

This commit is contained in:
TechWizzart 2020-08-19 16:20:26 +02:00
parent 0a48c66515
commit 8a08523e13
No known key found for this signature in database
GPG Key ID: 151E66B6CEF55F2E
7 changed files with 176 additions and 24 deletions

Binary file not shown.

View File

@ -9,10 +9,11 @@
\usepackage{appendix} \usepackage{appendix}
\usepackage{float} \usepackage{float}
\usepackage{verbatim} \usepackage{verbatim}
\usepackage[normalem]{ulem}
\setcounter{section}{-1} \setcounter{section}{-1}
\title{CLimate Analysis using Digital Estimations Non-Offical Manual (CLAuDE NOM)} \title{CLimate Analysis using Digital Estimations Non-Offical Manual (CLAuDE NOM)}
\author{TechWizard} \author{Sam "TechWizard" Baggen}
\date{\today} \date{\today}
\begin{document} \begin{document}
@ -46,22 +47,24 @@ One important thing to note, the layout may change significantly when new sectio
a pain to fix and if something later on changes the whole layout may be messed up again and is a pain to fix again. Hence I opt to let \LaTeX (the software/typeset language used to create this a pain to fix and if something later on changes the whole layout may be messed up again and is a pain to fix again. Hence I opt to let \LaTeX (the software/typeset language used to create this
manual) figure out the placement of the algorithm blocks, which may or may not be in the right places. manual) figure out the placement of the algorithm blocks, which may or may not be in the right places.
\input{Streams/Stream1.tex} \input{streams/Stream1.tex}
\input{Streams/Stream2.tex} \input{streams/Stream2.tex}
\input{Streams/Stream3.tex} \input{streams/Stream3.tex}
\input{Streams/Stream4.tex} \input{streams/Stream4.tex}
\input{Streams/Stream5.tex} \input{streams/Stream5.tex}
\input{Streams/Stream6.tex} \input{streams/Stream6.tex}
\input{Streams/Stream7.tex} \input{streams/Stream7.tex}
\input{streams/Stream8.tex}
\newpage \newpage
\input{Streams/TTNMETAF.tex} \input{streams/TTNMETAF.tex}
\newpage \newpage
\bibliography{references} \bibliography{references}

View File

@ -210,7 +210,7 @@ The equation we will need for that is the mass continuity equation as shown in \
\end{equation} \end{equation}
Using this equation means that we will no longer assume that the atmosphere is incompressible. Therefore we need to change a few things in the code. First we need to change the $\rho$ in Using this equation means that we will no longer assume that the atmosphere is incompressible. Therefore we need to change a few things in the code. First we need to change the $\rho$ in
\autoref{alg:stream3}. Since $\rho$ is no longer constant we need to access the right value of $\rho$ by specifying the indices. So $\rho$ will chnage to $\rho[lat, lon]$. Furthermore we need \autoref{alg:stream3}. Since $\rho$ is no longer constant we need to access the right value of $\rho$ by specifying the indices. So $\rho$ will change to $\rho[lat, lon]$. Furthermore we need
to calculate $\rho$ after the movement of air has taken place, so we need to change \autoref{alg:advection} as well to include the calculations for $\rho$. The new version can be found in to calculate $\rho$ after the movement of air has taken place, so we need to change \autoref{alg:advection} as well to include the calculations for $\rho$. The new version can be found in
\autoref{alg:advectionv2}. Again the $\nabla$ represents the call to \autoref{alg:divergence}. \autoref{alg:advectionv2}. Again the $\nabla$ represents the call to \autoref{alg:divergence}.

View File

@ -68,20 +68,34 @@ the layer part in the gradient.
\label{alg:gradient y layer} \label{alg:gradient y layer}
\end{algorithm} \end{algorithm}
With those changes done, let us define the gradient in the $z$ direction. The function can be found in \autoref{alg:gradient z layer}. With those changes done, let us define the gradient in the $z$ direction. The function can be found in \autoref{alg:gradient z layer}. Here $a.dimensions$ is the attribute that tells us how
deeply nested the array $a$ is. If the result is $1$ we have just a normal array, if it is $2$ we have a double array (an array at each index of the array) which is also called a matrix and if it
is $3$ we have a triple array. We need this because we have a one-dimensional case, for when we do not use multiple layers and a three-dimensional case for when we do use multiple layers. This
distinction is needed to avoid errors being thrown when running the model with one or multiple layers.
\begin{algorithm}[hbt] \begin{algorithm}[hbt]
\SetKwInOut{Input}{Input} \SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output} \SetKwInOut{Output}{Output}
\Input{Matrix (double array) $a$, first index $i$, second index $j$, third index $k$} \Input{Matrix (double array) $a$, first index $i$, second index $j$, third index $k$}
\Output{Gradient in the $z$ direction} \Output{Gradient in the $z$ direction}
\uIf{$i == 0$}{ \uIf{$a.dimensions == 1$}{
$grad \leftarrow 2\frac{a[i, j, k + 1] - a[i, j, k]}{\delta z[k]}$ \; \uIf{$k == 0$}{
}\uElseIf{$i == nlat - 1$}{ $grad \leftarrow \frac{a[k + 1] - a[k]}{\delta z[k]}$ \;
$grad \leftarrow 2\frac{a[i, j, k] - a[i, j, k - 1]}{\delta z[k]}$ \; }\uElseIf{$k == nlevels - 1$}{
}\uElse{ $grad \leftarrow \frac{a[k] - a[k - 1]}{\delta z[k]}$ \;
$grad \leftarrow \frac{a[i, j, k + 1] - a[i, j, k - 1]}{\delta z[k]}$ \; }\uElse{
$grad \leftarrow \frac{a[k + 1] - a[k - 1]}{2\delta z[k]}$ \;
}
} \uElse {
\uIf{$k == 0$}{
$grad \leftarrow \frac{a[i, j, k + 1] - a[i, j, k]}{\delta z[k]}$ \;
}\uElseIf{$k == nlevels - 1$}{
$grad \leftarrow \frac{a[i, j, k] - a[i, j, k - 1]}{\delta z[k]}$ \;
}\uElse{
$grad \leftarrow \frac{a[i, j, k + 1] - a[i, j, k - 1]}{2\delta z[k]}$ \;
}
} }
\Return $grad$ \; \Return $grad$ \;
\caption{Calculating the gradient in the $z$ direction} \caption{Calculating the gradient in the $z$ direction}
\label{alg:gradient z layer} \label{alg:gradient z layer}
@ -229,9 +243,9 @@ use gravity ($g$) instead of the coriolis force ($f$) and calculate the pressure
\For{$lat \in [1, nlat - 1]$}{ \For{$lat \in [1, nlat - 1]$}{
\For{$lon \in [0, nlon]$}{ \For{$lon \in [0, nlon]$}{
\For{$layer \in [0, nlevels]$}{ \For{$layer \in [0, nlevels]$}{
$u[lan, lon, layer] \leftarrow u[lan, lon, layer] + \delta t \frac{-u[lan, lon, layer]S_{xu} - v[lan, lon, layer]S_{yu} + f[lan]v[lan, lon, layer] - S_{px}}{\rho}$ \; $u[lan, lon, layer] \leftarrow u[lat, lon, layer] + \delta t \frac{-u[lat, lon, layer]S_{xu} - v[lat, lon, layer]S_{yu} + f[lat]v[lat, lon, layer] - S_{px}}{\rho}$ \;
$v[lan, lon, layer] \leftarrow v[lan, lon, layer] + \delta t \frac{-u[lan, lon, layer]S_{xv} - v[lan, lon, layer]S_{yv} - f[lan]u[lan, lon, layer] - S_{py}}{\rho}$ \; $v[lan, lon, layer] \leftarrow v[lat, lon, layer] + \delta t \frac{-u[lat, lon, layer]S_{xv} - v[lat, lon, layer]S_{yv} - f[lat]u[lat, lon, layer] - S_{py}}{\rho}$ \;
$w[lan, lon, layer] \leftarrow w[lan, lon, layer] + \delta t (\frac{S_{pz}}{\rho[lan, lon, layer]} + g)$ \; $w[lan, lon, layer] \leftarrow w[lat, lon, layer] + \delta t (\frac{S_{pz}}{\rho[lat, lon, layer]} + g)$ \;
} }
} }
} }
@ -241,7 +255,7 @@ use gravity ($g$) instead of the coriolis force ($f$) and calculate the pressure
\end{algorithm} \end{algorithm}
Lastly, we need to add the correct indices to the advection algorithm \autoref{alg:advectionfix}. Let us add it, with \autoref{alg:advection layer} as a result. Here the ':' means all indices Lastly, we need to add the correct indices to the advection algorithm \autoref{alg:advectionfix}. Let us add it, with \autoref{alg:advection layer} as a result. Here the ':' means all indices
that the 3 dimensional matrix. of the 3 dimensional matrix.
\begin{algorithm} \begin{algorithm}
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \; $\alpha_a \leftarrow 2 \cdot 10^{-5}$ \;

View File

@ -5,9 +5,9 @@ this manual and hence has been left out. The plan was to add vertical momentum a
\subsection{Discovering That Things Are Broken} \subsection{Discovering That Things Are Broken}
While trying to add vertical momentum, it appears that some parts of the model are broken in their current state. The horizontal advection is one of the things that is broken. If you recall, While trying to add vertical momentum, it appears that some parts of the model are broken in their current state. The horizontal advection is one of the things that is broken. If you recall,
we needed to use the Laplacian operator in the advection equations (as shown in \autoref{eq:diffusion}, diffusion is considered a part of advection since diffusion transports energy and matter we needed to use the Laplacian operator in the advection equations (as shown in \autoref{eq:diffusion}, diffusion is considered a part of advection since diffusion transports energy and matter
which is what advection does as well). The Laplacian operator (as shown in \autoref{alg:laplacian layer}) does not work. It is currently unknown why that is. If a fix has been found, the original which is what advection does as well). The Laplacian operator (as shown in \autoref{alg:laplacian layer}) did not work. This is because there was a misplaced bracket causing weird numerical errors.
algorithm will be fixed accordingly (unless a lot of stuff changes and we need additional functions to be defined, then I will put a reference there to the section where it will be fixed). For This has been fixed in the code (but was never present in the manual, yay for me) and can be safely enabled, though for this stream we disabled the Laplacian operator as it has a small effect on
now we disabled the Laplacian operator as it has a small effect on the total advection (and because it is broken). the total advection (and because it was at this time broken). %The Laplacian has been re-enabled in Stream 8 (\autoref{sec:stream8}).
Another thing that we found out was broken is the vertical momentum. We tried to add it, ran into problems and just set it to 0 to fix the other problems that occured. One of those problems was Another thing that we found out was broken is the vertical momentum. We tried to add it, ran into problems and just set it to 0 to fix the other problems that occured. One of those problems was
a wrong initialisation of the density. We basically told the model that the density is the same on every layer of the atmosphere, which is obviously not true. Hence we need to adjust that. The a wrong initialisation of the density. We basically told the model that the density is the same on every layer of the atmosphere, which is obviously not true. Hence we need to adjust that. The

View File

@ -0,0 +1,113 @@
\section{Getting Radiation Right in our Climate Model! 3D Motion Here We Come} \label{sec:stream8}
The time has come to finally fix 3D motion. For this to work, we need to use a radiation scheme, which Simon \sout{shamelessly stole} got inspired by the Isca project \cite{isca}. So he followed
the references and found a paper which he is going to use in our model \cite{greyRad}. Great, so let's get into it shall we.
\subsection{Grey Radiation Scheme}
A radiation scheme is a model for how energy is redistributed using light in a system. Such a model is a Grey radiation scheme if you split it into two parts, short and long wavelength radiation.
So you have two redistribution systems, one for short wavelength light and one for long wavelength light. Another assumption we make when using the Grey radiation scheme, is that the atmosphere
is transparent to short wavelength radiation, meaning it lets through light with short wavelengths. Additionally we use a two stream approximation, which means that we have a stream of radiation
going up, and another stream of radiation going down. Note that these two streams are both long wavelength radiation, because we said earlier we assume the atmosphere completely ignores short
wavelength radiation.
The two long wavelength radiation streams are described in \autoref{eq:upward radiation} and \autoref{eq:downward radiation} \cite{greyRad}. In those equations, the symbols are:
\begin{itemize}
\item $U$: Upward flux.
\item $D$: Downward flux.
\item $B$: The Stefan-Boltzmann equation (see \autoref{eq:stefan-boltzmann}).
\item $\tau$: Optical depth.
\end{itemize}
\begin{subequations}
\begin{equation}
\frac{dU}{d\tau} = U - B
\label{eq:upward radiation}
\end{equation}
\begin{equation}
\frac{dD}{d\tau} = B - D
\label{eq:downward radiation}
\end{equation}
\end{subequations}
With \autoref{eq:upward radiation} and \autoref{eq:downward radiation} written down, we can discuss how they work. These equations need a boundary condition to work, a starting point if you like.
For those equations the boundary conditions are that $U$ is at the surface equal to $B$ and that $D$ at the top of the atmosphere is equal to $0$. Meaning that in the beginning the top of the
atmosphere has no downward flux as there is no heat there, and that the bottom of the atmosphere has a lot of upward flux as most if not all of the heat is located there. Then after the spin up
time this should stabilise. We are interested in the change of the fluxes, so $dU$ and $dD$, to get those we need to multiply the right hand side by $d\tau$. Then we have the flow of radiation
that we need. However we cannot solely use these two equations to calculate the heat of a given layer. For that we need a few more components. These are described in \autoref{eq:heat layer}.
Here $Q_R$ is the amount of heat in a layer, $c_p$ is the specific heat capacity of dry air (our atmosphere), $\rho$ is the density of the air in that layer and $\delta z$ is the change in height.
$\delta U - D$ are the change in net radiation, meaning the amount of radiation that is left over after you transferred the upward and downward flux. See it as incoming and outgoing energy for a
given layer, the net change (either cooling down or heating up) is what remains after you have subtracted the incoming energy from the outgoing energy. While this explanation is not entirely true
(as flux is not entirely equivalent to energy), it explains the concept the best.
\begin{equation}
Q_R = \frac{1}{c_p\rho}\frac{\delta(U - D)}{\delta z}
\label{eq:heat layer}
\end{equation}
Now only one question remains: what is optical depth? Optical depth is the amount of work a photon has had to do to get to a certain point. This might sound really vague, but bear with me.
Optical depth describes how much stuff a certain photon has had to go through to get to a point. As you'd expect this is $0$ at the top of the atmosphere as space is a big vacuum so no stuff to
move through, so no work. Then the further the photon moves into the atmosphere, the more work the photon has had to do to get there. This is because it now needs to move through gases, like air,
water vapour and other gases. Hence the closer the photon gets to the surface of the planet, the larger the optical depth is because the photon has had to work more to get there. This phenomenon
is described in \autoref{eq:optical depth}. The symbols in the equation mean:
\begin{itemize}
\item $\tau_0$: Optical depth at the surface.
\item $p$: Atmospheric pressure ($Pa$).
\item $p_s$: Atmospheric pressure at the surface ($Pa$).
\item $f_l$: The linear optical depth parameter, with a value of 0.1.
\end{itemize}
\begin{equation}
\tau = \tau_0[f_l(\frac{p}{p_s}) + (1 - f_l)(\frac{p}{p_s})^4]
\label{eq:optical depth}
\end{equation}
As one can see, \autoref{eq:optical depth} has two parts, a linear part and a quatric part (to the power $4$). The quatric term approximates the structure of water vapour in the atmosphere, which
roughly scales with $\frac{1}{4}$ with respect to the height. The linear term is present to fix numerical behaviour because this is an approximation which will not be completely correct (that's
why it is an approximation) so we add this term to make it roughly right. The same thing holds for $f_l$ which can be manually tuned to fix weird numerical behaviour.
\subsection{Getting the equations to code}
With these equations in our mind, let's get coding. First we add the pressure profile, the pressure of all atmospheric layers at a lat lon point. We need this to accurately represent the optical
depth per atmospheric layer. Then we need to use the pressure profile with regards to \autoref{eq:optical depth}. The resulting code can be found in \autoref{alg:optical depth}. This algorithm
replaces the temperature calculations we have done in \autoref{alg:temperature layer}, as this is basically a better version of the calculations done in that algorithm. $f_l$ has a value of $0.1$
and is located near all the other constants in the code, henceforth we will refer to this section in the code as the control panel, since most if not all of the constants can be tweaked here.
$\tau_0$ is a function that gives the surface optical depth for a given latitude. The corresponding equation can be found in \autoref{eq:optical depth surface} \cite{simon}. Translating this
into code is left as an exercise to the reader. $U[0]$ is the boundary condition discussed before (being the same as \autoref{eq:stefan-boltzmann}), just as $D[nlevels]$ is the boundary condition.
$S_z$ represents the call to \autoref{alg:gradient z layer}.
\begin{algorithm}
\For{$lat \in [-nlat, nlat]$}{
\For{$lon \in [0, nlon]$}{
$pressureProfile \leftarrow p[i,j,:]$ \;
$\tau = \tau_0(lat)f_l\frac{pressureProfile}{pressureProfile[0]} + (1 - f_l)(\frac{pressureProfile}{pressureProfile[0]})^4)$ \;
$U[0] \leftarrow \sigma T_p[lat, lon]^4$ \;
\For{$level \in [1, nlevels]$}{
$U[level] \leftarrow U[level - 1] + (\tau[level] - \tau[level - 1])(U[level - 1] - \sigma \cdot (mean(T_a[:, :, level]))^4)$ \;
}
$D[nlevels] \leftarrow 0$ \;
\For{$level \in [nlevels - 1, 0]$}{
$D[level] \leftarrow (\tau[level] - \tau[level - 1])(\sigma \cdot (mean(T_a[:, :, level]))^4) - D[level + 1]$ \;
}
\For{$level \in [0, nlevels]$}{
$Q[level] \leftarrow - \frac{S_z(U - D, 0, 0, level)}{10^3 \cdot densityProfile[level]}$ \;
}
$T_a[lat, lon, :] \leftarrow T_a[lat, lon, :] + Q$ \;
}
}
\caption{Adding in radiation}
\label{alg:optical depth}
\end{algorithm}
\begin{equation}
\tau_0 = 3.75 + \cos(lat \frac{\pi}{90})\frac{4.5}{2}
\label{eq:optical depth surface}
\end{equation}
Note that in this form, it did not work on stream yet. This may be due to a coding error or to a missing equation, constant or something similar. If it turns out to be a simple fix, then it will
be fixed in this section. If a lot of other things change in order for the fix to work, then it will probably be a seperate section with a reference to that section here.

View File

@ -284,4 +284,26 @@ publisher={Wikimedia Foundation},
author={Beldin, Dick}, author={Beldin, Dick},
year={2020}, year={2020},
month={May} month={May}
}
@article{isca,
title={Isca, v1.0: a framework for the global modelling of the atmospheres of Earth and other planets at varying levels of complexity},
volume={11},
DOI={10.5194/gmd-11-843-2018},
number={3},
journal={Geoscientific Model Development},
author={Vallis, Geoffrey K. and Colyer, Greg and Geen, Ruth and Gerber, Edwin and Jucker, Martin and Maher, Penelope and Paterson, Alexander and Pietschnig, Marianne and Penn, James and Thomson, Stephen I. and et al.},
year={2018},
pages={843859}
}
@article{greyRad,
title={A Gray-Radiation Aquaplanet Moist GCM. Part I: Static Stability and Eddy Scale},
volume={63},
DOI={10.1175/jas3753.1},
number={10},
journal={Journal of the Atmospheric Sciences},
author={Frierson, Dargan M. W. and Held, Isaac M. and Zurita-Gotor, Pablo},
year={2006},
pages={25482566}
} }