mirror of https://github.com/Askill/claude.git
Finished the rewrite
This commit is contained in:
parent
47a20e14d6
commit
cf4c8b8311
BIN
CLAuDE NOM.pdf
BIN
CLAuDE NOM.pdf
Binary file not shown.
|
|
@ -25,13 +25,9 @@ Now to get this into code we need the following algorithms \autoref{alg:laplacia
|
|||
\autoref{alg:diffusion} implements the diffusion calculations. $\nabla^2$ in \autoref{alg:diffusion} represents the call to \autoref{alg:laplacian}.
|
||||
|
||||
\begin{algorithm}
|
||||
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \;
|
||||
$\alpha_p \leftarrow 1.5 \cdot 10^{-6}$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
$T_a \leftarrow T_a + \delta t \alpha_a \nabla^2(T_a)$ \;
|
||||
$T_p \leftarrow T_p + \delta t \alpha_p \nabla^2(T_p)$ \;
|
||||
}
|
||||
\caption{The main loop for calculating the effects of diffusion}
|
||||
\caption{The main calculations for calculating the effects of diffusion}
|
||||
\label{alg:diffusion}
|
||||
\end{algorithm}
|
||||
|
||||
|
|
@ -55,14 +51,10 @@ With the divergence functon defined in \autoref{alg:divergence}, we now need to
|
|||
\autoref{alg:advection}. Here $\nabla$ represents the function call to \autoref{alg:divergence}.
|
||||
|
||||
\begin{algorithm}
|
||||
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \;
|
||||
$\alpha_p \leftarrow 1.5 \cdot 10^{-6}$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
$T_{add} \leftarrow T_a + \delta t \alpha_a \nabla^2(T_a) + \nabla(T_a)$ \;
|
||||
$T_a \leftarrow T_a + T_{add}[5:-5, :] \text{ //Only add } T_{add} \text{ to } T_a \text{ for indices in the interval } [-nlat + 5, nlat - 5]$. \;
|
||||
$T_p \leftarrow T_p + \delta t \alpha_p \nabla^2(T_p)$ \;
|
||||
}
|
||||
\caption{The main loop for calculating the effects of advection}
|
||||
\caption{The main calculations for calculating the effects of diffusion}
|
||||
\label{alg:advection}
|
||||
\end{algorithm}
|
||||
|
||||
|
|
@ -82,15 +74,11 @@ to calculate $\rho$ after the movement of air has taken place, so we need to cha
|
|||
|
||||
|
||||
\begin{algorithm}
|
||||
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \;
|
||||
$\alpha_p \leftarrow 1.5 \cdot 10^{-6}$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
$T_{add} \leftarrow T_a + \delta t \alpha_a \nabla^2(T_a) + \nabla(T_a)$ \;
|
||||
$T_a \leftarrow T_a + T_{add}[5:-5, :] \text{ //Only add } T_{add} \text{ to } T_a \text{ for indices in the interval } [-nlat + 5, nlat - 5]$. \;
|
||||
$\rho \leftarrow \rho + \delta t \nabla \rho$ \;
|
||||
$T_p \leftarrow T_p + \delta t \alpha_p \nabla^2(T_p)$ \;
|
||||
}
|
||||
\caption{The main loop for calculating the effects of advection}
|
||||
\caption{The main calculations for calculating the effects of diffusion}
|
||||
\label{alg:advectionv2}
|
||||
\end{algorithm}
|
||||
|
||||
|
|
@ -100,16 +88,11 @@ we are going to define boundaries and assume that the advection only works withi
|
|||
boundary.
|
||||
|
||||
\begin{algorithm}
|
||||
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \;
|
||||
$\alpha_p \leftarrow 1.5 \cdot 10^{-6}$ \;
|
||||
$boundary \leftarrow 7$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
$T_{add} \leftarrow T_a + \delta t \alpha_a \nabla^2(T_a) + \nabla(T_a)$ \;
|
||||
$T_a \leftarrow T_a - 0.5T_{add}[boundary:-boundary, :] \text{ //Only subtract } T_{add} \text{ to } T_a \text{ for indices in the interval } [-nlat + boundary, nlat - boundary]$. \;
|
||||
$\rho[boundary: -boundary, :] \leftarrow \rho - 0.5(\delta t \nabla \rho) \text{ //Only change the density for indices in the interval } [-nlat + boundary, nlat - boundary]$ \;
|
||||
$T_a \leftarrow T_a - 0.5T_{add}[adv\_bound:-adv\_boun, :] \text{ //Only subtract } T_{add} \text{ to } T_a \text{ for indices in the interval } [-nlat + adv\_boun, nlat - adv\_boun]$. \;
|
||||
$\rho[adv\_boun: -adv\_boun, :] \leftarrow \rho - 0.5(\delta t \nabla \rho) \text{ //Only change the density for indices in the interval } [-nlat + adv\_boun, nlat - adv\_boun]$ \;
|
||||
$T_p \leftarrow T_p + \delta t \alpha_p \nabla^2(T_p)$ \;
|
||||
}
|
||||
\caption{The main loop for calculating the effects of advection}
|
||||
\caption{The main calculations for calculating the effects of diffusion}
|
||||
\label{alg:advectionfix}
|
||||
\end{algorithm}
|
||||
|
||||
|
|
@ -118,16 +101,11 @@ With the atmospheric layers, and all matrices that have an extra dimension to ac
|
|||
add it, with \autoref{alg:advection layer} as a result. Here the ':' means all indices of the 3 dimensional matrix.
|
||||
|
||||
\begin{algorithm}
|
||||
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \;
|
||||
$\alpha_p \leftarrow 1.5 \cdot 10^{-6}$ \;
|
||||
$boundary \leftarrow 7$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
$T_{add} \leftarrow T_a + \delta t \alpha_a \nabla^2(T_a) + \nabla(T_a)$ \;
|
||||
$T_a \leftarrow T_a - 0.5T_{add}[boundary:-boundary, :, :] \text{ //Only subtract } T_{add} \text{ to } T_a \text{ for indices in the interval } [-nlat + boundary, nlat - boundary]$. \;
|
||||
$\rho[boundary: -boundary, :, :] \leftarrow \rho - 0.5(\delta t \nabla \rho) \text{ //Only change the density for indices in the interval } [-nlat + boundary, nlat - boundary]$ \;
|
||||
$T_a \leftarrow T_a - 0.5T_{add}[adv\_boun:-adv\_boun, :, :] \text{ //Only subtract } T_{add} \text{ to } T_a \text{ for indices in the interval } [-nlat + adv\_boun, nlat - adv\_boun]$. \;
|
||||
$\rho[adv\_boun: -adv\_boun, :, :] \leftarrow \rho - 0.5(\delta t \nabla \rho) \text{ //Only change the density for indices in the interval } [-nlat + adv\_boun, nlat - adv\_boun]$ \;
|
||||
$T_p \leftarrow T_p + \delta t \alpha_p \nabla^2(T_p)$ \;
|
||||
}
|
||||
\caption{The main loop for calculating the effects of advection}
|
||||
\caption{The main calculations for calculating the effects of diffusion}
|
||||
\label{alg:advection layer}
|
||||
\end{algorithm}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ definitions can be found in \autoref{alg:model constants}. What the $adv$ boolea
|
|||
$C_a \leftarrow 287$ \Comment*[l]{Heat capacity of the atmosphere in $JKg^{-1}K^{-1}$}
|
||||
$C_p \leftarrow 1 \cdot 10^6$ \Comment*[l]{Heat capacity of the planet in $JKg^{-1}K^{-1}$}
|
||||
$\delta y \leftarrow \frac{2\pi r}{nlat}$ \Comment*[l]{How far apart the gridpoints in the y direction are (degrees latitude)}
|
||||
$\alpha_a \leftarrow 2 \cdot 10^{-5}$ \Comment*[l]{The diffusivity constant for the atmosphere}
|
||||
$\alpha_p \leftarrow 1.5 \cdot 10^{-6}$ \Comment*[l]{The diffusivity constant for the planet surface}
|
||||
|
||||
$count \leftarrow 0$ \;
|
||||
\For{$j \in [0, top]$}{
|
||||
|
|
|
|||
|
|
@ -41,6 +41,23 @@ the timestep and enables flow simulation. At this point in time, the advection i
|
|||
\label{alg:spinup}
|
||||
\end{algorithm}
|
||||
|
||||
\subsection{Varying the Albedo}
|
||||
The albdeo (reflectiveness of the planet's surface) is of course not the same over the whole planet. To account for this, we instead vary the albedo slightly for each point in the latitude
|
||||
longitude grid. The algorithm that does this is shown in \autoref{alg:albedo variance}. The uniform distribution basically says that each allowed value in the interval has an equal chance of
|
||||
being picked \cite{uniformdist}.
|
||||
|
||||
\begin{algorithm}
|
||||
$V_a \leftarrow 0.02$ \;
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
\For{$lon \in [0, nlon]$}{
|
||||
$R \leftarrow \text{ Pick a random number (from the uniform distribution) in the interval } [-V_a, V_a]$ \;
|
||||
$a[lat, lon] \leftarrow a[lat, lon] + V_a \cdot R$\;
|
||||
}
|
||||
}
|
||||
\caption{Varying the albedo of the planet}
|
||||
\label{alg:albedo variance}
|
||||
\end{algorithm}
|
||||
|
||||
\subsection{Non-uniform air density}
|
||||
While air density on the surface is in general consistent, this does not hold if you move up through the atmosphere. The planet will pull air down due to gravity, which means that more air is at
|
||||
the planet surface than at the top of the atmosphere. Hence the air density changes throughout the atmosphere and we need to account for that. This is done in \autoref{alg:density}. Because this
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ that $S$ is defined as the call to \autoref{alg:solar}.
|
|||
\SetAlgoLined
|
||||
\SetKwInput{Input}{Input}
|
||||
\SetKwInOut{Output}{Output}
|
||||
\Input{time $t$, amount of energy that hits the planet $S$}
|
||||
\Input{amount of energy that hits the planet $S$}
|
||||
\Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$}
|
||||
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
|
|
@ -227,7 +227,7 @@ reflected instead of absorbed, where we need the amount that is absorbed which i
|
|||
\SetAlgoLined
|
||||
\SetKwInput{Input}{Input}
|
||||
\SetKwInOut{Output}{Output}
|
||||
\Input{time $t$, amount of energy that hits the planet $S$}
|
||||
\Input{amount of energy that hits the planet $S$}
|
||||
\Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$}
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
\For{$lon \in [0, nlot]$}{
|
||||
|
|
@ -247,36 +247,18 @@ The air density is not at all points exactly the same. This may be due to the wi
|
|||
\SetAlgoLined
|
||||
\SetKwInput{Input}{Input}
|
||||
\SetKwInOut{Output}{Output}
|
||||
\Input{time $t$, amount of energy that hits the planet $S$}
|
||||
\Input{amount of energy that hits the planet $S$}
|
||||
\Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$}
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
\For{$lon \in [0, nlot]$}{
|
||||
$T_p[lat, lon] \leftarrow T_p[lat, lon] + \frac{\delta t ((1 - a[lat, lon])S + 4\epsilon \sigma (T_a[lat, lon])^4 - 4\sigma (T_p[lat, lon])^4)}{\rho[lat, lon]C_p[lat, lon]}$ \;
|
||||
$T_a[lat, lon] \leftarrow T_a[lat, lon] + \frac{\delta t (\sigma (T_p[lat, lon])^4 - 2\epsilon\sigma (T_a[lat, lon])^4)}{\rho[lat, lon]C_a}$ \;
|
||||
$t \leftarrow t + \delta t$ \;
|
||||
}
|
||||
}
|
||||
\caption{The main loop of the temperature calculations}
|
||||
\label{alg:temperature with density}
|
||||
\end{algorithm}
|
||||
|
||||
\subsection{Varying the Albedo}
|
||||
The albdeo (reflectiveness of the planet's surface) is of course not the same over the whole planet. To account for this, we instead vary the albedo slightly for each point in the latitude
|
||||
longitude grid. The algorithm that does this is shown in \autoref{alg:albedo variance}. The uniform distribution basically says that each allowed value in the interval has an equal chance of
|
||||
being picked \cite{uniformdist}.
|
||||
|
||||
\begin{algorithm}
|
||||
$V_a \leftarrow 0.02$ \;
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
\For{$lon \in [0, nlon]$}{
|
||||
$R \leftarrow \text{ Pick a random number (from the uniform distribution) in the interval } [-V_a, V_a]$ \;
|
||||
$a[lat, lon] \leftarrow a[lat, lon] + V_a \cdot R$\;
|
||||
}
|
||||
}
|
||||
\caption{Varying the albedo of the planet}
|
||||
\label{alg:albedo variance}
|
||||
\end{algorithm}
|
||||
|
||||
\subsection{Adding Layers}
|
||||
Remember \autoref{eq:atmos change}? We need this equation for every layer in the atmosphere. This also means that we have to adjust the main calculation of the code, which is described in
|
||||
\autoref{alg:temperature with density}. The $T_a$ needs to change, we need to either add a dimension (to indicate which layer of the atmosphere we are talking about) or we need to add different
|
||||
|
|
@ -308,6 +290,10 @@ regards to the storage of the values) by the addition of multiple atmospheric la
|
|||
|
||||
\begin{algorithm}[hbt]
|
||||
\SetAlgoLined
|
||||
\SetKwInput{Input}{Input}
|
||||
\SetKwInOut{Output}{Output}
|
||||
\Input{amount of energy that hits the planet $S$}
|
||||
\Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$}
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
\For{$lon \in [0, nlot]$}{
|
||||
\For{$layer \in [0, nlevels]$}{
|
||||
|
|
@ -323,7 +309,6 @@ regards to the storage of the values) by the addition of multiple atmospheric la
|
|||
$T_a[lat, lon, layer] \leftarrow T_a[lat, lon, layer] + \frac{\delta t \sigma(\epsilon[layer - 1](T_a[lat, lon, layer - 1])^4 + \epsilon[layer + 1]T_a[lat, lon, layer + 1]
|
||||
- 2\epsilon[layer](T_a[lat, lon, layer])^4)}{\rho[lat, lon, layer]C_a\delta z[layer]}$ \;
|
||||
}
|
||||
$t \leftarrow t + \delta t$ \;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -417,6 +402,10 @@ into code is left as an exercise to the reader. $U[0]$ is the boundary condition
|
|||
$S_z$ represents the call to \autoref{alg:gradient z}. \texttt{solar} represents the call to \autoref{alg:solar}.
|
||||
|
||||
\begin{algorithm}
|
||||
\SetKwInput{Input}{Input}
|
||||
\SetKwInOut{Output}{Output}
|
||||
\Input{amount of energy that hits the planet $S$}
|
||||
\Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$}
|
||||
\For{$lat \in [-nlat, nlat]$}{
|
||||
\For{$lon \in [0, nlon]$}{
|
||||
$pressureProfile \leftarrow p[lat, lon, :]$ \;
|
||||
|
|
|
|||
|
|
@ -98,14 +98,12 @@ With the gradient functions defined in \autoref{alg:gradient x} and \autoref{alg
|
|||
$S_{yv} \leftarrow \texttt{gradient\_y}(v, lan, lon)$ \;
|
||||
$S_{px} \leftarrow \texttt{gradient\_x}(p, lan, lon)$ \;
|
||||
$S_{py} \leftarrow \texttt{gradient\_x}(p, lan, lon)$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
\For{$lat \in [1, nlat - 1]$}{
|
||||
\For{$lon \in [0, nlon]$}{
|
||||
$u[lan, lon] \leftarrow u[lan, lon] + \delta t \frac{-u[lan, lon]S_{xu} - v[lan, lon]S_{yu} + f[lan]v[lan, lon] - S_{px}}{\rho}$ \;
|
||||
$v[lan, lon] \leftarrow v[lan, lon] + \delta t \frac{-u[lan, lon]S_{xv} - v[lan, lon]S_{yv} - f[lan]u[lan, lon] - S_{py}}{\rho}$ \;
|
||||
}
|
||||
}
|
||||
}
|
||||
\caption{Calculating the flow of the atmosphere (wind)}
|
||||
\label{alg:stream3}
|
||||
\end{algorithm}
|
||||
|
|
@ -143,7 +141,6 @@ then so does $y$.}
|
|||
$S_{yv} \leftarrow \texttt{gradient\_y}(v, lan, lon)$ \;
|
||||
$S_{px} \leftarrow \texttt{gradient\_x}(p, lan, lon)$ \;
|
||||
$S_{py} \leftarrow \texttt{gradient\_y}(p, lan, lon)$ \;
|
||||
\While{\texttt{TRUE}}{
|
||||
\For{$lat \in [1, nlat - 1]$}{
|
||||
\For{$lon \in [0, nlon]$}{
|
||||
\For{$layer \in [0, nlevels]$}{
|
||||
|
|
@ -152,7 +149,6 @@ then so does $y$.}
|
|||
$w[lan, lon, layer] \leftarrow w[lat, lon, layer] - \frac{p[lat, lon, layer] - p_o[lat, lon, layer]}{\delta t\rho[lat, lon, layer]g}$ \;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$p_o \leftarrow copy(p)$ \;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue