New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
chap_time_domain.tex in NEMO/trunk/doc/latex/NEMO/subfiles – NEMO

source: NEMO/trunk/doc/latex/NEMO/subfiles/chap_time_domain.tex @ 10354

Last change on this file since 10354 was 10354, checked in by nicolasmartin, 5 years ago

Vast edition of LaTeX subfiles to improve the readability by cutting sentences in a more suitable way
Every sentence begins in a new line and if necessary is splitted around 110 characters lenght for side-by-side visualisation,
this setting may not be adequate for everyone but something has to be set.
The punctuation was the primer trigger for the cutting process, otherwise subordinators and coordinators, in order to mostly keep a meaning for each line

File size: 21.2 KB
Line 
1\documentclass[../tex_main/NEMO_manual]{subfiles}
2\begin{document}
3
4% ================================================================
5% Chapter 2 ——— Time Domain (step.F90)
6% ================================================================
7\chapter{Time Domain (STP) }
8\label{chap:STP}
9\minitoc
10
11% Missing things:
12%  - daymod: definition of the time domain (nit000, nitend andd the calendar)
13
14
15\gmcomment{STEVEN :maybe a picture of the directory structure in the introduction which could be referred to here,
16  would help  ==> to be added}
17%%%%
18
19
20\newpage
21$\ $\newline    % force a new ligne
22
23
24Having defined the continuous equations in \autoref{chap:PE}, we need now to choose a time discretization,
25a key feature of an ocean model as it exerts a strong influence on the structure of the computer code
26($i.e.$ on its flowchart).
27In the present chapter, we provide a general description of the \NEMO time stepping strategy and
28the consequences for the order in which the equations are solved.
29
30$\ $\newline    % force a new ligne
31% ================================================================
32% Time Discretisation
33% ================================================================
34\section{Time stepping environment}
35\label{sec:STP_environment}
36
37The time stepping used in \NEMO is a three level scheme that can be represented as follows:
38\begin{equation} \label{eq:STP}
39   x^{t+\rdt} = x^{t-\rdt} + 2 \, \rdt \  \text{RHS}_x^{t-\rdt,\,t,\,t+\rdt}
40\end{equation} 
41where $x$ stands for $u$, $v$, $T$ or $S$;
42RHS is the Right-Hand-Side of the corresponding time evolution equation;
43$\rdt$ is the time step;
44and the superscripts indicate the time at which a quantity is evaluated.
45Each term of the RHS is evaluated at a specific time step depending on the physics with which it is associated.
46
47The choice of the time step used for this evaluation is discussed below as well as
48the implications for starting or restarting a model simulation.
49Note that the time stepping calculation is generally performed in a single operation.
50With such a complex and nonlinear system of equations it would be dangerous to let a prognostic variable evolve in
51time for each term separately.
52
53The three level scheme requires three arrays for each prognostic variable.
54For each variable $x$ there is $x_b$ (before), $x_n$ (now) and $x_a$.
55The third array, although referred to as $x_a$ (after) in the code,
56is usually not the variable at the after time step;
57but rather it is used to store the time derivative (RHS in \autoref{eq:STP}) prior to time-stepping the equation.
58Generally, the time stepping is performed once at each time step in the \mdl{tranxt} and \mdl{dynnxt} modules,
59except when using implicit vertical diffusion or calculating sea surface height in which
60case time-splitting options are used.
61
62% -------------------------------------------------------------------------------------------------------------
63%        Non-Diffusive Part---Leapfrog Scheme
64% -------------------------------------------------------------------------------------------------------------
65\section{Non-diffusive part --- Leapfrog scheme}
66\label{sec:STP_leap_frog}
67
68The time stepping used for processes other than diffusion is the well-known leapfrog scheme
69\citep{Mesinger_Arakawa_Bk76}.
70This scheme is widely used for advection processes in low-viscosity fluids.
71It is a time centred scheme, $i.e.$ the RHS in \autoref{eq:STP} is evaluated at time step $t$, the now time step.
72It may be used for momentum and tracer advection, pressure gradient, and Coriolis terms,
73but not for diffusion terms.
74It is an efficient method that achieves second-order accuracy with
75just one right hand side evaluation per time step.
76Moreover, it does not artificially damp linear oscillatory motion nor does it produce instability by
77amplifying the oscillations.
78These advantages are somewhat diminished by the large phase-speed error of the leapfrog scheme,
79and the unsuitability of leapfrog differencing for the representation of diffusion and Rayleigh damping processes.
80However, the scheme allows the coexistence of a numerical and a physical mode due to
81its leading third order dispersive error.
82In other words a divergence of odd and even time steps may occur.
83To prevent it, the leapfrog scheme is often used in association with a Robert-Asselin time filter
84(hereafter the LF-RA scheme).
85This filter, first designed by \citet{Robert_JMSJ66} and more comprehensively studied by \citet{Asselin_MWR72},
86is a kind of laplacian diffusion in time that mixes odd and even time steps:
87\begin{equation} \label{eq:STP_asselin}
88x_F^t  = x^t + \gamma \, \left[ x_F^{t-\rdt} - 2 x^t + x^{t+\rdt} \right]
89\end{equation} 
90where the subscript $F$ denotes filtered values and $\gamma$ is the Asselin coefficient.
91$\gamma$ is initialized as \np{rn\_atfp} (namelist parameter).
92Its default value is \np{rn\_atfp}\forcode{ = 10.e-3} (see \autoref{sec:STP_mLF}),
93causing only a weak dissipation of high frequency motions (\citep{Farge1987}).
94The addition of a time filter degrades the accuracy of the calculation from second to first order.
95However, the second order truncation error is proportional to $\gamma$, which is small compared to 1.
96Therefore, the LF-RA is a quasi second order accurate scheme.
97The LF-RA scheme is preferred to other time differencing schemes such as predictor corrector or trapezoidal schemes,
98because the user has an explicit and simple control of the magnitude of the time diffusion of the scheme.
99When used with the 2nd order space centred discretisation of the advection terms in
100the momentum and tracer equations, LF-RA avoids implicit numerical diffusion:
101diffusion is set explicitly by the user through the Robert-Asselin
102filter parameter and the viscosity and diffusion coefficients.
103
104% -------------------------------------------------------------------------------------------------------------
105%        Diffusive Part---Forward or Backward Scheme
106% -------------------------------------------------------------------------------------------------------------
107\section{Diffusive part --- Forward or backward scheme}
108\label{sec:STP_forward_imp}
109
110The leapfrog differencing scheme is unsuitable for the representation of diffusion and damping processes.
111For a tendancy $D_x$, representing a diffusion term or a restoring term to a tracer climatology
112(when present, see \autoref{sec:TRA_dmp}), a forward time differencing scheme is used :
113\begin{equation} \label{eq:STP_euler}
114   x^{t+\rdt} = x^{t-\rdt} + 2 \, \rdt \ {D_x}^{t-\rdt}
115\end{equation} 
116
117This is diffusive in time and conditionally stable.
118The conditions for stability of second and fourth order horizontal diffusion schemes are \citep{Griffies_Bk04}:
119\begin{equation} \label{eq:STP_euler_stability}
120A^h < \left\{
121\begin{aligned}
122                    &\frac{e^2}{  8 \; \rdt }   &&\quad \text{laplacian diffusion}  \\
123                    &\frac{e^4}{64 \; \rdt }    &&\quad \text{bilaplacian diffusion} 
124            \end{aligned}
125\right.
126\end{equation}
127where $e$ is the smallest grid size in the two horizontal directions and $A^h$ is the mixing coefficient.
128The linear constraint \autoref{eq:STP_euler_stability} is a necessary condition, but not sufficient.
129If it is not satisfied, even mildly, then the model soon becomes wildly unstable.
130The instability can be removed by either reducing the length of the time steps or reducing the mixing coefficient.
131
132For the vertical diffusion terms, a forward time differencing scheme can be used,
133but usually the numerical stability condition imposes a strong constraint on the time step.
134Two solutions are available in \NEMO to overcome the stability constraint:
135$(a)$ a forward time differencing scheme using a time splitting technique (\np{ln\_zdfexp}\forcode{ = .true.}) or
136$(b)$ a backward (or implicit) time differencing scheme                   (\np{ln\_zdfexp}\forcode{ = .false.}).
137In $(a)$, the master time step $\Delta $t is cut into $N$ fractional time steps so that
138the stability criterion is reduced by a factor of $N$.
139The computation is performed as follows:
140\begin{equation} \label{eq:STP_ts}
141\begin{split}
142& x_\ast ^{t-\rdt} = x^{t-\rdt}   \\
143& x_\ast ^{t-\rdt+L\frac{2\rdt}{N}}=x_\ast ^{t-\rdt+\left( {L-1} 
144\right)\frac{2\rdt}{N}}+\frac{2\rdt}{N}\;\text{DF}^{t-\rdt+\left( {L-1} \right)\frac{2\rdt}{N}}
145        \quad \text{for $L=1$ to $N$}      \\
146& x^{t+\rdt} = x_\ast^{t+\rdt}
147\end{split}
148\end{equation}
149with DF a vertical diffusion term.
150The number of fractional time steps, $N$, is given by setting \np{nn\_zdfexp}, (namelist parameter).
151The scheme $(b)$ is unconditionally stable but diffusive. It can be written as follows:
152\begin{equation} \label{eq:STP_imp}
153   x^{t+\rdt} = x^{t-\rdt} + 2 \, \rdt \  \text{RHS}_x^{t+\rdt}
154\end{equation} 
155
156%%gm
157%%gm   UPDATE the next paragraphs with time varying thickness ...
158%%gm
159
160This scheme is rather time consuming since it requires a matrix inversion,
161but it becomes attractive since a value of 3 or more is needed for N in the forward time differencing scheme.
162For example, the finite difference approximation of the temperature equation is:
163\begin{equation} \label{eq:STP_imp_zdf}
164\frac{T(k)^{t+1}-T(k)^{t-1}}{2\;\rdt}\equiv \text{RHS}+\frac{1}{e_{3t} }\delta 
165_k \left[ {\frac{A_w^{vT} }{e_{3w} }\delta _{k+1/2} \left[ {T^{t+1}} \right]} 
166\right]
167\end{equation}
168where RHS is the right hand side of the equation except for the vertical diffusion term.
169We rewrite \autoref{eq:STP_imp} as:
170\begin{equation} \label{eq:STP_imp_mat}
171-c(k+1)\;T^{t+1}(k+1) + d(k)\;T^{t+1}(k) - \;c(k)\;T^{t+1}(k-1) \equiv b(k)
172\end{equation}
173where
174\begin{align*} 
175 c(k) &= A_w^{vT} (k) \, / \, e_{3w} (k)     \\
176 d(k) &= e_{3t} (k)       \, / \, (2\rdt) + c_k + c_{k+1}    \\
177 b(k) &= e_{3t} (k) \; \left( T^{t-1}(k) \, / \, (2\rdt) + \text{RHS} \right)   
178\end{align*}
179
180\autoref{eq:STP_imp_mat} is a linear system of equations with an associated matrix which is tridiagonal.
181Moreover,
182$c(k)$ and $d(k)$ are positive and the diagonal term is greater than the sum of the two extra-diagonal terms,
183therefore a special adaptation of the Gauss elimination procedure is used to find the solution
184(see for example \citet{Richtmyer1967}).
185
186
187
188% -------------------------------------------------------------------------------------------------------------
189%        Surface Pressure gradient
190% -------------------------------------------------------------------------------------------------------------
191\section{Surface pressure gradient}
192\label{sec:STP_spg_ts}
193
194===>>>>  TO BE written....  :-)
195
196%\gmcomment{
197%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
198\begin{figure}[!t]
199  \begin{center}
200    \includegraphics[width=0.7\textwidth]{Fig_TimeStepping_flowchart}
201    \caption{  \protect\label{fig:TimeStep_flowchart}
202      Sketch of the leapfrog time stepping sequence in \NEMO from \citet{Leclair_Madec_OM09}.
203      The use of a semi-implicit computation of the hydrostatic pressure gradient requires the tracer equation to
204      be stepped forward prior to the momentum equation.
205      The need for knowledge of the vertical scale factor (here denoted as $h$) requires the sea surface height and
206      the continuity equation to be stepped forward prior to the computation of the tracer equation.
207      Note that the method for the evaluation of the surface pressure gradient $\nabla p_s$ is not presented here
208      (see \autoref{sec:DYN_spg}).
209    }
210\end{center}   \end{figure}
211%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
212%}
213
214% -------------------------------------------------------------------------------------------------------------
215%        The Modified Leapfrog -- Asselin Filter scheme
216% -------------------------------------------------------------------------------------------------------------
217\section{Modified Leapfrog -- Asselin filter scheme}
218\label{sec:STP_mLF}
219
220Significant changes have been introduced by \cite{Leclair_Madec_OM09} in the LF-RA scheme in order to ensure tracer conservation and to allow the use of a much smaller value of the Asselin filter parameter.
221The modifications affect both the forcing and filtering treatments in the LF-RA scheme.
222
223In a classical LF-RA environment, the forcing term is centred in time,
224$i.e.$ it is time-stepped over a $2\rdt$ period:
225$x^t  = x^t + 2\rdt Q^t $ where $Q$ is the forcing applied to $x$,
226and the time filter is given by \autoref{eq:STP_asselin} so that $Q$ is redistributed over several time step.
227In the modified LF-RA environment, these two formulations have been replaced by:
228\begin{align} 
229x^{t+\rdt}  &= x^{t-\rdt} + \rdt \left( Q^{t-\rdt/2} + Q^{t+\rdt/2} \right)                   \label{eq:STP_forcing} \\
230%
231x_F^&= x^t + \gamma \, \left[ x_F^{t-\rdt} - 2 x^t + x^{t+\rdt} \right] 
232           - \gamma\,\rdt \, \left[ Q^{t+\rdt/2} -  Q^{t-\rdt/2} \right]                          \label{eq:STP_RA}
233\end{align}
234The change in the forcing formulation given by \autoref{eq:STP_forcing} (see \autoref{fig:MLF_forcing})
235has a significant effect:
236the forcing term no longer excites the divergence of odd and even time steps \citep{Leclair_Madec_OM09}.
237% forcing seen by the model....
238This property improves the LF-RA scheme in two respects.
239First, the LF-RA can now ensure the local and global conservation of tracers.
240Indeed, time filtering is no longer required on the forcing part.
241The influence of the Asselin filter on the forcing is be removed by adding a new term in the filter
242(last term in \autoref{eq:STP_RA} compared to \autoref{eq:STP_asselin}).
243Since the filtering of the forcing was the source of non-conservation in the classical LF-RA scheme,
244the modified formulation becomes conservative \citep{Leclair_Madec_OM09}.
245Second, the LF-RA becomes a truly quasi-second order scheme.
246Indeed, \autoref{eq:STP_forcing} used in combination with a careful treatment of static instability
247(\autoref{subsec:ZDF_evd}) and of the TKE physics (\autoref{subsec:ZDF_tke_ene}),
248the two other main sources of time step divergence,
249allows a reduction by two orders of magnitude of the Asselin filter parameter.
250
251Note that the forcing is now provided at the middle of a time step:
252$Q^{t+\rdt/2}$ is the forcing applied over the $[t,t+\rdt]$ time interval.
253This and the change in the time filter, \autoref{eq:STP_RA},
254allows an exact evaluation of the contribution due to the forcing term between any two time steps,
255even if separated by only $\rdt$ since the time filter is no longer applied to the forcing term.
256
257%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
258\begin{figure}[!t]
259  \begin{center}
260    \includegraphics[width=0.90\textwidth]{Fig_MLF_forcing}
261    \caption{  \protect\label{fig:MLF_forcing}
262      Illustration of forcing integration methods.
263      (top) ''Traditional'' formulation:
264      the forcing is defined at the same time as the variable to which it is applied
265      (integer value of the time step index) and it is applied over a $2\rdt$ period.
266      (bottom)  modified formulation:
267      the forcing is defined in the middle of the time (integer and a half value of the time step index) and
268      the mean of two successive forcing values ($n-1/2$, $n+1/2$) is applied over a $2\rdt$ period.
269    }
270  \end{center}
271\end{figure}
272%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
273
274% -------------------------------------------------------------------------------------------------------------
275%        Start/Restart strategy
276% -------------------------------------------------------------------------------------------------------------
277\section{Start/Restart strategy}
278\label{sec:STP_rst}
279
280%--------------------------------------------namrun-------------------------------------------
281\nlst{namrun}
282%--------------------------------------------------------------------------------------------------------------
283
284The first time step of this three level scheme when starting from initial conditions is a forward step
285(Euler time integration):
286\begin{equation} \label{eq:DOM_euler}
287   x^1 = x^0 + \rdt \ \text{RHS}^0
288\end{equation}
289This is done simply by keeping the leapfrog environment ($i.e.$ the \autoref{eq:STP} three level time stepping) but
290setting all $x^0$ (\textit{before}) and $x^{1}$ (\textit{now}) fields equal at the first time step and
291using half the value of $\rdt$.
292
293It is also possible to restart from a previous computation, by using a restart file.
294The restart strategy is designed to ensure perfect restartability of the code:
295the user should obtain the same results to machine precision either by
296running the model for $2N$ time steps in one go,
297or by performing two consecutive experiments of $N$ steps with a restart.
298This requires saving two time levels and many auxiliary data in the restart files in machine precision.
299
300Note that when a semi-implicit scheme is used to evaluate the hydrostatic pressure gradient
301(see \autoref{subsec:DYN_hpg_imp}), an extra three-dimensional field has to
302be added to the restart file to ensure an exact restartability.
303This is done optionally via the  \np{nn\_dynhpg\_rst} namelist parameter,
304so that the size of the restart file can be reduced when restartability is not a key issue
305(operational oceanography or in ensemble simulations for seasonal forecasting).
306
307Note the size of the time step used, $\rdt$, is also saved in the restart file.
308When restarting, if the the time step has been changed, a restart using an Euler time stepping scheme is imposed.
309Options are defined through the  \ngn{namrun} namelist variables.
310%%%
311\gmcomment{
312add here how to force the restart to contain only one time step for operational purposes
313
314add also the idea of writing several restart for seasonal forecast : how is it done ?
315
316verify that all namelist pararmeters are truly described
317
318a word on the check of restart  .....
319}
320%%%
321
322\gmcomment{       % add a subsection here 
323
324%-------------------------------------------------------------------------------------------------------------
325%        Time Domain
326% -------------------------------------------------------------------------------------------------------------
327\subsection{Time domain}
328\label{subsec:STP_time}
329%--------------------------------------------namrun-------------------------------------------
330
331\nlst{namdom}         
332%--------------------------------------------------------------------------------------------------------------
333
334Options are defined through the  \ngn{namdom} namelist variables.
335 \colorbox{yellow}{add here a few word on nit000 and nitend}
336
337 \colorbox{yellow}{Write documentation on the calendar and the key variable adatrj}
338
339add a description of daymod, and the model calandar (leap-year and co)
340
341}        %% end add
342
343
344
345%%
346\gmcomment{       % add implicit in vvl case  and Crant-Nicholson scheme   
347
348Implicit time stepping in case of variable volume thickness.
349
350Tracer case (NB for momentum in vector invariant form take care!)
351
352\begin{flalign*}
353&\frac{\left( e_{3t}\,T \right)_k^{t+1}-\left( e_{3t}\,T \right)_k^{t-1}}{2\rdt}
354\equiv \text{RHS}+ \delta _k \left[ {\frac{A_w^{vt} }{e_{3w}^{t+1} }\delta _{k+1/2} \left[ {T^{t+1}} \right]} 
355\right]      \\
356&\left( e_{3t}\,T \right)_k^{t+1}-\left( e_{3t}\,T \right)_k^{t-1}
357\equiv {2\rdt} \ \text{RHS}+ {2\rdt} \ \delta _k \left[ {\frac{A_w^{vt} }{e_{3w}^{t+1} }\delta _{k+1/2} \left[ {T^{t+1}} \right]} 
358\right]      \\
359&\left( e_{3t}\,T \right)_k^{t+1}-\left( e_{3t}\,T \right)_k^{t-1}
360\equiv 2\rdt \ \text{RHS}
361+ 2\rdt \ \left\{ \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k+1/2} [ T_{k+1}^{t+1} - T_k      ^{t+1} ]
362                          - \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k-1/2} [ T_k       ^{t+1} - T_{k-1}^{t+1} ]  \right\}     \\
363&\\
364&\left( e_{3t}\,T \right)_k^{t+1}
365{2\rdt} \           \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k+1/2}                  T_{k+1}^{t+1} 
366+ {2\rdt} \ \left\{  \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k+1/2} 
367                            +  \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k-1/2}     \right\}   T_{k    }^{t+1}
368{2\rdt} \           \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k-1/2}                  T_{k-1}^{t+1}      \\
369&\equiv \left( e_{3t}\,T \right)_k^{t-1} + {2\rdt} \ \text{RHS}    \\
370%
371\end{flalign*}
372
373\begin{flalign*}
374\allowdisplaybreaks
375\intertext{ Tracer case }
376%
377&  \qquad \qquad  \quad   -  {2\rdt}                  \ \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k+1/2}   
378                                                                                                      \qquad \qquad \qquad  \qquad  T_{k+1}^{t+1}   \\
379&+ {2\rdt} \ \biggl\{  (e_{3t})_{k   }^{t+1}  \bigg. +    \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k+1/2} 
380                                                                               +   \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k-1/2} \bigg. \biggr\}  \ \ \ T_{k   }^{t+1}  &&\\
381& \qquad \qquad  \qquad \qquad \qquad \quad \ \ {2\rdt} \                          \left[ \frac{A_w^{vt}}{e_{3w}^{t+1}} \right]_{k-1/2}                          \quad \ \ T_{k-1}^{t+1}     
382\ \equiv \ \left( e_{3t}\,T \right)_k^{t-1} + {2\rdt} \ \text{RHS}  \\
383%
384\end{flalign*}
385\begin{flalign*}
386\allowdisplaybreaks
387\intertext{ Tracer content case }
388%
389& -  {2\rdt} \              & \frac{(A_w^{vt})_{k+1/2}} {(e_{3w})_{k+1/2}^{t+1}\;(e_{3t})_{k+1}^{t+1}}  && \  \left( e_{3t}\,T \right)_{k+1}^{t+1}   &\\
390& + {2\rdt} \ \left[ 1  \right.+ & \frac{(A_w^{vt})_{k+1/2}} {(e_{3w})_{k+1/2}^{t+1}\;(e_{3t})_k^{t+1}} 
391                                    + & \frac{(A_w^{vt})_{k -1/2}} {(e_{3w})_{k -1/2}^{t+1}\;(e_{3t})_k^{t+1}}  \left\right& \left( e_{3t}\,T \right)_{k   }^{t+1}  &\\
392& -  {2\rdt} \               & \frac{(A_w^{vt})_{k -1/2}} {(e_{3w})_{k -1/2}^{t+1}\;(e_{3t})_{k-1}^{t+1}}     &\  \left( e_{3t}\,T \right)_{k-1}^{t+1}   
393\equiv \left( e_{3t}\,T \right)_k^{t-1} + {2\rdt} \ \text{RHS}  &
394\end{flalign*}
395
396%%
397}
398%%
399\end{document}
Note: See TracBrowser for help on using the repository browser.