%% LyX 2.0.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,french]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm,headheight=2cm,headsep=2cm,footskip=2cm}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\newcommand{\noun}[1]{\textsc{#1}}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

\makeatother

\usepackage{babel}
\addto\extrasfrench{%
   \providecommand{\og}{\leavevmode\flqq~}%
   \providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}%
}

\begin{document}
\includegraphics[width=5cm]{Logo-INRAE_Transparent.png}

~

~

~

\begin{center}
Tutorial for Pamhyr2

January 2024
\par\end{center}

~

~

\begin{center}
\textbf{\LARGE 1D Modeling of the Hogneau River (Nord, France)}

using Pamhyr2
\par\end{center}{\LARGE \par}

~

~

\begin{center}
{\large INRAE Lyon-Grenoble Auvergne-Rhône-Alpes}
\par\end{center}{\large \par}

\begin{center}
Riverly, river hydraulics
\par\end{center}

~

~

~

~

~

~

\begin{center}
\begin{tabular}{lll}
Autors : & Pierre-Antoine Rouby & pierre-antoine.rouby@inrae.fr\tabularnewline
& Théophile TERRAZ & theophile.terraz@inrae.fr\tabularnewline
\end{tabular}
\par\end{center}

~

\pagebreak{}

\begin{center}
\tableofcontents{}
\par\end{center}

~

\pagebreak{}

\section{Introduction}

TODO

\pagebreak{}

\section{Install Pamhyr2}

Pamhyr2 can be downloaded from \url{https://gitlab.irstea.fr/theophile.terraz/pamhyr}.
\begin{center}
\includegraphics[width=15cm]{dl.png}
\par\end{center}

Use the GNU Linux or the Windows download button depending on your system. On windows, launch the installer. On Linux, unpack the archive and launch Pamhyr2.


\section{Create your first study}

On the main windows, click on \texttt{[Files] => [New Study]} to create a new study.

Click on \texttt{[River Network] => [Edit River Network]} to create the reaches of your river. In this window, you must define an oriented graph that represents the reaches of your river network: the edges are the reaches and the nodes are either upstream boundary conditions, downstream boundary conditions or junctions.
Press the \includegraphics[width=0.5cm]{gtk_add.png} to enter the \textit{add} mode. Create two nodes by clicking in the grey zone of the window, and create a link by clicking again on each node. press \includegraphics[width=0.5cm]{gtk_add.png} again to exit the \textit{add} mode. You created your first reach, with an upstream node and a downstream node. In the lower part of the \textit{Edit River Network} window you can rename the nodes and the reaches. As the reach you created is automaticaly selected, all the next steps will apply to this reach. The window should look like that:

\begin{center}
\includegraphics[width=15cm]{network.png}
\par\end{center}

Close the \textit{Edit River Network} window.


\section{Edit the river geometry}

Click on \texttt{[Geometry] => [Edit Geometry]} to define the geometry of the selected bief. Click on the \texttt{[Import]} button and select the file \texttt{Data/Bief\_1.st}. You should see:

\begin{center}
\includegraphics[width=15cm]{Geo.png}
\par\end{center}

On the left panel is a list of all the cross sections with their name and longitudinal abscisa. In the top left plot you can see the top view of the river, on the top right panel the longitudinal cross-section of the river and in the bottom plot you can see the selected cross-section (blue) along with the next one (dashed purple) and previous one (dashed black). You can move in the section list using the slider at the very right of the window.

You can edit the selected cross section by clicking on the \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"} icon.

select the cross section named \textit{PontRD101m} and open the edition window. You should see:

\begin{center}
\includegraphics[width=15cm]{editsect.png}
\par\end{center}

On the left panel is the list of all the points of the section, with their coordinates, their name and their transversal absisa. The Z coordinate of the highest point is written in blue and the lowest in red. Points can have a name. If a point with the same name exists in every section in a reach, it forms a longitudinal line. For example, here we have \textit{rg} and \textit{rd} which represent the left bank and the right bank of the main chanel.

On the plot is a projection of the cross section. You can use \texttt{[ctrl + click]} to select a point in the plot. For now we don't have to change anything. You can close the cross section edition window and the geometry edition window.

\section{Edit the boundary conditions}

From the main window, click on \texttt{[Hydraulics] => [Boundary conditions and punctual contributions]}.You should see:

\begin{center}
\includegraphics[width=15cm]{boundary.png}
\par\end{center}

 Use the \textit{add} button on the top left of the window to add a liquid boundary condition.
 On the new line, click to select the whole line, double click to select the cell.
 Select the \textit{Type} cell to give a name to the boundary condition. here, we will define the flow discharge mesured during the february 2002 flood. You can name this boundary condition "flood2002".
 Select the \textit{Type} cell and use the combo box to put a Q(t) law.
 Select the \textit{Node} cell and atribute this condition to the upstream node.
 Names of the nodes are recalled in network in the right panel.
 Now select the whole line and click on the edit button \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"}. You opened the \textit{Edit Boundary Conditions} window.
 On a text editor, open the \texttt{Data/Fevrier\_2002.txt} file. Copy the content of the file (for example with \textit{ctrl+a ctrl+c}) and paste it in the left panel of the \textit{Edit Boundary Conditions} window with \textit{ctrl+v}. You can now see the flow discharge curve:

\begin{center}
\includegraphics[width=15cm]{fev2002.png}
\par\end{center}

Close this window. Go back on the \textit{Boundary Conditions} window. Add a new line, give it a name, give it the textit{Z(T)} type and associate it to the downstream node of the network. Open the \textit{Edit Boundary Conditions} window (\includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"}). Add two lines. In the first one, enter time: 0.00.00 and Z: 15.000.
On the second one, time: 1.00.00 and Z: 15.000. It creates a constant downstream water elevation. For the computaion, Mage will extrapolate continuously the water elevation, that's why we only need to define one hour.
You can close the the \textit{Edit Boundary Conditions} and the \textit{Boundary Conditions} window.

\section{Create initial conditions}

From the main window, click on \texttt{[Hydraulics] => [Initial conditions]}.
Click on \texttt{Generate minimal height} and enter a height of 2 meters in the pop-up window to generate an initial water height condition that verify the folowing conditions: a water height of at least 2 meters and a decreasing water surface elevation from upstream to downstream. You should see:

\begin{center}
\includegraphics[width=15cm]{ic.png}
\par\end{center}

Close the \textit{Initial conditions} window.


\section{Edit friction coefficients}

From the main window, click on \texttt{[Hydraulics] => [Edit friction]}.
You fist have to define sets of Strickler coefficients. Click on \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"} to open the \textit{Strickler} window. Here you can create couples of Strickler coefficients, the first one for the minor bed, the second one for the medium bed. Click on \textit{add} four times  to create four new couple. Give them the folowing values:

\begin{center}
\includegraphics[width=15cm]{K.png}
\par\end{center}

Close the \textit{Strickler} window. On the \textit{Edit friction} window, add four lines with the button \includegraphics[width=0.5cm]{gtk_add.png} to create fous friction zones. Each zone is defined by a \textit{begin} and \textit{end} PK and a \textit{begin} and \textit{end} Strickler couple. The strickler coefficient couples inside a zone are interpolated from the \textit{begin} and \textit{end} couples. In our case, we will use constant coefficients per zone. Set the zones as follow:

\begin{center}
\includegraphics[width=15cm]{frictions.png}
\par\end{center}

\pagebreak{}
\end{document}

