\section{Results and discussions}
In this section,  we present the evaluation of the proposed models based on numerical data of \(95\) different cases representing the frames of the full wavefield propagation.
The developed models and their capabilities of predicting delamination location, shape and size were tested on numerical and experimental data.
Three representative cases were selected from numerical dataset to show the performance of developed models.
Further, the generalisation capabilities were evaluated on experimental datasets.
Single and multiple delamination scenarios were considered.
The \(IoU\) metric was utilised to examine the performance of the models.
Further, the proposed deep learning models were implemented
on Keras API~\cite{chollet2015keras} running on top of TensorFlow on a Tesla V100 GPU  from NVIDIA.
\subsection{Numerical cases}
In the first numerical case, the delamination is located at the upper left corner as shown in Fig.~\ref{fig:num_GT_391} representing its ground truth (GT).
This case is considered difficult due to edge wave reflections which have similar patterns as delamination reflection.
The predicted outputs are shown in Fig.~\ref{fig:Convlstm_num_391}, and~\ref{fig:AE_num_391} with respect to model-\RNum{1}, and \RNum{2}, respectively.
For the second numerical case, the delamination is located at the upper centre of the plate as shown in Fig.~\ref{fig:num_GT_462} representing the GT.
This case is also considered difficult due to the waves reflected from the edge which have similar patterns as those reflected from the delamination.
Figures~\ref{fig:Convlstm_num_462}, and~\ref{fig:AE_num_462} show prediction with respect to model-\RNum{1}, and \RNum{2}, respectively.
In the third case, the delamination is located upper left corner but little farther from the edges as shown in Fig.~\ref{fig:num_GT_453} representing the GT.
Figures~\ref{fig:Convlstm_num_453}, and \ref{fig:AE_num_453} show the predicted outputs with respect to model-\RNum{1}, and \RNum{2}, respectively.

As can be seen in all predicted outputs, our models are able to identify the delamination with high accuracy and without any noise.
Furthermore, the achieved mean \(IoU\) with respect to all numerical data of \(95\) cases was \((0.90)\) for model-\RNum{1}, and \((0.87)\) for model-\RNum{2}.
%\begin{table}[!h]
%	\centering
%	\caption{\(IoU\) of the numerical cases}
%	\label{tab:numerical_cases_iou}
%	\begin{tabular}{cccc}
%		\hline
%		& 1st case & 2nd case & 3rd case \\ \hline
%		Model-\RNum{1} & \(0.86\) & \(0.89\) & \(0.98\)  \\
%		Model-\RNum{2} & \(0.87\) & \(0.93\) & \(0.99\)  \\ \hline
%	\end{tabular}
%\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Numerical cases
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	\centering
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{numerical_GT_391.png}
		\caption{GT image of 1st case}
		\label{fig:num_GT_391}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{model_1_predicted_output_391.png}
		\caption{\(IoU\) value = 0.86}
		\label{fig:Convlstm_num_391}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{model_2_predicted_391.png}
		\caption{\(IoU\) value =  0.87}
		\label{fig:AE_num_391}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\par\medskip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{numerical_GT_462.png}
		\caption{GT image of 2nd case}
		\label{fig:num_GT_462}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{model_1_predicted_output_462.png}
		\caption{\(IoU\) value = 0.89}
		\label{fig:Convlstm_num_462}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{model_2_predicted_462.png}
		\caption{\(IoU\) value = 0.93}
		\label{fig:AE_num_462}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\par\medskip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{numerical_GT_453.png}
		\caption{GT image of 3rd case}
		\label{fig:num_GT_453}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{model_1_predicted_output_453.png}
		\caption{\(IoU\) value = 0.98 }
		\label{fig:Convlstm_num_453}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{model_2_predicted_453.png}
		\caption{\(IoU\) value = 0.99}
		\label{fig:AE_num_453}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{Delamination cases on numerical data (Figures: (a), (e), and (h) correspond to model-\RNum{1}.
		Figures: (c), (f) and (i) correspond to model-\RNum{2}).}
	\label{fig:num_case}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\subsection{Experimental cases}
In this work, we investigated our models on several experimentally acquired data.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Similarly to the synthetic dataset, we applied a frequency of \(50\)~kHz to excite a signal in a transducer placed at the centre of the plate.
\(A0\) mode wavelength for this particular CFRP material at such frequency is about \(20\)~mm.
The measurements were performed by using Polytec PSV-\(400\) SLDV on the bottom surface of the plate of dimensions \(500\times500\)~mm.
The sampling frequency was \(512\)~kHz.
The measurements were conducted on a regular grid of \(333\times333\) points.
Next, median filter using window size of three was applied to each frame. Additionally, all frames were upscaled to \(500\times500\) points and \(512\times512\) for model-\RNum{1} and model-\RNum{2}, respectively.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
During the testing stage of the synthetic dataset,  we fed the models with a consecutive number of identified frames (window of frames) containing the interactions of the Lamb waves with the delamination to identify it.
However, for the experimentally acquired data, the window of frames depicting the interaction of Lamb waves with the delaminations is unknown.
Therefore, to overcome this issue, we introduced a sliding window of frames.
The window sizes are \(64\) and \(24\) for model-\RNum{1} and \RNum{2}, respectively.
Accordingly, we slide the window over all input frames (depicting the experimental data).
The shift of the window is one frame at a time.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Single delamination}
The first experimental case is for a CFRP specimen with single delamination created artificially by Teflon insert.
A plain weave fabric reinforcement was used.
The Teflon of a square shape was inserted during specimen manufacturing so its shape and location is known.
Figure~\ref{fig:exp_CFRP_teflon_3o_GT} shows the GT image which corresponds to the artificial delamination location, shape and size.
The number of the full wavefield frames is \(256\) frames in this case.
Figure~\ref{fig:model_1_CFRP_teflon_3o} shows the delamination prediction for model-\RNum{1} in which the sliding window size is \(64\) frames, and the highest \(IoU\) is \((0.53)\) achieved for group of frames \((35-99)\).
Figure~\ref{fig:model_2_CFRP_teflon_3o} shows the predicted output of model-\RNum{2} which has as sliding window of \(24\) frames, and the highest \(IoU\) is \((0.47)\) was achieved for group of frames \((72-96)\).
Moreover, since the window of model-\RNum{1} is larger than the window of model-\RNum{2}, it is expected that model-\RNum{1} starts to identify the delamination before model-\RNum{2}.

It should be noted that for the same damage scenario, the \(IoU\) value for the models developed previously in~\cite{Ijjeh2021} was very low \((0.081)\).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Single delaminatio of Teflon inserted
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\centering
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{CFRP_teflon_3o_375_375p_50kHz_5HC_x12_15Vpp_Ground_truth_0.png}
		\caption{GT of Teflon insert}
		\label{fig:exp_CFRP_teflon_3o_GT}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{Saeed_CFRP_teflon_3o_375_375p_50kHz_5HC_x12_15Vpp_predicted_output_35.png}
		\caption{\(IoU\) = 0.53 }
		\label{fig:model_1_CFRP_teflon_3o}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{CFRP_teflon_3o_375_375p_50kHz_5HC_x12_15Vpp_predicted_output_72.png}
		\caption{\(IoU\) = 0.47}
		\label{fig:model_2_CFRP_teflon_3o}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{Experimental case: single delamination of Teflon insert.}
	\label{fig:exp_Teflon_insert}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In both models, the predictions were the highest for group of frames corresponding to the first interaction of the guided waves with the delamination.
Accordingly, such frames contain the most valuable feature patterns regarding delamination.
Furthermore, this behaviour can be depicted in Fig.~\ref{fig:CFRP_Teflon_3o_IoU_centre_window}, which shows the \(IoU\) values with respect to the predicted outputs as we slide the window over all input frames from the starting frame till end.
Since there are \(256\) frames of full wavefield in this damage case, there are \(192\) of windows for model-\RNum{1}, and \(232\) of windows for model-\RNum{2}.
Furthermore, in Fig.~\ref{fig:CFRP_Teflon_3o_IoU_} we selected three places of the sliding window.
The first place depicted in a dark blue star shown in Fig.~\ref{fig:CFRP_teflon_3o_shapes_} represents group of frames \((72-96)\) which correspond to initial interaction of guided waves with the delamination.
The second place depicted in pink pentagon shape shown in Fig.~\ref{fig:CFRP_teflon_3o_shapes_} represents group of frames \((129-153)\) which correspond to the guided waves reflected from the edges, in which we can notice the drop in the \(IoU\) values as these frames have less damage features.
The third place depicted in green circle shown in Fig.~\ref{fig:CFRP_teflon_3o_shapes_} represents group of frames \((206-230)\) corresponding to the interaction of the guided waves reflected from the edges with the delamination.
As we can see, the value of \(IoU\) increases again as the valuable features patterns regarding delamination start to appear again.
The predicted outputs of model-\RNum{1} and model-\RNum{2} regarding the dark blue star, pink pentagon, and the green circle are shown in Fig.~\ref{fig:CFRP_Teflon_3o_predictions}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% IoU ouput values with a sliding window
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{1\textwidth}
		\centering
		\includegraphics[scale=1]{CFRP_Teflon_3o_IoU_centre_window.png}
		\caption{}
		\label{fig:CFRP_Teflon_3o_IoU_}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\par\medskip
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{1\textwidth}
		\centering
		\includegraphics[scale=1]{CFRP_teflon_3o_shapes_blue_pink_circle.png}
		\caption{}
		\label{fig:CFRP_teflon_3o_shapes_}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{IoU corresponding to a sliding window of frames (Teflon insert-single delamination).}
	\label{fig:CFRP_Teflon_3o_IoU_centre_window}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Predicted outuputs at diffirent window places
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[!h]
	\centering
	\includegraphics[scale=1]{CFRP_teflon_3o_Centre_predictions.png}
	\caption{Predictions of models \RNum{1} and \RNum{2} at different window places (Teflon insert-single delamination).}
	\label{fig:CFRP_Teflon_3o_predictions}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Additionally, for the experimental cases, we applied the root mean square (RMS) for all output predictions regarding all slided windows in order to show the damage map.
Figures~\ref{fig:RMS_CFRP_Teflon_3o_saeed} and~\ref{fig:RMS_CFRP_Teflon_3o_ijjeh} show the RMS images for the experimental case of single delamination predicted by model-\RNum{1} and model-\RNum{2}, respectively.
Additionally, to separate undamaged and damaged classes from the RMS images, we applied a binary threshold with a value \((threshold=0.5)\) as shown in Figs.~\ref{fig:RMS_threshold_CFRP_Teflon_3o_saeed} and~\ref{fig:RMS_threshold_CFRP_Teflon_3o_ijjeh} for model-\RNum{1} and model-\RNum{2}, respectively.
The threshold level was selected to limit the influence of noise, and at the same time, highlight the damage.
The calculated \(IoU\) values for the case of single delamination are \((0.46)\) and \((0.42)\) for model-\RNum{1} and model-\RNum{2}, respectively.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RMS predictions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.48\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{RMS_CFRP_Teflon_3o_5HC_Saeed.png}
		\caption{RMS image of model-\RNum{1} predicted output}
		\label{fig:RMS_CFRP_Teflon_3o_saeed}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.48\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{RMS_CFRP_Teflon_3o_5HC_ijjeh.png}
		\caption{RMS image of model-\RNum{2} predicted output}
		\label{fig:RMS_CFRP_Teflon_3o_ijjeh}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{RMS images of predicted outputs -Teflon insert (single delamination).}
	\label{fig:RMS_CFRP_Teflon_3o_images}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RMS THRESHOLDED IMAGES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.48\textwidth}
		\centering
		\includegraphics[scale=1]{RMS_CFRP_teflon_3o_375_375p_50kHz_5HC_saeed_cmap_viridis_greyscale_THRESHOLDED.png}
		\caption{Model-\RNum{1}, \(IoU\) = \(0.46\)}
		\label{fig:RMS_threshold_CFRP_Teflon_3o_saeed}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.48\textwidth}
		\centering
		\includegraphics[scale=1]{RMS_CFRP_teflon_3o_375_375p_50kHz_5HC_ijjeh_cmap_viridis_greyscale_THRESHOLDED.png}
		\caption{Model-\RNum{2}, \(IoU\) = \(0.42\)}
		\label{fig:RMS_threshold_CFRP_Teflon_3o_ijjeh}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{Thresholded RMS images of predicted outputs -Teflon insert (single delamination).}
	\label{fig:RMS_threshold_CFRP_Teflon_3o_images}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\subsection{Multiple delaminations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In the second experimental case, we investigated three specimens of carbon/epoxy laminate reinforced by 16 layers of plain weave fabric as shown in Fig.~\ref{fig:plate_delam_arrangment}.
The prepregs GG 205 P (fibres Toray FT 300–3K 200 tex) by G. Angeloni and epoxy resin IMP503Z‐HT by Impregnatex Compositi were used for the fabrication of the specimen in the autoclave.
The average thickness was \(3.9 \pm 0.1\) mm.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In Specimen~\RNum{2}, three large artificial delaminations (Teflon insert) of elliptic shape were inserted in the upper thickness quarter of the plate between the \(4^{th}\) and the \(5^{th}\) layer.
The delaminations were located at the same distance equal to \(150\) mm from the centre of the plate.
For Specimen~\RNum{3} delaminations were inserted in the middle thickness of the plate between \(8^{th}\) layer and \(9^{th}\) layer.
For Specimen~\RNum{4}, three small delaminations were inserted in the middle of thickness of the plate, and thee large delaminations were inserted at the lower quarter of the thickness of the plate between the \(12^{th}\) layer and \(13^{th}\) layer.
The details of Specimen~\RNum{2}, \RNum{3} and \RNum{4} are presented in Fig.~\ref{fig:plate_delam_arrangment}.

Furthermore, the SLDV measurements were conducted from the bottom surface of the plate, accordingly, Specimen \RNum{2} is the most difficult case as the delaminations are barely visible.
For Specimens~(\RNum{2}, \RNum{3}, and \RNum{4})  we have generated \(512\) consecutive frames representing the full wavefield measurements in the plate.
The measurement parameters were the same as in the experiment with single delamination.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[!h]
	\centering
	\includegraphics[width=1\textwidth]{plate_delam_arrangement_exp_MSSP2.png}
	\caption{Experimental case of delamination arrangement.}
	\label{fig:plate_delam_arrangment}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Since SLDV measurements were conducted from the bottom surface of the plate, the GT images and the output predictions of the proposed models are flipped horizontally (mirrored).
Figure~\ref{fig:gt_specimen_2} shows the GT image of Specimen~\RNum{2}.
The predicted output of model-\RNum{1} is shown in Fig.~\ref{fig:L3_S2_B_saeed} in which the highest calculated \(IoU\) value is \(0.15\) achieved for group of frames \((167-231)\).
Figure~\ref{fig:L3_S2_B_ijjeh} shows the predicted output of model-\RNum{2}, in which the highest calculated \(IoU\) value is \(0.35\) achieved for group of frames \((68-92)\).

Figure~\ref{fig:gt_specimen_3} shows the GT image of Specimen~\RNum{3}.
The predicted output of model-\RNum{1} is shown in Fig.~\ref{fig:L3_S3_B_saeed} in which the highest calculated \(IoU\) value is \(0.18\) achieved for group of frames \((279-343)\).
Figure~\ref{fig:L3_S3_B_ijjeh} shows the predicted output of model-\RNum{2}, in which the highest calculated \(IoU\) value is \(0.32\) achieved for group of frames \((60-84)\).

Figure~\ref{fig:gt_specimen_4} shows the GT image of Specimen~\RNum{4}.
The predicted output of model-\RNum{1} is shown in Fig.~\ref{fig:L3_S4_B_saeed} in which the highest calculated \(IoU\) value is \(0.18\) achieved for group of frames \((235-299)\).
Figure~\ref{fig:L3_S4_B_ijjeh} shows the predicted output of model-\RNum{2}, in which the highest calculated \(IoU\) value is \(0.27\) achieved for group of frames \((68-92)\).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Specimen~\RNum{2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\centering
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S4_B_333x333p_50kHz_5HC_18Vpp_x10_pzt_Ground_truth_0.png}
		\caption{GT of Specimen~\RNum{2}}
		\label{fig:gt_specimen_2}
	\end{subfigure}
	\hfill
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S2_B_333x333p_50kHz_5HC_15Vpp_x10_pzt_predicted_output_167.png}
		\caption{\(IoU\) = \(0.15\)}
		\label{fig:L3_S2_B_saeed}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S2_B_333x333p_50kHz_5HC_15Vpp_x10_pzt_predicted_output_68.png}
		\caption{\(IoU\) = \(0.35\)}
		\label{fig:L3_S2_B_ijjeh}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\par\medskip
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Specimen~\RNum{3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S4_B_333x333p_50kHz_5HC_18Vpp_x10_pzt_Ground_truth_0.png}
		\caption{GT of Specimen~\RNum{3}}
		\label{fig:gt_specimen_3}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S3_B_333x333p_50kHz_5HC_18Vpp_x10_pzt_predicted_output_279.png}
		\caption{\(IoU\) = \(0.18\)}
		\label{fig:L3_S3_B_saeed}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S3_B_333x333p_50kHz_5HC_18Vpp_x10_pzt_predicted_output_60.png}
		\caption{\(IoU\) = \(0.32\)}
		\label{fig:L3_S3_B_ijjeh}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\par\medskip
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Specimen~\RNum{4}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S4_B_333x333p_50kHz_5HC_18Vpp_x10_pzt_Ground_truth_0.png}
		\caption{GT of Specimen~\RNum{4}}
		\label{fig:gt_specimen_4}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S4_B_333x333p_50kHz_5HC_18Vpp_x10_pzt_predicted_output_235.png}
		\caption{\(IoU\) = \(0.18\)}
		\label{fig:L3_S4_B_saeed}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	\begin{subfigure}[b]{0.32\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{L3_S2_B_333x333p_50kHz_5HC_15Vpp_x10_pzt_predicted_output_68.png}
		\caption{\(IoU\) = \(0.27\)}
		\label{fig:L3_S4_B_ijjeh}
	\end{subfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\caption{Experimental cases of Specimen (\RNum{2}-\RNum{4}).}
\label{fig:exp_case}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

It is worth to mention, that we tested FCN-DenseNet which we developed previously~\cite{Ijjeh2021} for data related to specimens II-IV.
However, poor results were obtained.
This is attributed to the fact that RMS images are fed to FCN-DenseNet which carry limited amount of damage related information.
On the other hand, currently proposed methods utilise full wavefield frames which carry more damage-reach features.

Moreover, in Fig.~\ref{fig:L3_S4_B_333x333p_50kHz_5HC_IoU_centre_window}, we presented the calculated \(IoU\) values corresponding to predicted outputs of model-\RNum{1} and \RNum{2} regarding Specimen~\RNum{4} as we slide the window of size~\(64\) and \(24\) frames, respectively, over the \(512\) full wavefield frames.
Both models start to identify the delaminations after the propagated guided waves interact with the delamination.

The red square depicted in Fig.~\ref{fig:L3_S4_B_333x333p_50kHz_5HC_shapes_} corresponds to \(IoU\) value calculated for group of frames before the interactions with delaminations (see first, middle and last frame in the group).
This behaviour is expected since the models were trained on those frames depicting the beginning of the interactions, as a result, the valuable features patterns start to appear.

The light blue star depicted in Fig.~\ref{fig:L3_S4_B_333x333p_50kHz_5HC_shapes_} refers to a window of frames regarding the initial interactions of propagated guided with the delaminations and before reflecting from the edges.
As a result, valuable features patterns regarding the damage start to appear.

The pink pentagon shape depicted in Fig.~\ref{fig:L3_S4_B_333x333p_50kHz_5HC_shapes_} refers to a window of frames that pass the initial interaction with the delaminations, additionally, it shows the reflections of the guided waves from the edges just before interacting with the delaminations again.
As can be seen, the calculated \(IoU\) values drop drastically as expected as there are no valuable damage features to be extracted.

The blue rectangle depicted in Fig.~\ref{fig:L3_S4_B_333x333p_50kHz_5HC_shapes_} represents a window of \((64)\) frames regarding model-\RNum{1}.
It depicts the interactions of the reflected guided waves from the edges and their interaction with the delaminations, hence, model-\RNum{1} are able to identify the delaminations as it has a larger window.

The green circle depicted in Fig.~\ref{fig:L3_S4_B_333x333p_50kHz_5HC_shapes_} represents a window of \((24)\) frames regarding model-\RNum{2}.
Although this window shows complex patterns of waves reflections, the model can extract the valuable damage features and identify the delaminations accordingly.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\centering
	\begin{subfigure}[b]{1\textwidth}
		\centering
		\includegraphics[scale=1]{L3_S4_B_333x333p_50kHz_5HC_IoU_centre_window.png}
		\caption{}
		\label{fig:L3_S4_B_333x333p_50kHz_5HC_IoU}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\par\medskip
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{1\textwidth}
		\centering
		\includegraphics[scale=1]{L3_S4_B_333x333p_50kHz_5HC_shapes_.png}
		\caption{}
		\label{fig:L3_S4_B_333x333p_50kHz_5HC_shapes_}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{IoU corresponding to a sliding window of frames (Specimen~\RNum{4}).}
	\label{fig:L3_S4_B_333x333p_50kHz_5HC_IoU_centre_window}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Figure~\ref{fig:L3_S4_B_5HC_predictions} shows the predicted outputs of model-\RNum{1} and model-\RNum{2} corresponding to the group of frames with respect to the red square, light blue star, pink pentagon, blue rectangle, and the green circle.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[!h]
	\centering
	\includegraphics[scale=1]{L3_S4_B_predictions_different_windows.png}
	\caption{Predictions of models \RNum{1} and \RNum{2} at different window places (Specimen~\RNum{4}).}
	\label{fig:L3_S4_B_5HC_predictions}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The RMS images depicting the damage maps of Specimen~\RNum{4} are presented in Figs.~\ref{fig:RMS_L3_S4_B_saeed} and~\ref{fig:RMS_L3_S4_B_ijjeh} regarding model-\RNum{1} and model-\RNum{2}, respectively.
Figure~\ref{fig:RMS_threshold_L3_S4_B_saeed} shows the thresholded RMS image for model-\RNum{1}, and the calculated value of \(IoU\) is \((0.07)\).
Figure~\ref{fig:RMS_threshold_L3_S4_B_ijjeh}  shows the thresholded RMS image for model-\RNum{2}, and the calculated \(IoU\) is \((0.23)\).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RMS predictions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.49\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{RMS_L3_S4_B_saeed.png}
		\caption{RMS image of model-\RNum{1} predicted output}
		\label{fig:RMS_L3_S4_B_saeed}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.49\textwidth}
		\centering
		\includegraphics[width=1\textwidth]{RMS_L3_S4_B_ijjeh.png}
		\caption{RMS image of model-\RNum{2} predicted output}
		\label{fig:RMS_L3_S4_B_ijjeh}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{RMS images of predicted outputs - Specimen~\RNum{4}.}
	\label{fig:RMS_L3_S4_B__images}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RMS THERSHOLDED predictions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure} [!h]
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.49\textwidth}
		\centering
		\includegraphics[scale=1]{RMS_L3_S4_B_333x333p_50kHz_5HC_saeed_cmap_viridis_greyscale_THRESHOLDED.png}
		\caption{Model-\RNum{1}, \(IoU\) = \(0.07\)}
		\label{fig:RMS_threshold_L3_S4_B_saeed}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\hfill
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{subfigure}[b]{.49\textwidth}
		\centering
		\includegraphics[scale=1]{RMS_L3_S4_B_333x333p_50kHz_5HC_ijjeh_cmap_viridis_greyscale_THRESHOLDED.png}
		\caption{Model-\RNum{2}, \(IoU\) = \(0.23\)}
		\label{fig:RMS_threshold_L3_S4_B_ijjeh}
	\end{subfigure}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\caption{Thresholded RMS images of predicted outputs - Specimen~\RNum{4}.}
	\label{fig:RMS_threshold_L3_S4_B__images}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\XtoCBlock{Div}
\label{block:Div}
\begin{figure}[H]\includegraphics{Div}\end{figure}

\begin{XtoCtabular}{Inports}
Num & Dividend (Numerator)\tabularnewline
\hline
Den & Divisor (Denominator)\tabularnewline
\hline
\end{XtoCtabular}

\begin{XtoCtabular}{Outports}
Out & Quotient\tabularnewline
\hline
\end{XtoCtabular}

\subsubsection*{Description:}
Division of input Num by input Den.

% include optional documentation file
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Div_Info.tex}{\vspace{1ex}}{}

\subsubsection*{Implementations:}
\begin{tabular}{l l}
\textbf{FiP8} & 8 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP16} & 16 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP32} & 32 Bit Fixed Point Implementation\tabularnewline
\textbf{Float32} & 32 Bit Floating Point Implementation\tabularnewline
\textbf{Float64} & 64 Bit Floating Point Implementation\tabularnewline
\end{tabular}

\XtoCImplementation{FiP8}
\index{Block ID!4928}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP8 \tabularnewline
\textbf{ID} & 4928 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Div\_FiP8.c \tabularnewline
\textbf{H filename} & Div\_FiP8.h \tabularnewline
\end{tabular}
\vspace{1ex}

8 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int8          *Num;
     int8          *Den;
     int8          Out;
} DIV_FIP8;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Div_FiP8.tex}{}{}
\fi
\XtoCImplementation{FiP16}
\index{Block ID!4929}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP16 \tabularnewline
\textbf{ID} & 4929 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Div\_FiP16.c \tabularnewline
\textbf{H filename} & Div\_FiP16.h \tabularnewline
\end{tabular}
\vspace{1ex}

16 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int16         *Num;
     int16         *Den;
     int16         Out;
} DIV_FIP16;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Div_FiP16.tex}{}{}
\fi
\XtoCImplementation{FiP32}
\index{Block ID!4930}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP32 \tabularnewline
\textbf{ID} & 4930 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Div\_FiP32.c \tabularnewline
\textbf{H filename} & Div\_FiP32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int32         *Num;
     int32         *Den;
     int32         Out;
} DIV_FIP32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Div_FiP32.tex}{}{}
\fi
\XtoCImplementation{Float32}
\index{Block ID!4931}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & Float32 \tabularnewline
\textbf{ID} & 4931 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Div\_Float32.c \tabularnewline
\textbf{H filename} & Div\_Float32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Floating Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     float32       *Num;
     float32       *Den;
     float32       Out;
} DIV_FLOAT32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Div_Float32.tex}{}{}
\fi
\XtoCImplementation{Float64}
\index{Block ID!4932}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & Float64 \tabularnewline
\textbf{ID} & 4932 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Div\_Float64.c \tabularnewline
\textbf{H filename} & Div\_Float64.h \tabularnewline
\end{tabular}
\vspace{1ex}

64 Bit Floating Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     float64       *Num;
     float64       *Den;
     float64       Out;
} DIV_FLOAT64;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Div_Float64.tex}{}{}
\fi


\documentclass{article}
\usepackage{ stmaryrd }
\usepackage{amsmath,amsthm,amsfonts,amssymb,array}

\usepackage{geometry}
\usepackage{todonotes}

\usepackage[center,xpart]{figbib}
\usepackage{hyperref}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm}
\usepackage[section]{placeins}
\usepackage{caption}
\usepackage{xcolor}

\newcommand{\etodo}[1]{\textcolor{purple}{[E: #1]}}
\newtheorem{theorem}{Theorem}[section]
\numberwithin{theorem}{subsection}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem*{definition}{Definition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{exercise}[theorem]{Excercise}
\newtheorem{remark}[theorem]{Remark}
\theoremstyle{remark}
\newtheorem*{solution}{Solution}

\newcommand{\eqdef}{=\mathrel{\mathop:}}

\begin{document}

\title{Problem Space formulation}
\date{\vspace{-5ex}}
\maketitle

\section{Introduction}

The following is an explanation of the formal terms used in defining
and identifiying the cuts used to generate the plots for re-compare library.

\begin{definition}[Solution]
	Given a general problem $F$ which is takes parameters $p_{i}\in P_{i}\mid1\le i\le n$
	and whose possible solution can be represented in a tuple of independant
	values $s_{i}\in S_{i}\mid1\le j\le m$, the problem can be seen as
	a function
	\[\begin{array}{l}
	f:P\rightarrow 2^{S} \\
	P=\times_{i=1}^nP_i\\
	S=\times_{j=1}^mS_i \\
	\end{array}
	\]
	we would say that $s\in S$ is a solution of $p\in P$ if $s\in f(p)$.
\end{definition}

\begin{definition}[Problem space]
	Using the notations above, we mark $ P $ as the parameter space, $ S $ as the solution space and $ Pr \eqdef P \times S  $ as the solution space. We define $ \{ (p,s)) \mid p\in P, s\inf(p) \} $ as the proper (feasible) problem space
\end{definition}

When analyzing high dimensional information, we often time try look for a dependancy between some $ P_i $ and some $ S_j $ when leaving all other $ P_k \mid k\ne i $ constants. This defines a sub space on the problem space.

\begin{definition}[Cuts]
	A cut of the problem space of a problem $ f $ is a sub space the proper solution space
	\[ \pi_{k_1=c_1,\dots,k_r=c_r,k'_1=d_1,\dots,k'_{r'}=d_r' }(Pr) = \{ (p,f(p)) \mid p_{k_i}=c_i, s_{k'_j}=d_j \} \]
	Basically, we take only the proper tuples that agreed with the designated constant equality constraints we put on some of the dimensions of the problem space.

	We define a $ k $-cut as a cut that is not constrained on $ k $ dimensions. We define a $ r_1,r_2 $-cut as a subspace that in not constrained only on dimensions $ r_1 $ and $ r_2 $. This definition generalises to any amount of dimensions.
\end{definition}

\section*{Analyzing and Visualizing }

When trying to analyze a Problem space by experimental computations and present results in a manner
that's is informative for a human, we will present 3 dimensional cuts of the problems space as 2 dimensional plots as \textbf{discrete layer plots}.

\begin{definition}[DLPs (Discrete layer plots) ]
	A DLP is a tuple of the form $ (Q_{1},Q_{2},F,C_1,C_2) $ Where
	\begin{itemize}
		\item $ Q_1, Q_2, F $ are dimensions of the problem space.
		\item $ C_1,C_2 $ are discrete subsets of $ Q_1,Q_2 $ respectively.
	\end{itemize}
\end{definition}

We visualize the DLP on a $ 2 $-dimensional plot by taking
\begin{itemize}
	\item $ Q_1 $ to be the independent variable on the $ x $ axis
	\item $ F $ to be the dependent variable on the $ y $ axis
	\item $ Q_2 $ to be another independent variable that varies across layers of the plot
\end{itemize}
The discreteness restriction on $ Q_2 $ stems from a visualization constraint (since we cant have a continuum of layers in a plot) and both independent parameters are constrained because we are sampling Algorithms on finite sets of inputs.

\subsection*{Localization to Re-comp}

In Re-comp we compare algorithms of the type $match(text,patern)$ and are usually interested in the time performance of the matching operations. Thus, for a set of Algs $A$ and a space of texts and regex patterns $T,R$ we would define the Problem space as
\[\begin{array}{l}
P=A\times T\times R \\
S=\mathbb{R}\cong time \\
\end{array}
\]

Since we are interested in seeing how different algorithms fair in time across varying texts and patterns, we are
interested in DLPs of the form $(T_{i},A,time,C,A)$ or $(R_{i},A,time,C,A)$.
This basically means that we show all the results in terms of $ time $ keeping all parameters of the problems constant except the algorithm chosen and a single parameter of the regex's or texts.

\begin{figure}[h]
	\centering
	\captionsetup{justification=centering,width=0.5\textwidth}
	\includegraphics[width=0.5\textwidth]{../output/all_matches_cut_4.png}
  \caption{An example of DLP plot from re-compare. $R_i$ is regex difficulty with $C$ being \{easy,hard\}. $A$ consists of $3$ regex matching Algs, each of which gets a label }
	\label{fig:medial}
\end{figure}

What makes re-compare stands out is that it computes all such DLPs given any parametrisation to the regex space and text space.

\end{document}


\begin{figure}
 \centerline{
 \includegraphics[width=3.15in]{../Pyfig/fig_spatiotempspectra}}
\caption{Spatio-temporal spectra of KE  and APE for $c = 20$ and $n = 3840$ versus $\omega/\omega_l$, where
$\omega_l = c k$.  From top to bottom: $k/\delta k
= 12$, 27, 62, 143, 327, and 746.  }
\label{fig_spatiotemp_spectra}
\end{figure}

Figure~\ref{fig_spatiotemp_spectra} presents the spatio-temporal
spectra plotted as a function of the normalized frequency
$\omega/\omega_l$.
%\PA{Explain how these spectra have been calculated.}
In order to calculate these spectra, we have saved well-resolved time
series of $\hat d(\kk)$ and $\hat a(\kk)$ for wave numbers inside
particular shells such as $k\leqslant \kk<k+\delta k$, computed the
temporal spectrum of each signal and averaged over the wave numbers
inside each shell.

\begin{figure}
 \centerline{
 \includegraphics[width=6.0in]{../Pyfig/fig_phys_fields_wave}}
\caption{ }
\label{Physical}
\end{figure}
%
The spectra are strongly dominated by large peaks at $\omega =
\omega_l$ indicating that the characteristic frequency for each wave
number is the linear frequency.  However, the widening of the peaks
can be explained only by nonlinear effects.  The equipartition
between kinetic and potential energies is expected since the flow only
consists of gravity waves and the total energy is nearly equal to the
quadratic energy which is equal to the sum over all waves of their
equipartitioned quadratic energy.}

\subsection{Time- and space-averaged energy as a function of $c$}

Figure~\ref{fig_Evsc}(\textit{a}) shows the time- and space-averaged
energy for the statistically stationary flows divided by the square
root of the mean energy dissipation rate as a function of $c$ and for
three resolutions: $n = 960$, dotted lines; $n = 1920$, continuous
lines and $n = 3840$, dashed lines.
%
For all resolutions, the energy increases with $c$.  More precisely,
the curves can be well fitted to a law $E = C_n \sqrt{\eps L_f c}$
(blue lines).  However, the coefficient $C_n$ varies with the
resolution, i.e.\ with the effective Reynolds number.
%
This is very different from the case of isotropic turbulence where the
energy scales as $E \sim (\eps L_f)^{2/3}$ and does not vary with the
Reynolds number in the limit of very large Reynolds number.
%
Weak wave turbulence theory predicts an energy-flux law of the form $E
\propto \eps^{1/(N-1)}$, where $N$ is the number of waves involved
in the nonlinear interactions \cite[]{Nazarenko2011}.  Therefore, the
scaling $E = C_n \sqrt{\eps L_f c}$ would correspond to interactions
involving three waves.
%
However, the hypothesis needed for applying the weak wave turbulence
formulation are not fulfilled.

This effect of the increase of the energy with the resolution is
investigated in figure~\ref{fig_Evsc}(\textit{b}) where the quantity
$C_n = E/\sqrt{\eps L_f c}$ is plotted as a function of the
resolution.
%
For $c = 10$ (dotted line), the waves are not very fast and the
variation with the resolution is weak.
%
However, in the limit of very fast waves ($c>100$), the curves for the
different wave speeds nearly collapse and increase at least up to $n =
5760$.  The increase tends to saturate but it is difficult to know
from our results what is the scaling of $C_n$ as a function of the
resolution and if it really saturates for very large $n$ and $c$.
%
In order to decide on this issue, we would need to run simulations in
the very-fast-wave regime, $c>100$, and at very large resolutions $n >
5760$.  In this regime the energy fluctuations are large so
that the simulations would have to be carried out for very long time
in order to get a good convergence for the mean energy.  Since the
time step has to be extremely small in this regime, such simulations
would be too costly.

We now turn to the study of the energy spectra.  A dimensional
analysis based on the assumption that the spectra only depend on
$\eps$, $c$ and $k_f$ gives the following general expression
\begin{equation}
E_{\alpha, \beta}(k) = k^{-\alpha} \eps^\beta   c^{2- 3\beta}
{k_f}^{\alpha -1 - \beta}, \label{eq_E_alpha_beta}
\end{equation}
where $\alpha$ and $\beta$ are two free parameters.

The scaling of the energy as $\sqrt{\eps L_f c}$ suggests that the
spectra should scale like the Zakharov-Sagdeev spectrum, $E(k) \sim
k^{-3/2}\sqrt{\eps c}$, which is the prediction of weak wave
turbulence theory for three-dimensional acoustic turbulence
\cite[]{Nazarenko2011}.
%
The compensated spectra $E(k) / ( k^{-3/2}\sqrt{\eps c})$ are plotted
in figure~\ref{fig_spectra_c}(\textit{a}) for $n = 1920$ and in
figure~\ref{fig_spectra_c}(\textit{b}) for $n = 3840$.  The different
curves correspond to different wave speeds, going from $c=10$ to
$c=1000$ for $n = 1920$ and from $c=10$ to $c=200$ for $n = 3840$.
%
For both resolutions, the compensated spectra collapse at the
energy-dominating small wave numbers.
%
However, these compensated spectra are not flat in the inertial range
and do not collapse in the inertial and dissipation ranges, i.e. for
$k\gtrsim 2k_f$.  In the inertial range, they follow a clear $k^{-2}$
scaling law and there is a bottleneck in the dissipation range where
the slope is close to $-3/2$.
%
\cite{Kuznetsov2004} showed that $k^{-2}$ spectra can be explained by
singularities and this scaling has already been observed in
two-dimensional acoustic turbulence \cite[]{FalkovichMeyer1996}.
%

Inserting $\alpha = 2$ in the spectrum (\ref{eq_E_alpha_beta}) gives
\begin{equation}
E_\beta(k) = k^{-2} {k_f}^{1-\beta} c^{2-3\beta} \eps^\beta
\end{equation}
and we have found that the numerical spectra are very close to the
spectrum $E_\beta(k)$ with $\beta = 5/9$.
%
The compensated spectra $E(k) / ( k^{-2} c^{1/3} \eps^{5/9} k_f^{4/9}
)$ are plotted in figure~\ref{fig_spectra_c}(\textit{c}) for $n =
1920$ and in figure~\ref{fig_spectra_c}(\textit{d}) for $n = 3840$.
The collapse is very good in the inertial range but we stress that we
are not aware of any theory predicting the empirical spectrum $k^{-2}
c^{1/3} \eps^{5/9} k_f^{4/9}$.

Figure~\ref{fig_spectra_c40} shows the compensated spectra $E(k) / (
k^{-2} c^{1/3} \eps^{5/9} k_f^{4/9} )$ of total energy (black line),
KE (red line) and APE (blue line) for $c = 40$ and $n = 7680$.  For
all wave numbers, we have $E(k) = 2E_K(k) = 2E_A(k)$ since the flow
only consists of \Add{gravity} waves.
%
The spectra are very close to $k^{-2}$ in the inertial range over more
than one decade and the shallowing to a slope close to $-3/2$ is
clearly confined to the dissipation range.  This confirms that this
bump is due to a dissipation effect and that there is no wide
$k^{-3/2}$ spectrum even at very large resolutions.

% \begin{figure}
% \centerline{
% \includegraphics[width=\halfwidth]{../Figs/fig_spectra_resol_c=10}
% \includegraphics[width=\halfwidth]{../Figs/fig_spectra_resol_c=40}
% }
% \caption{Compensated energy spectra $E(k) / ( k^{-3/2}\sqrt{\eps c})$
% for different resolutions.  In (\textit{a}), $c = 10$ and in
% (\textit{a}), $c = 40$.}
% \label{fig_spectra_resol}
% \end{figure}

% The compensated spectra $E(k) / ( k^{-3/2}\sqrt{\eps c})$ are plotted
% for different resolutions %
% in figure~\ref{fig_spectra_resol}(\textit{a}) for $c=10$ and
% in figure~\ref{fig_spectra_resol}(\textit{b}) for $c=40$.
% %
% We see that an inertial range with a $k^{-2}$ scaling starts to appear
% for $n\gtrsim 960$.
% %
% As seen in figure~\ref{fig_Evsc}, the ratio $E/\sqrt{\eps L_f c}$ only
% weakly varies for $c=10$ but increases in the fast-waves regime for
% $c=40$.  This effect can be seen here at the energy-containing wave
% numbers $k<2 k_f$.  However, the variation with the resolution is much
% weaker in the inertial range at $k>2 k_f$.

In subsection~\ref{subsection_cascade}, we have shown that third-order
structure functions scale like $r$ since there is a downscale energy
cascade.
%
The Kolmogorov method predicts $k^{-5/3}$-spectra but the numerical
spectra are much steeper in the inertial range, with a slope equal to
-2.  The fact that third-order and second-order quantities can not be
simply related by the Kolmogorov scaling implies that the cascade is
very intermittent.

\subsection{Effect of the shocks and intermittency}

\begin{figure}
\setlength{\halfwidth}{2.72in}
% \centerline{
% \includegraphics[width=\halfwidth]{../Figs/fig_2Dh_c20}
% \hspace{-4mm}
% \includegraphics[width=\halfwidth]{../Figs/fig_2Dh_c200}
% }
% \centerline{
% \includegraphics[width=\halfwidth]{../Figs/fig_2Duy_c20}
% \hspace{-4mm}
% \includegraphics[width=\halfwidth]{../Figs/fig_2Duy_c200}
% }
\caption{
Snapshots for $n = 1920$ and two values of the wave speed
$c= 20$ (\textit{a,c}) and $c= 200$ (\textit{b,d}).
The colors represent the thickness in (\textit{a,b}) and
the $y$-component of the velocity in (\textit{c,d}).
The arrows represent the velocity field.
%
The coordinates are nondimensionalized by the characteristic scale of
the forcing $L_f = 3.57$.  }
\label{fig_phys}
\end{figure}

Figure~\ref{fig_phys} shows %
the normalized thickness $h$ %
(figures~\ref{fig_phys}\textit{a,b}) %
and the $y$-component of the velocity $u_y$ %
(figures~\ref{fig_phys}\textit{c,d}) %
for $c = 20$ (figures~\ref{fig_phys}\textit{a,c}) and %
$c = 200$ (figures~\ref{fig_phys}\textit{b,d}).
%
These wave speeds correspond %
to a moderate forcing Froude number $F_f \sim 0.05$ and %
to a very small forcing Froude number $F_f \sim 0.005$, respectively.
The normalized surface displacement $\eta = h - 1$ is of order 0.3 for
$c = 20$ and one order of magnitude smaller, 0.03, for $c = 200$.
%
The typical velocity is also much smaller than the wave speed, %
with $u_y/c \sim 0.2$ for $c = 20$ %
and $u_y/c \sim 0.03$ for $c = 200$. %
This confirms that the flows are in a fast-wave regime, especially for
$c = 200$.
%
However, many discontinuities can be seen in both fields $h$ and
$u_y$.  These discontinuities are hydraulic jumps, which are the
equivalent to shocks in a compressible flows.
%
\Add{Baines (1998) provides a theoretical prediction for the velocity
of the hydraulic jumps is one-layer shallow-water flow:
\begin{equation}
c_s = c \sqrt{\frac{h_+}{h_-} \frac{h_+ + h_-}{2}},
\end{equation}
where $h_+$ and $h_-$ are the dimensionless thickness before and after
the jump.
%
We have verified that the velocity of the discontinuities in the
simulations is consistent with this theoretical prediction, implying
that the associated Froude number (or Mach number) is of the order
unity.}

\nocite{Baines1998}

% We have verified that these shocks are very fast and travel at a
% velocity of the order of the wave speed \Add{(more precisely, Baines 1998)}
% , implying
% that their associated Froude number (or Mach number) is of the order
% unity.
%el (This is not necessarily true...)
% The existence of shocks implies that there is a strong coherence
% between small and large wave numbers and indicates nonlocal
% interactions between wave numbers.
%
In between the shocks, the flow is very smooth for $c=20$ and slightly
more irregular for $c = 200$.

Figures~\ref{fig_phys}(\textit{c,d}) display the $y$-component of the
velocity.  There are less discontinuities in this quantity than in the
thickness. More precisely, the $h$-discontinuity lines that are along
the $y$-axis are not associated with corresponding discontinuities of
the $y$-component of the velocity. This can be seen for example for
the shock at $x/L_f\simeq 0.4$ and $y/L_f\simeq 2.1$ in
figures~\ref{fig_phys}(\textit{a}) and \ref{fig_phys}(\textit{c}).
%
This illustrates that the singularity in the velocity is in the
component perpendicular to the shock line, which is the assumption on
the structure of the velocity discontinuities used in the model
presented in \S~\ref{subsection_shock_model}.

\begin{figure}
% \centerline{
% \includegraphics[width=\halfwidth]{../Figs/fig_interm_strfct_ux}
% \includegraphics[width=\halfwidth]{../Figs/fig_interm_strfct_uy}
% }
\caption{
Compensated fifth-order structure functions $\mean{|\delta u_L|^5}/r$
of (\textit{a}) the longitudinal increments and (\textit{b}) the
transverse increments. %
The crosses indicate the range of separation $r$ where the exponent
$\zeta_p$ is computed. %
The dashed lines correspond to the Kolmogorov scaling laws $r^{p/3}$
and $\zeta_p = p/3$.  The wave speed and the resolution are $c = 40$
and $n = 7680$.  }
\label{fig_strfct5}
\end{figure}

The shock model derived in subsection~\ref{subsection_shock_model}
predicts that structure functions of all orders should scale linearly
with $r$.
%
Figure~\ref{fig_strfct5} presents fifth-order structure functions
compensated by $r$.
%
Figures~\ref{fig_strfct5}(\textit{a}) and
\ref{fig_strfct5}(\textit{b}) correspond to the structure functions
computed from the longitudinal increments and the transverse
increments, respectively.  The structure functions compensated by $r$
are nearly flat between $r \simeq 0.012 L_f$ and $r \simeq 0.06 L_f$,
showing that they scale like $r$ on this relatively narrow range of
scale compared to the inertial range.
%
The $r$-scaling is very different from the slope of the fifth-order
structure functions calculated from the Kolmogorov scaling $\zeta_5 =
p/3 \simeq 1.66$ (dashed straight line).  This shows that the wave
cascade is strongly intermittent and that this intermittency can be
explained by the presence of discontinuities related to the shocks.

\begin{figure}
% \centerline{
% \includegraphics[width=\halfwidth]{../Figs/fig_interm_ux}
% \includegraphics[width=\halfwidth]{../Figs/fig_interm_uy}
% }
\caption{
Exponents $\zeta_p$ of the structure functions
of (\textit{a}) the longitudinal increments
and (\textit{b}) the transverse increments versus the order $p$.
%
The dashed lines correspond to
the Kolmogorov scaling laws $r^{p/3}$ and $\zeta_p = p/3$.
The wave speed and the resolution are $c = 40$ and $n = 7680$.
}
\label{fig_interm}
\end{figure}

The slope of the structure functions of order $p$ over the range
$0.012 L_f\leqslant r \leqslant 0.06 L_f$, $\zeta_p$, are plotted in
figure~\ref{fig_interm}(\textit{a}) for the longitudinal increments
and in figure~\ref{fig_interm}(\textit{b}) for the transverse
increments.
%
The exponent are very far from the Kolmogorov scaling $\zeta_p = p/3$.
They increase as $p$ for $p\ll1$, saturate to a value close to 1 for
$p>2$ and tend to decrease for $p>3$.
%
A similar shape of the $\zeta_p$ function has been predicted for
Burger turbulence \cite[]{BouchaudMezardParisi1995}.
%
The shape of $\zeta_p$ at very small $p$ is determined by the
scaling of the smallest velocity increments and the $p^1$-variation
shows that these smallest increments scales like $\delta u \sim r^p$.
%
The plateau at $p > 2$ is a consequence of the dominance by shocks of
the largest increments.
%
Note that these results are obtained for a relatively small forcing
Froude number $F_f \simeq 0.03$ corresponding to $c=40$.  The function
$\zeta_p$ has approximately the same extreme shape for a larger Froude
number $F_f \simeq 0.01$, corresponding to $c=10$.  Note also that the
decrease of $\zeta_p$ for $p>3$ is anomalous, which could be due to
the relatively narrow width of the range over which $\zeta_p$ is
computed.

\begin{figure}
\centerline{\includegraphics[width=8cm]{../Pyfig/fig_ratio_strfct}}
\caption{
Ratio of the structure functions of the velocity increments
$R_p(r) \equiv \mean{|\delta u_L|^p} / \mean{|\delta u_T|^p}$
for $p = 2,$ 3 and 4.
The dotted straight lines indicate the values computed by the shock model:
$R_2 = 2$, $R_3 = 6\pi/8$ and $R_4 = 8/3$.
%
The wave speed and the resolution are $c = 10$ and $n = 7680$.  }
\label{fig_ratio}
\end{figure}

The functions $R_p = \mean{|\delta u_L|^p}/\mean{|\delta u_T|^p}$ are
plotted in figure~\ref{fig_ratio} for $p =2$ to 4.  The predictions of
the shock model, $R_2 = 2$, $R_3 = 6\pi/8$ and $R_4 = 8/3$, are also
plotted in dotted lines for comparison.  We see that the numerical
results are reasonably close to these predictions.  However, the
agreement is less good for smaller Froude number (not shown).  The
structure functions are fully determined by shocks only for Froude
numbers that are not too small, which is consistent with the snapshots
in figure~\ref{fig_phys} showing that the fields between the shocks
are more irregular for the smallest Froude number.

\begin{figure}
\centerline{\includegraphics[width=12cm]{../Pyfig/fig_flatness}}
\caption{ Flatness of the longitudinal and transverse increments for
$c = 10$ and $n = 7680$. The straight continuous lines indicate the
$r^{-1}$-scaling and the straight dashed line the $r^{-3/2}$-scaling.
The inset shows the ratio $F_T/F_L$ and the corresponding value computed by the shock model, $F_T/F_L = 1.5$.  }
\label{fig_flatness}
\end{figure}'

\begin{figure}
\centerline{\includegraphics[width=8cm]{../Pyfig/fig_spectra}}
\caption{Compensated spectra
of total energy (thick black line)
kinetic energy (thin dark line) and
available potential energy (thin light line)
for $c = 40$ and $n = 7680$.}
\label{fig_spectra_c40}
\end{figure}
%
Figure~\ref{fig_flatness} shows the flatness of the longitudinal and
transverse increments, computed from a numerical simulation for $c =
10$ and $n = 7680$.
%
For a Gaussian probability distribution the flatness factor is equal
to 3 whereas the shock model predict flatness factors scaling like
$r^{-1}$.
%
We see that here the flatness factors are much larger than 3, of the
order of $10^3$.
%
Remarkably, they scale approximately as $r^{-1}$ as predicted by the
shock model and the ratio $F_T/F_L$ is very close to the predicted
value 1.5.

% Figure~\ref{fig_flatness}(\textit{b}) shows the same quantities
% computed from atmospheric data measured by commercial aircraft.
% %
% The flatness curves have been taken from \cite{Lindborg1999}.
% Surprisingly, the atmospheric results are quite similar to the
% numerical ones. The flatness factors are very large and strongly
% decrease at scales smaller than 100 km.  Interestingly, the ratio
% $F_T/F_L$ is also very close to the value 1.5 predicted by the shock
% model.
% %
% We stress that even though these similarities are striking, the
% underlying dynamics are very different.
% %
% While there is no energy in the quasi-geostrophic modes in the
% numerical simulations, the atmospheric flows are usually close to be
% quasi-geostrophic at horizontal scales larger than 500 km and the
% vertical vorticity is in average of the same order of magnitude than
% the horizontal divergence at the mesoscales, i.e. at horizontal scales
% between 10 and 500 km \cite[]{Lindborg2007jas}.
% %
% Therefore, it is not surprising to also see differences between the
% atmospheric and the numerical results. The flatness factors in
% figure~\ref{fig_flatness}(\textit{b}) vary approximately as $r^{-3/2}$
% (dashed line), which is significantly faster than for the numerical
% simulations of the shallow-water model. Moreover, the second-order
% structure functions in the atmosphere scale as $r^{2/3}$
% \cite[]{Lindborg1999, ChoLindborg2001,
% FrehlichSharman2010}. Considering the scaling for the flatness
% factors, this implies that the variation with scale of the
% fourth-order structure functions is actually very weak, which is
% not in agreement with the prediction of the shock model.
% %
% Nevertheless, we do not know other explanations of such very large
% flatness factors with a ratio $F_T/F_L=1.5$ observed in the atmosphere.
% %
% Thus, we think that these results raise interesting questions
% regarding the interpretation of structure functions measured in the
% atmosphere.  How important are the discontinuities on horizontal
% cross-sections in these cases?
% %
% It is well known that the fronts separating cold and warm regions
% explain many meteorological phenomena.
% %
% The curves in figure~\ref{fig_flatness} seem to indicate that
% they could also have strong effects on the statistics of the atmosphere
% over a quite large range of scales.


\subsection{Aqueous Complexation} \label{sec:AqueousComplexation}

\subsubsection{Overview}

It is customary to treat the reaction network corresponding to the homogeneous reactions
in the aqueous phase as a distinct set of processes taking place within a single aqueous phase \citep{steefel_1996}.
%although these can also be described within the same more general formalism provided in Section~\ref{sec:mathframework}
%that includes multiphase reactions.
This reaction network is sometimes referred to as \textit{aqueous complexation},
since it involves reactions between individual dissolved species to form complexes.

\subsubsection{Process Model Equations} \label{sec:aqueous-complexation-eq}

\paragraph{Equilibrium Reactions.}

If we assume that the various aqueous species are in chemical
equilibrium, it is possible to reduce the number of
\textit{independent} concentrations, that is, the number that actually
need to be solved for. Mathematically, this means that in a system
containing $N_{tot} $ aqueous species, the number of independent
chemical components in the system $N_{c} $ is reduced from the total
number of species by the $N_{x} $ linearly independent chemical
reactions between them (for further discussion,
see~\citet{hooyman_1961, aris_1965, bowen_1968, van_1970, reed_1982,
  lichtner_1985, kirkner_1988}. This leads to a natural partitioning
of the system into $N_{c} $ \textit{primary} or \textit{basis}
species, designated here as $C_{j} $, and the $N_{x} $
\textit{secondary} species, referred to as $C_{i}
$~\citep{reed_1982, lichtner_1985, kirkner_1988}. The equilibrium
chemical reactions between the primary and secondary species take the
form
%
\begin{equation}
  \A_{i}
     \rightleftharpoons
        \sum _{j=1}^{N_{c} } \,
        \nu _{ij} \A_{j} \; \; \;
        (i=1,...,N_{x} ),
\label{eq:AqueousComplexation:EquilibriumReaction}
\end{equation}
%
where $\A_{j} $ and $\A_{i} $ are the
chemical formulas of the primary and secondary species respectively
and $\nu _{ij} $ is the number of moles of primary
species $j$ in one mole of secondary species $i$.
It should be noted here that the partitioning between the primary
and secondary species is not unique, that is, we can write the
chemical reactions in more than one way. The equilibrium reactions
provide an algebraic link between the primary and secondary species
via the law of mass action for each reaction
\begin{equation}
  C_{i}
     = K_{i}^{-1} \gamma _{i}^{-1}
       \prod _{j=1}^{N_{c} } \,
          ( \gamma _{j} C_{j} )^{\nu _{ij}}
     \; \; \;
     (i=1,...,N_{x} ),
\label{eq:AqueousComplexation:MassAction}
\end{equation}
%
where $\gamma _{j} $ and $\gamma _{i} $ are
the activity coefficients for the primary and secondary species
respectively, and $K_{i} $ is the equilibrium
constant of the reaction given in
Equation~\eqref{eq:AqueousComplexation:MassAction}, written here as
the destruction\todo[color=cyan]{GEH: What does ``destruction'' mean?} of one mole of the secondary
species. Equation~\eqref{eq:AqueousComplexation:MassAction} implies
that the rate of production of a primary component $j$ due to
homogeneous reactions, $R_{j}^{aq}$, can be written in terms of the
sum of the total rates of production of the secondary
species~\citep{kirkner_1988}
%
\begin{equation}
  R_{j}^{aq} \eq -\sum _{i=1}^{N_{x} } \, \nu_{ ij} I_{i}^{aq} ,
 \label{eq:AqueousComplexation:RateSecondary}
\end{equation}
%
where $I_{i}^{aq}$ is the reaction rate of the secondary species in
the aqueous
phase. Equation~\eqref{eq:AqueousComplexation:RateSecondary} suggests
that one can think of a mineral dissolving, for example, as producing
\textit{only primary species} which then equilibrate instantly with
the secondary species in the system. Using
Equation~\eqref{eq:AqueousComplexation:RateSecondary} and neglecting
transport for the sake of simplicity here, the rates of the
equilibrium reactions can be eliminated~\citep{steefel_1996}
%
\begin{equation} \label{eq:PartitioningEquilibriumKinetic}
 \frac{\partial }{\partial t} \left[\phi s_w \rho _{w}  \left(C_{j} + \sum _{i=1}^{N_{x} } \, \nu _{ij} C_{i} \right)\right] =R_{j}^{min} \; \; \; (j=1,...,N_{c} ),
\end{equation}
%\[
%\_ \boldsymbol{\nabla} \bullet \left[u\rho _{f} M_{H_{2} O} \left(C_{j} +\sum _{i=1}^{N_{x} } \, \nu _{ij} X_{i} \right)-D\boldsymbol{\nabla} \left\{\rho _{f} M_{H_{2} O} \left(C_{j} +\sum _{i=1}^{N_{x} } \, \nu _{ij} X_{i} \right)\right\}\right]
%\]
%\begin{equation} \label{eq:AqueousComplexation:PrimaryTransport}
%\_ =R_{j}^{min} \; \; \; (j=1,...,N_{c} )
%\end{equation}
where $s_w$ and $\rho_w$ refer to the saturation and mass density of
the aqueous phase, respectively.  Note that only the term
$R_{j}^{min} $ remains on the right hand side of
Equation~\eqref{eq:PartitioningEquilibriumKinetic} because we have
assumed that they are the only kinetic reactions.

\paragraph{Definition of a Total Concentration.}
\noindent If a total concentration, $\Psi_{j} $, is defined as~\citep{reed_1982, lichtner_1985, kirkner_1988}
\begin{equation} \label{eq:AqueousComplexation_GrindEQ__12}
  \Psi_{j} =C_{j} +\sum _{i=1}^{N_{x} } \, \nu _{ij} C_{i} ,
\end{equation}
then the governing differential equations can be written in terms of the total concentrations in the case where only aqueous (and therefore mobile) species are involved (Kirkner and Reeves, 1988)
\begin{equation} \label{eq:AqueousComplexation_GrindEQ__13}
  \frac{\partial }{\partial t} \left( \phi s_w \rho _{w}  \Psi_{j} \right)
  +
  \boldsymbol{\nabla} \cdot \left[ \phi s_w \rho _{w} \boldsymbol{v}_w \Psi_{j} -D\boldsymbol{\nabla}
  \left( \phi s_w \rho_{w}  \Psi_{j} \right) \right] \eq R_{j}^{min} \; \; \; (j=1,...,N_{c} ),
\end{equation}
where $\boldsymbol{v}_w$ is the velocity of the aqueous phase and $R_j^{\rm min}$ denotes the kinetic mineral reaction rate.
As pointed out by~\citet{reed_1982} and~\citet{lichtner_1985}, the total concentrations can usually be interpreted in a straightforward fashion as the total elemental concentrations (e.g., total aluminum in solution), but in the case of $H^{+} $ and redox species, the total concentration has no simple physical meaning and the total concentrations may take on negative values. Such quantities, however, do appear occasionally in geochemistry, the best example of which is alkalinity. In fact, the alkalinity (which may take on negative values) is just the negative of the total H$^{+} $ concentration where CO$_{2}$(aq) or H$_{2}$ CO$_{3}$ is chosen as the basis species for the carbonate system.

Note that the total concentration is generally only a useful concept computationally where equilibrium reactions allow the definition of secondary species described with Equation~\eqref{eq:AqueousComplexation:RateSecondary}.  In the case where the reactions among aqueous species are described kinetically, then the various aqueous complexes cannot be eliminated algebraically and they have to be solved for individually.

\paragraph{Kinetic Aqueous Reactions.}
If the aqueous phase reactions are not sufficiently fast for a given time scale of interest that they reach equilibrium, then they must be treated kinetically by solving an ordinary differential equation.  A convenient way to represent the reactions is with a Transition State Theory (TST) type of rate law~\citep{lasaga_1981, lasaga_1984, aagaard_1982}
\begin{equation} \label{eq:AqueousTSTkinetics}
  I_j^{aq} \eq k_{+}^{aq} \left(  \frac{Q^{aq}}{K^{aq}} \right) \prod a_{i}^{n},
\end{equation}
where $k_{+}^{aq}$ is the rate constant for the aqueous reaction, $Q^{aq}$ is the ion activity product , $K^{aq}$ is the corresponding equilibrium constant, and $a_i$ are the activities of the species affecting the rate far from equilibrium raised to the power $n$.

Alternatively, the reactions can be considered as completely irreversible, in which case there is no back reaction.  A good example is radioactive decay. The reactions are assumed to take the form
\begin{equation} \label{eq:IrreversibleKinetics}
  I_j^{aq} \eq k_{+}^{aq} \prod a_{i}^{n} ,
\end{equation}
and are therefore similar to the TST form except that a dependence on the saturation state is missing.   This more general form of irreversible reactions can be used to model decay and ingrowth of daughter products.

%\paragraph{References}

%\noindent Aagaard P. and Helgeson H.C. (1982) Thermodynamic and kinetic constraints on reaction rates among minerals and aqueous solutions, I, Theoretical considerations. \textit{Amer. J. Sci. }, 237-285.
%
%\noindent Aris R. (1965) Prolegomena to the rational analysis of systems of chemical reactions. \textit{Arch. Rational Mech. and Anal.} , 81-99.
%
%
%\noindent Bowen R.M. (1968) On the stoichiometry of chemically reacting materials. \textit{Arch. Rational Mech. Anal.} , 114-124.
%
%
%\noindent Hooyman G.J. (1961) On thermodynamic coupling of chemical reactions. \textit{Proc. Nat. Acad. Sci.} , 1169-1173.
%
%\noindent Kirkner D.J. and Reeves H. (1988) Multicomponent mass transport with homogeneous and heterogeneous chemical reactions: Effect of chemistry on the choice of numerical algorithm. I. Theory. \textit{Water Resources Res. }, 1719-1729.
%
%\noindent Lasaga A.C. (1981) Rate laws in chemical reactions. In \textit{Kinetics of Geochemical Processes} (ed. A.C. Lasaga and R.J. Kirkpatrick), Rev. Mineral. , 135-169.
%
%\noindent Lasaga A.C. (1984) Chemical kinetics of water-rock interactions. \textit{J. Geophys. Res. }, 4009-4025.
%
%\noindent Lichtner P.C. (1985) Continuum model for simultaneous chemical reactions and mass transport in hydrothermal systems. \textit{Geochim. Cosmochim. Acta }, 779-800.
%
%
%\noindent Reed M.H. (1982) Calculation of multicomponent chemical equilibria and reaction processes in systems involving minerals, gases, and an aqueous phase. \textit{Geochim. Cosmochim. Acta }, 513-528.
%
%
%\noindent Steefel, C.I. and MacQuarrie, K.T.B. (1996) Approaches to modeling reactive transport in porous media.  In \textit{Reactive Transport in Porous Media} (P.C. Lichtner, C.I. Steefel, and E.H. Oelkers, eds.), \textit{Reviews in Mineralogy} 34, 83-125.
%
%
%
%
%
%\noindent Van Zeggeren F. and Storey S.H. (1970) \textit{The Computation of Chemical Equilibria}. Cambridge University Press, Cambridge, 176 p.
%
%


\section{Quasi-likelihood function}


\appendix
\chapter{Ranges of parameters}
These parameters indicate the choices one can make from the
graphical interface. Not all of them are necessary if any of the
functions are to be embedded in a program.

\section{Physical constants}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline Parameter  & Max & Min  \\ \hline Air density  & 1.5e-3 &
0.9e-3
\\ \hline
Sound velocity  & 3.6e+4  & 3.3e+4 \\ \hline Wall resistance  &
2000 & 1000
\\ \hline
Wall mass  & 2 & 1 \\ \hline Wall compliance  & 4e+5 & 2e+5 \\
\hline
\end{tabular}
\end{center}

\section{Uniform tube model parameters}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline Parameter  & Max & Min  \\ \hline Area  & 15 & 0 \\ \hline
Length  & 20 & 5 \\ \hline Segments & 60 & 5
\\ \hline
Nasal coupling  & 3 & 0 \\ \hline
\end{tabular}
\end{center}

\section{Two tube model parameters}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline Parameter  & Max & Min  \\ \hline A1 & 10 & 0 \\ \hline x1
& 20-x2 & 0 \\ \hline A2 & 10 & 0 \\ \hline x2  & 20-x1 & 0 \\
\hline Nasal coupling & 3 & 0 \\ \hline
\end{tabular}
\end{center}

\section{Three parameter model parameters}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline Parameter  & Max & Min  \\ \hline At & 8 & 0 \\ \hline Xt &
13 & 3 \\ \hline Al & 4 & 0 \\ \hline Nasal coupling & 3 & 0 \\
\hline
\end{tabular}
\end{center}

\section{Articulator model parameters}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline Parameter  & Max & Min  \\ \hline All articulators  & 3 &
-3
\\ \hline
Vowel & 11 & 0\\ \hline Nasal coupling  & 3 & 0 \\ \hline
\end{tabular}
\end{center}
The vowels are as follows:
\begin{center}
\begin{tabular} {|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \hline
None & iy & ey & eh & ah & aa & ao & oh & uw & iw & ew & oe \\
\hline
\end{tabular}
\end{center}

\section{Area function model parameters}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline Parameter  & Max & Min  \\ \hline No. of Sliders  & 30 & 5
\\ \hline
Tube length  & 20 & 5 \\ \hline Internal tube segments  & 60 & 5
\\ \hline
Nasal coupling & 3 & 0 \\ \hline
\end{tabular}
\end{center}


\paragraph{Threshold Determination} \label{threshold_determination}
It is assumed that a large number of incoming time series windows should be unclassifiable. This can only be determined
by specifying a threshold as upper bound for the distance between a time series window and its nearest neighbour. An
intuitive approach for the threshold determinations would include knowledge about the distances between the instances of
a class. This approach can not be tested in this experiment, because the recording instructions do have the great weakness
to contain only one instance for every class in the training data as later mentioned in section \ref{instructions_review}. The
following threshold determinations were tested.

\begin{itemize}
    \item \textbf{HMinD:} Stands for half minimum distance, this approach determines the threshold for a class by the
        half minimum distance of the class to all other classes in the training data.
    \item \textbf{HAveD:} Stands for half average distance, this approach determines the threshold for a class by the
        half average distance of the class to all other classes in the training data.
    \item \textbf{HMidD:} Stands for half middle distance, this approach determines the threshold for a class by the
        half average of the minimum and maximum distance of the class to all other classes in the training data.
    \item \textbf{Peak:} Stands for peaking, this approach fakes already generated knowledge about the distance
        threshold by setting the threshold to the by a small factor increased distance between the only existing
        training class instance and the test instance that has to be found. Two more intuitively chosen factors were
        tested, $\frac{11}{10}$ and $\frac{12}{10}$. The peaking approach exists only to judge the performance of other
        threshold determinations.
\end{itemize}


\documentclass[a4paper,11pt,twoside]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsfonts, amssymb, amsmath}
\usepackage{verbatim}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{a4wide}
\usepackage{pstricks}
\usepackage[font={it,small},textfont=small,labelfont=bf]{caption}
\usepackage{bbm}

\newcommand{\md}{\mathrm{d}}
\newcommand{\e}[1]{\times 10^{#1}}
\newcommand{\bra}[1]{\langle #1 |}
\newcommand{\ket}[1]{| #1 \rangle}
\newcommand{\braket}[2]{\langle #1 | #2 \rangle}
\renewcommand{\vec}[1]{\mathbf{#1}}
\newcommand{\gvec}[1]{\boldsymbol{#1}}
\newcommand{\dr}{\, \mathrm d^3 \vec r}
\newcommand{\dk}{\, \mathrm d^3 \vec k}

\setcounter{secnumdepth}{0}

\title{The beloved commutator gym}
\author{Morten's brute force approach}
\date{\today}

\begin{document}

\maketitle

We have defined the following unperturbed Hamiltonian
\begin{equation}
\hat H_0 = \xi \sum_{p,\sigma} (p-1) \hat a_{p\sigma}^\dagger \hat a_{p\sigma},
\label{eq:H_0}
\end{equation}
%
and interacting part as
\begin{equation}
\hat V = -\frac{1}{2} g \sum_{p,q} \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} ,\label{eq:V}
\end{equation}
with the full Hamiltonian being given by $\hat H = \hat H_0 + \hat V$. The spin operator is defined as
\begin{align}
\hat S_z &= \frac{1}{2} \sum_{p,\sigma} \sigma \hat a_{p\sigma}^\dagger \hat a_{p\sigma}
\label{eq:S_z} \\
%
\hat S^2 &= \hat S_z^2 + \frac{1}{2} \left( \hat S_+ \hat S_- + \hat S_- \hat S_+ \right)
\label{eq:S^2} \\
%
\hat S_\pm &= \sum_p \hat a_{p\pm}^\dagger \hat a_{p\mp}
\label{eq:S_pm}.
\end{align}
%
We define the pair creation and annihilation operators $\hat P_p^+$ and $\hat P_p^-$ as
\begin{equation}
\hat P_p^+ = \hat a_{p+}^\dagger \hat a_{p-}^\dagger, \qquad
\hat P_p^- = \hat a_{p-} \hat a_{p+} .
\label{eq:P}
\end{equation}

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

\section{Yes, I did code all this Latex stuff, don't ask me why}
We compute first the commutator between $\hat H_0$ and $\hat S_z$ using \eqref{eq:H_0} and~\eqref{eq:S_z}:
\begin{align*}
\left[ \hat H_0 , \hat S_z \right]
%
&= \left[ \xi \sum_{p,\sigma} (p-1) \hat a_{p\sigma}^\dagger \hat a_{p\sigma} , \frac{1}{2} \sum_{p,\sigma} \sigma \hat a_{p\sigma}^\dagger \hat a_{p\sigma} \right] \\
%
&= \frac{\xi}{2} \sum_{p,\sigma} \sum_{p',\sigma'} (p-1) \sigma' \left[ a_{p\sigma}^\dagger \hat a_{p\sigma}, \hat a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} \right].
\end{align*}
%
We continue
\begin{align*}
\left[ a_{p\sigma}^\dagger \hat a_{p\sigma}, a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} \right]
%
&= a_{p\sigma}^\dagger \hat a_{p\sigma} \hat a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} -
a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} \hat a_{p\sigma}^\dagger \hat a_{p\sigma} \\
%
&= a_{p\sigma}^\dagger \hat a_{p\sigma} \hat a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} -
a_{p'\sigma'}^\dagger \left( \delta_{pp'} \delta_{\sigma \sigma'} - \hat a_{p\sigma}^\dagger  \hat a_{p'\sigma'} \right) \hat a_{p\sigma} \\
%
&= a_{p\sigma}^\dagger \hat a_{p\sigma} \hat a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} -
a_{p'\sigma'}^\dagger \hat a_{p\sigma} \delta_{pp'} \delta_{\sigma \sigma'} +
\hat a_{p\sigma}^\dagger a_{p'\sigma'}^\dagger \hat a_{p\sigma} \hat a_{p'\sigma'} \\
%
&= a_{p\sigma}^\dagger \hat a_{p\sigma} \hat a_{p'\sigma'}^\dagger \hat a_{p'\sigma'} -
a_{p'\sigma'}^\dagger \hat a_{p\sigma} \delta_{pp'} \delta_{\sigma \sigma'} +
\hat a_{p\sigma}^\dagger \left( \delta_{pp'} \delta_{\sigma\sigma'} - \hat a_{p\sigma} a_{p'\sigma'}^\dagger \right) \hat a_{p'\sigma'} \\
%
&= a_{p'\sigma'}^\dagger \hat a_{p\sigma} \delta_{pp'} \delta_{\sigma \sigma'} -
a_{p\sigma}^\dagger \hat a_{p'\sigma'} \delta_{pp'} \delta_{\sigma \sigma'} .
\end{align*}
%
This gives
\begin{align*}
\left[ \hat H_0 , \hat S_z \right]
%
&= \frac{\xi}{2} \sum_{p,\sigma} \sum_{p',\sigma'} (p-1) \sigma' \left(
a_{p'\sigma'}^\dagger \hat a_{p\sigma} \delta_{pp'} \delta_{\sigma \sigma'} -
a_{p\sigma}^\dagger \hat a_{p'\sigma'} \delta_{pp'} \delta_{\sigma \sigma'} \right) \\
%
&= \frac{\xi}{2} \sum_{p,\sigma} (p-1) \sigma \left(
a_{p\sigma}^\dagger \hat a_{p\sigma} -
a_{p\sigma}^\dagger \hat a_{p\sigma} \right) \\
%
&= 0 .
\end{align*}
%
Then we compute the commutator between
$\hat V$ and $\hat S_z$, using $\hat V$ from Eq.~\eqref{eq:V}:
\begin{align*}
\left[ \hat V , \hat S_z \right]
%
&= \left[ -\frac{1}{2} g \sum_{p,q} \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} , \frac{1}{2} \sum_{p,\sigma} \sigma \hat a_{p\sigma}^\dagger \hat a_{p\sigma} \right] \\
%
&= -\frac{1}{4} g \sum_{p,q} \sum_{p',\sigma} \sigma \left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+}, \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} \right] .
\end{align*}
%
Using the commutation relation between the creation and annihilation operators we obtain
\begin{align*}
\left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+}, \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} \right]
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \left( \delta_{pp'} \delta_{\sigma+} - \hat a_{p+}^\dagger \hat a_{p'\sigma} \right) \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \left( \delta_{pp'} \delta_{\sigma-} - \hat a_{p-}^\dagger \hat a_{p'\sigma} \right) \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma-} -
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma-} -
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \left( \delta_{qp'} \delta_{\sigma-} - \hat a_{q-} \hat a_{p'\sigma}^\dagger \right) \hat a_{q+} \hat a_{p'\sigma} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} -
\hat a_{p'\sigma}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma-} -
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q+} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma-} + \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'\sigma}^\dagger \hat a_{q+} \hat a_{p'\sigma} .
\end{align*}
%
Only one change is needed now
\begin{align*}
\left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+}, \hat a_{p'\sigma}^\dagger \hat a_{p'\sigma} \right]
%
&= - \hat a_{p'\sigma}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} -
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma-} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q+} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma-} +
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma+} \\
%
&= \hat a_{p-}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} -
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma-} - \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q+} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma-} +
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma+} .
\end{align*}
%
If we then insert this in $\hat V$ and $\hat S_z$ above we obtain
\begin{align*}
\left[ \hat H_0 , \hat S_z \right]
%
&= -\frac{1}{4} g \sum_{p,q} \sum_{p',\sigma} \sigma \left(
\hat a_{p-}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma+} -
\hat a_{p+}^\dagger \hat a_{p'\sigma}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \delta_{\sigma-} - \right. \\
&\quad\,\, \left.
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q+} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma-} +
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'\sigma} \delta_{qp'} \delta_{\sigma+} \right) \\
%
&= -\frac{1}{4} g \sum_{p,q} \left(
\hat a_{p-}^\dagger \hat a_{p+}^\dagger \hat a_{q-} \hat a_{q+} -
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} -
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q+} \hat a_{q-} +
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \right) \\
%
&= 0.
\end{align*}
%
Then we move to the commutator between
$\hat H_0$ and $\hat S^2$. Using Eqs.~\eqref{eq:H_0},~\eqref{eq:S_z},~\eqref{eq:S^2} and~\eqref{eq:S_pm}:
\[
\left[ \hat H_0, \hat S^2 \right]
%
= \left[ \hat H_0, \hat S_z^2 + \frac{1}{2} \left( \hat S_+ \hat S_- + \hat S_- \hat S_+ \right) \right]
%
= \frac{1}{2} \left(  \left[ \hat H_0, \hat S_+ \hat S_- \right] + \left[ \hat H_0, \hat S_- \hat S_+ \right] \right), \]
%
where we have used the fact that $\hat H_0$ commutes with $\hat S_z$ and thereby  $\hat S_z^2$. The other operators give rise to
\begin{align*}
\left[ \hat H_0, \hat S_+ \hat S_- \right]
%
&=  \left[ \xi \sum_{p,\sigma} (p-1) \hat a_{p\sigma}^\dagger \hat a_{p\sigma}, \left( \sum_p \hat a_{p+}^\dagger \hat a_{p-} \right) \left( \sum_p \hat a_{p-}^\dagger \hat a_{p+} \right) \right] \\
%
&= \xi \sum_{p,\sigma} \sum_{p',p''} (p-1)
\left[ \hat a_{p\sigma}^\dagger \hat a_{p\sigma},
\hat a_{p'+}^\dagger \hat a_{p'-} \hat a_{p''-}^\dagger \hat a_{p''+} \right] . \\
\end{align*}
%
We use again the commutation relation between creation and annihilation operators and find
\begin{align*}
\left[ \hat H_0, \hat S_+ \hat S_- \right]
%
&= - \xi \sum_{p,\sigma} \sum_{p',p''} (p-1)
\left[ \hat a_{p'+}^\dagger \hat a_{p'-} \hat a_{p''-}^\dagger \hat a_{p''+},
\hat a_{p\sigma}^\dagger \hat a_{p\sigma} \right] \\
%
&= - \xi \sum_{p,\sigma} \sum_{p',p''} (p-1) \left(
\hat a_{p'-}^\dagger \hat a_{p\sigma}^\dagger \hat a_{p''-} \hat a_{p''+} \delta_{pp'} \delta_{\sigma+} -
\hat a_{p'+}^\dagger \hat a_{p\sigma}^\dagger \hat a_{p''-} \hat a_{p''+} \delta_{pp'} \delta_{\sigma-} - \right. \\
&\quad\,\, \left.
\hat a_{p'+}^\dagger \hat a_{p'-}^\dagger \hat a_{p''+} \hat a_{p\sigma} \delta_{pp''} \delta_{\sigma-} +
\hat a_{p'+}^\dagger \hat a_{p'-}^\dagger \hat a_{p''-} \hat a_{p\sigma} \delta_{pp''} \delta_{\sigma+} \right) \\
%
&= - \xi \sum_{p',p''} (p-1) \left(
\hat a_{p'-}^\dagger \hat a_{p'+}^\dagger \hat a_{p''-} \hat a_{p''+} -
\hat a_{p'+}^\dagger \hat a_{p'-}^\dagger \hat a_{p''-} \hat a_{p''+} - \right. \\
&\quad\,\, \left.
\hat a_{p'+}^\dagger \hat a_{p'-}^\dagger \hat a_{p''+} \hat a_{p''-} +
\hat a_{p'+}^\dagger \hat a_{p'-}^\dagger \hat a_{p''-} \hat a_{p''+} \right) \\
%
&= 0 .
\end{align*}
%
We proceed then with the commutator between $\hat H_0$ and $\hat S_- \hat S_+$. Here we need
\[ \left[ \hat S_+ , \hat S_- \right] = 2 \hat S_z \quad \Rightarrow \quad
\hat S_- \hat S_+ = \hat S_+ S_- - 2 \hat S_z . \]
%
Using this relation and the fact that
$\hat S_+ \hat S_-$ commutes with $\hat H_0$, we can find the commutator between $\hat H_0$ and $\hat S^2$:
\begin{align*}
\left[ \hat H_0, \hat S^2 \right]
%
&= \frac{1}{2} \left( \left[ \hat H_0, \hat S_+ \hat S_- \right] + \left[ \hat H_0, \hat S_- \hat S_+ \right] \right) \\
%
&= \frac{1}{2} \left( \left[ \hat H_0, \hat S_+ S_- - \hat S_z \right] \right) \\
%
&= 0,
\end{align*}
where we have also used that $\hat H_0$ commutes with $\hat S_z$.

Finally, we need to find the corresponding commutator between
$\hat V$ and $\hat S^2$. Using Eq.~\eqref{eq:S^2}, and that $\hat S_z$ og $\hat S_z^2$ commute with  $\hat V$ and
\begin{align*}
\left[ \hat V, \hat S^2 \right]
%
&= \left[ \hat V, \hat S_z^2 + \frac{1}{2} \left( \hat S_+ \hat S_- + \hat S_- \hat S_+ \right) \right]
%
= \left[ \hat V, \hat S_z^2 + \hat S_+ \hat S_- - \hat S_z \right] \\
%
&= \left[ V, \hat S_+ \hat S_- \right]
%
= \left( \left[ V, \hat S_+ \right] \hat S_- + \hat S_+ \left[ \hat V, \hat S_- \right] \right),
\end{align*}
combined with  $\hat S_- = \hat S_+^\dagger$ and  $\hat V^\dagger = \hat V$,  we find
\[ \left[ \hat V, \hat S^2 \right] =
\left[ V, \hat S_+ \right] \hat S_- - \hat S_+ \left[ \hat V, \hat S_+ \right]^\dagger
= \left[ V, \hat S_+ \right] \hat S_- - \left( \left[ V, \hat S_+ \right] \hat S_- \right)^\dagger. \]
%
We need to find  $[V, \hat S_+]$. Inserting for $\hat V$ using Eq.~\eqref{eq:V} and for $\hat S_+$ from Eq.~\eqref{eq:S_pm} we can calculate
\[ \left[ \hat V, \hat S_+ \right] = \left[ -\frac{1}{2} g \sum_{p,q} \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+}, \sum_p \hat a_{p+}^\dagger \hat a_{p-} \right]
%
= -\frac{1}{2} g \sum_{p,p',q} \left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+}, \hat a_{p'+}^\dagger \hat a_{p'-} \right] . \]
Let us then look at the commutator between the creation and annihilation operators
\begin{align*}
\left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+}, \hat a_{p'+}^\dagger \hat a_{p'-} \right]
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'+}^\dagger \hat a_{p'-} - \hat a_{p'+}^\dagger \hat a_{p'-} \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'+}^\dagger \hat a_{p'-} - \hat a_{p+}^\dagger \hat a_{p'+}^\dagger \hat a_{p'-} \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'+}^\dagger \hat a_{p'-} - \hat a_{p+}^\dagger \hat a_{p'+}^\dagger \left( \delta_{pp'} - \hat a_{p-}^\dagger \hat a_{p'-} \right) \hat a_{q-} \hat a_{q+} \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'+}^\dagger \hat a_{p'-} - \hat a_{p+}^\dagger \hat a_{p'+}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} + \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p'+}^\dagger \hat a_{p-}^\dagger \hat a_{p'-} \hat a_{q-} \hat a_{q+}  \\
%
&= \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q+} \hat a_{p'+}^\dagger \hat a_{p'-} - \hat a_{p+}^\dagger \hat a_{p'+}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} + \\
&\quad\,\,
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'+}^\dagger \hat a_{q+} \hat a_{p'-}  \\
%
&= - \hat a_{p+}^\dagger \hat a_{p'+}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} +
\hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'-} \delta_{qp'} .
\end{align*}
%
Inserting back in  $[\hat V, \hat S_+]$:
\begin{align*}
\left[ \hat V, \hat S_+ \right]
%
&= -\frac{1}{2} g \sum_{p,p',q} \left( \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{p'-} \delta_{qp'}  - \hat a_{p+}^\dagger \hat a_{p'+}^\dagger \hat a_{q-} \hat a_{q+} \delta_{pp'} \right) \\
%
&= -\frac{1}{2} g \sum_{p,q} \left( \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q-} + \hat a_{p+}^\dagger \hat a_{p+}^\dagger \hat a_{q+} \hat a_{q-} \right).
\end{align*}
%
We insert then this expression in $[\hat V, \hat S^2]$ and employing Eq.~\eqref{eq:S_pm} again for for $S_\pm$ we arrive at
\begin{align*}
\left[ \hat V, \hat S^2 \right]
%
&= -\frac{g}{2} \sum_{p,p',q} \left( \left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q-} + \hat a_{p+}^\dagger \hat a_{p+}^\dagger \hat a_{q+} \hat a_{q-} \right] \hat a_{p'-}^\dagger \hat a_{p'+} - \right. \\
%
&\quad\,\, \left.
\hat a_{p'+}^\dagger \hat a_{p'-} \left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q-} + \hat a_{p+}^\dagger \hat a_{p+}^\dagger \hat a_{q+} \hat a_{q-} \right]^\dagger \right) \\
%
&= -\frac{g}{2} \sum_{p,p',q} \left( \left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q-} + \hat a_{p+}^\dagger \hat a_{p+}^\dagger \hat a_{q+} \hat a_{q-} \right] \hat a_{p'-}^\dagger \hat a_{p'+} - \right. \\
%
&\quad\,\, \left.
\hat a_{p'+}^\dagger \hat a_{p'-} \left[ \hat a_{q-}^\dagger \hat a_{q-}^\dagger \hat a_{p-} \hat a_{p+} + \hat a_{q-}^\dagger \hat a_{q+}^\dagger \hat a_{p+} \hat a_{p+}  \right] \right) .
\end{align*}
%
Further manipulations result in
\begin{align*}
\left[ \hat V, \hat S^2 \right]
%
&= -\frac{g}{2} \sum_{p,p',q} \left( \left[ \hat a_{p+}^\dagger \hat a_{p-}^\dagger \hat a_{q-} \hat a_{q-} + \hat a_{p+}^\dagger \hat a_{p+}^\dagger \hat a_{q+} \hat a_{q-} \right] \hat a_{p'-}^\dagger \hat a_{p'+} - \right. \\
%
&\quad\,\, \left.
\hat a_{p'+}^\dagger \hat a_{p'-} \left[ \hat a_{q-}^\dagger \hat a_{q-}^\dagger \hat a_{p-} \hat a_{p+} + \hat a_{q-}^\dagger \hat a_{q+}^\dagger \hat a_{p+} \hat a_{p+}  \right] \right) .
\end{align*}
A commutator between two operators is also an operator. When such an operator acts on a state we see that
\[ \left[ \hat V, \hat S^2 \right] = 0. \]
%
It is straightforward to see from Eq.~\eqref{eq:P} that the interaction of Eq.~\eqref{eq:V} can be written as
\[ \hat V = -\frac{1}{2} g \sum_{p,q} \hat P_p^+ \hat P_q^- , \]
and since $\hat H = \hat H_0 + \hat V$, where $\hat H_0$ is given by Eq.~\eqref{eq:H_0}, we have
\begin{equation}
\hat H = \sum_{p,\sigma} (p-1) \hat a_{p\sigma}^\dagger \hat a_{p\sigma} -\frac{1}{2} g \sum_{p,q} \hat P_p^+ \hat P_q^-,
\label{eq:H}
\end{equation}
%
with $\xi = 1$.

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

\section{The Hamiltonian matrix}
The aim here is to compute the Hamiltonian matrix for a system with no broken pairs. This means that every level $p$ contains
two particles, one with spin up and one with spin down. We employ the basis
\[ \ket{\Phi_0} = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{pmatrix}, \quad
\ket{\Phi_1} = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \end{pmatrix}, \quad \cdots \quad
\ket{\Phi_5} = \begin{pmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 1 \end{pmatrix}, \]
%
where
\begin{align*}
\ket{\Phi_0} &= \hat a_{2+}^\dagger \hat a_{2-}^\dagger \hat a_{1+}^\dagger \hat a_{1-}^\dagger \ket{0} = \hat P_2^+ \hat P_1^+ \ket{0}, \\
%
\ket{\Phi_1} &= \hat P_3^+ \hat P_1^+ \ket{0}, \\
%
\ket{\Phi_2} &= \hat P_4^+ \hat P_1^+ \ket{0}, \\
%
\ket{\Phi_3} &= \hat P_3^+ \hat P_2^+ \ket{0}, \\
%
\ket{\Phi_4} &= \hat P_4^+ \hat P_2^+ \ket{0}, \\
%
\ket{\Phi_5} &= \hat P_4^+ \hat P_3^+ \ket{0}. \\
\end{align*}
%
We are now going to compute $\bra{\Phi_i} \hat H \ket{\Phi_j}$ using the Hamiltonian of Eq.~\eqref{eq:H}.
The one-body operator acts only on the diagonal and results in terms proportional with $(p-1)$. The interaction
will excite or deexcite a pair of particles from level $q$ to level $p$. Using this it is easy to see that the Hamilotnian matrix becomes
\[ \hat H = \begin{pmatrix}
2 - g & -g/2 & -g/2 & -g/2 & -g/2 & 0 \\
-g/2 & 4- g & -g/2 & -g/2 & 0 & -g/2 \\
-g/2 & -g/2 & 6 -g & 0 & -g/2 & -g/2 \\
-g/2 & -g/2 & 0 & 6 -g & -g/2 & -g/2 \\
-g/2 & 0 & -g/2 & -g/2 & 8 - g & -g/2 \\
0 & -g/2 & -g/2 & -g/2 & -g/2 & 10 - g \\
\end{pmatrix} . \]
%
This matrix can easily be diagonalized using for example Octave or Matlab or python.

\end{document}