The primitive equations are a hydrostatic approximation of the compressible Navier-Stokes equations for an ideal gas on a rotating sphere. We largely follow the idealised spectral dynamical core developed by GFDL1 and documented therein2.
The primitive equations solved by SpeedyWeather.jl for relative vorticity \zeta
, divergence \mathcal{D}
,
logarithm of surface pressure \ln p_s
, temperature T
and specific humidity q
are
with velocity \mathbf{u} = (u, v)
, rotated velocity \mathbf{u}_\perp = (v, -u)
,
Coriolis parameter f
, W
the Vertical advection operator, dry air gas constant R_d
,
Virtual temperature T_v
, Geopotential \Phi
, pressure p
and surface pressure p_s
, thermodynamic \kappa = R\_d/c_p
with c_p
the heat capacity at constant pressure. Horizontal hyper diffusion of the
form (-1)^{n+1}\nu\nabla^{2n}
with coefficient \nu
and power n
is added for
every variable that is advected, meaning \zeta, \mathcal{D}, T, q
, but left out
here for clarity, see [Horizontal diffusion](@ref diffusion).
The parameterizations for the tendencies of u, v, T, q
from physical processes are denoted as
\mathcal{P}_\mathbf{u} = (\mathcal{P}_u, \mathcal{P}_v), \mathcal{P}_T, \mathcal{P}_q
and are further described in the corresponding sections, see Parameterizations.
SpeedyWeather.jl implements a PrimitiveWet
and a PrimitiveDry
dynamical core.
For a dry atmosphere, we have q = 0
and the virtual temperature T_v = T
equals the temperature (often called absolute to distinguish from the virtual temperature).
The terms in the primitive equations and their discretizations are discussed in
the following sections.
!!! info "In short: Virtual temperature" Virtual temperature is the temperature dry air would need to have to be as light as moist air. It is used in the dynamical core to include the effect of humidity on the density while replacing density through the ideal gas law with temperature.
We assume the atmosphere to be composed of two ideal gases: Dry air and water vapour.
Given a specific humidity q
both gases mix, their pressures p_d
, p_w
(d
for dry, w
for water vapour), and densities \rho_d, \rho_w
add in a given
air parcel that has temperature T
. The ideal gas law then holds for both gases
with the respective specific gas constants R_d = R/m_d
and R_w = R/m_w
obtained from the universal gas constant R
divided by the molecular masses
of the gas. The total pressure p
in the air parcel is
We ultimately want to replace the density \rho = \rho_w + \rho_d
in the dynamical core,
using the ideal gas law, with the temperature T
, so that we never have
to calculate the density explicitly. However, in order to not deal with
two densities (dry air and water vapour) we would like to replace
temperature with a virtual temperature that includes the effect of
humidity on the density. So, wherever we use the ideal gas law
to replace density with temperature, we would use the virtual temperature,
which is a function of the absolute temperature and specific humidity,
instead. A higher specific humidity in an air parcel lowers
the density as water vapour is lighter than dry air. Consequently,
the virtual temperature of moist air is higher than its absolute temperature
because warmer air is lighter too at constant pressure. We therefore
think of the virtual temperature as the temperature dry air would need to have
to be as light as moist air.
Starting with the last equation, with some manipulation we can write
the ideal gas law as total density \rho
times a gas constant
times the virtual temperature that is supposed to be a function
of absolute temperature, humidity and some constants
Now we identify
as some constant that is positive for water vapour being lighter than dry air
(\tfrac{R_d}{R_w} = \tfrac{m_w}{m_d} < 1
) and
as the specific humidity. Given temperature T
and specific humidity q
, we
can therefore calculate the virtual temperature T_v
as
For completeness we want to mention here that the above product, because it is a
product of two variables q, T
has to be computed in grid-point space,
see Spherical Harmonic Transform.
To obtain an approximation to the virtual temperature in spectral space without
expensive transforms one can linearize
with a global constant temperature \bar{T}
, for example obtained from the
l=m=0
mode, \bar{T} = T_{0, 0}\frac{1}{\sqrt{4\pi}}
but depending on the
normalization of the spherical harmonics that factor needs adjustment.
We call this the linear virtual temperature which is used for the geopotential
calculation, see #254.
We start with some general considerations that apply when changing the vertical
coordinate from height z
to something else. Let \Psi(x, y, z, t)
be some variable that depends on space and time. Now we want to express
\Psi
using some other coordinate \eta
in the vertical. Regardless of
the coordinate system the value of \Psi
at the to z
corresponding \eta
(and vice versa) has to be the same as we only want to change the coordinate,
not \Psi
itself.
So you can think of z
as a function of \eta
and \eta
as a function of z
.
The chain rule lets us differentiate \Psi
with respect to z
or \eta
But for derivatives with respect to x, y, t
we have to apply the multi-variable
chain-rule as both \Psi
and \eta
depend on it. So a derivative with respect to
x
on \eta
levels (where \eta
constant) becomes
So we first take the derivative of \Psi
with respect to x
, but then also have to
account for the fact that, at a given \eta
, z
depends on x
which is again
dealt with using the univariate chain rule from above. We will make use of that
for the Pressure gradient.
The problem with pure pressure coordinates is that they are not terrain-following. For example, the 1000 hPa level in the Earth's atmosphere cuts through mountains. A flow field on such a level is therefore not continuous and one would need to deal with boundaries. Especially with spherical harmonics we need a terrain-following vertical coordinate to transform between continuous fields in grid-point space and spectral space.
SpeedyWeather.jl currently uses so-called sigma coordinates for the vertical. This coordinate system uses fraction of surface pressure in the vertical, i.e.
with \sigma = [0, 1]
and \sigma = 0
being the top (zero pressure) and \sigma = 1
the surface (at surface pressure). As a consequence the vertical dimension is also
indexed from top to surface.
!!! info "Vertical indexing"
Pressure, sigma, or hybrid coordinates in the vertical range from lowest values at the top
to highest values at the surface. Consistently, we also index the vertical dimension top to
surface. This means that k=1
is the top-most layer, and k=N_{lev}
(or similar)
is the layer that sits directly above the surface.
Sigma coordinates are therefore terrain-following, as \sigma = 1
is always at surface pressure
and so this level bends itself around every mountain, although the actual pressure on this
level can vary. For a visualisation see #329.
One chooses \sigma
levels associated with the k
-th layer and the pressure
can be reobtained from the surface pressure p_s
The layer thickness in terms of pressure is
which can also be expressed with the layer thickness in sigma coordinates \Delta \sigma_k
times the surface pressure. In SpeedyWeather.jl one chooses the half levels
\sigma_{k+\tfrac{1}{2}}
first and then obtains the full levels through averaging
In the hydrostatic approximation the vertical momentum equation becomes
meaning that the (negative) vertical pressure gradient is given by the density in that layer times the gravitational acceleration. The heavier the fluid the more the pressure will increase below. Inserting the ideal gas law
with the geopotential \Phi = gz
we can write this in terms of the logarithm
of pressure
Note that we use the Virtual temperature here as we replaced the density
through the ideal gas law with temperature. Given a vertical temperature profile
T_v
and the (constant) surface geopotential \Phi_s = gz_s
where z_s
is the orography, we can integrate this equation from the surface to the top
to obtain \Phi_k
on every layer k
.
The surface is at k = N+\tfrac{1}{2}
(see Vertical coordinates)
with N
vertical levels. We can integrate the geopotential onto half levels as
(T_k^v
is the virtual temperature at layer k
, the subscript v
has been
moved to be a superscript)
or onto full levels with
We use this last formula first to get from \Phi_s
to \Phi_N
, and then for
every k
twice to get from \Phi_k
to \Phi_{k-1}
via \Phi_{k-\tfrac{1}{2}}
.
For the first half-level integration we use T_k
for the second T_{k-1}
.
!!! warning "Semi-implicit time integration: Geopotential" With the semi-implicit time integration in SpeedyWeather the Geopotential is not calculated from the spectral temperature at the current, but at the previous time step. This is because this is a linear term that we solve implicitly to avoid instabilities from gravity waves. For details see section [Semi-implicit time stepping](@ref implicit_primitive).
The surface pressure increases with a convergence of the flow above. Written in terms of the surface pressure directly, and not its logarithm
For k
discrete layers from 1
at the top to N
at the surface layer this can be written as
which can be thought of as a vertical integration of the pressure thickness-weighted divergence.
In \sigma
-coordinates with \Delta p_k = \Delta \sigma_k p_s
(see Vertical coordinates)
this becomes
Using the logarithm of pressure \ln p
as the vertical coordinate this becomes
The second term is the divergence \mathcal{D}_k
at layer k
.
We introduce \bar{a} = \sum_k \Delta \sigma_k a_k
, the \sigma
-weighted vertical integration operator
applied to some variable a
. This is essentially an average as \sum_k \Delta \sigma_k = 1
.
The surface pressure tendency can then be written as
which is form used by SpeedyWeather.jl to calculate the tendency of (the logarithm of) surface pressure.
As we will have \ln p_s
available in spectral space at the beginning of a time step, the
gradient can be easily computed (see Derivatives in spherical coordinates). However,
we then need to transform both gradients to grid-point space for the scalar product with
the (vertically \sigma
-averaged) velocity vector \mathbf{\bar{u}}
before transforming it
back to spectral space where the tendency is needed. In general, we can do the \sigma
-weighted
average in spectral or in grid-point space, although it is computationally cheaper in spectral space.
We therefore compute - \bar{\mathcal{D}}
entirely in spectral space. With ()
denoting
spectral space and []
grid-point space (hence, ([])
and [()]
are the transforms in the
respective directions) we therefore do
But note that it would also be possible to do
Meaning that we would compute the vertical average in grid-point space, subtract from the pressure gradient flux before transforming to spectral space. The same amount of transforms are performed but in the latter, the vertical averaging is done in grid-point space.
!!! warning "Semi-implicit time integration: Surface pressure tendency"
With the semi-implicit time integration in SpeedyWeather the
- \overline{(\mathcal{D})}
term is not evaluated from the spectral divergence
\mathcal{D}
at the current, but at the previous time step.
This is because this is a linear term that we solve implicitly
to avoid instabilities from gravity waves.
For details see section [Semi-implicit time stepping](@ref implicit_primitive).
The advection equation \tfrac{DT}{Dt} = 0
for a tracer T
is, in flux form,
for layer k
which can be through the gradient product rule, and using the conservation of mass (see Vertical velocity) transformed into an advective form. In sigma coordinates this simplifies to
With the reconstruction at the faces, T_{k+\tfrac{1}{2}}
, and T_{k-\tfrac{1}{2}}
depending on one's choice
of the advection scheme. For a second order centered scheme, we choose T_{k+\tfrac{1}{2}} = \tfrac{1}{2}(T_k + T_{k+1})
and obtain
However, note that this scheme is dispersive and easily leads to instabilities at higher resolution, where a
more advanced vertical advection scheme becomes necessary. For convenience, we may write W(T)
to denote the vertical advection term \dot{\sigma}\partial_\sigma T
, without specifying which schemes is used.
The vertical velocity \dot{\sigma}
is calculated as described in the following.
In the section Surface pressure tendency we used that the surface pressure changes
with the convergence of the flow above, which derives from the conservation of mass.
Similarly, the conservation of mass for layer k
can be expressed as
(setting T=1
in the advection equation in section Vertical advection)
Meaning that the pressure thickness \Delta p_k
of layer k
changes with
a horizontal divergence -\nabla \cdot (\mathbf{u}_k \Delta p_k)
if not
balanced by a net vertical mass flux M
into of the layer through the
bottom and top boundaries of k
at k\pm\tfrac{1}{2}
. M
is defined positive
downward as this is the direction in which both pressure and sigma coordinates increase.
The boundary conditions are M_\tfrac{1}{2} = M_{N+\tfrac{1}{2}} = 0
, such that there
is no mass flux into the top layer from above or out of the surface layer N
and into the ground
or ocean.
When integrating from the top down to layer k
we obtain the mass flux downwards out of layer k
In sigma coordinates we have M_{k+\tfrac{1}{2}} = p_s \dot{\sigma}_{k+\tfrac{1}{2}}
with
\dot{\sigma}
being the vertical velocity in sigma coordinates, also defined at interfaces
between layers. To calculate \dot{\sigma}
we therefore compute
With \bar{A}
denoting a sigma thickness-weighted vertical average as in section Surface pressure tendency.
Now let \bar{A_k}
be that average from r=1
to r=k
only and not necessarily down to the surface, as required in the
equation above, then we can also write
See also Hoskins and Simmons, 19753. These vertical averages are the same as required by the
Surface pressure tendency and in the Temperature equation, they are therefore all calculated
at once, storing the partial averages \overline{\mathbf{u}_k \cdot \nabla \ln p_s}
and \bar{\mathcal{D}}_k
on the fly.
The pressure gradient term in the primitive equations is
with density \rho
and pressure p
. The gradient here is taken at constant z
hence the
subscript. If we move to a pressure-based vertical coordinate system we will need to evaluate
gradients on constant levels of pressure though, i.e. \nabla_p
. There is, by definition,
no gradient of pressure on constant levels of pressure, but we can use the chain rule (see
Vertical coordinates) to rewrite this as (use only x
but y
is equivalent)
Using the hydrostatic equation \partial_z p = -\rho g
this becomes
Or, in terms of the geopotential \Phi = gz
which is the actual reason why we use pressure coordinates: As density \rho
also depends on
the pressure p
the left-hand side means an implicit system when solving for pressure p
.
To go from pressure to sigma coordinates we apply the chain rule from section
Vertical coordinates again and obtain
where the last step inserts the hydrostatic equation again. With the ideal gas law, and note
that we use Virtual temperature T_v
everywhere where the ideal gas law is used,
but in combination with the dry gas constant R_d
Combining the pressure in denominator and gradient to the logarithm and with
\nabla \ln p = \nabla \ln p_s
in Sigma coordinates (the logarithm of
\sigma_k
adds a constant that drops out in the gradient) we therefore
have
From left to right: The pressure gradient force in z
-coordinates; in pressure coordinates;
and in sigma coordinates. Each denoted with the respective subscript on gradients.
SpeedyWeather.jl uses the latter.
In sigma coordinates we may drop the \sigma
subscript on gradients, but still meaning
that the gradient is evaluated on a surface of our vertical coordinate.
In vorticity-divergence formulation of the momentum equations the \nabla_\sigma \Phi
drops out in the vorticity equation (\nabla \times \nabla \Phi = 0
),
but becomes a -\nabla^2 \Phi
in the divergence equation,
which is therefore combined with the kinetic energy term
-\nabla^2(\tfrac{1}{2}(u^2 + v^2))
similar as it is done in the Shallow water equations.
You can think of \tfrac{1}{2}(u^2 + v^2) + \Phi
as the Bernoulli potential in
the primitive equations. However, due to the change into sigma coordinates the surface pressure
gradient also has to be accounted for. Now highlighting only the pressure gradient force, we
have in total
In our vorticity-divergence formulation and with sigma coordinates.
With the [semi-implicit time integration](@ref implicit_primitive) in SpeedyWeather.jl the pressure gradient terms are further modified as follows. See that section for details why, but here is just to mention that we need to split the terms into linear and non-linear terms. The linear terms are then evaluated at the previous time step for the implicit scheme such that we can avoid instabilities from gravity waves.
We split the (virtual) temperature into a reference vertical profile T_k
and its anomaly,
T_v = T_k + T_v'
. The reference profile T_k
has to be a global
constant for the spectral transform but can depend on the vertical.
With this, the previous equation becomes
In the vorticity equation the term with the reference profile drops out as \nabla \times \nabla = 0
,
and in the divergence equation we move it into the Laplace operator. Now the linear terms
are gathered with the Laplace operator and for the semi-implicit scheme we calculate both the
Geopotential \Phi
and the contribution to the "linear pressure gradient"
R_dT_k \ln p_s
at the previous time step for the
[semi-implicit time integration](@ref implicit_primitive) for details see therein.
Vorticity advection in the primitive equation takes the form
Meaning that we add the Coriolis parameter f
and the relative vorticity \zeta
and multiply by the respective velocity component. While the primitive equations here
are written with vorticity and divergence, we use u, v
here as other tendencies
will be added and the curl and divergence are only taken once after transform into
spectral space. To obtain a tendency for vorticity and divergence, we rewrite this as
with \mathbf{u}_\perp = (v, -u)
the rotated velocity vector, see [Barotropic vorticity
equation](@ref barotropic_vorticity_model).
The dynamical core treats humidity as an (active) tracer, meaning that after the physical
parameterizations for humidity \mathcal{P}
are calculated in grid-point space,
humidity is only advected with the flow. The only exception is the Virtual temperature
as high levels of humidity will lower the effective density, which is why we use the
virtual instead of the absolute temperature. The equation to be solved for humidity
is therefore,
With ()
denoting spectral space and []
grid-point space, so that
([])
and [()]
are the transforms in the respective directions.
To avoid confusion with that notation, we write the tendency of humidity due
to Vertical advection as W_q
. This equation is identical to a tracer equation,
with \mathcal{P}_q
denoting sources and sinks. Note that Horizontal diffusion
should be applied to every advected variable.
A very similar equation is solved for (absolute) temperature as described in the following.
The first law of thermodynamic states that the internal energy I
is increased by
the heat Q
applied minus the work W
done by the system. We neglect changes
in chemical composition (4, chapter 1.5). For an ideal gas, the internal
energy is c_vT
with c_v
the heat capacity at constant volume and temperature
T
. The work done is pV
, with pressure p
and the specific volume V
For fluids we replace the differential d
here with the material derivative \tfrac{D}{Dt}
.
With V = \tfrac{1}{\rho}
and density \rho
we then have
Using the ideal gas law to replace \tfrac{1}{\rho}
with \tfrac{RT_v}{p}
(we are
using the Virtual temperature again), and using
we have
And further, with c_p = c_v + R
the heat capacity at constant pressure,
\kappa = \tfrac{R}{c_p}
, and using the logarithm of pressure
This is the form of the temperature equation that SpeedyWeather.jl uses. Temperature
is advected through the material derivative and first term on the right-hand side
represents an adiabatic conversion term describing how the temperature changes with
changes in pressure. Recall that this term originated from the work term in
the first law of thermodynamics. The forcing term \tfrac{Q}{c_p}
is here
identified as the physical parameterizations changing the temperature, for example
radiation, and hence we will call it P_T
.
Similar to the Humidity equation we write the equation for (absolute) temperature T
as
W_T
is the Vertical advection of temperature. We evaluate the adiabatic conversion
term completely in grid-point space following Simmons and Burridge, 19815 Equation 3.12 and 3.13.
Leaving out the \kappa T_v
for clarity, the term at level k
is
with
In sigma coordinates this simplifies to, following similar steps as in Surface pressure tendency
Let A_k = \mathcal{D}_k + \mathbf{u}_k \cdot \nabla \ln p_s
and
\beta_k = \tfrac{1}{\Delta \sigma_k} \left( \ln \tfrac{\sigma_{k+\tfrac{1}{2}}}{\sigma_{k-\tfrac{1}{2}}}\right)
,
then this can also be summarised as
The \alpha_k, \beta_k
are constants and can be precomputed. The surface pressure flux
\mathbf{u}_k \cdot \nabla \ln p_s
has to be computed, so does the vertical sigma-weighted
average from top to k-1
, which is done when computing other vertical averages for the
Surface pressure tendency.
For the [semi-implicit scheme](@ref implicit_primitive) we need to split the temperature
equation into linear and non-linear terms, as the linear terms need to be evaluated
at the previous time step. Decomposing temperature T
into T = T_k + T'
with the reference profile T_k
and its anomaly T'
, the temperature equation
becomes
Note that we do not change the adiabatic conversion term. While its linear
component \kappa T_k^v \tfrac{D \ln p_s}{D t}
(the subscript v
for
Virtual temperature as been raised)
would need to be evaluated at the previous time step, we still evaluate this
term at the current time step and move it within the semi-implicit corrections
to the previous time step afterwards.
Conceptually, the semi-implicit time stepping in the [Primitive equation model](@ref primitive_equation_model) is the same as in the [Shallow water model](@ref implicit_swm), but
- tendencies for divergence
\mathcal{D}
, logarithm of surface pressure\ln p_s
but also temperatureT
are computed semi-implicitly, - the vertical layers are coupled, creating a linear equation system that is solved via matrix inversion.
The linear terms of the primitive equations follow a linearization around a state of rest without orography and a reference vertical temperature profile. The scheme described here largely follows Hoskins and Simmons 3, which has also been used in Simmons and Burridge 5.
As before, let \delta V = \tfrac{V_{i+1} - V_{i-1}}{2\Delta t}
be the tendency we need for the Leapfrog
time stepping. With the implicit time step \xi = 2\alpha\Delta t
, \alpha \in [\tfrac{1}{2}, 1]
we have
with N_E
being the explicitly-treated non-linear terms and N_I
the implicitly-treated linear terms, such that
N_I
is a linear operator. We can therefore solve for \delta V
by inverting N_I
,
where we gathered the uncorrected right-hand side as G
So for every linear term in N_I
we have two options corresponding to two sides of this equation
- Evaluate it at the previous time step
i-1
- Or, evaluate it at the current time step
i
asN(V_i)
, but then move it back to the previous time stepi-1
by adding (in spectral space) the linear operatorN_I
evaluated with the difference between the two time steps.
If there is a tendency that is easily evaluated in spectral space it is easier to follow 1. However,
a term that is costly to evaluate in grid-point space should usually follow the latter. The reason is that
the previous time step is generally not available in grid-point space (unless recalculated through a costly transform
or stored with additional memory requirements) so it is easier to follow 2 where the N_I
is
available in spectral space. For the adiabatic conversion term in the Temperature equation
we follow 2 as one would otherwise need to split this term into a non-linear and linear term,
evaluating it essentially twice in grid-point space.
So what is G
in the [Primitive equation model](@ref primitive_equation_model)?
G
is for the divergence, pressure and temperature equation the "uncorrected" tendency.
Moving time step i - 1 \to i
we would be back with a fully explicit scheme. In the divergence equation
the Geopotential \Phi
is calculated from temperature T
at the previous time step
i-1
(denoted as superscript) and the "linear" Pressure gradient from the logarithm of
surface pressure at the previous time step.
One can think of these two calculations as linear operators, \mathbf{R}
and \mathbf{U}
.
We will shortly discuss their properties. While we could combine them with the Laplace operator
\nabla^2
(which is also linear) we do not do this as \mathbf{R, U}
do not depend on
the degree and order of the spherical harmonics (their wavenumber) but on the vertical,
but \nabla^2
does not depend on the vertical, only on the wavenumber.
All other terms are gathered in N_\mathcal{D}^E
(subscript E
has been raised)
and calculated as described in the respective section at the current time step i
.
For the pressure tendency, the subtraction with the thickness-weighted vertical average \bar{\mathcal{D}}
is the linear term that is treated implicitly. We call this operator \mathbf{W}
.
For the temperature tendency, we evaluate all terms explicitly at the current time step in N_T
but then move the linear term in the adiabatic conversion term with the operator \mathbf{L}
back to the previous time step. For details see Semi-implicit temperature equation.
The operators \mathbf{R, U, L, W}
are all linear, meaning that we can apply them
in spectral space to each spherical harmonic independently -- the vertical is coupled however.
With N
being the number of vertical levels and the prognostic variables like
temperature for a given degree l
and order m
being a column vector in the vertical,
T_{l, m} \in \mathbb{R}^N
, these operators have the following shapes
\mathbf{R}
is an integration in the vertical hence it is an upper triangular matrix such that
the first (an top-most) k=1
element of the resulting vector depends on all vertical levels
of the temperature mode T_{l, m}
, but the surface k=N
only on the temperature mode at the surface.
\mathbf{U}
takes the surface value of the l, m
mode of the logarithm of surface pressure
(\ln p_s)_{l, m}
and multiplies it element-wise with the reference temperature profile and
the dry gas constant. So the result is a column vector.
\mathbf{L}
is an N \times N
matrix as the adiabatic conversion term couples all layers.
\mathbf{W}
is a row vector as it represents the vertical averaging of the spherical harmonics
of a divergence profile. So, \mathbf{W}\mathcal{D}
is a scalar product for every l, m
giving a contribution of all vertical layers in divergence to the (single-layer!) logarithm of
surface pressure tendency.
With the G
s defined we can now write the semi-implicit tendencies \delta \mathcal{D}
,
\delta T
, \delta \ln p_s
as (first equation in this section)
Solving for \delta \mathcal{D}
with the "combined" tendency
via
(\mathbf{UW}
is a matrix of size N \times N
) yields
The other tendencies \delta T
and \delta \ln p_s
are then obtained
through insertion above. We may call the operator to be inverted \mathbf{S}
which is of size l_{max} \times N \times N
, hence for every degree l
of
the spherical harmonics (which the Laplace operator depends on) a
N \times N
matrix coupling the N
vertical levels. Furthermore, S
depends
- through
\xi
on the time step\Delta t
, - through
\mathbf{R, W, L}
on the vertical level spacing\Delta \sigma_k
- through
\mathbf{U}
on the reference temperature profileT_k
so for any changes of these the matrix inversion of \mathbf{S}
has to
be recomputed. Otherwise the algorithm for the semi-implicit scheme is as follows
0. Precompute the linear operators \mathbf{R, U, L, W}
and with them the matrix inversion \mathbf{S}^{-1}
.
Then for every time step
- Compute the uncorrected tendencies evaluated at the current time step for the explicit terms and the previous time step for the implicit terms.
- Exception in SpeedyWeather.jl is the adiabatic conversion term, which is, using
\mathbf{L}
moved afterwards from the currenti
to the previous time stepi-1
. - Compute the combined tendency
G
from the uncorrected tendenciesG_\mathcal{D}
,G_T
,G_{\ln p_s}
. - With the inverted operator get the corrected tendency for divergence,
\delta \mathcal{D} = \mathbf{S}^{-1}G
. - Obtain the corrected tendencies for temperature
\delta T
and surface pressure\delta \ln p_s
from\delta \mathcal{D}
. - Apply Horizontal diffusion (which is only mentioned here as it further updates the tendencies).
- Use
\delta \mathcal{D}
,\delta T
and\delta \ln p_s
in the [Leapfrog time integration](@ref leapfrog).
Horizontal diffusion in the primitive equations is applied to vorticity \zeta
, divergence \mathcal{D}
,
temperature T
and humidity q
. In short, all variables that are advected.
For the dry equations, q=0
and no diffusion has to be applied.
The horizontal diffusion is applied implicitly in spectral space, as already described in Horizontal diffusion for the barotropic vorticity equation.
The following algorithm describes a time step of the PrimitiveWetModel
, for
the PrimitiveDryModel
humidity can be set to zero and respective steps skipped.
0. Start with initial conditions of relative vorticity \zeta_{lm}
, divergence D_{lm}
,
temperature T_{lm}
, humidity q_{lm}
and the logarithm of surface pressure (\ln p_s)_{lm}
in spectral space. Variables \zeta, D, T, q
are defined on all vertical levels, the logarithm
of surface pressure only at the surface. Transform this model state to grid-point space,
obtaining velocities is done as in the shallow water model
- Invert the Laplacian of
\zeta_{lm}
to obtain the stream function\Psi_{lm}
in spectral space - Invert the Laplacian of
D_{lm}
to obtain the velocity potential\Phi_{lm}
in spectral space - obtain velocities
U_{lm} = (\cos(\theta)u)_{lm}, V_{lm} = (\cos(\theta)v)_{lm}
from\nabla^\perp\Psi_{lm} + \nabla\Phi_{lm}
- Transform velocities
U_{lm}
,V_{lm}
to grid-point spaceU, V
- Unscale the
\cos(\theta)
factor to obtainu, v
Additionally we
- Transform
\zeta_{lm}
,D_{lm}
,T_{lm}, (\ln p_s)_{lm}
to\zeta, D, \eta, T, \ln p_s
in grid-point space - Compute the (non-linearized) Virtual temperature in grid-point space.
Now loop over
- Compute all tendencies of
u, v, T, q
due to physical parameterizations in grid-point space. - Compute the gradient of the logarithm of surface pressure
\nabla (\ln p_s)_{lm}
in spectral space and convert the two fields to grid-point space. Unscale the\cos(\theta)
on the fly. - For every layer
k
compute the pressure flux\mathbf{u}_k \cdot \nabla \ln p_s
in grid-point space. - For every layer
k
compute a linearized Virtual temperature in spectral space. - For every layer
k
compute a temperature anomaly (virtual and absolute) relative to a vertical reference profileT_k
in grid-point space. - Compute the Geopotential
\Phi
by integrating the virtual temperature vertically in spectral space from surface to top. - Integrate
u, v, D
vertically to obtain\bar{u}, \bar{v}, \bar{D}
in grid-point space and also\bar{D}_{lm}
in spectral space. Store on the fly also for every layerk
the partial integration from 1 tok-1
(top to layer above). These will be used in the adiabatic term of the Temperature equation. - Compute the Surface pressure tendency with the vertical averages from the previous step. For the [semi-implicit time stepping](@ref implicit_primitive)
- For every layer
k
compute the Vertical velocity. - For every layer
k
add the linear contribution of the Pressure gradientRT_k (\ln p_s)_{lm}
to the geopotential\Phi
in spectral space. - For every layer
k
compute the Vertical advection foru, v, T, q
and add it to the respective tendency. - For every layer
k
compute the tendency ofu, v
due to Vorticity advection and the Pressure gradientRT_v \nabla \ln p_s
and add to the respective existing tendency. Unscale\cos(\theta)
, transform to spectral space, take curl and divergence to obtain tendencies for\zeta_{lm}, \mathcal{D}_{lm}
. - For every layer
k
compute the adiabatic term and the horizontal advection in the Temperature equation in grid-point space, add to existing tendency and transform to spectral. - For every layer
k
compute the horizontal advection of humidityq
in the Humidity equation in grid-point space, add to existing tendency and transform to spectral. - For every layer
k
compute the kinetic energy\tfrac{1}{2}(u^2 + v^2)
, transform to spectral and add to the Geopotential. For the [semi-implicit time stepping](@ref implicit_primitive) also add the linear pressure gradient calculated from the previous time step. Now apply the Laplace operator and subtract from the divergence tendency. - Correct the tendencies following the [semi-implicit time integration](@ref implicit_swm) to prevent fast gravity waves from causing numerical instabilities.
- Compute the [horizontal diffusion](@ref diffusion) for the advected variables
\zeta, \mathcal{D}, T, q
- Compute a leapfrog time step as described in [Time integration](@ref leapfrog) with a Robert-Asselin and Williams filter
- Transform the new spectral state of
\zeta_{lm}
,\mathcal{D}_{lm}
,T_{lm}
,q_{lm}
and(\ln p_s)_{lm}
to grid-pointu, v, \zeta, \mathcal{D}, T, q, \ln p_s
as described in 0. - Possibly do some output
- Repeat from 1.
Footnotes
-
Geophysical Fluid Dynamics Laboratory, Idealized models with spectral dynamics ↩
-
Geophysical Fluid Dynamics Laboratory, The Spectral Dynamical Core ↩
-
Hoskins and Simmons, 1975. A multi-layer spectral model and the semi-implicit method, Quart. J. R. Met. Soc. DOI: 10.1002/qj.49710142918 ↩ ↩2
-
GK Vallis, 2006. Atmopsheric and Ocean Fluid Dynamics, Cambridge University Press. ↩
-
Simmons and Burridge, 1981. An Energy and Angular-Momentum Conserving Vertical Finite-Difference Scheme and Hybrid Vertical Coordinates, Monthly Weather Review. DOI: 10.1175/1520-0493(1981)109<0758:AEAAMC>2.0.CO;2. ↩ ↩2