% $Id: newsletter.tex,v 1.9 2026/06/21 08:16:02 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).}
\newcommand{\const}{{\rm const}  {}}
\def\half{{\textstyle{1\over2}}}

%\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{xcolor, soul}
\usepackage{listings}
\usepackage{amssymb}
\usepackage{amsmath}

\graphicspath{{./fig/}{./png/}}
\thispagestyle{empty}
\input ../../jour_def
\newcommand{\Fig}[1]{Figure~\ref{#1}}
\newcommand{\Figs}[2]{Figures~\ref{#1} and \ref{#2}}
\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}}}
\newcommand{\Cou}{{\mbox{Cou}}}
\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}}
%\newcommand{\Sec}[1]{Sect.~\ref{#1}}
\newcommand{\Sec}[1]{\S\ref{#1}}
\newcommand{\ymn}[5]{, ``#5,'' {\em Month. Not. Roy.\ Astron.\ Soc.\ }{\bf #2}, #3--#4 (#1).}

\title{The {\sc Pencil Code} Newsletter}
\author{Issue 2026/1}
\date{\today,~ $ $Revision: 1.9 $ $}
%\date{June 29, 2026,~ $ $Revision: 1.9 $ $}
\begin{document}
\maketitle

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

\vspace{5mm}

%\noindent

\section{}

\subsection{No yz-slices?}

During the Pencil Code office hours in xx and April, a problem about
missing yz slices was reported.

\subsection{}

In viscosity.f90, we had a piece:

\begin{verbatim}
        if (ldynamical_diffusion .and. lvisc_hyper3_mesh) then
          diffus_nu3 = p%diffus_total3 * sum(abs(dline_1),2)
        else
          diffus_nu3 = p%diffus_total3*dxyz_6
        endif

which was not correct, because it makes diffus_nu3 finite in cases that
have nothing to do with hyper3. I noticed this because of its timestep
constraint, and this could have been a problem also in a few other cases.
I noticed that this piece of code goes back to 2011-08-02 and it seems
that it was coded by Chao-Chin with the message

  By fixing the mesh Reynolds number, dynamically adjust the mesh hyper3
  coefficients for density, magnetic, and viscosity.  Generally work with
  non-equidistant grids.  cdtv3 may be as high as 0.9, or even 1.

after earlier work by Wlad. I then disentagled the loop into two, but
realized that diffus_nu3 will be needed in a few other cases. For example
in samples/MRI-turbulence_hyper we have lvisc_hyper3_rho_nu_const_symm=T,
so I included this and it worked. I have now added all 14 logicals
that seem to be needed.

        if (lvisc_hyper3_mesh .or. lvisc_hyper3_simplified .or. lvisc_hyper3_simplified_tdep .or. &
            lvisc_hyper3_mesh_residual .or. lvisc_hyper3_mesh .or. lvisc_hyper3_rho_nu_const .or. &
            lvisc_hyper3_mu_const_strict .or. lvisc_hyper3_nu_const .or. &
            lvisc_hyper3_cmu_const_strt_otf .or. lvisc_hyper3_rho_nu_const_symm .or. &
            lvisc_hyper3_rho_nu_const_aniso .or. lvisc_hyper3_nu_const_aniso .or. &
            lvisc_hyper3_rho_nu_const_bulk .or. lvisc_hyper3_nu_const) then
\end{verbatim}

\begin{verbatim}
I wanted to explain my changing of the interstellar sample data.
With Matthias, we enabled the possibility to output spectra and
slices based on another trigger than just the time. Therefore,
in general, the time may not be available, which could be unfortunate.
Therefore we added it to the spectra. In the usual case, the time
comes now twice, but the advantage is that we don't need to nake
complicated queries. Let me know if there are questions.
Axel

PS: here the differences:

<    1.7948403418635799E-008   1.7948403418635799E-008
---
>    1.7948403418635799E-008
3c3
<    3.4513211517011286E-008   3.4513211517011286E-008
---
>    3.4513211517011286E-008
5c5
<    3.9465918924760758E-008   3.9465918924760758E-008
---
>    3.9465918924760758E-008
7c7
<    5.6922915463575225E-008   5.6922915463575225E-008
---
>    5.6922915463575225E-008
\end{verbatim}


%\begin{figure*}[ht]
%\begin{center}
%\includegraphics[width=0.9 \textwidth]{screenshots/git-hist-1-5.png}
%\end{center}
%\caption[]{History graph of 15th of October 2025 as shown by GitHub network. From top: a) point of divergence, b+c) linear history of commit 1+2 in the original remote `Master', d) a commit in Matthias' local `Master', and finally e) erroneous merge is pushed and marks Matthias' local history now as the new linear history of the remote `Master'. The green and black lines indicate the linear history of the remote `Master' branch in its original and latest state, respectively. The blue line is from a remote branch that is not relevant here.}\label{git-hist}
%\end{figure*}

\begin{verbatim}
 start_run.csh habe ich angepasst, funktioniert jetzt auch mit HDF5.
\end{verbatim}

\section{Default changes}

\subsection{Lorentz force spectra for kinematic flows}

Since 6-mar-26 (i.e., since revision r42876), we compute Lorentz spectrum
also for lhydro\_kinematic.and.iux/=0, i.e., when the velocity is defined
as an auxiliary array.

\section{Code additions}

\subsection{Persist variables}

src/record\_types.h

The relevant routine (e.g., special) must have

    subroutine input\_persist\_special\_id(id,done)


\subsection{Regarding GPUs}

Changes for GPU capability.
To explain meaning of \texttt{!\$omp do collapse(2)} 
and \texttt{!\$omp workshare}
and \texttt{}
and \texttt{}

Also, why do we need \texttt{m=m\_loc;n=n\_loc}?
We should explain this both in the newsletter and in \texttt{src/power\_spectrum.f90}.

\begin{verbatim}
!$omp parallel private(k,k2) num_threads(num_helper_threads) &
!$omp copyin(MPI_COMM_GRID,MPI_COMM_PENCIL,MPI_COMM_XBEAM,MPI_COMM_YBEAM,MPI_COMM_ZBEAM, &
!$omp MPI_COMM_XYPLANE,MPI_COMM_XZPLANE,MPI_COMM_YZPLANE)
!$ thread_id = omp_get_thread_num()+1
\end{verbatim}

\section{sourceme.sh}

--rebase.

\section{Signalling NaNs}

Initializing the code with signalling NaNs can be helpful in detecting uninitialized variables.
To enable this, one can compile the code with with \texttt{FFLAGS += -finit-real=sNaN}
(for the gnu compiler) and with \texttt{FFLAGS += -finit-integer=-2147483648} for integer.
During the last \texttt{Pencil Code} office hours in May, Philippe reminded us that such
options and similar ones are listed in the directory
\begin{verbatim}
pencil-code/config/compilers/extensions
\end{verbatim}
in the file
\begin{verbatim}
GNU-GCC_debug.conf
\end{verbatim}

\begin{verbatim}
~/pencil-code/config/compilers/extensions/GNU-GCC_debug.conf
\end{verbatim}

\section{Excessive NaN run-time output}

Put ip$>$14 (14 is the default)

\section{ReadTheDocs: tutorials and postprocessing}
%IL: added

ReadTheDocs hosts the central Pencil Code documentation and resources: general 
documentation, developer guides, API reference, tutorials, and sample workflows. 
See 
\url{https://pencil-code.readthedocs.io/}{https://pencil-code.readthedocs.io/} 
for an overview.


\subsection{The {\sc Pencil Code}: samples}
% pencil-code/doc/readthedocs/tutorials/samples

The documentation now includes a new set of tutorial samples that walk users 
through complete workflows for different physical processes. 
Each sample is designed to cover:
\begin{itemize}
    \item Scientific background and motivation
    \item Simulation configuration and setup
    \item Useful runtime checks and diagnostics
    \item Post-processing with Python for analysis and visualization
\end{itemize}
This makes it easier for new users to reproduce results and learn standard workflows.

The first published example is a simple convection simulation, with a step-by-step guide from problem setup through execution and Python-based post-processing:
\href{https://pencil-code.readthedocs.io/en/latest/tutorials/samples/tutorial-
conv-slab.html}{Convection simulation}

This is the beginning of a larger tutorial collection, and we encourage 
contributors to add new samples for other physics cases. 
If you are working with existing example directories under 
\texttt{pencil-code/samples}, your material would be a great addition.

\subsection{IDL to Python}
% pencil-code/doc/readthedocs/tutorials/python/IDL_to_Python_Translation_Guide.rst

A new documentation page provides an expanded translation guide from IDL to 
Python, tailored to the {\sc Pencil Code} ecosystem. 
It explains how to convert legacy IDL analysis scripts into modern Python code, 
including recommended {\sc Pencil Code} utilities, common syntax differences, 
and practical examples for arrays, plotting, and file handling.

This guide is especially useful for users who want to migrate existing IDL 
workflows while preserving the same data-processing logic in Python. 
It helps users modernize legacy analysis without losing existing workflow logic. 
See the new page here:
\href{https://pencil-code.readthedocs.io/en/latest/tutorials/python/
IDL_to_Python_Translation_Guide.html}{IDL to Python}

%IL:


\section{Pencil Code Python: package, tests, and recent meetings}

The idea of these meetings is to share developments, discuss ideas, present new 
work, and help the community.

This year we held two meetings (2026 Jan 29 and 2026 Mar 30). The Python 
postprocessing group has made rapid progress on packaging, testing, and 
tutorials; the meetings concentrated on three priority areas: making the Python 
toolkit an installable package, establishing automated Python tests, and 
organizing tutorial samples linked from the documentation.


Key outcomes and ongoing work:
\begin{itemize}
    \item Packaging: the project is moving toward an official pip-installable 
package (\texttt{pypencil}); this is a high-priority effort led by Alberto and 
will make installation as simple as ``pip install pypencil``.
    \item Testing: Kishore has developed a suite of Python tests; the next step 
is to host these on an automated server (options such as Nordita machines are 
being explored) so tests run on new commits.
    \item Tutorials and docs: the group agreed to develop a set of tutorial 
samples; the first published example is the convection simulation described in 
section \ref{samples}. Samples live in subdirectories of 
\texttt{pencil-code/samples} (for example 
\texttt{pencil-code/samples/conv-slab}); each sample may be a Jupyter notebook 
or an RST file and will be linked from ReadTheDocs.
    \item API and usability improvements: work is underway to standardize 
array-order conventions, unify error handling (raise informative exceptions), 
harmonize debug output defaults (``quiet`` flag), and provide example usage in 
docstrings to aid both users and tests.
    \item Interoperability: routines to export var files to other formats (e.g., 
Athena-compatible output) are being modularized and integrated into the Python 
toolkit.
\end{itemize}

The \texttt{pypencil} package is a high-priority effort and will make it 
straightforward to install the postprocessing toolkit via pip.

We warmly encourage the community to join the Python working-group meetings, 
propose agenda items, and contribute tests or tutorial samples (place them under 
\texttt{pencil-code/samples}). Your participation directly shapes priorities and 
improves the tools for everyone.

\section{Papers since January 2026}

As usual, we look here at new papers that make use of the {\sc Pencil Code}.
Since the last newsletter of August 2025, six new papers have appeared    
on the arXiv, plus nine others, some of which had been just preprints and now have been published with a journal reference on ADS.
We list both here, altogether 15.
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 136 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 764 research papers that use the {\sc Pencil Code}.

\nocite{
2026ApJ..1002..165B,%Brandenburg+ "Magnetic Field Spreading from Stellar and Galactic Dynamos into the Exterior"
2026arXiv260417230S,%Sharma+ "Suppressed Magnetogenesis from Ultralight Dark Matter due to Finite Conductivity"
2026ApJ..1001...16V,%Vemareddy+ "Understanding the Formation and Eruption of Sigmoidal Structure through Data-driven Modeling of Magnetic Evolution in Solar Active Region 13500"
%2025arXiv251026918G,%Ghosh+ "Can galactic magnetic fields diffuse into the voids?"
%2025arXiv251119508M,%Mtchedlidze "Simulated Rotation Measure Sky from Primordial Magnetic Fields"
%2025arXiv251209177G,%Gurgenidze+ "Primordial magnetic field from chiral plasma instability with sourcing"
%2025arXiv251209725E,%Elias-Lopez "Numerical simulations of astrophysical dynamos and applications to giant planets"
%2025arXiv251211973S,%Skalidis+ "Residual energy in weakly compressible turbulence with a mean guide field"
%2025arXiv251217770B,%Brandenburg+ "Magnetic field spreading from stellar and galactic dynamos into the exterior"
%2025arXiv251217885G,%Gent+ "Asymptotic behaviour of galactic small-scale dynamos at modest magnetic Prandtl number"
%2025arXiv250921141Z,%Zhang+Brandenburg "Resistive Scaling in the Magnetic Helicity-Driven Inverse Cascade"
%2025arXiv250906173Q,%Qazi+ "Mathematical Aspects of Geophysical and Astrophysical Fluid Dynamics: Magnetic buoyancy instability in galaxies"
%
%2024arXiv240115860Z,%Zhou+Jingade "Correlation times of velocity and kinetic helicity fluctuations in nonhelical hydrodynamic turbulence"
%2024arXiv240416096D,%Dey+ "Spinning solar jets explained through the interplay between plasma sheets and vortex columns"
%
% outdated
%2023arXiv231109082K,%Kapyla "Effects of rotation and surface forcing on deep stellar convection zones"
%2023arXiv230705490Z,%Zhu+Shi "Helical and nonhelical (magneto-)Burgers turbulence: I. Compressibility reduction and beyond"
%2023arXiv230300911Y,%Yuvraj "On flame speed enhancement in turbulent premixed hydrogen-air flames during local flame-flame interaction"
%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"
%2021arXiv210508287R,%Roper Pol "Gravitational radiation from MHD turbulence in the early universe"
}

\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}
