%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%   BornAgain Physics Manual
%%
%%   homepage:   http://www.bornagainproject.org
%%
%%   copyright:  Forschungszentrum Jülich GmbH 2015
%%
%%   license:    Creative Commons CC-BY-SA
%%
%%   authors:    Scientific Computing Group at MLZ Garching
%%               C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{Polarized GISAS}  \label{SPol}

In this chapter,
we generalize our treatment of wave propagation and
grazing-incidence small-angle scattering
to polarized neutrons.
\index{Neutron!polarized}
\index{Polarization!neutron}
We therefore need to study spinor wave equations,
in contrast to the scalar theory of the previous chapter.

\MissingSection
\iffalse
%===============================================================================
\section{Polarized neutrons}\label{Snpol}
%===============================================================================


\Work{This is preliminary and incomplete material waiting for revision and extension}


%===============================================================================
\subsection{Wave equation and propagation within one layer}
%===============================================================================

%\cite{Deak_ppt, PhysRevB.76.224420, Deak2001113, PhysRevB.53.6158}.
%\cite{RevModPhys.23.287}

To allow for polarization-dependent interactions,
we replace the squared index of refraction $n^2$
by $1+\uu\chi$, where $\uu\chi$ is a $2\times 2$ susceptibility matrix.
The wave equation \cref{EHomoK} for layer~$l$ becomes
\begin{equation}\label{Ewaveqp}
(\Delta +K^2 +K^2 \uu\chi_l) \u\psi(\r)= 0,
\end{equation}
where $\u\psi(\r)$ is a two-component spinor wavefunction,
with components $\psi_\UP(\r)$ and~$\psi_\DN(\r)$.
At interfaces between layers,
both spinor components of $\u\psi(\r)$ and $\Nabla\u\psi(\r)$
must evolve continuously.

The reasons for the factorization \cref{Ekpar} still apply,
and so we can write
\begin{equation}\label{Ewave3p}
\u\psi(\r) = \u\psi(z) \e^{i \k_\parallel\r_\parallel}.
\end{equation}
As before, $\k_\parallel$ is constant across layers.
The wave equation~\cref{Ewaveqp} reduces to
\begin{equation}\label{Ewavezp}
\left(\partial_z^2 + K^2 + K^2\uu\chi_l - k_\parallel^2 \right) \u\psi(z) = 0.
\end{equation}
We abbreviate
\begin{equation}
  \uu H_l \coloneqq  K^2(1+\uu\chi_l)-k_\parallel^2
\end{equation}
so that the wave equation becomes simply
\begin{equation}\label{Ewaveqp2}
  \left(\partial_z^2 + \uu H_l\right) \u\psi(z) = 0.
\end{equation}
The solution is
\begin{equation}\label{Epsizp}
  \u\psi_l(z)
  = \sum_{k=1}^2 \u x_{l k}\left(\alpha_{l k}\e^{i p_{l k}(z-z_k)}
                            + \beta_{l k}\e^{-i p_{l k}(z-z_k)}\right),
\end{equation}
where the $\u x_{l k}$ are eigenvectors of $\uu H_l$
with eigenvalues $p_{l k}^2$:
\begin{equation}
  \left( -p_{l k}^2 + \uu H_l \right) \u x_{l k} = 0
   \;\text{ for }\;l=1,2.
\end{equation}
In a reproducible algorithm,
the eigenvectors $\u x_{l k}$ must be chosen according to some arbitrary
normalization rule,
for instance
\begin{equation}
  |\u x_{l k}|=1,\quad x_{il\UP} \text{ real and nonnegative}.
\end{equation}
Similarly,
a rule is needed how to handle the case of one degenerate eigenvalue,
which includes in particular the case of scalar interactions.


%-------------------------------------------------------------------------------
\subsection{Wave propagation across layers}
%-------------------------------------------------------------------------------

Generalizing \Cref{Sacrolay},
we introduce the coefficient vector
\begin{equation}
  c_l \coloneqq  {(\alpha_{l1}, \alpha_{l2}, \beta_{l1}, \beta_{l2})}^\text{T}.
\end{equation}
To match solutions for neighboring layers,
continuity is requested for both spinorial components
of $\u\psi$ and $\Nabla\u\psi$.
We have at the bottom of layer~$l$
\begin{equation}\label{EFcFDcp}
  F_l c_l = F_{l+1} D_{l+1} c_{l+1},
\end{equation}
where the matrices are
\begin{equation}
  F_l \coloneqq  \left(\begin{array}{cccc}
    x_{i1\UP}      &x_{i2\UP}     &x_{i1\UP}       &x_{i2\UP}       \\
    x_{i1\DN}      &x_{i2\DN}     &x_{i1\DN}       &x_{i2\DN}       \\
    x_{i1\UP}p_{l1}&x_{i2\UP}p_{l2}&-x_{i1\UP}p_{l1}&-x_{i2\UP}p_{l2}\\
    x_{i1\DN}p_{l1}&x_{i2\DN}p_{l2}&-x_{i1\DN}p_{l1}&-x_{i2\DN}p_{l2}
  \end{array}\right)
\end{equation}
and
\begin{equation}
  D_l \coloneqq  \text{diag}(\delta_{l1}, \delta_{l2}, \delta_{l1}^*, \delta_{l2}^*)
\end{equation}
with the phase factor
\begin{equation}
   \delta_{l k} \coloneqq  \e^{ip_{l k}d_k}.
\end{equation}
Note that matrix $F_l$ has the block form
\begin{equation}
  F_l
  =\left(\begin{array}{ll}\uu x_l&\hphantom{-}\uu x_l\\[1ex]
    \uu x_l\; \uu P_l&-\uu x_l\; \uu P_l\end{array}\right)
    = \uu x_l \cdot
    \left(\begin{array}{cc}\uu 1&\uu 1\\[1ex]
    \uu P_l&-\uu P_l\end{array}\right),
\end{equation}
with
\begin{equation}
  \uu x_l \coloneqq
  \left(\u x_{l1}, \u x_{l2}\right),
  \quad
  \uu P_l \coloneqq
  \text{diag}\left(p_{l1},p_{l2}\right).
\end{equation}
This facilitates the computation of the inverse
\begin{equation}
  F_l^{-1}
    = \frac{1}{2}
    \left(\begin{array}{cc}\uu 1&\hphantom{-}\uu P_l^{-1}\\[1.2ex]
      \uu 1 &-\uu P_l^{-1}\end{array}\right)
      \cdot\uu x_l^{-1},
\end{equation}
which is needed for the transfer matrix $M_l$,
defined as in \cref{EMil}.
With the new meaning of $c_l$ and $M_l$,
the recursion \cref{EcMc} and the explicit solution~\cref{EAtildel}
hold as derived above.
To resolve~\cref{Eci} for the reflected amplitudes $\alpha_{0l}$
as function of the incident amplitudes $\beta_{0l}$,
we choose the notations
\begin{equation}
  \u\alpha_l
  \coloneqq \left(\begin{array}{c}\alpha_{l1}\\\alpha_{l2}\end{array}\right),\quad
  \u\beta_l
  \coloneqq \left(\begin{array}{c}\beta_{l1}\\\beta_{l2}\end{array}\right),\quad
  M\coloneqq M_1 ... M_N % TODO restore \cdots
  \eqqcolon \left(\begin{array}{cc}\uu m_{11}&\uu m_{12}\\
                           \uu m_{21}&\uu m_{22}\end{array}\right),
\end{equation}
where the $\uu m_{l k}$ are $2\times2$ matrices.
Eq.~\cref{Eci} then takes the form
\begin{equation}
  \left(\begin{array}{c}\u\alpha_{0}\\\u\beta_{0}\end{array}\right)
  =
  \left(\begin{array}{cc}\uu m_{11}&\uu m_{12}\\
    \uu m_{21}&\uu m_{22}\end{array}\right)
  \left(\begin{array}{c}\u{0}\\\u\beta_{N}\end{array}\right),
\end{equation}
which immediately yields
\begin{equation}
  \u\alpha_0 = \uu m_{12}\,\uu m_{22}^{-1}\,\u\beta_0.
\end{equation}
\fi
