% $Id: newsletter.tex,v 1.42 2023/08/22 04:16:35 brandenb Exp $
%\documentclass{article}
\documentclass[twocolumn]{article}
\setlength{\textwidth}{170mm}
\setlength{\oddsidemargin}{-7mm}
\setlength{\textheight}{220mm}
\setlength{\topmargin}{-8mm}
\newcommand{\yapjN}[4]{, ``#4,'' {\em Astrophys.\ J.\ }{\bf #2}, #3 (#1).}

%\bibliographystyle{apalike}
\bibliographystyle{gGAF} %is checked in (say "make ln")
%\usepackage{bm,natbib,html,wrapfig,graphicx,multicol,color} %,etoollbox}  %setspace,tocloft}
\usepackage{bm,natbib,wrapfig,graphicx,multicol,color} %,etoollbox}  %setspace,tocloft}
\usepackage{hyperref}
\usepackage[anythingbreaks]{breakurl} %AB: is needed
\usepackage{listings}

\graphicspath{{./fig/}{./png/}}
\thispagestyle{empty}
\input ../../jour_def
\newcommand{\Fig}[1]{Figure~\ref{#1}}
\def\red{\textcolor{red}}
\def\blue{\textcolor{blue}}
\newcommand{\yjourN}[5]{:~#1, ``#5,'' {\em #2} {\bf #3}, #4}
\newcommand{\bra}[1]{\langle #1\rangle}
\newcommand{\Eq}[1]{Eq.~(\ref{#1})}
\newcommand{\AAA}{\bm{A}}
\newcommand{\BB}{\bm{B}}
\newcommand{\kk}{\bm{k}}
\newcommand{\xx}{\bm{x}}
\newcommand{\ii}{{\rm i}}
\newcommand{\dd}{{\rm d} {}}
\newcommand{\nab}{{\bm{\nabla}}}
\def\HM{H_{\rm M}}
\def\EM{E_{\rm M}}
\def\EEM{{\cal E}_{\rm M}}
\def\Pm{\mbox{\rm Pr}_{\rm M}}
\def\Rm{\mbox{\rm Re}_{\rm M}}
\def\Rey{\mbox{\rm Re}}
\def\urms{u_{\rm rms}}
\def\kf{k_{\rm f}}

\title{The {\sc Pencil Code} Newsletter}
\author{Issue 2023/2}
\date{August 21, 2023,~ $ $Revision: 1.42 $ $}
\begin{document}
\maketitle

\renewcommand{\baselinestretch}{-.4}\normalsize
\tableofcontents
\renewcommand{\baselinestretch}{1}\normalsize

\section{Last April Fool's Day}

As in 2021, the publication of the first newsletter of this year fell
on April Fool's Day.
The item about Artificial Intelligence facilitating the maintenance of
the code was unfortunately a joke.

\begin{figure}[h]\begin{center}
\includegraphics[width=\columnwidth]{plambda_NatAst}
\end{center}\caption[]{
Small-scale dynamo growth rate as function of the fluid and
magnetic Reynolds numbers ($\Rey$ and $\Rm$). The diamonds represent the results
of this work and the triangles those of Brandenburg et al.\ (2018, MNRAS 479, 2827).
The color coding indicates the value of the normalized growth rate
$\lambda\tau$ with $\tau=1/u_{\rm rms} k_{\rm f}$, a rough estimate for the
turnover time. Dotted lines indicate constant magnetic Prandtl number
$\Pm$. White circles indicate zero growth rate for certain $\Pm$,
obtained from fitting the critical magnetic Reynolds number.
The green dashed line shows the power-law fit of the critical $\Rm$ for
$\Pm\le0.08$
}\label{plambda_NatAst}\end{figure}

\begin{figure*}[h]\begin{center}
\includegraphics[width=.80\textwidth]{cover_NatAst}
\end{center}\caption[]{
Visualization of the magnetic field in a logarithmic scale for
simulation with 4096$^3$ mesh points, $\Rey$=33.000 and $\Pm$=0.005.
}\label{cover_NatAst}\end{figure*}

\section{New Nature Astronomy paper}

In a recent paper in Nature Astronomy (\url{https://www.nature.com/articles/s41550-023-01975-1}),
J\"orn Warnecke, Maarit J. Korpi-Lagg, Matthias Rheinhardt, and Fred Gent
reported on {\sc Pencil Code} runs with a resolution of $4096^3$ mesh points.
This allowed the authors to reach Reynolds numbers, $\Rey=\urms/\nu\kf$,
of up to 33,000 and magnetic Prandtl numbers ($\Pm$) down to 0.0025.
This high resolution is indeed needed to answer the question,
whether a small-scale dynamo (SSD) is possible at the extremely low $\Pm$
that are present in the Sun and other stars.
The authors found that the SSD not only turns
out to be possible for $\Pm$ down to 0.0031, but it also becomes increasingly
easier to excite for $\Pm$ below about 0.05, see \Fig{plambda_NatAst}.
This behavior is related to the known hydrodynamic phenomenon called the bottleneck
effect. Extrapolating the results to solar values of $\Pm\approx10^{-5}$, the authors
find that an SSD would be possible under such conditions.

The study of the Nature Astronomy paper is currently being
extended to even higher resolutions using the GPU code
Astaroth, achieving speed-ups of 20--60 compared to the {\sc Pencil code}.
This solver enables them to determine not only the critical magnetic Reynolds
number, but also the saturation field strengths at low $\Pm$;
see \Fig{cover_NatAst} for an illustration of the magnetic field.

The paper was highlighted by Steven Tobias in a Nature Astronomy news
\& view item \url{https://www.nature.com/articles/s41550-023-01971-5}
and even in the New York Times
\url{https://www.nytimes.com/interactive/2023/06/20/science/summer-solstice-sun.html}.

\section{Realizability}

Inverse cascading is known to occur in helical hydromagnetic turbulence because of
magnetic helicity conservation and in non-helical turbulence because of
the conservation of the Hosking integral.   
(For readers of the previous newsletter, this name should not be
entirely new!)
Magnetic helicity can also be canceled by fermion chirality such
that there is also {\em no net} chirality, and again, the suitably adapted Hosking
integral is conserved and there is inverse cascading \citep{2023PhRvR...5b2028B}.
But \Fig{rspec_select_1024a_mu10_k002o}, which is taken from
a recent preprint of such work \citep{2023arXiv230406612B},
showed that the realizability condition is violated, and
$k\HM(k)$ was found to exceed $2\EM(k)$.
This is mathematically impossible.
Here we demonstrate that it is the result of the finite discretization
error in the current implementation of the {\sc Pencil Code}.

\begin{figure}[t]\begin{center}
\includegraphics[width=\columnwidth]{rspec_select_1024a_mu10_k002o}
\end{center}\caption[]{
Magnetic energy (solid lines) and normalized helicity spectra
$k\HM(k)/2$ (dotted lines with red and blue symbols for positive
and negative helicity spectra, respectively) for Run~O at
times $t=0.3$, $460$, 1500, 4600, 15,000, and 46,000.
The peaks of the red curves evolve underneath an envelope
$\propto k^{3/2}$, which is characteristic of Hosking.
Taken from arXiv:2304.06612v1; the figure in the revised version
will be different.
}\label{rspec_select_1024a_mu10_k002o}\end{figure}

The magnetic helicity and energy spectra, $\HM(k)$ and $\EM(k)$,
respectively, satisfy the realizability condition:
\begin{equation}
-1\leq\frac{k\HM(k)}{2\EM(k)}\leq1.
\label{realizability}
\end{equation}
The spectra $\HM(k)$ and $\EM(k)$ are normalized such that
$\int\HM(k)\,\dd k=\bra{\AAA\cdot\BB}$ and $\int\EM(k)\,\dd k=\bra{\BB^2}/2$.
The spectra are obtained from the magnetic vector potential $\AAA(\xx,t)$
by computing $\BB=\nab\times\AAA$ using the standard derivative routines.
At high wavenumbers close to the Nyquist wavenumber,
$k_{\rm Ny}=\pi/\delta x$, where $\delta x$ is the mesh spacing,
the numerical derivatives give values that are somewhat too low;
see Section~H.1 and Figure~30 of the manual.
This affects the denominator in \Eq{realizability} more than
the numerator, because $\BB$ enters there quadratically.
This could explain why $k\HM(k)$ was found to exceed $2\EM(k)$.

\begin{figure}[t!]\begin{center}
\includegraphics[width=\columnwidth]{pcheck_r_t0}
\end{center}\caption[]{
$r(k/k_{\rm Ny})$ using the {\sc Pencil Code} at 2nd, 6th, and 10th order.
The second panel shows the same in a semilogarithmic plot to emphasize
that the damage is relatively small and restricted only to the
very smallest scales.
}\label{pcheck_r_t0}\end{figure}

To check this, Matthias suggested during the last {\sc Pencil Code}
office hours to verify this using the 10th order derivative routines.
This can easily be done by setting {\tt DERIV=deriv\_10th}.
Likewise, we can put {\tt DERIV=deriv\_2nd}.
The results are shown in \Fig{pcheck_r_t0}, where we show
$r(k)=k\HM(k)/2\EM(k)$ as a function of $k/k_{\rm Ny}$.
The second panel shows $r(k)$ in a semilogarithmic representation.

Not surprisingly, the second-order accurate scheme gives large departures
where $r(k)$ can reach values of around 2.4, so the error is 240\%.
As expected, the 10th order accurate scheme is clearly better
(error about 30\%) than the usual 6th order scheme (error about 50\%),
which is the default.

It would be possible to compute the derivatives for $\BB$ using
multiplications by $\ii\kk$.
In practice, however, the residual error is not very important, 
that's why this has not yet been done.

\section{PC steering committee}

We had a {\sc Pencil Code} Steering Committee (PCSC) meeting on June 12, 2023.
The minutes of the meeting are on \url{http://norlx65.nordita.org/~brandenb/pencil-code/PCSC/minutes/2023_06_12.txt}.

\section{Website outage}

The Nordita website is still down, and this also affected the
{\sc Pencil Code} homepage.
The {\sc Pencil Code} pages have now been decoupled and we are grateful
to Philippe Bourdin for his help in setting them up on another server;
see \url{http://pencil-code.nordita.org/}.
The website is now also available via the encrypted {\tt https} connection.

\section{Code developments}

As usual, we find the latest code developments on
\url{https://github.com/pencil-code/pencil-code/commits/master}.
The green and red check marks indicate whether
the travis test went through or not; see
\url{https://app.travis-ci.com/github/pencil-code/pencil-code}.

\subsection{Saving memory for {\tt df}}

As in {\tt run.f90} for {\tt nt=0}, now also in {\tt start.f90} the array of the PDE right-hand sides, {\tt df}, is only allocated when needed.

\subsection{{\tt pc\_start} with configuration file}

{\tt pc\_run} now inherits all the parameters of {\tt pc\_start}, which allows one to provide a configuration file at starting ({\tt -f <config file>}). 

\subsection{Specific heats}

At the moment, the {\sc Pencil Code} suffers from the fact that arbitrary combinations of {\it energy} and {\it equation-of-state} modules are in many cases not meaningful.
One of the major problems is that many modules use $\gamma$, $c_p$,
or $c_v$ as constants, although in general they are fields.
A major revision of the code in this respect should be planned during the upcoming User Meeting.
At the moment, if proper pencils (as during boundary conditions
evaluation) or auxiliary variables are not available, these values
are provided by the generic function {\tt get\_gamma\_etc} of the eos
modules in the form of the constants valid for an {\it ideal monatomic gas},
accompanied with a warning in case this is actually wrong. From {\tt
eos\_idealgas.f90}, however, the correct values are returned.

\subsection{Parallel remeshing}

The remeshing code, which has been parallelized recently, has been
modified to read the snapshot chunks from distributed I/O in a strictly
serial way, with even a waiting time of 0.4 sec between consecutive reads
(hardcoded at the moment).
This became necessary in order to deal with an unstable machine like LUMI.

\subsection{Auto-tests}

The results of the hourly auto-test are, as usual, on:
\url{http://norlx51.nordita.org/~brandenb/pencil-code/tests/hourly/}
Already some time ago, Philippe implemented an important new
functionality that allows us to see which last check-in caused
a particular auto-test to break!
You just follow the indicated link.

\section{Meetings}

\subsection{{\sc Pencil Code} User Meeting 2023}

If you haven't booked yet, you can perhaps still do it.
The details are on \url{http://pencil-code.nordita.org/UserMeetings/2023/}.
Vartika Pandey and Johannes Tschernitz, both from the IGAM/Graz,
belong to the local organizing committee.
There is a special deal with Hotel Daniel for 79 Euro/night; see the
link from the meeting page.
An even cheaper option, bookable via hotels.com, is the
hostel at Hauptbahnhof, which costs just 20 bucks, plus tax.

Important: if you just want to listen in to some talks,
it would be good to register, so we have your details,
and it is good for the statistics!

\subsection{Turbulence in Astrophysical ...}

During January 8 -- March 15, 2024, there will be a program at
the KITP in Santa Barbara on ``Turbulence in Astrophysical Environments'';
see \url{https://www.kitp.ucsb.edu/activities/uniturb24}.
Associated with this is a one-week conference on
``Turbulence in the Universe'' starting on Feb 20, 2024; see
\url{https://www.kitp.ucsb.edu/activities/uniturb-c24}
The registration deadline is Jan 21, 2024.

\subsection{Stellar convection: modelling, ...}

During August 26 -- September 20, there will be the Nordita program
``Stellar convection: modelling, theory and observations''; see
\url{https://indico.fysik.su.se/event/8136/}.
For more information, contact the organizers:
Petri K\"apyl\"a \url{<pkapyla@leibniz-kis.de>},
Isabelle Baraffe \url{<I.Baraffe@exeter.ac.uk>},
Markus Roth \url{<mroth@tls-tautenburg.de>}, or
Hideyuki Hotta \url{<hotta.h@isee.nagoya-u.ac.jp>}.

\section{Papers since April 2023}

As usual, we look here at new papers that make use of the {\sc Pencil Code}.
Since the last newsletter of April 1st, 14 new papers have appeared    
on the arXiv, and 11 others, some of which were just preprints and have now been published. 
We list both here, 25 altogether.
A browsable ADS list of all {\sc Pencil Code} papers can be found on:
\url{https://ui.adsabs.harvard.edu/public-libraries/iGR7N570Sy6AlhDMQRTe_A}.
If something is missing in those entries, you can also include it yourself in:
\url{https://github.com/pencil-code/pencil-code/blob/master/doc/citations/ref.bib},
or otherwise just email brandenb@nordita.org.
A compiled version of this file is available as
\url{https://github.com/pencil-code/website/blob/master/doc/citations.pdf},
where we also list a total of now 102 code comparison papers in the last
section ``Code comparison \& reference''.
Those are not included in our list below, nor among the now total number
of 630 research papers that use the {\sc Pencil Code}.

\nocite{
2023JCAP...06..025H,%He+ "Modified propagation of gravitational waves from the early radiation era"
2023JPlPh..89d9012M,%Mizerski+ "Cross-helicity effect on $\alpha$-type dynamo in non-equilibrium turbulence"
2023PhPl...30h2102C,%Candelaresi+Beck "Twisted magnetic knots and links"
2023arXiv230705490Z,%Zhu+Shi "Helical and nonhelical (magneto-)Burgers turbulence: I. Compressibility reduction and beyond"
2023PhFl...35g5150G,%Ganti+ "Interactions between high hydrogen content syngas-air premixed flames and homogeneous isotropic turbulence: Flame thickening"
2023arXiv230701281M,%Mondal+Bhat "A unified treatment of mean-field dynamo and angular-momentum transport in magnetorotational instability-driven turbulence"
2023arXiv230704602B,%Brandenburg "Inverse cascading for initial MHD turbulence spectra between Saffman and Batchelor"
2023arXiv230709385B,%Brandenburg "Relic Gravitational Waves from the Chiral Plasma Instability in the Standard Cosmological Model"
2023arXiv230715118S,%Schober+ "Chiral magnetic anomaly and dynamos from spatial chemical potential fluctuations"
2023arXiv230800662B,%Brandenburg+Protiti "Electromagnetic conversion into kinetic and thermal energies"
2023MNRAS.523.1056P,%Pavaskar+ "Magnetic field measurement from the Davis-Chandrasekhar-Fermi method employed with atomic alignment"
2023arXiv230607838H,%Hackman+ "From convective stellar dynamo simulations to Zeeman-Doppler images"
2023arXiv230607051G,%Gent+ "Transition from small-scale to large-scale dynamo in a supernova-driven, multiphase medium"
2023LRSP...20....3K,%Karak "Models for the long-term variations of solar activity"
2023arXiv230516790K,%Kapyla+ "Simulations of solar and stellar dynamos and their theoretical interpretation"
2023arXiv230516447O,%Ortiz-Rodriguez+ "Simulations of dynamo action in slowly rotating M dwarfs: Dependence on dimensionless parameters"
2023arXiv230503318T,%Tharakkal "Steady states of the Parker instability: the effects of rotation"
2023arXiv230501312N,%Navarrete+ "Effects of the centrifugal force on stellar dynamo simulations"
2023PhRvR...5b2028B,%Brandenburg "Decay law of magnetic turbulence with helicity balanced by chiral fermions"
2023PhFl...35e5128L,%Lipatnikov+Sabelnikov "Influence of small-scale turbulence on internal flamelet structure"
2023NatAs.tmp..107W,%Warnecke "Numerical evidence for a small-scale dynamo approaching solar magnetic Prandtl numbers"
2023Atmos..14..932B,%Brandenburg+Larsson "Turbulence with Magnetic Helicity That Is Absent on Average"
2023arXiv230411929E,%Elias-Lopez+ "Vorticity and magnetic dynamo from subsonic expansion waves"
2023arXiv230406612B,%Brandenburg "Chiral magnetohydrodynamics with zero total chirality"
2023RNAAS...7...69L%Lyra "Stability Analysis for General Order Central Finite-difference Hyperdiffusivity with Time Integrators of Arbitrary Accuracy"
%
%2023arXiv230310707H,%Hidalgo+ "Origin of magnetism in early-type stars"
%2023arXiv230300911Y,%Yuvraj "On flame speed enhancement in turbulent premixed hydrogen-air flames during local flame-flame interaction"
%2023arXiv230206042Z,%Zhou+Blackman "Helical dynamo growth at modest versus extreme magnetic Reynolds numbers"
%2022arXiv221203215T,%Tharakkal+ "Steady states of the Parker instability"
%
%2022arXiv220804333C,%Carenza+ "Magnetohydrodynamics predicts heavy-tailed distributions of axion-photon conversion"
%2022arXiv220606566M,%Masada+Sano "Rotational Dependence of Large-scale Dynamo in Strongly-stratified Convection: What Causes It?"
%2022arXiv220509261R,%Roper Pol "Gravitational waves from MHD turbulence at the QCD phase transition as a source for Pulsar Timing Arrays"
%2021arXiv211201193C,%Candelaresi+Del Sordo "Stability of plasmas through magnetic helicity"
%2021arXiv210508287R,%Roper Pol "Gravitational radiation from MHD turbulence in the early universe"
%%2021arXiv210301597P,%Pekkila+ "Scalable communication for high-order stencil computations using CUDA-aware MPI"
}

\bibliography{ref}
\vspace{5mm}
\hrule
\vspace{2mm}
This {\sc Pencil Code} Newsletter was edited by
Axel Brandenburg {\tt <brandenb@nordita.org>}, Nordita, KTH Royal Institute of Technology and Stockholm University, SE-10691 Stockholm, Sweden;
and Matthias Rheinhardt {\tt <matthias.rheinhardt@aalto.fi>}, Department of Computer Science, Aalto University, PO Box 15400, FI-00076 Aalto, Finland.
See \url{http://www.nordita.org/~brandenb/pencil-code/newsletter} or
\url{https://github.com/pencil-code/website/tree/master/NewsLetters}
for the online version as well as back issues.
\end{document}
