% $Id: notes.tex,v 1.32 2019/10/24 06:25:41 brandenb Exp $
%\documentclass{article}
\documentclass[twocolumn]{article}
\setlength{\textwidth}{160mm}
\setlength{\oddsidemargin}{-0mm}
\setlength{\textheight}{240mm}
\setlength{\topmargin}{-25mm}
%\usepackage{graphicx,natbib,bm,url,color,slashed,amsmath,mathtools}
\usepackage{graphicx,natbib,bm,url,color,mathtools}
\newcommand{\fsl}[1]{\ensuremath{\mathrlap{\!\not{\phantom{#1}}}#1}}
\graphicspath{{./fig/}{./png/}}
\thispagestyle{empty}
\input apj
\input gafd_journ
\def\red{\textcolor{red}}
\def\blue{\textcolor{blue}}
\title{}
\author{}
\date{\today,~ $ $Revision: 1.32 $ $}
\begin{document}
%\maketitle

\noindent\large
{\bf Axel's analysis of Etienne's data}
\normalsize

\vspace{-1mm}
\noindent
{\tiny\url{http://norlx51.nordita.org/~brandenb/issi/etienne/}}

\noindent
{\small\today,~ $ $Revision: 1.32 $ $}
\vspace{3mm}

\begin{figure}[b!]\begin{center}
\includegraphics[width=\columnwidth]{pspec_fe_eruption_t140_unigrid1}
\includegraphics[width=\columnwidth]{pspec_fe_eruption_t280_unigrid}
\includegraphics[width=\columnwidth]{pspec_fe_eruption_t320_unigrid}
\end{center}\caption[]{
$xy$ slice and spectra for the erupting case.
}\label{eruption}\end{figure}

\noindent
We analyze the magnetic energy and helicity spectra for the simulations of
Etienne of erupting and nonerupting regions, as described by \cite{LLA14}.
The spectra are normalized such that
\begin{equation}
\half\bra{\BB^2}\equiv\EEM=\int\EM(k)\,\dd k,
\end{equation}
\begin{equation}
\bra{A_zB_z}\equiv\HHM=\int\HM(k)\,\dd k,
\end{equation}
and $\nabla^2A_z=-J_z$ in the Coulomb gauge.
We determine these spectra on the lower boundary of the simulation domain
at the three times provided ($t=140$, 280, and 320).
We see that the magnetic helicity has positive values at all wavenumbers
below $kL_0=1$.
At later times, the peak of the fractional magnetic helicity moves
to progressively smaller wavenumbers, down to about 0.3--0.4, and the
fractional magnetic helicity decreases.
It is useful to define
\EQ
r(k)=k\HM(k)/2\EM(k),
\EN
which is in the range $-1\leq r(k)\leq1$.
This quantity characterizes the fractional magnetic helicity at each
wavenumber.
At early times, the scale where $r(k)$ is maximum is at
somewhat smaller scales, reflecting perhaps the gradual separation
of the initial bipoles of the emerging structure.

\begin{figure}[b!]\begin{center}
\includegraphics[width=\columnwidth]{pspec_fe_noeruption_t140_unigrid}
\includegraphics[width=\columnwidth]{pspec_fe_noeruption_t280_unigrid}
\includegraphics[width=\columnwidth]{pspec_fe_noeruption_t320_unigrid}
\end{center}\caption[]{
$xy$ slice and spectra for nonerupting case.
}\label{noeruption}\end{figure}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_frac}
\end{center}\caption[]{
Fractional magnetic helicity spectra.
}\label{pspec_frac}\end{figure*}

In is interesting to note that the two-dimensional magnetic energy spectra
shown here do not possess a sub-inertial range, i.e., the spectrum for
small $k$ is approximately flat and not rising.
This is a general feature of two-dimensional spectra that has also been
seen in other spectra (to provide details, e.g., classes paper).

\begin{table}[htb]\caption{
}\vspace{12pt}\centerline{\begin{tabular}{lccccccc}
case & $\EEM$ & $\HHM$ & $\HHC$ & $L_{\rm M}$ & $r_{\rm M}$ \\
\hline
E-140 &  4.47 &  22.1 &  0.68 &  9.99 &  0.25 \\
E-280 &  2.91 &  13.6 &  0.35 &  9.30 &  0.25 \\
E-320 &  2.53 &  10.8 &  0.27 &  8.91 &  0.24 \\
\hline
N-140 &  4.42 &  37.0 &  0.72 &  9.54 &  0.44 \\
N-280 &  3.51 &  36.0 &  0.44 &  9.70 &  0.53 \\
N-320 &  3.23 &  33.6 &  0.37 &  9.48 &  0.55 \\
\label{Tsummary}\end{tabular}}\end{table}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pcomp}
\end{center}\caption[]{
Time dependence.
}\label{pcomp}\end{figure*}

In both cases with and without eruption,
the magnetic energy density, the magnetic helicity
density, the current helicity density, and the integral scale are
monotonically decrease with time.
However, the {\em fractional helicity evolves differently in the erupting
and non-erupting cases}: it increases in the non-erupting case (from
0.44 to 0.55), but it decreases by a small amount (from 0.25 to 0.24)
in the erupting case.

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_comp}
\end{center}\caption[]{
The different spectra for the full volume at the 10 times.
}\label{pspec_comp}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_comp_stab}
\end{center}\caption[]{
Same as \Fig{pspec_comp}, but for the stable case.
}\label{pspec_comp_stab}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_comp_time}
\end{center}\caption[]{
Time dependence of the different spectral helicities
for the full volume.
}\label{pspec_comp_time}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_comp_time_stab}
\end{center}\caption[]{
Same as \Fig{pspec_comp_time}, but for the stable case.
}\label{pspec_comp_time_stab}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_slice_k1}
\end{center}\caption[]{
Horizontal spectral helicities for $k=1$ versus $z$.
}\label{pspec_slice_k1}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_slice_k1_stab}
\end{center}\caption[]{
Same as \Fig{pspec_slice_k1}, but for the stable case.
}\label{pspec_slice_k1_stab}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_slice_k2}
\end{center}\caption[]{
Same as \Fig{pspec_slice_k1}, but for $k=2$.
}\label{pspec_slice_k2}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pspec_slice_k2_stab}
\end{center}\caption[]{
Same as \Fig{pspec_slice_k2}, but for the stable case.
}\label{pspec_slice_k2_stab}\end{figure*}

\begin{table}[t!]\caption{
Mean magnetic helicities for the different snapshots
($k$ integrals over the full volume spectra).
}\vspace{12pt}\centerline{\begin{tabular}{rrrrrr}
snap & $H_{\rm rel}\;$ & $H_{\rm J}\;\;$
& $H\;\;$ & $H_{\rm JP}\;\;$ \\
\hline
  50 & 0.00004 & 0.00005 &$ 0.00000$ &$-0.00001$ \\
  70 & 0.00011 & 0.00013 &$-0.00002$ &$-0.00002$ \\
  90 & 0.00020 & 0.00024 &$-0.00001$ &$-0.00004$ \\
 110 & 0.00030 & 0.00028 &$-0.00003$ &$ 0.00001$ \\
 120 & 0.00033 & 0.00027 &$-0.00005$ &$ 0.00006$ \\
 130 & 0.00037 & 0.00022 &$-0.00005$ &$ 0.00014$ \\
 140 & 0.00040 & 0.00014 &$-0.00000$ &$ 0.00026$ \\
 150 & 0.00042 & 0.00011 &$ 0.00014$ &$ 0.00031$ \\
 160 & 0.00045 & 0.00014 &$ 0.00015$ &$ 0.00031$ \\
 180 & 0.00049 & 0.00015 &$ 0.00013$ &$ 0.00034$ \\
\label{Tsummary2}\end{tabular}}\end{table}

\begin{table}[t!]\caption{
Same as \Tab{Tsummary2}, but for the stable case.
}\vspace{12pt}\centerline{\begin{tabular}{rrrrrr}
snap & $H_{\rm rel}\;$ & $H_{\rm J}\;\;$
& $H\;\;$ & $H_{\rm JP}\;\;$ \\
\hline
  50 & 0.00036 &$ 0.00002$ & 0.00020 & 0.00034 \\
  70 & 0.00093 &$-0.00002$ & 0.00039 & 0.00095 \\
  90 & 0.00141 &$ 0.00005$ & 0.00058 & 0.00135 \\
 110 & 0.00182 &$ 0.00021$ & 0.00078 & 0.00161 \\
 120 & 0.00200 &$ 0.00030$ & 0.00087 & 0.00171 \\
 130 & 0.00217 &$ 0.00038$ & 0.00095 & 0.00179 \\
 140 & 0.00232 &$ 0.00046$ & 0.00103 & 0.00186 \\
 150 & 0.00245 &$ 0.00055$ & 0.00110 & 0.00191 \\
 160 & 0.00258 &$ 0.00062$ & 0.00117 & 0.00195 \\
 180 & 0.00279 &$ 0.00077$ & 0.00128 & 0.00202 \\
\label{Tsummary2_stab}\end{tabular}}\end{table}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pbdry}
\end{center}\caption[]{
(a) mean magnetic helicity flux on the lower boundary ($z=z_1$) versus time;
(b) spectral magnetic helicity flux versus $k$ for early times;
(c) spectral magnetic helicity flux versus $k$ for intermediate times;
(d) spectral magnetic helicity flux versus $k$ for late times.
In each of panels (b)--(d), the last time is shown as a fat line.
}\label{pbdry}\end{figure*}

\begin{figure*}[t!]\begin{center}
\includegraphics[width=\textwidth]{pbdry_stab}
\end{center}\caption[]{
Same as \Fig{pbdry}, but for the stable case.
}\label{pbdry_stab}\end{figure*}

The initial values of magnetic energy are about similar in the two
cases, but it drops faster in the erupting case.
The magnetic helicity is, even at early times, weaker in the erupting
case.
This combination implies that the fractional magnetic helicity is about
constant in the erupting case, but increasing in the non-erupting case.
The correlation length, on the other hand, is nearly constant in the
non-erupting case, but decreases by about 10\% in the erupting case.

%Todo:
%investigate different heights;
%look for sign reversals with height;
%think about the best way to decompose into different scales;
%and how to deal with non-periodic cases.
%Also do cross helicity.

\section*{Decomposition into potential and current carrying parts}

We now consider the decomposition of the magnetic field into potential and
current carrying parts, i.e., we write
\begin{equation}
\BB=\BB_{\rm P}+\BB_{\rm J},
\end{equation}
and compute the associated magnetic vector potential $\AAA$ in the DeVore
gauge, i.e., $A_z=0$, with
\begin{equation}
\AAA=\AAA_{\rm P}+\AAA_{\rm J}.
\end{equation}
Note that, for computing the magnetic helicity,
$\AAA\cdot\BB=A_xB_x+A_yB_y$, so the $B_z$ component of
the field does not enter and all the information is in
$B_x$ and $B_y$ alone.
The relevant {\tt IDL} routines are publicly
available\footnote{\url{https://www.nordita.org/~brandenb/projects/issi19/etienne/}}.
We compute the magnetic helicity spectrum from the Fourier
transforms\footnote{The Fourier transforms for 311 points is slower
than for 310 points, so I skipped the last point. This typically makes
an 0.7\% difference.  OK, I can use 311 next time.}
of vector potential and magnetic field, denoted by hat: $\hatAA(\kk)$
and $\hatBB(\kk)$,
\begin{equation}
H(k)=\half\int_{4\pi}\hatAA\cdot\hatBB^\ast \, k^2\,\dd\Omega+\mbox{c.c.}
\end{equation}
where the factor 1/2 accounts for the two contributions
resulting from having added the complex conjugate (c.c.).
Note that $\int H(k)\,\dd k=\bra{\AAA\cdot\BB}$ is the mean
magnetic helicity density computed in real space.

We consider different combinations of potential and current carrying parts,
in particular
\begin{equation}
H_{\rm P}(k)=\half\int_{4\pi}\hatAA_{\rm P}\cdot\hatBB_{\rm P}^\ast
\, k^2\,\dd\Omega+\mbox{c.c.}
\end{equation}
and
\begin{equation}
H_{\rm J}(k)=\half\int_{4\pi}\hatAA_{\rm J}\cdot\hatBB_{\rm J}^\ast
\, k^2\,\dd\Omega+\mbox{c.c.},
\end{equation}
respectively, and also the relative mean magnetic helicity density,
\begin{equation}
H_{\rm rel}(k)=\half\int_{4\pi}\left(\hatAA+\hatAA_{\rm P}\right)\cdot
\left(\hatBB-\hatBB_{\rm P}\right)^\ast \,k^2\,\dd\Omega+\mbox{c.c.}.
\end{equation}

\FFig{pspec_comp} shows that the relative spectral magnetic helicity,
$H_{\rm rel}(k)$, is governed by the contributions from small values of $k$
($1$ to $4$).
At $k>2$, it is always positive, but at early times, it is negative at
$k=1$ and $2$.

Comparing with the stable case (\Fig{pspec_comp_stab}), we see that
now the spectral magnetic helicity is always positive, even at low $k$.
It is also about 6 times bigger than in the unstable case.
This suggests that the negative sign in the unstable case could be
caused by the actual eruption.

The time evolution is shown in \Fig{pspec_comp_time}, which shows the
sign change at snapshot 110 for $k=1$ and at snapshot 80 for $k=2$.
In the non-erupting case (\Fig{pspec_comp_time_stab}), the spectral
magnetic helicity is, again, always positive.
This is quite striking even at early times, where we see a mild
decline from strong positive values in the beginning.
At $k=4$ and $8$, the spectral magnetic helicity is similar to
that in the erupting case, but it is now about 3 times smaller.

The evolution of $H_{\rm J}(k)$ is rather different: it is mostly
positive and growing for $k=2$ and $4$, but decaying for $k=8$.
$H_{\rm P}(k)$ is in all cases basically vanishing.
The behaviors of $H_{\rm JP}(k)$ and $H(k)$ are broadly similar
to those of $H_{\rm rel}(k)$, which are rather different from those
of $H_{\rm J}(k)$.

\section*{Height dependence of spectral helicities}

Next, we compute the various spectral mean relative magnetic helicities
in two-dimensional horizontal slices.
The vertical {\em average} over the $k$ integrals of these spectra
agrees with $k$ integrals of the volume spectra.
Those values are listed in \Tab{Tsummary2}.
In \Fig{pspec_slice_k1} we show the $z$ dependence at the 10 times
for $k=1$ and in \Fig{pspec_slice_k2} for $k=2$.

Interestingly, we find a height reversal of the spectral magnetic
helicity at $z\approx4$ for $k=1$.
This sign reversal is not seen in $H_{\rm J}(k)$, which stays
mostly positive.

In the stable case, no sign reversal is seen; see \Fig{pspec_slice_k1_stab}.
However, both for $k=1$ and for $k=2$ (\Fig{pspec_slice_k2_stab}), there
is a local positive maximum at $z=5$, which is similar to the erupting case.
The main difference between stable and unstable cases is that the spectral
magnetic helicity is negative at the bottom in the unstable case, but not
in the stable case.
This is true also at later times.
The values of the various helicities for the stable case are listed in
\Tab{Tsummary2_stab}.

\section*{Spectral magnetic helicity flux}

We compute the spectral magnetic helicity flux on the lower boundary as
\EQ
F(k)=\int(\tildeEE\times\tildeAA_{\rm P}^\ast)_z\,k^2\dd\Omega+\mbox{c.c.},
\EN
where $\tildeEE$ and $\tildeAA_{\rm P}$ are the Fourier transforms of the
electric field $\EE=-\uu\times\BB$ and the vector potential of the reference field on the boundary,
$\AAA_{\rm P}=\nab_\perp\times(\psi\zzz)$, respectively.
Here $\nab_\perp^2\psi=-B_z$ on the lower boundary $z=z_1$.
Thus, in Fourier space, we compute $\tilde{A}_{{\rm P}\,x}=\ii k_y\tilde{B}_z/k^2$ and
$\tilde{A}_{{\rm P}\,y}=-\ii k_x\tilde{B}_z/k^2$.

The integral over $F(k)$ gives $\int F(k)\,\dd k=2\bra{\EE\times\AAA_{\rm P}}_z$.
To get the flux across the boundary, we would still need to multiply by the surface area.

%\begin{verbatim}
%To check: aspect ratio
%\end{verbatim}

%r e f
\begin{thebibliography}{}

\bibitem[Leake et al.(2014)]{LLA14}
Leake, J. E., Linton, M. G., \& Antiochos, S. K.\yapjN{2014}{787}{46}
{Simulations of emerging magnetic flux. II. The formation of unstable coronal flux ropes and the initiation of coronal mass ejections}

\end{thebibliography}

%\appendix
%\section{Link to the rele}
%\label{Bz_never_enters}.



\vfill\bigskip\noindent\tiny\begin{verbatim}
$Header: /var/cvs/brandenb/tex/mhd/issi/etienne/notes.tex,v 1.32 2019/10/24 06:25:41 brandenb Exp $
\end{verbatim}

\end{document}
