% $Id: newsletter.tex,v 1.17 2024/05/02 23:59:15 rei 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}
\usepackage{amssymb}

\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}}}
\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 2024/1}
\date{April 30, 2024,~ $ $Revision: 1.17 $ $}
\begin{document}
\maketitle

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

\section{PCUM 2024 in Barcelona}

\begin{figure}[h]\begin{center}
\includegraphics[width=\columnwidth]{IMG-20231205-WA0001}
\end{center}\caption[]{
The Institute of Space Sciences in Bellaterra (Barcelona).
}\label{IMG-20231205-WA0001.jpg}\end{figure}

As already advertised in the last newsletter 2023/3, the next Pencil
Code User Meeting will be held at the Institute of Space Sciences on
the Campus of University Autonoma de Barcelona during September 23--27,
2024; see \Figs{IMG-20231205-WA0001.jpg}{IMG-20231205-WA0000.jpg}.

The organizers include Fabio Del Sordo and his team, who
are in the process of creating a webpage for the event.
A preliminary version can be found at the following address
\url{https://indico.ice.csic.es/event/40/}.
In May, the organizers will share on the webpage the most important information
about the meeting and logistics and they will open the registration.

Finding accommodation in Barcelona might not be easy.
If someone is interested in securing an accommodation already now, one
possibility is the Resid\`encia d'Investigadors, downtown in Barcelona; see
\url{https://www.residencia-investigadors.es/en/}.
It is located close to the center and close to the train station (FGC,
line S2) that takes you to the UAB Campus in 40--45 minutes, where the
Pencil Code User Meeting will be.

For any preliminary inquire you can contact Fabio Del Sordo
\texttt{<delsordo@ice.csic.es>}.

\begin{figure}[h]\begin{center}
\includegraphics[width=\columnwidth]{IMG-20231205-WA0000}
\end{center}\caption[]{
One of ``our'' meeting rooms at the Space Sciences in Bellaterra.
}\label{IMG-20231205-WA0000.jpg}\end{figure}

\section{Proposals for PCUM 2025}

At the last PCUM, we discussed the possibility to apply for hosting
the PCUM in 2025 and thereafter.
Thus, please come forward with suggestions to the editors of this
newsletter.
While this implies a significant amount of work, it can also be a
%real pleasure for those who have been organizing a small meeting  %MR: unclear - "have been"?
%AB: wrote now "are"
real pleasure for those who are organizing a small meeting
for the first time.
If you are able to apply for additional funding, this would be
great, but even without that, you can do it.
The participants are usually paying their own accommodation and travel,
as well as dinners and T-shirts, if the organizers design one.
As before, the PCSC decides at the end of the PCUM where the next 
one will be.

\section{Gfortran bug fixed}

\textit{Kishore Gopalakrishnan informed us of the following:}
Gfortran users should note that a bug that affected cleaning up of 1D
average files after an improperly terminated Pencil run has been fixed
in GCC (\url{https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107031}).
The fix is expected to be included in the upcoming GCC 14.

\section{Coding considerations}

%\subsection{dot-inc files}
%During the April Pencil Code Office Hours, we discussed changing the
%names of the automatically-generated \texttt{*.inc} files to include
%instead autocommon in the name.
%No further steps were undertaken at the time, but this news item
%may serve as a little warning of such an upcoming change.
\subsection{Where is the source code?}
Most users will answer ``in \texttt{src/*.f90} and \texttt{src/*.h}". True, but there is more:
We have also Fortran 77 and C sources (\texttt{src/*.f} and \texttt{src/*.c}). Additionally, 
some Fortran code dwells in \texttt{src/*.inc} files, which come in two flavors:
\texttt{*\_dummies.inc} are not in the repository but generated during the build. They contain
dummy routines, which are needed for linking, but are otherwise without function.
When named \texttt{*\_common.inc}, the files {\it do} exist in the repository
and contain code which is common to different implementations of a physics module, like, e.g., 
\texttt{chemistry}.

Don't forget that \texttt{src} has several source-code containing subdirectories.

\subsection{Grepping source code}

During code development, one often uses grep, e.g., in the form
\begin{verbatim}
  grep ind_glob ~/pencil-code/src/*.f90
\end{verbatim}
but then you will miss the \texttt{*.inc} and \texttt{*.h} files.
Therefore, we discussed having a
\begin{verbatim}
  pc_grepsrc
\end{verbatim}
command, that would also grep in Astaroth files 
(in subdirectory \texttt{src/astaroth/submodule})
if they are linked.

\section{Call for help}
At Aalto University, Finland, computer scientists from Prof.\ Maarit K\"apyl\"a's and Prof.\ Linh Truong's groups 
are running a one-year project (Inno4scale-202301-068) to create an ``Opportunistic data operations platform" (ODOP).
The idea is, to identify so-called {\it windows of opportunity} when running an application, which
doesn't permanently make use of all compute resources on a node of a cluster. During such a window, there is then 
an opportunity to schedule an additional task to be processed. A typical example (and also the 
major application case for the development) is the Pencil Code, with GPU acceleration by Astaroth.
In this case, most of the CPUs on a node are only from time to time busy for creating diagnostics and performing 
output, but idle otherwise. An ``additional task" would then naturally be some post-processing on data, created
just by the running code, or even on data from another run. 
The community can be of significant help for the developers  by digging into their past or recent work with the Pencil Code and identifying
such post-processing tasks, which should, of course, be computationally somewhat heavy.
If you find appropriate cases, please send corresponding Python or IDL scripts (or any other program tool) with a short explanation to
\texttt{matthias.rheinhardt@aalto.fi}.

\section{Random tips}

\subsection{Non-Cartesian averages}

\textit{Kishore Gopalakrishnan wrote us the following:}
1D and 2D diagnostic averages are now computed correctly for non-Cartesian
coordinate systems (but the grid still needs to be equispaced).
Earlier, e.g., the quantity reported in spherical coordinates as \texttt{+rhomx}
was actually \texttt{((cos(y0) - cos(y1))/(y1-y0))*x**2*rhomx}.

\subsection{Reading several subvolumes}

Many tools have existed for a long time, but not everybody knows about them.
It has long been clear that the reading of a subvolume can be useful if the
data file is big, and it is easy if the relevant subvolume corresponds to
that of a single processor and if each processor writes its own var files.
But since 2012, employing the IDL script \texttt{pc\_read\_subvol\_raw.pro},
one can also select {\it arbitrary index ranges}, for example
like so:
\begin{verbatim}
ixs=1230 & ixe=ixs+255
iys= 315 & iye=iys+255
izs=1920 & ize=2047
pc_read_subvol_raw,obj=var,xs=ixs,xe=ixe, $
  ys=iys,ye=iye,zs=izs,ze=ize, $
  allprocs=0,/single,/addghost
\end{verbatim}
This is an example where a $256\times256\times128$ mesh point subvolume
is read from a $2048^3$ simulation.
Here, \texttt{s} and \texttt{e} in the variable names refer to start and end.
As you see from the logs, this was coded and developed by Philippe in
2012 and 2013.
Except for additional five \texttt{Merge branch 'master'} commits
in the meantime, also Matthias worked on it in 2024.

The instruction \texttt{/single} helps to reduce the amount of data
if the original data was in double precision.
(It also doesn't hurt if the original data
was already in single precision.)
Finally, the \texttt{/addghost} is included to add the ghost zones.
This is needed if you want to compute $\bm{B}$ and $\bm{J}$ from that
data, e.g., like so:
\begin{verbatim}
bb=curl(var[*,*,*,4:6])
jj=curlcurl(var[*,*,*,4:6])
\end{verbatim}
Note that \texttt{curlcurl} is the double curl and corresponds to
$\bm{\nabla}\bm{\nabla}\cdot\bm{A}-\nabla^2\bm{A}$.
This method was used in \cite{2024arXiv240108569B} where the
points from a small subvolume were visualized.

The script has also a ``simulation mode" (\texttt{/simulate}), which doesn't read any data,
but creates a list of the processor chunks needed for the subvolume and informs about the 
needed amount of main memory. This can be useful if one has to retrieve the data from some 
mass storage like Allas.

\subsection{Kinematic sound waves}

In the paper by \cite{2023JCAP...12..042S}, the driving of gravitational
waves by stochastic sound waves was studied.
In their repertoire of different cases, they also studied \textit{linear}
random sound waves.
Instead of solving the hydrodynamic equations without nonlinearity, they
just constructed sound waves from their dispersion relation with random
phases.
They did this using \texttt{HYDRO = hydro\_kinematic} with the entry:
\begin{verbatim}
&hydro_run_pars
  kinematic_flow='sound3D'
  lkinflow_as_comaux=T, power1_kinflow=4.,
  power2_kinflow=-2., kpeak_kinflow=30.
  cs21_kinflow=3.
/
\end{verbatim}
The full details of this run are given in
\url{http://norlx65.nordita.org/~brandenb/projects/ShallowGW/run_directories/512a_2nd_dt5c_cos_dt/}.

\section{Papers since December 2023}

As usual, we look here at new papers that make use of the {\sc Pencil Code}.
Since the last newsletter of December 15st, 9 new papers have appeared    
on the arXiv, plus 14 others, some of which were just preprints and have now been published in a journal.
We list both here, 23 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 112 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 699 research papers that use the {\sc Pencil Code}.

\nocite{
2024JCAP...04..018I,%Iarygina "Backreaction of axion-SU(2) dynamics during inflation"
2024arXiv240407845S,%Schober+ "Efficiency of dynamos from autonomous generation of chiral asymmetry"
2024PhRvL.132f5101S,%Schober+ "Chiral Anomaly and Dynamos from Inhomogeneous Chemical Potential Fluctuations"
2024arXiv240410804E,%Elias-Lopez+ "Vorticity and magnetic dynamo from subsonic expansion waves II: Dependence on magnetic Prandtl number, forcing scale, cooling time"
2024arXiv240410720K,%Kesri+ "Dependence of spicule properties on magnetic field -- results from Magnetohydrodynamics simulations"
2024ApJ...961....7G,%Gent+ "Transition from small-scale to large-scale dynamo in a supernova-driven, multiphase medium"
2024MNRAS.527.3018Z,%Zhou "Helical and non-helical large-scale dynamos in thin accretion discs"
2024PhRvE.109a5206Z,%Zhou+Blackman "Helical dynamo growth and saturation at modest versus extreme magnetic Reynolds numbers"
2024MNRAS.527.7994Q,%Qazi+ "Nonlinear magnetic buoyancy instability and turbulent dynamo"
2024arXiv240101336H,%Hosking+ "Metastability of stratified magnetohydrostatic equilibria and their relaxation"
2024arXiv240101965D,%Dwivedi+ "Quasi-two-dimensionality of three-dimensional, magnetically dominated, decaying turbulence"
2024arXiv240104015K,%Korpi-Lagg+ "Computational approaches to modeling dynamos in galaxies"
2024arXiv240108569B,%Brandenburg+ "Resistively controlled primordial magnetic turbulence decay"
2024arXiv240215475S,%Sengupta+ "Length and Velocity Scales in Protoplanetary Disk Turbulence"
2024arXiv240115860Z,%Zhou+Jingade "Correlation times of velocity and kinetic helicity fluctuations in nonhelical hydrodynamic turbulence"
2024A&A...682A.156H,%Hackman+ "From convective stellar dynamo simulations to Zeeman-Doppler images"
2024ApJ...962...86M,%Sankar+ "Photospheric Lorentz force changes in eruptive and confined solar flares"
2024NatCo..15.1841K,%Kirchschlager+ "Supernova dust destruction in the magnetized turbulent ISM"
2024PSJ.....5...55C,%Canas+ "A Solution for the Density Dichotomy Problem of Kuiper Belt Objects with Multispecies Streaming Instability and Pebble Accretion"
2024PhRvD.109d3534B,%Brandenburg "Relic Gravitational Waves from the Chiral Plasma Instability in the Standard Cosmological Model"
2024RAA....24b5007V,%Vemareddy+ "Data-driven Simulations of Magnetic Field Evolution in Active Region 11429: Magneto-frictional Method Using PENCIL CODE"
2024A&A...683A.221K,%K{\"a}pyl{\"a}} "Convective scale and subadiabatic layers in simulations of rotating compressible convection"
2024MNRAS.527.3018Z,%Zhou "Helical and non-helical large-scale dynamos in thin accretion discs"
2023JCAP...12..042S%Sharma+ "Shallow relic gravitational wave spectrum with acoustic peak"
%
%2023arXiv231109082K,%Kapyla "Effects of rotation and surface forcing on deep stellar convection zones"
%2023arXiv231107557I,%Iarygina "Backreaction of axion-SU(2) dynamics during inflation"
%2023arXiv231016480V%V{\"a}is{\"a}l{\"a}}+ "Exploring the Formation of Resistive Pseudodisks with the GPU Code Astaroth"
%
%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"
%2023arXiv230206042Z,%Zhou+Blackman "Helical dynamo growth at modest versus extreme magnetic Reynolds numbers"
%
%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"
}

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