From 46e5bd6254a8fe33490a2fb94f17ab813a012ebf Mon Sep 17 00:00:00 2001 From: TechWizzart Date: Mon, 21 Sep 2020 13:50:35 +0200 Subject: [PATCH] Changed notation of the for loops in the algorithms and fixed incorrect algorithm names --- tex-docs/topics/advection.tex | 8 +++--- tex-docs/topics/master.tex | 2 +- tex-docs/topics/radiation.tex | 52 +++++++++++++++++----------------- tex-docs/topics/util_funcs.tex | 43 +++++++++++++--------------- tex-docs/topics/velocity.tex | 12 ++++---- 5 files changed, 57 insertions(+), 60 deletions(-) diff --git a/tex-docs/topics/advection.tex b/tex-docs/topics/advection.tex index 2eb659d..8a297e7 100644 --- a/tex-docs/topics/advection.tex +++ b/tex-docs/topics/advection.tex @@ -54,7 +54,7 @@ With the divergence functon defined in \autoref{alg:divergence}, we now need to $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 calculations for calculating the effects of diffusion} + \caption{The main calculations for calculating the effects of advection} \label{alg:advection} \end{algorithm} @@ -78,7 +78,7 @@ to calculate $\rho$ after the movement of air has taken place, so we need to cha $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 calculations for calculating the effects of diffusion} + \caption{The main calculations for calculating the effects of advection} \label{alg:advectionv2} \end{algorithm} @@ -92,7 +92,7 @@ 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 calculations for calculating the effects of diffusion} + \caption{The main calculations for calculating the effects of advection} \label{alg:advectionfix} \end{algorithm} @@ -105,7 +105,7 @@ add it, with \autoref{alg:advection layer} as a result. Here the ':' means all i $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 calculations for calculating the effects of diffusion} + \caption{The main calculations for calculating the effects of advection} \label{alg:advection layer} \end{algorithm} diff --git a/tex-docs/topics/master.tex b/tex-docs/topics/master.tex index 4e62f39..f281fba 100644 --- a/tex-docs/topics/master.tex +++ b/tex-docs/topics/master.tex @@ -21,7 +21,7 @@ calculations in \autoref{alg:temperature with density} we would calculate the ve } } } - \caption{Main loop that can simulate flow and advection conditionally} + \caption{Main loop that can simulate velocities and advection conditionally} \label{alg:stream4v1} \end{algorithm} diff --git a/tex-docs/topics/radiation.tex b/tex-docs/topics/radiation.tex index ee1525a..36a1c4e 100644 --- a/tex-docs/topics/radiation.tex +++ b/tex-docs/topics/radiation.tex @@ -146,13 +146,13 @@ we change that) amd the current time is obviously not constant. All constants ca \SetKwInOut{Output}{Output} \Input{time $t$, amount of energy that hits the planet $S$} \Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$} - \For{$lat \in [-90, 90]$}{ - \For{$lon \in [0, 360]$}{ + \For{$lat \leftarrow -90$ \KwTo $90$}{ + \For{$lon \leftarrow 0$ \KwTo $360$}{ $T_p[lat, lon] \leftarrow T_p[lat, lon] + \frac{\delta t (S + 4\epsilon \sigma (T_a[lat, lon])^4 - 4\sigma (T_p[lat, lon])^4)}{C_p}$ \; $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)}{C_a}$ \; } } - \caption{The main function of the temperature calculations} + \caption{The main function for the temperature calculations} \label{alg:stream1v1} \end{algorithm} @@ -197,13 +197,13 @@ that $S$ is defined as the call to \autoref{alg:solar}. \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{$lat \leftarrow -nlat$ \KwTo $nlat$}{ + \For{$lon \leftarrow 0$ \KwTo $nlot$}{ $T_p[lat, lon] \leftarrow T_p[lat, lon] + \frac{\delta t (S + 4\epsilon \sigma (T_a[lat, lon])^4 - 4\sigma (T_p[lat, lon])^4)}{C_p}$ \; $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)}{C_a}$ \; } } - \caption{The main function of the temperature calculations} + \caption{The main function for the temperature calculations} \label{alg:stream1v2} \end{algorithm} @@ -229,13 +229,13 @@ reflected instead of absorbed, where we need the amount that is absorbed which i \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{$lat \leftarrow -nlat$ \KwTo $nlat$}{ + \For{$lon \leftarrow 0$ \KwTo $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)}{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)}{C_a}$ \; } } - \caption{The main loop of the temperature calculations} + \caption{The main function for the temperature calculations} \label{alg:stream2v3} \end{algorithm} @@ -249,13 +249,13 @@ The air density is not at all points exactly the same. This may be due to the wi \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{$lat \leftarrow -nlat$ \KwTo $nlat$}{ + \For{$lon \leftarrow 0$ \KwTo $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}$ \; } } - \caption{The main loop of the temperature calculations} + \caption{The main function for the temperature calculations} \label{alg:temperature with density} \end{algorithm} @@ -294,15 +294,15 @@ regards to the storage of the values) by the addition of multiple atmospheric la \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]$}{ + \For{$lat \leftarrow -nlat$ \KwTo $nlat$}{ + \For{$lon \leftarrow 0$ \KwTo $nlot$}{ + \For{$layer \leftarrow 0$ \KwTo $nlevels$}{ $T_p[lat, lon] \leftarrow T_p[lat, lon] + \frac{\delta t ((1 - a[lat, lon])S + \sigma(4\epsilon[0](T_a[lat, lon, 0])^4 - 4(T_p[lat, lon])^4))} {4C_p[lat, lon]}$ \; - \uIf{$layer == 0$}{ + \uIf{$layer = 0$}{ $T_a[lat, lon, layer] \leftarrow T_a[lat, lon, layer] + \frac{\delta t \sigma((T_p[lat, lon])^4 - 2\epsilon[layer](T_a[lat, lon, layer])^4)} {\rho[lat, lon, layer]C_a\delta z[layer]}$ \; - }\uElseIf{$layer == nlevels - 1$}{ + }\uElseIf{$layer = nlevels - 1$}{ $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 - 2\epsilon[layer](T_a[lat, lon, layer])^4)} {\rho[lat, lon, layer]C_a\delta z[layer]}$ \; }\uElse{ @@ -312,7 +312,7 @@ regards to the storage of the values) by the addition of multiple atmospheric la } } } - \caption{The main loop of the temperature calculations} + \caption{The main function for the temperature calculations} \label{alg:temperature layer} \end{algorithm} @@ -320,7 +320,7 @@ We also need to initialise the $\epsilon$ value for each layer. We do that in \a \begin{algorithm} $\epsilon[0] \leftarrow 0.75$ \; - \For{$i \in [1, nlevels]$}{ + \For{$i \leftarrow 1$ \KwTo $nlevels$}{ $\epsilon[i] \leftarrow 0.5\epsilon[i - 1]$ } \caption{Intialisation of the insulation of each layer (also known as $\epsilon$)} @@ -406,23 +406,23 @@ $S_z$ represents the call to \autoref{alg:gradient z}. \texttt{solar} represents \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]$}{ + \For{$lat \leftarrow -nlat$ \KwTo $nlat$}{ + \For{$lon \leftarrow 0$ \KwTo $nlot$}{ $pressureProfile \leftarrow p[lat, lon, :]$ \; $\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]$}{ + \For{$level \leftarrow 1$ \KwTo $nlevels$}{ $U[level] \leftarrow U[level - 1] - \frac{(\tau[level] - \tau[level - 1])(\sigma \cdot (mean(T_a[:, :, level]))^4)}{1 + (\tau[level - 1] - \tau[level])}$ \; } $D[nlevels - 1] \leftarrow 0$ \; - \For{$level \in [nlevels - 1, 0]$}{ + \For{$level \leftarrow nleves - 1$ \KwTo $0$}{ $D[level] \leftarrow D[level + 1] - \frac{(\tau[level + 1] - \tau[level])(\sigma \cdot (mean(T_a[:, :, level]))^4)}{1 + (\tau[level] - \tau[level + 1])}$ \; } - \For{$level \in [0, nlevels]$}{ + \For{$level \leftarrow 0$ \KwTo $nlevels$}{ $Q[level] \leftarrow - \frac{S_z(U - D, 0, 0, level)}{10^3 \cdot densityProfile[level]}$ \; } @@ -433,7 +433,7 @@ $S_z$ represents the call to \autoref{alg:gradient z}. \texttt{solar} represents $T_p[lat, lon] \leftarrow T_p[lat, lon] \frac{\delta t((1 - a[lat, lon]) S + S_z(D, 0, 0, 0) - \sigma T_p[lat, lon]^4)}{C_p[lat ,lon]}$ \; } } - \caption{Adding in radiation} + \caption{Main function for calculating the temperature using radiation} \label{alg:optical depth} \end{algorithm} @@ -450,7 +450,7 @@ $Q$. We add in a check to see if we are currently calculating the radiation in t height. \begin{algorithm} - \For{$level \in [0, nlevels]$}{ + \For{$level \leftarrow 0$ \KwTo $nlevels$}{ $Q[level] \leftarrow - \frac{S_z(U - D, 0, 0, level)}{10^3 \cdot densityProfile[level]}$ \; \uIf{$heights[level] > 20 \cdot 10^3$}{ $Q[level] \leftarrow Q[level] + \texttt{solar}(5, lat, lon, t) \frac{24 \cdot 60 \cdot 60(\frac{heights[level] - 20 \cdot 10^3}{10^3})^2}{30^2}$ \; diff --git a/tex-docs/topics/util_funcs.tex b/tex-docs/topics/util_funcs.tex index bf845f9..3b94f4f 100644 --- a/tex-docs/topics/util_funcs.tex +++ b/tex-docs/topics/util_funcs.tex @@ -23,7 +23,7 @@ calculations we will do later on. \SetKwInOut{Output}{Output} \Input{Matrix (double array) $a$, first index $i$, second index $j$, third index $k$ with default value \texttt{NULL}} \Output{Gradient in the $x$ direction} - \eIf{$k == \texttt{NULL}$}{ + \eIf{$k = \texttt{NULL}$}{ $grad \leftarrow \frac{a[i, (j + 1)\text{ mod } nlon] - a[i, (j - 1) \text{ mod } nlon]}{\delta x[i]}$ \; }{ $grad \leftarrow \frac{a[i, (j + 1)\text{ mod } nlon, k] - a[i, (j - 1) \text{ mod } nlon, k]}{\delta x[i]}$ \; @@ -38,18 +38,18 @@ calculations we will do later on. \SetKwInOut{Output}{Output} \Input{Matrix (double array) $a$, first index $i$, second index $j$, third index $k$ with default value \texttt{NULL}} \Output{Gradient in the $y$ direction} - \eIf{$k == \texttt{NULL}$}{ + \eIf{$k = \texttt{NULL}$}{ \uIf{$i == 0$}{ $grad \leftarrow 2 \frac{a[i + 1, j] - a[i, j]}{\delta y}$ \; - }\uElseIf{$i == nlat - 1$}{ + }\uElseIf{$i = nlat - 1$}{ $grad \leftarrow 2 \frac{a[i, j] - a[i - 1, j]}{\delta y}$ \; }\uElse{ $grad \leftarrow \frac{a[i + 1, j] - a[i - 1 j]}{\delta y}$ \; } }{ - \uIf{$i == 0$}{ + \uIf{$i = 0$}{ $grad \leftarrow 2 \frac{a[i + 1, j, k] - a[i, j, k]}{\delta y}$ \; - }\uElseIf{$i == nlat - 1$}{ + }\uElseIf{$i = nlat - 1$}{ $grad \leftarrow 2 \frac{a[i, j, k] - a[i - 1, j, k]}{\delta y}$ \; }\uElse{ $grad \leftarrow \frac{a[i + 1, j] - a[i - 1 j]}{\delta y}$ \; @@ -65,18 +65,18 @@ calculations we will do later on. \SetKwInOut{Output}{Output} \Input{Matrix (double array) $a$, first index $i$, second index $j$, third index $k$} \Output{Gradient in the $z$ direction} - \uIf{$a.dimensions == 1$}{ - \uIf{$k == 0$}{ + \uIf{$a.dimensions = 1$}{ + \uIf{$k = 0$}{ $grad \leftarrow \frac{a[k + 1] - a[k]}{\delta z[k]}$ \; - }\uElseIf{$k == nlevels - 1$}{ + }\uElseIf{$k = nlevels - 1$}{ $grad \leftarrow \frac{a[k] - a[k - 1]}{\delta z[k]}$ \; }\uElse{ $grad \leftarrow \frac{a[k + 1] - a[k - 1]}{2\delta z[k]}$ \; } } \uElse { - \uIf{$k == 0$}{ + \uIf{$k = 0$}{ $grad \leftarrow \frac{a[i, j, k + 1] - a[i, j, k]}{\delta z[k]}$ \; - }\uElseIf{$k == nlevels - 1$}{ + }\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]}$ \; @@ -131,17 +131,17 @@ respectively. \SetKwInOut{Output}{Output} \Input{A matrix (double array) a} \Output{A matrix (double array) with results for the laplacian operator for each element} - \eIf{$a.dimensions == 2$}{ - \For{$lat \in [1, nlat - 1]$}{ - \For{$lon \in [0, nlon]$}{ + \eIf{$a.dimensions = 2$}{ + \For{$lat \leftarrow 1$ \KwTo $nlat - 1$}{ + \For{$lon \leftarrow 0$ \KwTo $nlon$}{ $output[lat, lon] \leftarrow \frac{\Delta_x(a, lat, (lon + 1) \text{ mod } nlon) - \Delta_x(a, lat, (lon - 1) \text{ mod } nlon)}{\delta x[lat]} + \frac{\Delta_y(a, lat + 1, lon) - \Delta_y(a, lat - 1, lon)}{\delta y}$\; } } }{ - \For{$lat \in [1, nlat - 1]$}{ - \For{$lon \in [0, nlon]$}{ - \For{$k \in [0, nlevels - 1]$}{ + \For{$lat \leftarrow 1$ \KwTo $nlat - 1$}{ + \For{$lon \leftarrow 0$ \KwTo $nlon$}{ + \For{$k \leftarrow 0$ \KwTo $nlevels - 1$}{ $output[lat, lon, k] \leftarrow \frac{\Delta_x(a, lat, (lon + 1) \text{ mod } nlon, k) - \Delta_x(a, lat, (lon - 1) \text{ mod } nlon, k)}{\delta x[lat]} + \frac{\Delta_y(a, lat + 1, lon, k) - \Delta_y(a, lat - 1, lon, k)}{\delta y} + \frac{\Delta_z(a, lat, lon, k + 1) - \Delta_z(a, lat, lon, k + 1)}{2\delta z[k]}$\; } @@ -164,12 +164,9 @@ as we expect that we might use it in combination with the divergence operator mo \SetKwInOut{Output}{Output} \Input{A matrix (double array) $a$} \Output{A matrix (double array) containing the result of the divergence operator taken over that element} - $dim_1 \leftarrow \text{ Length of } a \text{ in the first dimension}$ \; - \For{$i \in [0, dim_1]$}{ - $dim_2 \leftarrow \text{ Length of } a \text{ in the second dimension (i.e. the length of the array stored at index } i)$ \; - \For{$j \in [0, dim_2]$}{ - $dim_3 \leftarrow \text{ Length of } a \text{ in the third dimension}$ \; - \For{$k \in [0, dim_3]$}{ + \For{$i \leftarrow 0$ \KwTo $a.length$}{ + \For{$j \leftarrow 0$ \KwTo $a[i].length$}{ + \For{$k \leftarrow 0$ \KwTo $a[i, j].length$}{ $output[i, j, k] \leftarrow \Delta_x(au, i, j, k) + \Delta_y(av, i, j, k) + \Delta_z(aw, i, j, k)$ \; } } @@ -275,7 +272,7 @@ This symmetry as it is called can be exploited to produce a divide and conquer a } \uElse{ $B[0], \dots, B[\frac{N}{2} - 1] \leftarrow \texttt{FFT}(A, i, \frac{N}{2}, 2s)$ \; $B[\frac{N}{2}], \dots, B[N - 1] \leftarrow \texttt{FFT}(A, i + s, \frac{N}{2}, 2s)$ \; - \For{$k = 0$ to $\frac{N}{2} - 1$}{ + \For{$k \leftarrow 0$ \KwTo $\frac{N}{2} - 1$}{ $t \leftarrow B[k]$ \; $B[k] \leftarrow t + e^{-2i\pi \frac{k}{N}} B[k + \frac{N}{2}]$ \; $B[k + \frac{N}{2}] \leftarrow t - e^{-2i\pi \frac{k}{N}} B[k + \frac{N}{2}]$ \; diff --git a/tex-docs/topics/velocity.tex b/tex-docs/topics/velocity.tex index c58d60f..4b390e6 100644 --- a/tex-docs/topics/velocity.tex +++ b/tex-docs/topics/velocity.tex @@ -98,8 +98,8 @@ 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)$ \; - \For{$lat \in [1, nlat - 1]$}{ - \For{$lon \in [0, nlon]$}{ + \For{$lat \leftarrow 1$ \KwTo $nlat - 1$}{ + \For{$lon \leftarrow 0$ \KwTo $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}$ \; } @@ -116,7 +116,7 @@ Another change introduced is in the coriolis parameter. Up until now it has been \SetAlgoLined $\Omega \leftarrow 7.2921 \cdot 10^{-5}$ \; - \For{$lat \in [-nlat, nlat]$}{ + \For{$lat \leftarrow -nlat$ \KwTo $nlat$}{ $f[lat] \leftarrow 2\Omega \sin(lat \frac{\pi}{180})$ \; } \caption{Calculating the coriolis force} @@ -141,9 +141,9 @@ 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)$ \; - \For{$lat \in [1, nlat - 1]$}{ - \For{$lon \in [0, nlon]$}{ - \For{$layer \in [0, nlevels]$}{ + \For{$lat \leftarrow 1$ \KwTo $nlat - 1$}{ + \For{$lon \leftarrow 0$ \KwTo $nlon$}{ + \For{$layer \leftarrow 0$ \KwTo $nlevels$}{ $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[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[lat, lon, layer] - \frac{p[lat, lon, layer] - p_o[lat, lon, layer]}{\delta t\rho[lat, lon, layer]g}$ \;