\subsubsection{\stid{3.12} Sub-project: hypre}

\paragraph{Overview}
The {\sl hypre} software library \cite{hypre:homepage,hypre_design_impl_2006} provides high performance preconditioners and solvers for the solution of large sparse linear systems on massively parallel computers, with particular focus on algebraic multigrid solvers. One of {\sl hypre}’s unique features is the provision of a (semi)-structured interface, in addition to a traditional linear-algebra based interface. The semi-structured interface is appropriate for applications whose grids are mostly structured, but with some unstructured features. Examples include block-structured grids, composite grids in structured adaptive mesh refinement (AMR) applications, and overset grids. These interfaces give application users a more natural means for describing their linear systems, and provide access to methods such as structured multigrid solvers, which can take advantage of the additional information beyond just the matrix. Since current architecture trends are favoring regular compute patterns to achieve high performance, the ability to express structure has become much more important. The {\sl hypre} library provides both unstructured and structured multigrid solvers, which have shown excellent scalability on a variety of high performance computers, e.g Blue Gene systems (unstructured solver BoomerAMG has scaled up to 1.25 million MPI cores with a total of 4.5 million hardware threads). It is used by many ECP application teams, including ExaAM, Subsurface, ExaWind, CEED, and more. It requires a C compiler and an MPI implementation, but it also runs in an OpenMP environment. It also has GPU capabilities.

\paragraph{Key  Challenges}

While {\sl hypre}'s solvers contain much parallelism, their main focus is the solution of sparse linear systems, leading to  very large demands on memory bandwidth. In addition, the use of multiple levels, while greatly aiding convergence of the solvers, leads to decreasing systems sizes, number of operations and parallel efficiencies on coarser levels. Particularly the unstructured algebraic multigrid solver BoomerAMG\cite{HeYa2002}, which is {\sl hypre}'s most often used preconditioner, suffers from increasing communication complexities on coarser levels. Coarse grid operators are generated by multiplying three matrices leading to increasing numbers of nonzeroes per row in the resulting matrices and with it increasing numbers of neighbor processes. While BoomerAMG's solve phase mainly consists of matrix vector products and smoothing operations, which are fairly straight forward to parallelize, even on a GPU, its setup phase is highly complex, including many branches, a lot of integer operations as well as some sequential passages. Previous interpolation strategies that lead to best convergence and performance on distributed memory machines were not suitable for implementation on GPUs or similar architectures requiring extreme parallelism and required new algorithmic approaches. Since {\sl hypre} is a mature product with many solvers and interdependent features, any significant changes that affect the whole library, are tedious and require much testing to ensure that the library stays backward compatible and no features are broken.

\paragraph{Solution Strategy}

Since computer architectures continue to change rapidly, it was important to come up with strategies that will facilitate future porting of the software. Therefore we developed and implemented a new memory model that addresses the use of different memory locations.
Since the upcoming computer architectures are heterogeneous with accelerators, we focus on enabling {\sl hypre} for GPUs. We have looked into various options, such as the use of CUDA, OpenMP 4.5, as well as RAJA and Kokkos. We limited the latter three options to the structured interface and solvers which are more natural candidates for such an approach due to their use of macros, called BoxLoops, for loops. We adopted a modular approach for the unstructured interface, which relies on the restructuring the solver components to use smaller kernels that are and/or will be implemented in CUDA for Nvidia GPUs. Since hip is similar to CUDA, porting to AMD GPUs has been fairly straight forward. We are now investigating the use of a vendor conversion tool from CUDA to SYCL to port structured and unstructured solvers to upcoming exascale computers with Intel GPUs.

\paragraph{Recent Progress}

Previously we had enabled the structured interface and solvers, SMG and PFMG\cite{AsFa1996}, to completely run on GPUs, using CUDA, OpenMP4.5, RAJA and Kokkos, and have now also added hip to enable use on AMD GPUs.
For our unstructured AMG solver BoomerAMG, we had implemented suitable CUDA kernels for setup and solve phase, designed a new class of interpolation operators based on sparse matrix operations\cite{LiSY2020}, implemented it on GPUs and ported aggressive coarsening to the GPU. Recently, we added Umpire support for memory pooling on GPUs, which can significantly improve performance. We have enabled hypre's specialized solvers, including linear and eigensolvers for Maxwell problems and solvers for H-div problems, to run on Nvidia GPUs. Figure \ref{fig:AMS-PCG} shows some results for a Maxwell problem using finite elements of increasing order on 1 node of Lassen. We have ported many of the CUDA kernels and routines in the unstructured interface to hip to enable their use on AMD GPUs. We have also developed a new version of multipass interpolation based on matrix-matrix multiplications and implemented it in CUDA and hip. Multipass interpolation is a popular low-memory prolongation used with aggressive coarsening. Figure \ref{fig:Spock-AMG} shows a comparison of CPU and GPU runtimes on 2 nodes of Spock for a 3D diffusion problem with a 27-point stencil on a $n \times n \times n$ grid using AMG-PCG with aggressive coarsening on the first level for increasing $n$.

\begin{figure}[bth]
\centering
	\includegraphics[width=3.9in]{projects/2.3.3-MathLibs/2.3.3.12-SUNDIALS-hypre/AMS-PCG.png}
	%\includegraphics[width=3in]{AMS-PCG.png}
	\caption{\label{fig:AMS-PCG} Solution of a simple 3D electromagnetic diffusion problem corresponding to the 2nd order definite Maxwell equation  $\nabla \times \nabla \times E + E = f$ using AMS-PCG on 1 node of Lassen (4 GPUs vs. 40 CPU cores) using finite elements of increasing order on a Fichera mesh.}

\end{figure}

\begin{figure}[bth]
\centering
	\includegraphics[width=3in]{projects/2.3.3-MathLibs/2.3.3.12-SUNDIALS-hypre/spock-AMG-PCG.png}
	%\includegraphics[width=3in]{spock-AMG-PCG.png}
	\caption{\label{fig:Spock-AMG} Total times (setup plus solve times) on 2 nodes of Spock using AMG-PCG with aggressive coarsening and multi-pass interpolation for a 3D diffusion problem with a 27-point stencil on a $n \times n \times n$ grid. The CPU runs were performed with 8 MPI tasks with 16 OpenMP threads per MPI task, the GPU runs were performed on 8 AMD GPUs.}

\end{figure}

\paragraph{Next Steps}

We will pursue the following tasks:

\begin{itemize}
\item We will continue to add new GPU capabilities to {\sl hypre} and improve the performance of current capabilities. We will thoroughly investigate the performance on AMD GPUs and begin porting to Intel GPUs.
\item We will test and evaluate performance of important hypre solvers on AMD and Intel GPUs, improve their performance and port additional components if necessary.
\end{itemize}
In addition, we will work with ECP application teams who are using {\sl hypre}, such as ExaWind, ExaAM, AMReX,  to achieve best performance by tuning the solvers for them and potentially implementing suitable algorithmic changes.


%!TEX root = ../thesis.tex
%*******************************************************************************
%*********************************** Signal region optimisation *********
%*******************************************************************************

\chapter{Signal region optimisation}\label{ch:signal_region_optimisation}

\graphicspath{{chapter-optimisation/Figs/Vector/}{chapter-optimisation/Figs/}}

\glsreset{sr}

In order to discover the rare \gls{susy} signals considered in the following, dedicated kinematic regions enriched in signal events, so-called \glspl{sr}, are constructed.
They are optimised such as to be sensitive to a maximum number of signal models considered in this analysis.
In this chapter, the optimisation procedures leading to the final signal regions are introduced and discussed.

\section{Optimisation methods}

All optimisation methods used in the following require a figure of merit that is maximised in order to find configurations yielding optimal performance.
While the multidimensional cut scan and the \textit{N}--1 plots approach, introduced in \cref{sec:n-dim-scan,sec:n-1-scan}, respectively, use the binomial discovery significance $Z_\mathrm{B}$, the fit scan procedure, discussed in \cref{sec:fit-scan}, aims to maximise the area of the expected exclusion contour.

\subsection{Multidimensional cut scan}\label{sec:n-dim-scan}

 \begin{figure}
	\centering
	\begin{subfigure}[b]{0.5\linewidth}
		\centering\includegraphics[width=1.0\textwidth]{N-1_cut_scan/roc_curve_thesis_plots}
		\caption{\label{fig:roc_curve}}
	\end{subfigure}\hfill
	\begin{subfigure}[b]{0.5\linewidth}
		\centering\includegraphics[width=1.0\textwidth]{N-1_cut_scan/z_vs_effs_thesis_plots}
		\caption{\label{fig:z_vs_eff}}
	\end{subfigure}\hfill

	\caption{Small $N$-dimensional cut scan using $10^4$ unique cut combinations, illustrating the approach of~\subref{fig:roc_curve} generating a \gls{roc} curve from the scanned cut combinations in order to \subref{fig:z_vs_eff} reduce the number of candidates used in computationally expensive significance calculations. The cut combination candidates forming the \gls{roc} curve (dark blue) also maximise the discovery significance. In \subref{fig:z_vs_eff}, the significance $Z_\mathrm{B}$ includes the \gls{mc} statistical uncertainty on the expected background rate and a constant 30\% systematic uncertainty.}
	\label{fig:ahoi_examples}
\end{figure}

The first optimisation method used for designing the \glspl{sr} is an $N$-dimensional cut\footnote{In the following, the term \textit{cut} refers to a simple upper or lower requirement on kinematic observables like \eg requiring $\mt>\SI{100}{\GeV}$.} scan using $M$ observables.
For each unique combination of requirements on the set of observables considered, the expected signal and background rate as well as the statistical uncertainty on the background rate is determined from the \gls{mc} simulated events.
As this takes a considerable computational effort, it is crucial to restrict the amount of cut combinations to be tested. By comparing with distributions at preselection level, as for example those shown in \cref{fig:norm_obs}, a set of discrete cuts can be defined for each observable.
In practice, a total number of \mbox{$\mathcal{O}(10^7$--$10^8)$} cut combinations can still be tested on a single machine with a reasonable turnaround time.

After determining the expected event rates and statistical uncertainties, the different cut combinations are binned into a predefined number of signal efficiency bins.
For each bin, the background rejection is subsequently maximised, \ie the cut combination with the highest background rejection is chosen as a candidate combination for the respective signal efficiency bin.
The assumption is that, for a fixed signal efficiency, the cut combination candidate maximising the background rejection also maximises the discovery significance $Z_\mathrm{B}$.
With the significance definition used herein, this is in general a valid assumption, as the significance tends to monotonically increase with decreasing background rate, even while the statistical uncertainty on the background estimation increases due to tighter requirements and less available \gls{mc} statistics (cf. \cref{fig:ahoi_examples}).
This procedure effectively generates a \gls{roc} curve, that can be used to perform more computationally intensive calculations, as \eg calculating different variations of the discovery significance.
The approach is illustrated in a small scan using $10^4$ cut combinations in \cref{fig:ahoi_examples}.
The cut combination candidates maximising the background rejection and thus lying on the \gls{roc} curve in \cref{fig:roc_curve} are the same candidates that maximise the discovery significance in \cref{fig:z_vs_eff}.

A common problem of $N$-dimensional scans is the concept of \textit{over-tightening} the selections given the available \gls{mc} statistics.
Since the cross sections of the \gls{susy} processes considered are many orders of magnitude smaller than those of the dominant \gls{sm} processes, it is often necessary to apply tight requirements on the kinematic observables in order to achieve a significant signal-to-background separation.
However, due to the finite amount of \gls{mc} statistics available, many of the more extreme cut combinations select kinematic regions where not enough \gls{mc} statistics are available for a reasonable estimation of the background rates.
Thus, by maximising the background rejection, it may occur that cut combinations are selected where the mere lack of \gls{mc} statistics, needed to properly estimate the background rates, causes a high significance value.
As the significance values obtained for such configurations are obviously not trustworthy, they need to be avoided.

In the $N$-dimensional cut scan implementation used herein, the available \gls{mc} datasets are split in two statistically independent, equally sized subsets. Although resulting in an additional dilution of the available \gls{mc} statistics, this approach allows to generate two independent \gls{roc} curves and  to compute two independent values for the discovery significance for each cut combination candidate. A large difference in either the \gls{roc} curves or the significance values is an indication for statistical fluctuations as a result of over-tightened cuts. In addition, requirements on the minimum number of unweighted \gls{mc} events for different background processes, as well as the maximum allowed statistical uncertainty on a given process, can be applied. In combination, these precautions offer a good handle against statistical fluctuations. In the following, the $N$-dimensional cut scan implementation provided by \texttt{ahoi}~\cite{ahoi} is used.

\subsection[\textit{N}--1 plots]{$\makemebold{N}$--1 plots}\label{sec:n-1-scan}

Instead of performing a brute-force scan of a large set of cut combinations, a more manual approach, using iterative one-dimensional scans can be employed. In so-called `\textit{N}--1 plots', the kinematic distributions of the background components as well as representative signal processes are plotted in conjunction with the significance achieved by applying a cut on each value on the \textit{x}-axis of the one-dimensional distribution plotted. All other selection requirements, except the one on the observable plotted, are applied. This method allows to investigate the impact of a single kinematic requirement on the overall significance value. By repeatedly executing this process for each observable considered, it is possible to iteratively approach a cut combination yielding results comparable to that of a brute-force cut scan. Especially when considering a sizeable set of observables, this manual approach, however, quickly becomes very cumbersome and inefficient, and risks missing optimal cut combinations that would have been found by a brute-force approach.

For this reason, the following optimisation uses an $N$-dimensional cut scan to cover the full space spanned by the observables and scan ranges considered, while \textit{N}--1 plots are used to verify and fine-tune results obtained by the brute-force approach.

\subsection{Scans using asymptotic formulae}\label{sec:fit-scan}

The last of the optimisation methods, used in the following, relies on scans over sets of simplified profile likelihood fit configurations in order to run a simplified version of the full statistical inference machinery on a large number of signal region candidates.
While the preceding optimisation methods rely on the binomial significance computed in independent \textit{cut-and-count} signal regions, the simplified fit scans statistically combine disjunct signal regions by building a single likelihood, and compute the \textit{p}-values using the asymptotic formulae introduced in~\cref{ch:statistics}.
In addition, the simplified fits use all available signal points instead of relying on a limited set of benchmark points, and can thus derive an estimate of the expected exclusion contour for a large number of signal region candidates.
The estimation of the background event rates in the signal regions is taken from \gls{mc} simulation only and considers a constant systematic uncertainty of 30\% on the estimated event rate, correlated over all signal region bins. Statistical uncertainties on the background estimate from limited \gls{mc} statistics are also taken into account.

As building the likelihood and executing the statistical inference takes a considerable computational effort, this method benefits from the previous optimisation steps defining promising signal region candidates worth scanning over.
In order to keep the number of configurations to be tested at a manageable level, the signal region candidates obtained from the previous methods are only varied to a limited degree, assuming that they were already close to optimal to begin with.

\section[Optimisation for the $1\ell$ search]{Optimisation for the $\makemebold{1\ell}$ search}
%\section[Optimisation for the $\boldsymbol{1\ell}$ search]{Optimisation for the $\boldsymbol{1\ell}$ search}

\begin{table}
	\centering
	\small
	\setlength\heavyrulewidth{0.2ex}
	\caption{List of observables and cut ranges used in the $N$-dimensional cut scan. All cuts are optional and allowed not to be applied at all.}
	\begin{tabular} {l c l}
		\toprule
		Observable &  & Cut values \\
		\midrule
		$\etmiss$ [GeV]& $>$ & $\in \{200,220,240,260,280,300,320,340\}$ \\
		$\etmiss$ significance $\mathcal{S}$ & $>$ & $\in \{5,10,15\}$ \\
		$\mt$ [GeV]& $>$ & $\in \{100, 120, 140,160,180,200,220,240,260,280, 300\}$ \\
		$\mct$ [GeV]& $>$ & $\in \{100, 120, 140,160,180,200,220,240,260,280, 300\}$ \\
		$\mbb$ lower [GeV]& $>$ & $\in \{85,90,95,100,105,110,115\}$ \\
		$\mbb$ upper [GeV]& $<$ & $\in \{130,135,140,145,150\}$ \\
		$p_\textrm{T}^\ell$ $[\SI{}{\GeV}]$& $>$ & $\in \{20, 40, 60, 80\}$ \\
		$p_\textrm{T}^\mathrm{jet1}$ [GeV]& $>$ & $\in \{50, 100, 150\}$ \\
		$p_\textrm{T}^\mathrm{jet2}$ [GeV]& $>$ & $\in \{50, 75, 100\}$ \\
		$\upDelta R_{jj}$ & $<$ & $\in \{0.8,1.0,1.2,2.0\}$ \\
		$\upDelta R_{b\hspace{-0.06em}\bar{b}}$ & $<$ & $\in \{0.8,1.0,1.2,2.0\}$ \\
		$N_\mathrm{jet}$ & $\leq$ & $\in \{2,3,4\}$ \\
		$\upDelta\phi (\vetmiss,\vptlep )$ [rad]& $>$ & $\in \{0.5,1.0,2.0,2.5\}$ \\
		\bottomrule
	\end{tabular}\vspace{2mm}
	\label{tab:cut_scan}
\end{table}

The optimisation of the signal regions for the \onelepton search benefits from the experience of past analyses investigating the same simplified model in the same final state~\cite{SUSY-2013-23,SUSY-2017-01}, but explores new observables and considers signal region configurations optimised for the integrated luminosity of the full Run~2 dataset.

\subsection{Starting from benchmark signal points}

A total of six so-called \textit{benchmark} signal points, each representative of a different part of the model parameter space, are chosen for the first step of the optimisation procedure involving $N$-dimensional cut scans and \textit{N}--1 plots.
Apart from the variables introduced in~\cref{sec:variables}, a set of additional, potentially discriminative observables are considered in the $N$-dimensional cut scan\footnote{These variables will turn out not to be used for the final signal regions and are only introduced here for completeness of the optimisation procedure description. Representative kinematic distributions for all observables are shown as a reference in \cref{fig:additional_presel_plots}.}:
\begin{itemize}
	\item The transverse momenta of the two leading jets as well as of the lepton ($p_\textrm{T}^\mathrm{jet1}$, $p_\textrm{T}^\mathrm{jet2}$, $\ptl$). Especially for signal models with high mass differences between the electroweakinos, the transverse momenta of the lepton and the jets tend to have higher values than in \gls{sm} background processes.
	\item The object-based $\etmiss$ significance $\mathcal{S}$~\cite{met_significance:2294922}, an observable designed to quantify how genuine the reconstructed $\etmiss$ in an event is. It is determined through a hypothesis test using a log-likelihood ratio that takes into account the resolution of all objects entering the computation of $\etmiss$. As such, $\mathcal{S}$ offers good discrimination against events with a sizeable fraction of fake $\etmiss$ in the event originating, \eg, from jet mismeasurements or the non-hermeticity of the detector. Events with a large share of fake $\etmiss$ accumulate at low values of $\mathcal{S}$, while events with mostly real $\etmiss$ tend to have large values of $\mathcal{S}$.
	\item The distance between the two leading jets $\upDelta R_{jj}$ as well as between the two \textit{b}-jets $\upDelta R_{b\hspace{-0.06em}\bar{b}}$. Especially in events with a large mass difference between the electroweakinos, the Higgs can receive a significant boost, such that the two \textit{b}-jets from the Higgs decay tend to be close together in the laboratory frame (and are also the highest-$\pt$ jets in an event), resulting in small values of both $\upDelta R_{jj}$ and $\upDelta R_{b\hspace{-0.06em}\bar{b}}$. In \gls{sm} background processes, however, the two leading (\textit{b}-)jets often do not originate from the same object and thus tend to be further apart.
	\item The azimuthal distance between the lepton $\pt$ and the missing transverse momentum, denoted by $\upDelta \phi (\makemebold{p}_\mathrm{T}^\ell, \makemebold{p}_\mathrm{T}^\mathrm{miss})$. This observable exploits the fact that the lepton and the $\etmiss$ tend to have a more back-to-back configuration in signal events than in many \gls{sm} processes where the lepton and the neutrino (the latter often responsible for a large part of the $\etmiss$ in an event) often originate from the same $W$ boson decay.
\end{itemize}

\begin{figure}
	\centering
	\begin{subfigure}[b]{0.5\linewidth}
		\centering\includegraphics[width=1.0\textwidth]{N-1_cut_scan/z_vs_effs_300_150.pdf}
		\caption{$m(\charg$/$\neutr), m(\lsp) =  300, \SI{150}{\GeV}$}
	\end{subfigure}\hfill
	\begin{subfigure}[b]{0.5\linewidth}
		\centering\includegraphics[width=1.0\textwidth]{N-1_cut_scan/z_vs_effs_800_250.pdf}
		\caption{$m(\charg$/$\neutr), m(\lsp) =  800, \SI{250}{\GeV}$}
	\end{subfigure}\hfill

	\caption[N-dimensional cut scan results]{Results of the $N$-dimensional cut scan for two representative benchmark points. The binomial discovery significance $Z_\mathrm{B}$ is plotted against the signal efficiency for different uncertainty configurations. Additionally, the expected \gls{sm} background event rates are shown (grey), including their statistical uncertainties for one of the two statistically independent samples (grey shaded area). The solid and dashed lines represent the two statistically independent subsets that the \gls{mc} samples are split into.}
	\label{fig:results_z_vs_eff}
\end{figure}

In order to avoid selecting cut combination candidates with over-tightened selection criteria compared to the available \gls{mc} statistics, constraints are applied on the relative statistical uncertainty on the background, and on the number of unweighted \gls{mc} events passing the cut combination candidates.
Cut combinations are only considered if they result in less than 50\% relative statistical uncertainty on the total background.
In addition, all cut combinations need to result in at least five unweighted \gls{mc} events for each of the three major backgrounds, $\ttbar$, single top and $\wjets$.

The discrete selection possibilities for each of the observables are shown in \cref{tab:cut_scan}.
A preselection of a lepton and exactly two \textit{b}-jets (and thus at least two jets overall in the event) is always applied. Requirements on the different observables in~\cref{tab:cut_scan} are optional and do not need to be applied by the optimisation algorithm.
The results of the brute-force $N$-dimensional cut scans for each benchmark signal point can be visualised by plotting the expected discovery significance $Z_\mathrm{B}$ against the signal efficiency.
\Cref{fig:results_z_vs_eff} shows the results of two such cut scans using two of the benchmark signal points.
The corresponding plots for the remaining benchmark points are shown in~\cref{fig:results_z_vs_eff_rest}. In these figures, the binomial significance is calculated for different uncertainty configurations for each of the two statistically independent subsets.
In addition, the expected background rate is shown for each subset.
A cut combination with high achieved significance can be chosen, while avoiding statistical fluctuations and over-tightening.
The cut combinations chosen for each benchmark point, after a round of \textit{N}--1 plots, are shown in~\cref{tab:cut_scan_results}. The \textit{N}--1 plots, shown in~\cref{fig:results_n1_800_0,fig:results_n1_800_150,fig:results_n1_800_250,fig:results_n1_600_300,fig:results_n1_400_200,fig:results_n1_300_150}, are used to validate and fine-tune the cut values obtained through the cut scan and allow to identify and remove cuts on observables that do not contribute significantly to the achieved $Z_\mathrm{B}$ value.
From the 12 observables initially considered, only six (excluding the \textit{b}-jet multiplicity technically not part of the scan) are part of the optimised cut combination candidates.
The remaining observables turned out not to significantly improve the sensitivity and are therefore dropped in the following.

\begin{table}
	\begin{center}
	\small
			\begin{tabular} {l c c c c c c c}
				\toprule
				Observable &  $(300,150)$ & $(400,200)$ & $(600,300)$  & $(800,250)$ & $(800,150)$ & $(800,0)$ \\
				\midrule
				$N_{b\mathrm{-jet}}$ &  2 & 2 & 2 & 2 & 2 & 2 \\
				$N_\mathrm{jet}$ & 2 & 2 & 2 -- 3 & 2 -- 3  & 2 -- 3 & 2 -- 3\\
				$\mbb$  $[\SI{}{\GeV}]$& $[105-135]$ & $[100-140]$ & $[100-140]$ & $[95-145]$ & $[95-145]$ & $[95-145]$ \\
				$\met$ $[\SI{}{\GeV}]$ & $>240$ & $>240$ & $>240$ & $>240$ & $>240$  & $>240$\\
				$m_\mathrm{CT}$ $[\SI{}{\GeV}]$ &  $>200$ & $>240$ & $>260$ & $>260$ & $>260$   & $>280$ \\
				$m_\mathrm{T}$ $[\SI{}{\GeV}]$ &  $>100$ & $>120$ & $>140$ & $>200$ & $>240$ & $>240$ \\
				$\mlb$ $[\SI{}{\GeV}]$ &  -- & -- & $>150$ & $>120$ & $>120$ & $>120$ \\
				\midrule
				$Z_\mathrm{B}$ $[\sigma]$ & \multicolumn{1}{c}{0.8} & \multicolumn{1}{c}{1.9} & \multicolumn{1}{c}{2.1} & \multicolumn{1}{c}{1.8} & \multicolumn{1}{c}{2.2} & \multicolumn{1}{c}{2.3} \\
				\bottomrule
			\end{tabular}
		\caption{Optimal cut combination for each benchmark signal point obtained with a brute force cut scan and a round of \textit{N}--1 plots. The parameters of the benchmark points are $m(\charg$/$\neutr)$ and $m(\lsp)$, both given in $\SI{}{\GeV}$. The significance is computed for \onethirtynineifb with the binomial discovery significance $Z_\mathrm{B}$ and includes MC statistical uncertainty as well as a constant 30\% systematic uncertainty. A dash `--' is used where no requirement on the respective observable is applied.}
		\label{tab:cut_scan_results}
	\end{center}
\end{table}

\subsection{Towards final signal regions}\label{sec:towards_signal_regions}

The optimal cut combinations obtained for the benchmark signal points, shown in~\cref{tab:cut_scan_results}, need to be consolidated into a final set of signal regions.
From~\cref{tab:cut_scan_results}, it can be concluded, that all benchmark points favour a common baseline selection including exactly two \textit{b}-jets, possibly one additional light jet, a Higgs mass window requirement of roughly $\mbb\in [100,140]$~$\SI{}{\GeV}$, and $\etmiss > \SI{240}{\GeV}$.
The remaining requirements on $\mt$, $\mct$ and $\mlb$ are, however, not easily consolidated into a single signal region, as they vastly differ depending on the model parameter space and kinematic regime represented by each benchmark point.

It can already be seen from the normalised distributions in~\cref{fig:norm_obs,fig:norm_obs_app}, that signal points from different kinematic regimes in the parameter space would in principle prefer different requirements on all three of these observables.
Designing a single signal region that achieves optimal sensitivity to the entire parameter space studied, is thus not possible.
Instead, a more generalised configuration is chosen, defining multiple signal region bins orthogonal to each other through their requirements on $\mt$ and $\mct$.
Being mutually exclusive, such signal region bins can be statistically combined in a single likelihood and can be used in a simultaneous fit to data, effectively creating a two-dimensional shape-fit in these observables.
Such a shape-fit configuration allows to exploit the differences in shape between signal and background distributions, and is able to accommodate the varying shapes of signal points from different regions in the parameter space, making it an ideal statistical tool to cover a wide range of kinematic regimes.

The optimal number of bins as well as values of the individual bin edges in both distributions depends on the available \gls{mc} statistics and is determined using the simplified fit scans introduced in~\cref{sec:fit-scan}.
The \gls{mc} statistical uncertainties, as well as a systematic uncertainty of 30\%, correlated over all bins, are considered in each configuration.
The number of bins is varied in each direction ($\mt$ and $\mct$) between two and five using different bin edges, varied within ranges determined by the optimal cut values obtained for the benchmark points.
As configurations with more bins could, in some circumstances, potentially benefit from the additional \gls{mc} statistics resulting from looser selection criteria on the remaining variables, the previously consolidated baseline selection is also allowed to vary to some extent.
Finally, although not expected to yield better performance, configurations with multiple orthogonal signal region bins in $\etmiss$ or $\mbb$ are also included in the scan.
A subset of the investigated candidates is illustrated in~\cref{fig:fit_scan_optimisation}, showing the nominal expected exclusion limit at 95\% without uncertainty bands.
Configurations with multiple, disjoint patches of excluded areas in the parameter space are discarded, as they typically result from high statistical fluctuations.

\begin{figure}
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},capbesidewidth=0.35\textwidth}}]{figure}[\FBwidth]
{\caption{Expected exclusion contours obtained from a subset of the signal region candidates. The background estimate is directly taken from \gls{mc} and includes \gls{mc} statistical uncertainty as well as an uncorrelated scale uncertainty of 30\%. For the sake of visibility, only the nominal contours are shown (without uncertainty bands). Configurations resulting in multiple, disjoint patches of excluded areas are rejected.}\label{fig:fit_scan_optimisation}}
{\includegraphics[width=0.60\textwidth]{HF/batch_compare}}
\end{figure}

As expected from~\cref{tab:cut_scan_results}, the best performing configurations define multiple signal region bins in the $\mt$ and $\mct$ distributions, while keeping a constant baseline selection on the remaining observables.
\Cref{fig:plot_binnings} shows a comparison of the expected exclusion contour for exemplary two-dimensional shape-fit configurations, using signal regions binned in ($\mt$, $\etmiss$), ($\mt$, $\mbb$) or ($\mt$, $\mct$).
The setup using a two-dimensional shape-fit in $\mt$ and $\mct$ clearly maximises the expected excluded area.
%In addition, this configuration also leads to optimal sensitivity within the expected limit, as is illustrated in~\cref{fig:plot_binnings_cls}.
Finally, applying a requirement on high values of $\mlb$ in the highest $\mt$ bins has been shown (cf.~\cref{fig:plot_mlb1_cls}) to further increase sensitivity to signal models with high mass differences.

In~\cref{fig:previous_analysis_comparison}, the fully optimised two-dimensional shape-fit configuration is compared with the signal regions of the previous iteration of the search~\cite{SUSY-2017-01}, scaled up to the integrated luminosity of the full Run~2 dataset.
It can clearly be seen that a significant improvement in sensitivity is achieved through the introduction of the two-dimensional shape-fit strategy.

 \begin{figure}
	\centering
	\begin{subfigure}[b]{0.5\linewidth}
		\centering\includegraphics[width=1.0\textwidth]{HF/plot_binnings}
		\caption{\label{fig:plot_binnings}}
	\end{subfigure}\hfill
	\begin{subfigure}[b]{0.5\linewidth}
		\centering\includegraphics[width=1.0\textwidth]{HF/plot_2d_shapefit}
		\caption{\label{fig:previous_analysis_comparison}}
	\end{subfigure}\hfill

	\caption{Comparison of different shape-fit configurations. Figure~\subref{fig:plot_binnings} compares three different two-dimensional shape-fit configurations using $3\times 3$ bins in ($\mt$, $\etmiss$), ($\mt$, $\mbb$) and ($\mt$, $\mct$). Figure~\subref{fig:previous_analysis_comparison} compares the two-dimensional shape-fit in $\mt$ and $\mct$ to the signal regions of the previous analysis iteration signal regions scaled to \onethirtynineifb. All exclusion limits shown are expected limits at 95\% CL, using \gls{mc} statistical and 30\% systematic uncertainties.}
	\label{fig:results_HF_scans}
\end{figure}

\section{Signal region definitions}\label{sec:signal_region_definitions}

\begin{table}
	\begin{center}
		\begin{tabular} {l | c c c }
			\toprule
				&  \textbf{SR-LM} & \textbf{SR-MM} & \textbf{SR-HM} \\
			\midrule
			$N_{\mathrm{lepton}}$ & \multicolumn{3}{c}{$=$ 1}\\
			$\ptl$ [\GeV] & \multicolumn{3}{c}{ $>7(6)$ for $e$($\mu$)} \\
			$N_\mathrm{jet}$ & \multicolumn{3}{c}{$=$ 2 or 3}\\
			$N_{b\textrm{-jet}}$ &\multicolumn{3}{c}{$=$ 2} \\
			$\met$ $[\SI{}{\GeV}]$ & \multicolumn{3}{c}{$>240$}\\
			$\mbb$  $[\SI{}{\GeV}]$ & \multicolumn{3}{c}{$\in [100,140]$}\\
			$m(\ell,b_1)$ $[\SI{}{\GeV}]$ & -- & -- & $>120$ \\
			\midrule
			%                        \mt $[\SI{}{\GeV}]\mathrm{(excl.)}$&   $\in [100,160]$ & $\in [160,240]$ & $\in [240,\infty]$ \\
			$\mt$ $[\SI{}{\GeV}]~\mathrm{(excl.)}$&   $\in [100,160]$ & $\in [160,240]$ & $>240$ \\

			$\mct$ $[\SI{}{\GeV}]~\mathrm{(excl.)}$ &\multicolumn{3}{c}{ $ \{ \in [180,230]$,\,$\in [230,280]$, $>280  \}$}\\
			%                        &\multicolumn{3}{c}{ $\in [180,230]$}\\
			%                        \mct $[\SI{}{\GeV}]\mathrm{(excl.)}$ & \multicolumn{3}{c}{ $\in [230,280]$} \\
			%                         & \multicolumn{3}{c}{ $>280$}\\
			%                         & \multicolumn{3}{c}{ $\in [280,\infty]$}\\

			\midrule
			$\mt$ $[\SI{}{\GeV}]~\mathrm{(disc.)}$&   $>100$ & $>160$ & $>240$ \\
			$\mct$ $[\SI{}{\GeV}]~\mathrm{(disc.)}$ & \multicolumn{3}{c}{ $>180$}\\
			\bottomrule
		\end{tabular}
		\caption{Overview of the selection criteria for the signal regions. Exclusion \glspl{sr} (`excl.') are defined for model-dependent limits, and discovery \glspl{sr} (`disc.') are defined for model-independent upper limits. A dash `--' is used where no requirement on the respective observable is applied.}
		\label{tab:SignalRegionDef}
	\end{center}
\end{table}

An overview of the final signal region definitions is provided in~\cref{tab:SignalRegionDef}.
Based on the previously discussed results, three signal regions bins in $\mt$ are defined, optimised for different regimes in the \mbox{$\charg$/$\neutr$} and $\lsp$ mass difference. According to the mass difference regime targeted, they are aptly called low (SR-LM), medium (SR-MM), and high (SR-HM) mass signal regions, respectively.
While SR-LM targets the smallest values of $\mt$, SR-MM and SR-HM target progressively increasing values of $\mt$.
All three signal regions are further divided into three $\mct$ bins each, resulting in a total of nine disjoint signal region bins. The signal region with the highest requirement on $\mt$ (SR-HM) also requires $\mlb>\SI{120}{\GeV}$, for the reason explained previously.
All three signal regions otherwise share a common set of requirements on the number of jets, $\etmiss$ and $\mbb$.
As shape-fits are by construction highly model-dependent\footnote{The signal shapes need to be known in order to estimate the expected signal rates in multiple, disjoint signal region bins.}, these \glspl{sr} will be used for deriving model-dependent limits in the case where no significant excess, compared to the expected \gls{sm} background rate, is seen in data.
For this reason, the shape-fit regions will be referred to as \textit{exclusion} regions in the following. A graphical representation of the nine exclusion signal region bins is shown in~\cref{fig:sr_strategy}.
The kinematic distributions in SR-LM, SR-MM and SR-HM are shown as \textit{N}--1 plots in \cref{fig:Wh_reopt_second_round_n1_srlm,fig:Wh_reopt_second_round_n1_srmm,fig:Wh_reopt_second_round_n1_srhm}.

For evaluating a potential excess in data compared to the expected background rate, a second set of signal regions is derived from the optimised shape-fit setup.
For each of the three bins in the transverse mass (SR-LM, SR-MM, and SR-HM), the three $\mct$ bins are summed up and the upper bound on $\mt$ is removed (if present).
This results in three \textit{cut-and-count} signal regions in which only the total number of events after the selection is relevant. Since no information about the shape of the distribution of signal events is used, these so-called \textit{discovery} regions make minimal model assumptions, and can be used to constrain any \gls{bsm} physics process for which the expected event rates in one or multiple discovery signal regions are known (cf.~\cref{sec:model_independent_limits}).
In case no significant excess over the \gls{sm} expectation is seen in data, the discovery \glspl{sr} can be used to derive upper limits on the visible cross section of physics beyond the \gls{sm}, \ie the apparent cross section of \gls{bsm} processes including the acceptance and efficiency of the signal region selections.

% -------------------------------------------------------------------------------------------------------
\FloatBarrier
\newpage
% -------------------------------------------------------------------------------------------------------

%\begin{figure}
%\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},capbesidewidth=0.5\textwidth}}]{figure}[\FBwidth]
%{\caption{Configuration of the exclusion signal regions. Nine signal region bins are defined on $\mt$ and $\mct$ within the Higgs mass window. All signal regions can be statistically combined using a single likelihood, effectively resulting in a two-dimensional shape-fit.}\label{fig:sr_strategy}}
%{\includegraphics[width=0.45\textwidth]{strategy_2}}
%\end{figure}

\begin{figure}
	\centering\includegraphics[width=0.6\textwidth]{strategy_2}
	\caption{Configuration of the exclusion signal regions. Nine signal region bins are defined in $\mt$ and $\mct$ within the Higgs mass window. All signal regions can be statistically combined using a single likelihood, effectively resulting in a two-dimensional shape-fit.}\label{fig:sr_strategy}
\end{figure}

\begin{figure}
	\centering
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRLM_mct_bins/met.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srlm_met}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRLM_mct_bins/mct.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srlm_mct}}
	\end{subfigure}
	\par\medskip
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRLM_mct_bins/mt_both.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srlm_mt}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRLM_mct_bins/mbb_both.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srlm_mbb}}
	\end{subfigure}
%	\begin{subfigure}[b]{0.4\linewidth}
%		\centering\includegraphics[width=\textwidth]{n1_SRLM_mct_bins/mlb1.pdf}
%		\caption{\label{fig:Wh_reopt_second_round_n1_srlm_mlb1}}
%	\end{subfigure}%
	\par\medskip
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRLM_mct_bins/nJet30.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srlm_njet}}
	\end{subfigure}
	\caption{\textit{N}--1 plots for SR-LM, with representative signal points and all $\mct$ bins included. The dashed area represents the \gls{mc} statistical uncertainties on the background. In all figures except \figname~\subref{fig:Wh_reopt_second_round_n1_srlm_mct}, the significance in the lower pad is obtained by summing up all the events in the direction of the cut arrow and includes 30\% systematic uncertainties as well as MC statistical uncertainties. In \figname~\subref{fig:Wh_reopt_second_round_n1_srlm_mct} the significance is only computed on a bin-by-bin basis, \ie not summing up all events in the direction of the cut arrow.}
	\label{fig:Wh_reopt_second_round_n1_srlm}
\end{figure}

\begin{figure}
	\centering
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRMM_mct_bins/met.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srmm_met}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRMM_mct_bins/mct.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srmm_mct}}
	\end{subfigure}
	\par\medskip
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRMM_mct_bins/mt_both.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srmm_mt}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRMM_mct_bins/mbb_both.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srmm_mbb}}
	\end{subfigure}
%	\begin{subfigure}[b]{0.4\linewidth}
%		\centering\includegraphics[width=\textwidth]{n1_SRMM_mct_bins/mlb1.pdf}
%		\caption{\label{fig:Wh_reopt_second_round_n1_srmm_mlb1}}
%	\end{subfigure}%
	\par\medskip
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRMM_mct_bins/nJet30.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srmm_njet}}
	\end{subfigure}
	\caption{\textit{N}--1 plots for SR-MM, with representative signal points and all $\mct$ bins included. The dashed area represents the \gls{mc} statistical uncertainties on the background. In all figures except \figname~\subref{fig:Wh_reopt_second_round_n1_srmm_mct}, the significance in the lower pad is obtained by summing up all the events in the direction of the cut arrow and includes 30\% systematic uncertainties as well as MC statistical uncertainties. In \figname~\subref{fig:Wh_reopt_second_round_n1_srmm_mct} the significance is only computed on a bin-by-bin basis, \ie not summing up all events in the direction of the cut arrow.}
	\label{fig:Wh_reopt_second_round_n1_srmm}
\end{figure}

\begin{figure}
	\centering
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRHM_mct_bins/met.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srhm_met}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRHM_mct_bins/mct.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srhm_mct}}
	\end{subfigure}
	\par\medskip
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRHM_mct_bins/mt_both.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srhm_mt}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRHM_mct_bins/mbb_both.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srhm_mbb}}
	\end{subfigure}
	\par\medskip
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRHM_mct_bins/mlb1.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srhm_mlb1}}
	\end{subfigure}%
	\begin{subfigure}[b]{0.45\linewidth}
		\centering\includegraphics[width=\textwidth]{n1_SRHM_mct_bins/nJet30.pdf}
		\vspace{-2em}
		\caption{\label{fig:Wh_reopt_second_round_n1_srhm_njet}}
	\end{subfigure}
	\caption{\textit{N}--1 plots for SR-HM, with representative signal points and all $\mct$ bins included. The dashed area represents the \gls{mc} statistical uncertainties on the background. In all figures except \figname~\subref{fig:Wh_reopt_second_round_n1_srhm_mct}, the significance in the lower pad is obtained by summing up all the events in the direction of the cut arrow and includes 30\% systematic uncertainties as well as MC statistical uncertainties. In \figname~\subref{fig:Wh_reopt_second_round_n1_srhm_mct} the significance is only computed on a bin-by-bin basis, \ie not summing up all events in the direction of the cut arrow.}
	\label{fig:Wh_reopt_second_round_n1_srhm}
\end{figure}


% 270 words
% Limit: 500 words
\section{Method}

\subsection{The data}

We crossmatched the \mct\ catalog of stellar rotation periods, measured from
\kepler\ light curves, with the \gaia\ DR2 catalog.
Reddening and extinction from dust was calculated for each star using the
Bayestar dust map implemented in the dustmaps {\it Python} package
\citep{green2018}.
We estimated effective temperatures from dereddened \Gaia\ \gcolor\ color,
using an 8th-order polynomial relation calibrated using .... stars
\racomment{ask Jason for details}.
\begin{equation}
    \mathrm{T_{eff}} = 8960 -4802C + 1931C^2 -2446C^3 + 2669C^4 - 1324C^5 +
    301C^6 - 26C^7,
% 8959.8112335205078, -4801.5566310882568, 1931.4756631851196,
%           -2445.9980716705322, 2669.0248055458069, -1324.0671020746231,
%           301.13205924630165, -25.923997443169355]
\end{equation}
where C is \gaia\ \gcolor.

\begin{figure}
  \caption{
A \gaia\ color magnitude diagram showing the \citet{mcquillan2014} sample with
    extinction-corrected magnitudes, colored by rotation period.
We excluded photometric binaries and subgiants from our analysis by removing
stars above the two dashed lines.
The rotation periods of binaries and subgiants do not follow a Skumanich-like
braking law.
The rotation period gradient across the main sequence is visible by eye in
    this figure: young, rapidly rotating stars are located below the old,
    slowly rotating stars.
}
  \centering
    \includegraphics[width=1\textwidth]{CMD_cuts}
\label{fig:CMD_cuts}
\end{figure}
We removed visual binaries and subgiants from the sample as the
rotation-period evolution of these two types of stars is generally different
to that of single stars which more usually follow a Skumanich-like spin-down
law.
% Tidal and magnetic interactions between the two components of a binary system
% can influence the rotation periods of both stars, and the expanding envelopes
% of subgiants drive rapid spin-down through conservation of angular momentum.
We removed visual binaries and subgiants from the sample by applying cuts to
the color-magnitude diagram (CMD), shown in figure \ref{fig:CMD_cuts}.
We fit a 6th-order polynomial to the main sequence and raised it by 0.22 dex,
to approximate the division between single stars and visual binaries.
We eliminated visual binaries by removing all stars above this line from the
sample, and subgiants by removing stars brighter than 6th magnitude in \gaia\
G-band.

We removed stars with negative parallaxes and parallax signal-to-noise ratios
below 10 and a small number of stars fainter than 16th magnitude from the
sample.
We used the {\tt Pyia} \citep{price-whelan_2018} and {\tt astropy}
\citep{astropy2013, astropy2018} {\it Python} packages to calculate stellar
velocities.
{\tt Pyia} has built-in functionality for calculating velocity samples from
the full \gaia\ uncertainty covariance matrix via Monte Carlo sampling.
It therefore not only incorporates uncertainties on the \gaia\ positions
parallaxes and proper motions, it also accounts for the {\it covariance}
between these properties.
Finally, we removed stars with absolute \vb\ uncertainties greater than 1
\kms\ from the sample.

Gyrochronal ages were calculated using a polynomial gyrochronology relation
calibrated to Praesepe and the Sun \citep{angus2019}.
We used dereddened \gaia\ \gcolor\ color to calculate these ages.
Figure \ref{fig:period_teff} shows the \mct\ rotation period sample, separated
into three groups: stars above the gap in blue (classified as stars older than
1.1 Gyr), stars below the gap in orange (younger than 1.1 Gyr but older than
0.5 Gyr), and stars that are likely to be synchronized binaries (younger than
0.5 Gyr).
We used a gyrochronal isochrone (often called a gyrochrone) to separate these
groups of stars because the rotation period gap appears to fall on a
gyrochrone of 1.1 Gyr, and because the lower envelope of rotation periods is
also shaped like a gyrochrone at 0.5 Gyr.
This is probably because there is not a significant number of stars younger
than 500 Myr in the \kepler\ field.
Stars with short rotation periods, that seem younger than 500 Myr according to
the \citet{angus2019} gyrochronology relation are likely to be binaries.
Stars rotating more rapidly than 7 days were shown to be mostly synchronized
binaries \citep{citation}.
This is also borne out in the results section of this paper.
Although most rapid rotators are likely synchronized binaries (and therefore
not actually young -- just rotating rapidly because of tidal synchronization),
{\it some} of the rapid rotators probably {\it are} young and this could be an
extremely interesting group of stars from a scientific standpoint.

\begin{figure}
  \caption{
The rotation periods of stars in the \citet{mcquillan2014} sample vs.
effective temperature, with visual binaries and subgiants removed.
Blue circle points are non-photometric binary dwarfs, cooler than 4800 k, with
a rotation period and \gaia\ color indicating they are older than 1.1 gyr.
orange squares are stars that with rotation periods that fall just below the
gap: they have rotation-ages between 0.5 and 1.1 gyrs.
Green triangles are stars with rotation periods faster than the main envelope
of stars.
These are probably binaries whose rotation periods are synchronized to their
orbits and have been spun-up via tidal interactions.
}
  \centering
    \includegraphics[width=1\textwidth]{period_teff}
\label{fig:period_teff}
\end{figure}


%!TEX root = theory.tex
% =========================================================================
% -------------------------------------------------------------------------
% Single and Multiphase Flow:
% -------------------------------------------
%
%  This is a good place to outline key objectives of this section.
%
% -------------------------------------------------------------------------

% bold symbols
\def\bnabla{{\boldsymbol{\nabla}}}
\def\bg{{\boldsymbol{g}}}
\def\bq{{\boldsymbol{q}}}
\def\bx{{\boldsymbol{x}}}
\def\bJ{{\boldsymbol{J}}}
\def\K{{\mathbb K}}

% abbreviations
\def\Frac{\displaystyle \frac}

% units
\def\ucdot{{\,\cdot\,}}
\def\ukg{{\rm kg}}
\def\um{{\rm m}}
\def\us{{\rm s}}
\def\umol{{\rm mol}}
\def\upa{{\rm Pa}}

\section{Isothermal Flow Processes}
\label{sec:flow-processes}

\subsection{Overview}

Subsurface flow simulations typically assume that Darcy's law is valid.
As this law gives a relationship between velocity and pressure,
it essentially replaces the momentum equation.
There has been much research to support the validity of Darcy's
Law~\citep{bear-1972}.
Most references give the applicability of Darcy's Law to be
for laminar flows with Reynolds numbers less that 10 using the pore throat diameter for a soil.
There has been some effort to include inertial as well as turbulence effects that can occur near the wells.

It is also assumed that thermodynamic equilibrium (mechanical and thermal) exists for each grid block.
Sub-grid scale features often play a prominent role in multi-fluid simulations.
Faults and fractures will likely be fast paths for contaminant transport and can
effectively be treated with multiple porosity models.
Similarly, rate-limited diffusion from clay inclusions can also be modeled with a
multiple porosity material.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Fully Saturated Flow}
\label{sec:flow-single-phase}

The most basic flow model is a single-phase fully saturated flow in a porous medium.
Notwithstanding its simplicity, it has a wide application to
describing subsurface processes.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Assumptions and Applicability}

There are many assumptions required for the strict validity of Darcy's Law,
including
\begin{itemize}
\item
  incompressibility and
\item
  laminararity of the flow.
\end{itemize}
We also assume that
\begin{itemize}
\item
  solid/rock is incompressible,
\item
  fluid viscosity is constant,
\item
  there are no fractures, only pores.
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Process Model Equations}

Under the above assumptions fully saturated flow is governed by
\begin{subequations}
\label{eq:Darcy fully saturated}
\begin{align}
  \phi \left(\Frac{S_s}{g} + \Frac{S_y}{L\,g}\right) \frac{\partial p_l}{\partial t}
  &=
  -\boldsymbol{\nabla} \cdot (\rho_l \boldsymbol{q}_l) + Q,
  \\
  \bq_l &= -\frac{\K}{\mu_l}
  (\bnabla p_l - \rho_l \bg),
\end{align}
\end{subequations}
where the primary variable is the fluid presure $p_l$ [\upa].
The fluid velocity $\bq_l$ [$\um\ucdot\us^{-1}$] is the dependent variable.
All the other variables can be treated as material parameters
that sometimes may depend on pressure.
These include:
$\phi$ [-] is the porosity,
$S_s$ [$\um^{-1}$] and $S_y$ [-] are specific storage and yeild, respectively,
$g$ [$\um\ucdot\us^{-2}$] is the gravitational constant
and $\bg$ [$\um\ucdot\us^{-2}$] is the gravitational vector,
$L$ [$\um$] is a characteristic size of the yield layer,
$\K$ [$\um^2$] is an absolute permeability tensor, and
$Q$ [$\ukg \ucdot \um^{-3} \ucdot \us^{-1}$] is source or sink term.

It is common to see the Darcy Law written in terms of hydraulic head $h$
and the hydraulic conductivity tensor $\K_h$:
\begin{subequations}  \label{eq:HydraulicHead}
\begin{align}
  \bq_l &= -\K_h \bnabla h,
  \\
  h \, &=  z + \frac{p_l}{\rho_l g},
  \\
  \K_h &= \K \, \frac{\rho_l g}{\mu_l}.
\end{align}
\end{subequations}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Boundary conditions}

Three types of \textit{boundary conditions} are supported by the model:
\begin{enumerate}
\item
  prescribed pressure $p_l$ (or head), see \eqref{eq:BC pressure Darcy FS};
\item
  prescribed flux, i.e. normal component of the velocity $\bq_l$, see \eqref{eq:BC flux Darcy FS};
\item
  semipervious boundary, see \eqref{eq:BC semipervious Darcy FS}.
\end{enumerate}
%\citep[for reference see][]{bear-1979}.
%These boundary conditions are described in Section~\ref{sec:flow-boundary-conditions}.

\begin{figure}  [h]
\begin{center}
\includegraphics[scale=0.25]{figs/bc_flow.pdf}
\caption{Flow domain between two rivers \citep[it was partially based on]{bear-1972}.}
\label{fig:bc_flow}
\end{center}
\end{figure}

\paragraph{Boundary of prescribed pressure or head.}
This involves the specification of a fixed pressure or hydrostatic head on boundary $\Gamma_D$.
For instance, a boundary of this kind occurs whenever the flow domain is adjacent to a body of open water.
Segments A-B and E-F in Fig.~\ref{fig:bc_flow} are examples of a boundary of prescribed potential.
The pressure or head boundary conditions are given functions, e.g.
\begin{equation}
\label{eq:BC pressure Darcy FS}
  p_l(\bx,t) = p_{b}(\bx,t), \quad \bx \in \Gamma_D.
\end{equation}

\paragraph{Boundary of prescribed flux.}
This involves the specification of the flux normal to the boundary $\Gamma_N$
(see segment C-D in Figure \ref{fig:bc_flow}):
\begin{equation}
\label{eq:BC flux Darcy FS}
  \bq_l\cdot \bn = q_{b}(\bx,t), \quad \bx \in \Gamma_N,
\end{equation}
where $q_b$ [$\um\ucdot\us^{-1}$] is the given boundary flux.
For infiltration at the top horizontal surface, it equals to the Darcy velocity
and referred to as the infiltration velocity.

\paragraph{Semipervious boundary (or mixed boundary condition).}
This boundary condition is more complicated than the first two as it involves a case
in which local conditions within the computational domain influence the flux in or
out of the domain.
This type of boundary occurs when the porous medium domain is in contact with
a body of water continuum (or another porous medium domain, see for instance segments
A-B and E-F in Fig.~\ref{fig:bc_flow}), however, a relatively thin semipervious layer
separates the two domains:
\begin{equation}
\label{eq:BC semipervious Darcy FS}
  \bq_l \cdot \bn = I\, \left(p (\bx,t) - p_{b}(\bx,t) \right), \quad \bx \in \Gamma_R.
\end{equation}
where $I$ is an impedance and $p_{b}(\bx,t)$ is the given external pressure.

\clearpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Partially Saturated Flow}
\label{sec:richards-equation}

The Richards equation is often used to describe single phase flow under partially
saturated conditions (i.e., the pores are not occupied exclusively by a single phase).
As such, it requires the introduction of a relative permeability and a capillary
pressure relations. % as discussed in Section~\ref{sec:pc_s_relations}.
The Richards equation is well suited to very large numerical problems (millions of
degrees of freedom) because it requires only one independent variable per cell.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Assumptions and Applicability}

The Richards equation makes the fundamental assumption that
we are neglecting the movement of the gas phase.
Because of this assumption, using the Richards equation may limit the kinds of
transport analysis that can be done.
It should also be noted that the Richards equation is often highly nonlinear
due to strong dependence of the relative permeability of the liquid phase
on the liquid saturation.
We also assume that there are no fractures and the water flows through the pores only.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Process Model Equations}
\label{sec:richards-model-equations}

The Richards equation is derived from the conservation of
liquid mass equation.
In the mixed formulation it is written
for the volumetirc water content $\theta$ [$\umol\ucdot\um^{-3}$]
and the Darcy velocity $\bq_l$ [$\um\ucdot\us^{-1}$]:
\begin{subequations}\label{eq:Darcy}
\begin{align}
  \frac{\partial \theta(p_l)}{\partial t}
  &=
  -\bnabla \cdot (\eta_l \bq_l) + Q,
  \\
  \bq_l
  &=
  -\frac{\K k_{rl}}{\mu_l} (\bnabla p_l - \rho_l \bg),
\end{align}
\end{subequations}
where
$\eta_l$ [$\umol\ucdot\um^{-3}$] is the molar liquid density,
$Q$ [$\ukg \ucdot \um^{-3} \ucdot \us^{-1}$] is source or sink term,
$\K$ [$\um^2$] is absolute permeability tensor,
$\mu_l$ [$\upa\ucdot\us$ ] is liquid viscosity,
$\rho_l$ [$\ukg\ucdot\um^{-3}$ ] is liquid density, and
$k_{rl}$ [-] is relative permeability.
The total volumetric water content $\theta$ is defined as
a product of porosity $\phi$, molar liquid density $\eta_l$ and liquid saturation $s_l$:
$$
  \theta(p_l) = \phi(p_l) \eta_l\, s_l(p_c).
$$
Usage of the molar liquid density $\theta$
allows us to easily extend the model to a non-isothermal case.

Just like in the case of the fully saturated flow \eqref{eq:Darcy fully saturated},
the primary dependent variable in \eqref{eq:Darcy} is liquid pressure $p_l$.
The difference with \eqref{eq:Darcy fully saturated}
is in that the pressure enters the equations in a nonlinear form,
through a dependence $\theta_l(p_l)$ to be discussed in the following sections.

In general the porosity $\phi$ is a functions of pressure $p_l$.
The relative permeability $k_{rl}$ is a function of saturation $s_l$,
which in turns is a function of capillary pressure $p_c$.
The relation between pressures $p_l$ and $p_c$ will be discussed in the next section.
Typical models of relative permeability are
the van Genuchten-Mualem relations \eqref{eq:krl_vGM} and
the Brooks-Corey-Burdine relations \eqref{eq:krl_BCB}.
The equation \eqref{eq:Darcy} is continuous when transitioning from the saturated to the vadoze zones.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Capillary Pressure -- Saturation Relations}
\label{sec:richards-pc_s_relations}

Richards equation for unsaturated flow
%, as well as more general multiphase flow models,
requires representations of the capillary pressure $p_c$ and the relative permeability $k_{rl}$.
The capillary pressure is a fundamental dependent variable in the multi-phase flow model, and
relates the difference in pressure across an interface between two
fluids to the tendency of a porous medium to pull in the wetting fluid
and push out the non-wetting one.
For the partially saturated fluid flow model typically used to
characterize air-water systems,
there is only a single capillary pressure:
\begin{equation} \label{eq:GasLiquidCapillaryPressure}
  p_c = p_g - p_l
\end{equation}
where $p_g$ is the pressure of the air/gas.

Let us define the effective liquid saturation $s_e$ as
\begin{equation}
\label{eq:SaturationDefinition}
s_e \eq \frac{s_l^{} - s_l^r}{s_l^0 - s_l^r},
\end{equation}
where $s_l^0$ is the maximum and
$s_l^r$ is the residual (i.e. minimum) liquid saturations.
Notice that \eqref{eq:SaturationDefinition} implies the effective saturation $s_e$
takes values in the range from zero to one.

Using these definitions,
two widely used capillary pressure-saturation model relations are presented below,
namely the Brooks-Corey \citep{brooks1964hydraulic} and van Genuchten \citep{van1980closed}
models.

\paragraph{Brooks-Corey model.}
The Brooks-Corey form of the saturation function \citep{brooks1964hydraulic} is given by
\begin{equation}
  \label{eq:BC_s_pc_relation}
  s_e \eq \left( \alpha |p_c| \right)^{-\lambda},
\end{equation}
where the empirical parameters $\lambda$ [-], and $\alpha$ [$\upa^{-1}$]
are fit to experimental observations.
The inverse relation is written as
\begin{equation}
  \label{eq:BC_pc_s_relation}
  p_c \eq \frac{1}{\alpha} s_e^{-1/\lambda}.
\end{equation}

\paragraph{Van Genuchten model.}
In the \citet{van1980closed} model the effective liquid saturation is
described by the relation
%
\begin{equation}
  \label{eq:vG_s_pc_relation}
  s_e \eq \left[1+\left( \alpha |p_c| \right)^n \right]^{-m},
\end{equation}
%
with inverse relation
\begin{equation}
  \label{eq:vG_pc_s_relation}
  p_c \eq \frac{1}{\alpha} \left[ s_e^{-1/m} -1 \right]^{1/n}.
\end{equation}
%
The non-dimensional constants $n$ [-], $m$ [-] and dimensional $\alpha$ [$\upa^{-1}$] are
empirical parameters.

One may notice that Van Genuchten model is an evolution of Brooks-Corey model as evident
both by the dates and the form of the equations.
In particular notice that if we take
$\lambda = mn$ and $(\alpha p_c)^n \gg 1$,
then the Brooks-Corey and van Genuchten saturation functions,
Equations \eqref{eq:BC_s_pc_relation} and \eqref{eq:vG_s_pc_relation}, are equivalent.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Relative Permeability -- Saturation Relations}
\label{sec:richards-relative-permeability}

Given capillary pressure - saturation relations $p_c(s_l$,
the relative permeability relations needed by Richards equation can be defined.
Two popular relative permeability - saturation relations used in air-water
systems are the \citet{mualem1976new} and \citet{burdine1953relative} models.
The relative permeability model proposed by \citet{mualem1976new} has the form
\begin{equation} \label{eq:Mualem}
  k_{rl}(s_l)
  =
  s_e^{\ell} \,
  \frac{ \left\{ \displaystyle\int_0^{s_e} p_c(s)^{-1} ds \right\}^2 }
  { \left\{ \displaystyle\int_0^{1} p_c(s)^{-1} ds \right\}^2 },
\end{equation}
where the power $\ell$ in $s_e^\ell$ is a pore-connectivity parameter that varies
depending on the soil.
Although, \citet{mualem1976new} estimated an average value of
$\ell=1/2$, values of $\ell$ ranged from -5 to +5 across soils. More recent studies
[cf. \citet{vanG_retc_1991}] have suggested that $\ell=1/2$ may be
appropriate for coarse-textured soils, but not for many medium- and
fine-textured soils. Thus, $\ell$ should be available as a fitting parameter.

Similarly, the older \citet{burdine1953relative} model is given by
\begin{equation}
\label{eq:Burdine}
  k_{rl}(s_l) = s_e^{\ell} \,
    \frac{ \displaystyle\int_0^{s_e} p_c(s)^{-2} ds }
         { \displaystyle\int_0^{1} p_c(s)^{-2} ds },
\end{equation}
where \citet{burdine1953relative} assumed $\ell=2$. However, as with
the Mualem model \eqref{eq:Mualem}, $\ell$, should be available as a
fitting parameter.

\paragraph{Van Genuchten relative permeability.}
To obtain a closed-form solution for the relative permeability using
either the Mualem or Burdine models (Eqns.\eqref{eq:Mualem} and
\eqref{eq:Burdine}, respectively) combined with the van Genuchten
saturation function, the parameters $n$ and $m$ must be related by the
expressions
\begin{equation}
\label{eq:lambda}
m = \left\{
  \begin{array}{ll}
    1 - \dfrac{1}{n}, & \text{Mualem},\\[9pt]
    1 - \dfrac{2}{n}, & \text{Burdine}.
  \end{array}
\right.
\end{equation}
In the more general case of independent values of $m$ and $n$ the
relative permeability involves the incomplete beta function \citep{vangenuchten1985}.
More recently \citep{douradoneto2011} presented a general model for Mualem and
Burdine relative permeability functions for use with the van Genuchten saturation
function in terms of hypergeometric functions.

The Burdine relative permeability function for the liquid phase derived
from the van Genuchten saturation function is given by
\begin{equation}
  k_{rl} \eq s_e^{2} \left\{ 1 - \left[ 1 - s_e^{1/m} \right]^m \right\}.
  \label{eq:krl_vGB}
\end{equation}

The Mualem
relative permeability function has the form (note power 2):
\begin{equation}
  k_{rl} \eq s_e^{\ell} \left\{ 1 - \left[ 1 - s_e^{1/m} \right]^m \right\}^2.
  \label{eq:krl_vGM}
\end{equation}

\paragraph{Brooks-Corey relative permeability.}
Combined with the Brooks-Corey saturation function, the Mualem
relative permeability function is given by
\begin{equation} \label{eq:krl_BCM}
  k_{rl} = \big(s_e\big)^{\ell+2+2/\lambda}
         = \left(\alpha |p_c|\right)^{-((\ell+2)\lambda+2)}.
\end{equation}
The Burdine form originally considered by \citet{brooks1964hydraulic}
is given by
\begin{equation} \label{eq:krl_BCB}
  k_{rl} = \left( s_e \right)^{ \ell+1+2/\lambda}
         = \left( \alpha |p_c| \right)^{-((\ell+1)\lambda+2)}.
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Boundary conditions}
%
To facilitate the discussion on boundary conditions, consider the case of
flow described in Fig.~\ref{fig:bc_flow}.
Although the figure represents a two-dimensional flow field, the passage to three dimensions
is straightforward and requires no further explanations.

Four types of boundary conditions are supported by the model:
\begin{enumerate}
\item
  prescribed pressure $p_l$ (or head), see \eqref{eq:BC pressure Darcy PS};
\item
  prescribed flux, i.e. normal component of the velocity $\bq_l$, see \eqref{eq:BC flux Darcy PS};
\item
  semipervious boundary, see \eqref{eq:BC semipervious Darcy PS}; %\citep[for reference see][]{bear-1979};
\item
  seepage face.
\end{enumerate}

\paragraph{Boundary of prescribed pressure or head.}
This involves the specification of a fixed pressure or hydrostatic head on boundary $\Gamma_D$.
For instance, a boundary of this kind occurs whenever the flow domain is adjacent to a body of open water.
Segments A-B and E-F in Fig.~\ref{fig:bc_flow} are examples of a boundary of prescribed potential.
The pressure or head boundary conditions are given functions, e.g.
\begin{equation}
\label{eq:BC pressure Darcy PS}
  p_l(\bx,t) = p_{b}(\bx,t), \quad \bx \in \Gamma_D.
\end{equation}

\paragraph{Boundary of prescribed flux.}
This involves the specification of the flux normal to the boundary $\Gamma_N$
(see segment C-D in Figure \ref{fig:bc_flow}):
\begin{equation}
\label{eq:BC flux Darcy PS}
  \bq_l\cdot \bn = q_{b}(\bx,t), \quad \bx \in \Gamma_N,
\end{equation}
where $q_b$ [$\um\ucdot\us^{-1}$] is the given boundary flux.
For infiltration at the top horizontal surface, it equals to the Darcy velocity
and referred to as the infiltration velocity.

\paragraph{Semipervious boundary (or mixed boundary condition).}
This boundary condition is more complicated than the first two as it involves a case
in which local conditions within the computational domain influence the flux in or
out of the domain.
This type of boundary occurs when the porous medium domain is in contact with
a body of water continuum (or another porous medium domain, see for instance segments
A-B and E-F in Fig.~\ref{fig:bc_flow}), however, a relatively thin semipervious layer
separates the two domains:
\begin{equation}
\label{eq:BC semipervious Darcy PS}
  \bq_l \cdot \bn = I\, \left(p (\bx,t) - p_{b}(\bx,t) \right), \quad \bx \in \Gamma_R.
\end{equation}
where $I$ is an impedance and $p_{b}(\bx,t)$ is the given external pressure.

\paragraph{Seepage face.}
As is shown in Fig.~\ref{fig:bc_flow} (see segments B-C and D-E), seepage face (or surface)
is always present when a phreatic surface ends at the down-stream external boundary of flow domain.
In this case the phreatic surface is tangent to the boundary of the porous medium at points C and D.
Along a seepage surface, water emerges from the flow domain, trickling downward to the adjacent body of water.

A seepage surface is defined as the boundary
where water leaves the ground surface and then continues to flow in a thin film along its surface.
Being exposed to the atmosphere, the pressure along the seepage face is equal to the atmospheric pressure
(i.e. capillary pressure $p_{c}=0$).

The geometry of the seepage face is known (as it coincides with the boundary of the porous medium),
except for its limit (points C and D in Figure \ref{fig:bc_flow})
which is also lying on the (a priori) unknown phreatic surface.
The location of this point is, therefore, part of the required solution.
In unsteady flow, the location of the upper limit of the seepage face varies with time
and could be simulated in two ways:
\begin{enumerate}
\item Using a dynamic boundary condition that switches from a prescribed pressure boundary condition
to a prescribed flux boundary condition representing the recharge.
\item Combining boundary conditions in a hybrid one to represent the transition recharge/seepage
surface (e.g. see Fig.~\ref{fig:seepage_bc}).
\end{enumerate}

\begin{figure}  [h]
\begin{center}
\includegraphics[scale=0.3]{figs/seepage_bc.pdf}
\caption{Seepage face.}
\label{fig:seepage_bc}
\end{center}
\end{figure}

The state of the first option depends on the pressure inside the computational domain.
Regarding the second option, this hybrid boundary condition \citep[based on][]{hamm2000} can be formulated as
\begin{equation} \label{eq:fifth_bc_richard}
\begin{array} {lllll}
  \bq_l \cdot \bn & = & q_{b}(t) & \qquad \text{for} \quad &  p < \left( \frac{3}{2} p' + p_{0} \right), \\[0.5ex]
  \bq_l \cdot \bn & = & \frac{\left(  7-2f-f^{2}  \right)}{8} q_{b}(t)
                    & \qquad \text{for} \quad &  \left( \frac32 p' + p_{0} \right) \leq p \leq \left( \frac12 p' + p_{0} \right), \\[1.0ex]
  \bq_l \cdot \bn & = & I (p - p_{0}) &  \qquad \text{for} \quad & \left( \frac{1}{2} p' + p_{0} \right) < p,
\end{array}
\end{equation}
where $q_{b}(t)$ is the maximum recharge and $f(p,t)$ is a local variable between $-1$ and $1$
defined as
\begin{equation}
  f(p,t) = 2 \frac{p'- (p(x_{b},y_{b},z_{b},t) - p_{0}) }{p'},
\end{equation}
where $p_{0}$ is a reference pressure (in this particular example case, its value is equal to
the atmospheric pressure), and $p'$ is defined as
\begin{equation}
  p' = I^{-1} q_{b}(t).
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsection{Thermal Richards Equation}
%\label{sec:thermal-richards-equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsubsection{Process Model Equations}

%\begin{equation}
%  \frac{\partial \theta}{\partial t}
%  =
%  - \bnabla \cdot (\eta_l \bq_l)
%  - \bnabla \cdot (\K_g \bnabla \big(\frac{p_v}{p_g}\big)) + Q,
%  \qquad
%  \bq_l = -\frac{\K k_r}{\mu} (\bnabla p - \rho_l \bg)
%\end{equation}

\clearpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Isothermal Richards Equation with Dual Porosity Model}
\label{sec:dual-porosity-richards-equation}

Dual porosity model is designed to model fluid flows
when the solid contains both pores/matrix and fractures.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Assumptions and Applicability}

Typically flow in the fracture is much faster that that in the pores/matrix.
Therefore,
dual-porosity model assumes that water flow is restricted to the fractures.
The pores in the solid material (e.g. rock)
represent immobile pockets that can exchange, retain and store water
but do not permit convective flow.
This leads to dual-porosity type flow and transport models that partition the liquid
phase into mobile and immobile regions.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Process Model Equations}

The Richards equation in the mobile (fracture dominated) region is augmented by the water exchange
term $\Sigma_w$:
\begin{subequations}
\begin{align}
  \frac{\partial \theta_f}{\partial t}
  &=
  -\bnabla \cdot (\eta_l \bq_l) + Q_f - \Sigma_w,
  \\
  \bq_l
  &=
  -\frac{\K k_r}{\mu} (\bnabla p_l - \rho_l \bg),
\end{align}
\end{subequations}
where $\Sigma_w$ is the transfer rate of water from the matrix to the fracture,
and $Q_f$ is source or sink term [$\ukg \ucdot \um^{-3} \ucdot \us^{-1}$].
The equation for water balance in the matrix is
$$
  \frac{\partial \theta_m}{\partial t}
  = Q_m + \Sigma_w,
$$
where and $Q_m$ is source or sink term [$\ukg \ucdot \um^{-3} \ucdot \us^{-1}$].
The volumetric water contents $\theta_f$ and $\theta_m$ are defined as
$$
  \theta_f = \phi_f\, \eta_l\, s_{lf},\qquad
  \theta_m = \phi_m\, \eta_l\, s_{lm},
$$
where saturations $s_{lf}$ and $s_{lm}$ may use different
capillary pressure-saturation models.
The rate of water transfer from the matrix to the fracture regions $\Sigma_w$
is proportional to the difference in hydraulic heads:
$$
  \Sigma_w = \alpha_w (h_f - h_m),
$$
where $\alpha_w$ is the mass transfer coefficient.
Since hydraulic heads are needed for both regions, this equation requires
estimating retention curves for both regions and therefore is nonlinear.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Boundary conditions}
\label{sec:flow-boundary-conditions}

To facilitate the discussion on boundary conditions, consider the case of
flow described in Fig.~\ref{fig:bc_flow}.
Although the figure represents a two-dimensional flow field, the passage to three dimensions
is straightforward and requires no further explanations.

In the dual porosity model one has to specify the boundary conditions for the fracture and the matrix (pores).
Due to the assumption that the pores do not permit convective flow,
\paragraph{the boundary conditions for the matrix} are always zero flux conditions:
\begin{equation}
\label{eq:BC flux DP matrix}
  \bq_m\cdot \bn = 0, \quad \bx \in \Gamma.
\end{equation}

\paragraph{Boundary of prescribed pressure or head for fracture.}
This involves the specification of a fixed pressure or hydrostatic head on boundary $\Gamma_D$.
For instance, a boundary of this kind occurs whenever the flow domain is adjacent to a body of open water.
Segments A-B and E-F in Fig.~\ref{fig:bc_flow} are examples of a boundary of prescribed potential.
The pressure or head boundary conditions are given functions, e.g.
\begin{align}
\label{eq:BC pressure DP}
  p_f(\bx,t) = p_{b}(\bx,t), \quad \bx \in \Gamma_D.
\end{align}

\paragraph{Boundary of prescribed flux for fracture.}
This involves the specification of the flux normal to the boundary $\Gamma_N$
(see segment C-D in Figure \ref{fig:bc_flow}):
\begin{equation}
\label{eq:BC flux DP}
  \bq_f\cdot \bn = q_{b}(\bx,t), \quad \bx \in \Gamma_N,
\end{equation}
where $q_b$ [$\um\ucdot\us^{-1}$] is the given boundary flux.
For infiltration at the top horizontal surface, it equals to the Darcy velocity
and referred to as the infiltration velocity.

\paragraph{Semipervious boundary (or mixed boundary condition).}
This boundary condition is more complicated than the first two as it involves a case
in which local conditions within the computational domain influence the flux in or
out of the domain.
This type of boundary occurs when the porous medium domain is in contact with
a body of water continuum (or another porous medium domain, see for instance segments
A-B and E-F in Fig.~\ref{fig:bc_flow}), however, a relatively thin semipervious layer
separates the two domains:
\begin{equation}
\label{eq:BC semipervious DP}
  \bq_f \cdot \bn = I\, \left(p (\bx,t) - p_{b}(\bx,t) \right), \quad \bx \in \Gamma_R.
\end{equation}
where $I$ is an impedance and $p_{b}(\bx,t)$ is the given external pressure.

\paragraph{Seepage face.}
As is shown in Fig.~\ref{fig:bc_flow} (see segments B-C and D-E), seepage face (or surface)
is always present when a phreatic surface ends at the down-stream external boundary of flow domain.
In this case the phreatic surface is tangent to the boundary of the porous medium at points C and D.
Along a seepage surface, water emerges from the flow domain, trickling downward to the adjacent body of water.

A seepage surface is defined as the boundary
where water leaves the ground surface and then continues to flow in a thin film along its surface.
Being exposed to the atmosphere, the pressure along the seepage face is equal to the atmospheric pressure
(i.e. capillary pressure $p_{c}=0$).

The geometry of the seepage face is known (as it coincides with the boundary of the porous medium),
except for its limit (points C and D in Figure \ref{fig:bc_flow})
which is also lying on the (a priori) unknown phreatic surface.
The location of this point is, therefore, part of the required solution.
In unsteady flow, the location of the upper limit of the seepage face varies with time
and could be simulated in two ways:
\begin{enumerate}
\item Using a dynamic boundary condition that switches from a prescribed pressure boundary condition
to a prescribed flux boundary condition representing the recharge.
\item Combining boundary conditions in a hybrid one to represent the transition recharge/seepage
surface (e.g. see Fig.~\ref{fig:seepage_bc}).
\end{enumerate}

The state of the first option depends on the pressure inside the computational domain.
Regarding the second option, this hybrid boundary condition \citep[based on][]{hamm2000} can be formulated as
\begin{equation} \label{eq:fifth_bc_richard DP}
\begin{array} {lllll}
  \bq_f \cdot \bn & = & q_{b}(t) & \qquad \text{for} \quad &  p < \left( \frac{3}{2} p' + p_{0} \right), \\[0.5ex]
  \bq_f \cdot \bn & = & \frac{\left(  7-2f-f^{2}  \right)}{8} q_{b}(t)
                    & \qquad \text{for} \quad &  \left( \frac32 p' + p_{0} \right) \leq p \leq \left( \frac12 p' + p_{0} \right), \\[1.0ex]
  \bq_f \cdot \bn & = & I (p - p_{0}) &  \qquad \text{for} \quad & \left( \frac{1}{2} p' + p_{0} \right) < p,
\end{array}
\end{equation}
where $q_{b}(t)$ is the maximum recharge and $f(p,t)$ is a local variable between $-1$ and $1$
defined as
\begin{equation}
  f(p,t) = 2 \frac{p'- (p(x_{b},y_{b},z_{b},t) - p_{0}) }{p'},
\end{equation}
where $p_{0}$ is a reference pressure (in this particular example case, its value is equal to
the atmospheric pressure), and $p'$ is defined as
\begin{equation}
  p' = I^{-1} q_{b}(t).
\end{equation}

% =========================================================================
% -------------------------------------------------------------------------
% Infiltration Processes:
% -------------------------------------------
%
%  This is a good place to outline key objectives of this section.
%
% -------------------------------------------------------------------------

\begin{comment}

\subsection{Infiltration} \label{sec:infiltration}
%
%~\todo{This section is called Infiltration but really it
%       describes the near-surface water balance and recharge. -Freshley}

%\subsubsection{Overview}
%
The infiltration process models are components of the subsurface fluid migration.
Infiltration can be an important driving force for contaminant transport, especially in the vadose zone.
Engineered subsurface barrier technology seeks to minimize the infiltration
driving force for contaminant migration.
There are a number of approaches and models that can be applied to predict infiltration processes.
These range from simple storage routing models to the more mechanistic
Richards equation-based
\todo[color=cyan]{GEH: Suggest that we remove ``Richards equation-based'' and simply say ``more mechanistic models''
as Richards equation does not account for heat transport.}
models that simulate water flow and heat transport
in response to meteorological forcing and plant water uptake.
Within the complex interaction of physical, hydrologic, and biotic processes
that control field-scale infiltration at the site of interest,
the ideal model should be capable of assessing the impact
of infiltration on contaminant transport,
as well as supporting barrier design and performance assessment.

Predicting infiltration requires consideration of unsaturated flow processes,
precipitation, surface runoff, water storage,
lateral diversion along sloped layers, and, ultimately, deep percolation ~\citep{ward_1997,ward_2005}.
%(Ward and Gee 1997; Ward et al. 2005a).
All of these processes occur in response to forcing meteorology
that leads to temporal variability in air temperature, relative humidity, wind speed, and barometric
pressure and, in the most sophisticated implementations,
require the solution of coupled equations for mass and energy transport.

A minimum set of processes for modeling the water budget should include:
%
\begin{align}
P + I = R_{over} + \Delta W + D + GD,% + E + T,
\end{align}
where
$P$ is the precipitation,
$I$ -- irrigation,
$R_{over}$ -- overland flow (run-off and run-on),
$D$ -- drainage out of the soil cover (diverted by reduced-permeability layer),
$GD$ -- ground water recharge (deep percolation past a reduced-permeability layer), and
$\Delta W$ -- change in soil water storage.
%$E$ = evaporation\\
%$T$ = transpiration.

\noindent
Evaporation is defined as the process by which liquid water is
transformed into a gaseous state and the subsequent transfer of this
vapor to the atmosphere.
Transpiration is the loss of water from plants through their stomata to the atmosphere.
Plants compensate for transpiration losses by taking up water from the soil.

Another requirement is that the process models must include a full energy balance (nonisothermal) option for
evapotranspiration processes.
Water that does not run off the surface must be available for evaporation from the soil or plant surfaces,
or infiltration into the soil profile.
Soil water content must depend on the interactions of precipitation, temperature, vegetation, and albedo changes that vary temporally
(e.g., diurnally, seasonally, and episodically).
Spatially and temporally variable water storage and flux must be available for contaminant transport.

\subsubsection{Process Model Requirements}

\paragraph{Precipitation. }
The treatment of precipitation
%~\todo{Why this limitation? - Finsterle}
must include all natural sources of moisture that may reach the surface
in the form of rain, snow, sleet, hail, dew, and fog, and must account for precipitation not available for infiltration.
This includes precipitation intercepted by the plant canopy, from which it is evaporated
or transpired without ever contacting the soil; and sublimation, the direct conversion of water from the solid phase to the vapor phase.
This should also account for the presence of a snow cover that can delay
infiltration, reduce evaporation rates, and in the event of rapid snowmelt, lead to surface runoff.

%\subsubsection{Deterministic}

%\subsubsection{Stochastic}

\paragraph{Non-Precipitation Surface Recharge (including leaks).}
Process models should account for surface recharge sources (e.g., irrigation water used
during construction as a dust control agent and post-construction to
support the establishment of vegetation; water condensing on plant
surfaces and falling to the ground once the maximum storage depth in
the canopy is exceeded, pipe leaks).
These sources must also be subject to evaporation from soil and plant surfaces with the remainder
becoming available for runoff or infiltration.

% =========================================================================
% -------------------------------------------------------------------------
% Section 3 Data Requirements for Flow
% -------------------------------------------
%
%  Phases, Components, and Variables
%
% -------------------------------------------------------------------------

\subsection{Data Requirements for Flow}

\subsubsection{Permeability and Porosity}

The most basic properties of the subsurface, which are required for
all of the flow models, are permeability and porosity.  Often this
data can only be provided by sparsely located well logs and at a
spatial scale much finer than the scale of the model. As a
consequence, techniques of upscaling are required to fill in the
missing data and extrapolate to larger scales.

Permeability estimates are available for a large variety of soils and
rocks. When conceptual (and numerical) models have cells that
represent fractures or faults, field tests (pumping and/or tracer) are
required to determine effective permeabilities. Porosity data is also
available for many rock and soil types.

\subsubsection{Relative Permeability and Capillary Pressure.}

For both the Richards equation and more general multiphase problems, the
model requires representations of relative permeability and capillary
pressure.  For two-phase systems, relative permeability and capillary
pressure data are widely available for the more common forms such as
van Genuchten and Brooks Corey.

When a NAPL phase is present and the likelihood of three phases is
significant, much of the relative permeability data available from the
soil literature may have only limited applicability and experiments on
at least core size sample will be necessary.
\citet{stone1973estimation} presented a method to estimate three-phase
relative permeability that is in common usage in the oil
industry. However, when fractures or faults are present, parameters of
the relative permeability and capillary pressure models are estimated
with field data.  Relative permeabilities often exhibit strong
hysteretic behavior.  Land's method
\citep{land1968calculation,spiteri2006impact} is one approach for
handling hysteretic behavior that is relatively simple to implement
and is commonly used in the oil industry.

 Some capillary pressure data is available in the database described
by \citet{schaap2001computer}. Capillary models derived using surface
tension data of pure components \citep{prausnitz1977properties} are
used where experimental data is not available.

\subsubsection{Fluid Characterization}

The model equations must also be augmented with property data for the
fluids.  In simple problems we require only estimates of density and
viscosity for each of the flowing phases.  For more complex problems
in which we are modeling a multicomponent system, additional data is
required.

\end{comment}

\begin{comment}
\subsubsection{Boundary Conditions and Initial Conditions}

Boundary and initial conditions can take several different forms
depending on the application. Dirichlet boundary conditions specify
the pressure, temperature, and saturation at the boundary. Neumann
conditions specify the flux $\bq$ at the boundary.  Initial conditions
may consist of specifying a constant pressure or variable pressure,
temperature, and saturation, for example in the form of hydrostatic
conditions taking into account the change in fluid density.

Typical boundary condition for Richard's equation consist of
infiltration (recharge) and constant or time varying pressure
conditions. More sophisticated conditions such at unit gradient, free
drainage, and seepage face are also used.

%
%  Need to fix this with the BC section.
%

\subsubsection{Boundary Conditions and Initial Conditions}
%------------------------------------------------------------------------------
%------------------------------------------------------------------------------
%------------------------------------------------------------------------------
Boundary conditions for flow are exhaustively detailed in Subsection \ref{sec:bc_flow}.
They and initial conditions can take several different forms depending on the application.
Dirichlet boundary conditions specify the pressure, temperature, and saturation at the boundary.
Neumann conditions specify the flux $\bq$ at the boundary.
Initial conditions may consist of specifying a constant pressure or variable pressure, temperature, and saturation, for example in the form of hydrostatic conditions taking into account the change in fluid density.
%------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------
% For Richards equations
%------------------------------------------------------------------------------
Typical boundary conditions for the Richards equation consist of infiltration (recharge) and constant or time varying pressure conditions, but also to impose a prescribed pressure (i.e. Dirichlet boundary condition) is a valid option.
More sophisticated conditions such at unit gradient, free drainage, and seepage face are also used.
%More sophisticated conditions such at unit gradient and seepage face
%are also used.  For the component (NAPL) fluids, specified mole
%fractions and flowrates (sources/sinks) are usual boundary conditions.
%------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------
% For multiphase flow
%------------------------------------------------------------------------------
As regards the multiphase approach, additional data for the boundary and in initial conditions could be required such as the mass fraction for the {\textit{j}}th component in the phase $\alpha$ ($Y_{j \alpha}$, see equation \eqref{eq:MultiphaseConservationEquation}).
\end{comment}


\thispagestyle{empty}
\chapter*{Abstract}

Motion planning for legged robots is a challenging problem and remains an open area of research. Particular difficulties arise from effective underactuation, the mechanism complexity, as well as nonlinear and hybrid dynamics.
A common approach is to decompose this problem into smaller sub-problems that are solved sequentially. Recent research indicates that using a local optimal control solver, namely Differential Dynamic Programming (DDP), produces more efficient motions, with lower forces and impacts.

This master's thesis contributes in this direction by applying, evaluating and extending DDP-based whole-body trajectory optimization, pursuing three objectives.
First, we develop a method for constraining DDP-like solvers in order to generate inherently balanced motion plans.
Second, the proposed motion planning approach is evaluated for quasi-static and dynamic motions in a real-time physics simulation and in real-world experiments on the lightweight and biologically inspired RH5 humanoid robot.
Finally, the limits of the approach and the system design are examined by solving highly-dynamic movements.

\vfill
\noindent\textbf{Keywords:} Differential Dynamic Programming, Dynamic Bipedal Walking, Humanoid Robots, Motion Planning, Multi-Contact Optimal Control, Whole-Body Trajectory Optimization


\chapter{QDPT vs DPT with increasing coupling modes}

\begin{figure}[h!]
\includegraphics[scale=0.9, center]{Chapter4/figs/qdpt_err}
\caption{(QDPT - DPT) deviation with differing number of neighbouring modes being allowed to couple. From top, $\mode{0}{77}$ is made to couple with two, four, six, and eight closest $\Delta l=2$ neighbours (by frequency) as listed in table \ref{tab:mode_list}. The trend shows large deviations from DPT frequencies in modes placed at either extreme regardless of how many modes couple while QDPT-DPT departure in the inner modes stay the same. This hints at QDPT frequencies obtained for the extremal modes being artefacts of the calculation and hence being unreliable.}
\label{fig:DPT_err}
\end{figure}