{'fraction_non_alphanumeric': 0.0302239049546315, 'fraction_numerical': 0.0094000913897774, 'mean_word_length': 5.145206578419574, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
CRPropa 3.2: a framework for high-energy astroparticle propagation

The landscape of high- and ultra-high-energy astrophysics has changed in the last decade, in large part owing to the inflow of high-quality data collected by present cosmic-ray, gamma-ray, and neutrino observatories. At the dawn of the multimessenger era, the interpretation of these observations within a consistent framework is important to elucidate the open questions in this field. CRPropa 3.2 is a Monte Carlo code for simulating the propagation of high-energy particles in the Universe. This new version represents a step further towards a more complete simulation framework for multimessenger studies. Some of the new developments include: cosmic-ray acceleration, support for particle interactions within astrophysical sources, full Monte Carlo treatment of electromagnetic cascades, improved ensemble-averaged Galactic propagation, and a number of technical enhancements. Here we present some of these novel features and some applications to gamma- and cosmic-ray propagation.

The landscape of high-and ultra-high-energy astrophysics has changed in the last decade, in large part owing to the inflow of high-quality data collected by present cosmic-ray, gamma-ray, and neutrino observatories. At the dawn of the multimessenger era, the interpretation of these observations within a consistent framework is important to elucidate the open questions in this field. CRPropa 3.2 is a Monte Carlo code for simulating the propagation of high-energy particles in the Universe. This new version represents a step further towards a more complete simulation framework for multimessenger studies. Some of the new developments include: cosmic-ray acceleration, support for particle interactions within astrophysical sources, full Monte Carlo treatment of electromagnetic cascades, improved ensemble-averaged Galactic propagation, and a number of technical enhancements. Here we present some of these novel features and some applications to gamma-and cosmic-ray propagation.

Introduction
In the last decade, a wealth of observations of energetic astrophysical phenomena were delivered with unprecedented precision. At ultra-high energies, the Pierre Auger and the Telescope Array collaborations reported observations of medium-and large-scale anisotropies in the arrival directions of ultra-high-energy cosmic rays (UHECRs) whose origins are yet unexplained [1][2][3][4][5]. There are also noteworthy correlations between UHECRs and gamma-ray-emitting starburst galaxies [6]. The IceCube Neutrino Observatory detected a diffuse flux of neutrinos with ∼ PeV energies [7]. Together with observatories operating from radio to gamma rays, IceCube also identified the blazar TXS 0506+056 as a potential source of PeV neutrinos [8]. Observations of gamma rays with ∼ PeV energies hint at the existence of Galactic sources of high-energy CRs [9][10][11]. Moreover, gravitational waves (GWs) became an integral part of the multimessenger paradigm in astrophysics, delivering pieces of information which combined with those obtained by other messengers have offered us glimpses into extreme events.
Within this landscape, the interpretation of multimessenger observations is of paramount importance for fully grasping the phenomena at hand, and for answering the open questions in the field of cosmic rays [12][13][14]. This requires detailed theoretical knowledge of how each messenger is produced in astrophysical objects, how they can escape the environment wherein they are accelerated, how they propagate to Earth, and what are the multimessenger signatures associated to specific scenarios. For this purpose, we present here CRPropa 3.2.
CRPropa 3.2 extends the applicability of the code to a variety of applications beyond UHECR astrophysics, which range from the propagation of CRs in the Galaxy to gamma-ray and neutrino astronomy. Here we introduce the capabilities of CRPropa in section 2, followed by a description of some of the improvements made in this new version in section 3. We illustrate some applications of the code in section 4, and briefly address the current status of CRPropa 3.2 and future developments in section 5.

The CRPropa Framework
CRPropa 3 [15,16] is a flexible framework for high-energy astrophysical studies. It is written in C++ with Python bindings. The code structure is fully modular, handling each ingredient of the transport problem separately through the usage of individual modules that describe, e.g., sources, observer, particles, interactions, and magnetic fields. Each module acts on properties of an object from the Candidate class, which stores all the relevant information about a particle such as its position, energy, nature (type of particle), and momentum. At each step of propagation the modules update these properties according to prescriptions which may involve, for instance, kinematic changes due to a given physical process such as interactions, magnetic deflections, etc. Particles are tracked until some specified breaking condition is met, which may include trajectory length constraints or detection, for example.
CRPropa simulations can be processed in parallel, with shared memory, via OpenMP. This enables fast computations covering large parameter spaces. Moreover, depending on the specific problem at hand, one can make use of the fact that CRPropa is a Monte Carlo code and simply apply weights to a single set of simulations to create a family of scenarios. This greatly optimises performance and makes it possible to probe an even larger parameter space to compare different scenarios of interest.

New Features
In CRPropa 3.2 we have extended the physics capabilities of the code by introducing a number of new modules to treat phenomena that so far could not be modelled with the code. Below we list some of them.
Acceleration. CRPropa 3.2 contains modules to simulate the acceleration of charged particles scattering off magnetic-field irregularities. In particular, first-and second-order Fermi acceleration are available, generalising the implementation of ref. [17].
New Photon Production Channels. Processes such as photodisintegration of nuclei and radiative decays can produce (ultra-)high-energy photons. For this reason, we added such production channels to CRPropa, together with elastic scattering of CR nuclei off background photons [18]. The latter, in particular, does not incur substantial energy losses for cosmic rays, but can be important to obtain a consistent multimessenger picture.
Electromagnetic Cascades. So far, the propagation of photons in CRPropa was done using external packages such as the transport-equation solver DINT [19] or the Monte Carlo code EleCa [20]. For consistency and to enable a full three-dimensional treatment of photon propagation, we implemented all relevant electromagnetic processes for high-energy photons and electrons natively within CRPropa. These interactions can occur many times during the cascade process, leading to a rapid growth in the number of particles in the simulation, which renders a Monte Carlo treatment over a wide range of energies impractical. To enable faster simulations, we also implemented a thinning procedure following refs. [21,22], leading to speedups of up to four orders of magnitude.
Ensemble-Averaged Propagation. The propagation of charged particles can be diffusive, making the particle-by-particle treatment of propagation computationally expensive. One example is the propagation of CRs with energies 10 PeV in the Milky Way. Since CRPropa 3.1 [16], an ensemble treatment of this problem has been part of CRPropa by solving stochastic differential equations (SDEs) corresponding to the Parker transport equation. These SDEs describe the time evolution of pseudo-particles representing phase-space elements. This framework was extended to include macroscopic effects due to bulk motion such as advection and adiabatic compression/expansion.

Magnetic Field Models.
We implemented new generic magnetic-field models, namely a singlemode helical [23] and a helical turbulent [22] field. New models for the Galactic magnetic field (GMF) were added, in addition to the already existing ones. This includes modifications of the model by Jansson & Farrar [25,26] such as those from refs. [29,30], as well other models for the halo field [24] and the central Galactic zone [28].
In addition to the new physics features, several technical improvements were made aiming at optimising performance and accuracy.
Magnetic Field Improvements. We have redesigned the way in which CRPropa handles stochastic magnetic fields. The discrete three-dimensional turbulent fields were extended to allow for more sophisticated magnetic power spectra, now including a smooth bend-over of the spectrum and different indices for the injection and cascade regions. This grid-based method is useful and can be applied to a wide range of problems, but an alternative approach that computes magnetic fields on the fly can be more suitable for other problems. A notable example is the propagation of charged particles when their Larmor radii are smaller than the coherence length of the magnetic field (see, e.g., refs. [31][32][33]). This is implemented in CRPropa 3.2 using plane waves, following ref. [34].
Targeting. One of the main difficulties in three-and four-dimensional Monte Carlo simulations of particle propagation over large distances is the detection efficiency of the collection surfaces representing the detector. Particles emitted by a given source are tracked, deflected by intervening magnetic fields, but often they do not reach a small target that represents the observer within this setup, making this type of simulation computationally costly. CRPropa 3.2 features a novel algorithm which updates the direction of the particles emitted by a source according to the (non-)detections of smaller sample of events. This can lead to substantial performance gains depending on the scenario of interest, of up to four orders of magnitude [36].
Boris Push Algorithm. The transport of individual charged particles across a magnetised environment was currently done in CRPropa using the Cash-Karp algorithm [37]. In CRPropa 3.2 we implemented an additional algorithm, the Boris push [38], widely used in plasma physics thanks to its speed and accuracy. Both algorithms support adaptive step sizes.
Enhanced Interpolation Methods. Turbulent magnetic fields are often stored in grids before usage. When modelling the propagation of charged particles, the magnetic field is interpolated and the trajectory of the particle is corrected according to this value. The grids have to cover large distances whilst resolving small scales, such that poor interpolation methods could lead to miscalculation of particle trajectories [39]. For this reason, three-dimensional grids in CRPropa can now be interpolated using more alternative methods such as nearest-neighbour, trilinear, and tricubic interpolations. The optimal choice is a compromise between accuracy and performance, and it depends on the specific problem.

Applications
In this section we present a few applications of CRPropa to various problems. Some of the examples highlight the novel features of CRPropa 3.2.

Cosmic-Ray Diffusion at the Edge of the Galaxy
CRPropa can be used to study the propagation of CRs in the Milky Way and its outskirts including processes such as advection and adiabatic effects. Here, we show an example in which a Galactic termination shock re-accelerates over 10 8 years 1-10 PeV CRs blown out by the Galactic wind. Naturally, the energy gain depends on the magnetic field of the Galactic halo which. In this case, it is the recently-implemented Archimedean spiral. These results have immediate implications for understanding the end of the Galactic CR spectrum and the transition to the extra-galactic component. Figure 1 shows the time evolution of the CR spectrum just outside the Galaxy. For more details see ref. [40].

Cosmological Propagation of Gamma Rays
With the new modules for electromagnetic interactions recently added to CRPropa, it is possible to simulate a wide variety of scenarios. An interesting application is the study of gamma-ray induced electromagnetic cascades in intergalactic space. This includes effects such as absorption by the extragalactic background light (EBL) and the deflection of electron-positron pairs by intergalactic magnetic fields (IGMF) [41]. One such example is shown in fig. 2, in which we simulate the propagation of gamma rays through turbulent helical magnetic fields -another novel feature of CRPropa 3.2.

Multimessenger studies
CRPropa can self-consistently compute fluxes of multiple messengers compatible with UHECR observations, as done in, e.g., refs. [42,43]. In the left panel of fig. 3 we illustrate these capabilities by presenting a fit to the observations by Auger at energies 10 18.7 eV. We consider all relevant photohadronic interactions, namely photopion production, photodisintegration and Bethe-Heitler pair production with the CMB and the EBL. The cosmogenic neutrino fluxes associated with this scenario are shown in the right panel. For more details, the reader is referred to ref. [43]. Besides fluxes, correlations of arrival directions between multiple messengers can be computed self-consistently as well, as done in, e.g., ref. [44].

Particle Acceleration
To illustrate how CRPropa can treat particle acceleration, we consider the case of CRs being accelerated by a source with a Kolmogorov magnetic field power spectrum. The velocity of the scattering centres is assumed to be = 0.1. The simulation takes as argument the scattering length by plasma waves ( min ), which is approximately constant for Larmor radii much smaller than the maximum magnetic turbulence injection scale. The spectrum of accelerated CRs is shown in fig. 4 for several values of min .

Conclusions and Outlook
To interpret current astrophysics observations at high-and ultra-high energies, detailed theoretical models with multiple types of messengers are necessary to obtain a self-consistent picture of the Universe across many decades in energy. CRPropa 3.2 is a simulation framework with a broad scope that enables such studies. Our recent developments make substantial technical improvements to optimise the code performance in simulations with magnetic fields, whether in the Milky Way or outside of it. They also extend the range of possible applications of CRPropa by treating particle acceleration, by implementing powerful tools for transporting cosmic rays in the diffusion regime, by adding new channels for the production of photons, and by implementing a native treatment of electromagnetic interactions. Here, we illustrated some applications of CRPropa to a variety of problems involving the propagation of CRs, gamma rays, electrons, and neutrinos with energies from ∼ GeV (or TeV, in the case of CRs) up to ZeV. This consolidates CRPropa as a comprehensive framework for high-energy studies in various astrophysical environments.
Some of the latest developments were already released in the current version, whereas the others will be part of the upcoming CRPropa 3.2. More information about CRPropa can be found in our webpage: https://crpropa.desy.de.