diff --git a/docs/paper/the-karl-code/paper.tex b/docs/paper/the-karl-code/paper.tex index 38a8746..96d40e8 100755 --- a/docs/paper/the-karl-code/paper.tex +++ b/docs/paper/the-karl-code/paper.tex @@ -106,7 +106,7 @@ \changed{A new parallelized simulation code is presented, which uses a semi classical Monte Carlo method to determine particle spectra in the KATRIN source. Reaction chains are generated from the decay of tritium within the source. The code includes all relevant processes: elastic scattering, ionization, excitation (electric, vibrational, rotational), recombination and various clustering processes. The main emphasis of the code is the calculation of particle spectra and particle densities and currents at specific points within the source. It features a new technique to determine these quantities. It also calculates target fields for the interaction of particles with each other as it is needed for recombination processes.\\ The code has been designed for the KATRIN experiment but is easily adaptable for other tritium based experiments like Project 8. Geometry and background tritium gas flow can be given as user input.\\ -The code is parallelized using MPI and writes output using HDF5. Input to the simulation is read from a JSON description that provides general information on the simulation (resolution of the simulation domain).% and the various optional features of the code, namely user defined species with their own terminator, interaction types, movers and initialization. +The code is parallelized using MPI and writes output using HDF5. Input to the simulation is read from a JSON description that provides general information on the simulation (resolution of the simulation domain) and the various optional features of the code, namely user defined species with their own terminator, interaction types, movers and initialization. } %A new parallelized simulation code is presented, which uses a semi classical Monte Carlo method to determine particle spectra in the KATRIN source by tracking single particles from interaction to interaction. The moved distance is determined from the mean free path (MFP) and subsequently from cross sections and particle densities. Particle densities can be provided by the user, or are calculated during simulation from the movement of the simulated particles. This enables also the inclusion of recombination effects in the calculation. The implemented interaction types include elastic scattering, ionization, clustering and excitation (electric, vibrational, rotational) and recombination. Initial particles are created using the neutral gas density and known $\upbeta$-decay spectrum. The code is optimized for the conditions in the KATRIN source, being able to cope with a large density gradient, neutral gas flow and many different particle species in a Tritium environment. @@ -164,20 +164,22 @@ The atomic and molecular processes produce secondary particles which may subsequ Two different methods of descriptions seem obvious: a description through the temporal evolution of phasespace elements and a description through the Monte Carlo method by tracking of single particles \citep{MOBUS2001519}. \changed{The first method impresses with a high resolution in space and velocity but is very computational intensive, especially with many different interaction types and species. A comparison with Monte Carlo type simulations is complicated: Since this would not be a statistical method the noise is negligble, but the requirements to save the phase-space distribution (specifically for high velocities) are extremely high. Thus, it was rejected for the simulation of the problem at hand. However, in a classical Monte Carlo scheme each of the simulated events is independent of the others. This is not possible if direct interactions (e.g. recombination) between electrons and ions are of interest.} This problem is addressed in the KARL code, which is presented in the this paper. -\changed{The simulation approach presented in this paper and realized through the KARL code works under the assumption that all atomic and molecular processes are fast compared to the plasma processes. Using a Monte Carlo like approach the effects of different processes are taken into account and produce energy spectra of different species. These spectra will be utilized to calculate plasma potentials elsewhere. Resulting plasma potentials can then be fed back into the KARL code.} +\changed{The simulation approach realized through the KARL code works under the assumption that all atomic and molecular processes are fast compared to the plasma processes. Using a Monte Carlo like approach the effects of different processes are taken into account and energy spectra of different species are produced. These spectra will be utilized to calculate plasma potentials elsewhere. Resulting plasma potentials can then be fed back into the KARL code to obtain refined particle distributions.} -\changed{The experimental setup of the KATRIN experiment is used as the default setup in the code. Other experiments using tritium decay may be easily implemented as the geometry and injection characteristics can be modified. This applies particularly to the Project 8 experiment \citep{2022arXiv220307349P}. Within the KARL framework the majority of all tritium reactions are implemented, but some reactions that occur in vastly different parameter regimes may not be implemented yet.} +\changed{The experimental setup of the KATRIN experiment is used as the default setup in the code. Other experiments using tritium decay may easily be implemented as the geometry and injection characteristics can be modified. This applies particularly to the Project 8 experiment \citep{2022arXiv220307349P}. Within the KARL framework the majority of all tritium reactions are implemented, but some reactions that occur in vastly different parameter regimes may not be implemented yet.} \section{Description of the method} \label{sec:method} -\changed{The general setup of the code is such that in the first place incident particles from tritium beta decay are tracked. In the simulation decays are successively processed. Meaning that each decay particle is followed until its destruction, with an optional creation of new secondary particles. All primary and secondary particles are processed before new decay particles are added. -The initial electron energy spectrum for electrons created by tritium beta decay is comparably simple to describe, as it follows the Fermi statistics of beta decay \citep{Fermi:1934aa}. -In the KARL code, single particles are tracked through the source from one interaction to another. The moved distance between interactions is determined from the mean free path. The performed interactions are drawn from a list of available interactions. -Through their interactions they form a reaction tree with subsequently generated secondary particles (or with pre-existing particles that change properties via the interaction). In order to follow all interactions of this tree each secondary particle forms a new ``branch''. Within the code newly generated particles are put into a list that is processed after the incident particle reaches the end of its lifetime.} +\changed{The general setup of the code is such that in the first place incident particles from tritium beta decay are tracked. In the simulation decay events are successively processed. Meaning that each decay particle is followed until its destruction, during which it might produce new, secondary particles. All primary and secondary particles are processed until termination before new decay particles are added. +The initial energy spectrum for electrons created by the tritium beta decay is comparably simple to describe, as it follows the Fermi statistics of beta decay \citep{Fermi:1934aa}. +In the KARL code, single particles are tracked through the source from one interaction to another. The moved distance between interactions is determined from the mean free path. The performed interactions are drawn from a list of available, user-specified interactions. +%Through these interactions decay particles form a reaction tree with subsequently generated secondary particles. %(or with pre-existing particles that change properties via the interaction). +%In order to follow all interactions of this tree each secondary particle forms a new ``branch''. +Newly generated particles are put into a list that is processed after the incident particle reaches the end of its lifetime.} -\changed{Apart from the decay process new particles are created mainly by ionization.} +\changed{Apart from the decay process new particles are created mainly through electron impact ionization.} \changed{Ionization produces two indistinguishable electrons with energies between \SI{0}{eV} and the impact energy subtracted by the ionization energy.} \changed{For electrons below \SI{100}{eV} elastic scattering is the dominant process, while for electrons above that energy ionization becomes dominant, see Figure~\ref{fig:et2_interactions}. Depending on the neutral gas density this can lead to a large amount of secondary electrons being created.} @@ -191,11 +193,11 @@ The KARL code is customized to the special conditions in the KATRIN source. Henc \subsection{General diagram} \label{ssec:general_diagram} -\changed{The main simulation cycle of the code consists of three subcycles, see Figure~\ref{fig:simulation_flow}.} +\changed{The main simulation cycle of the code consists of three subcycles, as shown in Figure~\ref{fig:simulation_flow}.} %After initialization (see section~\ref{ssec:initialization}), the simulation starts its iterative cycle, which contains three subcycles, see Figure~\ref{fig:simulation_flow}. The first addresses how many primary particles/events are processed, which is predefined by the user. It adds primary particles to the particle queue, if it is empty. In the second subcycle a particle is selected at random from the particle queue. This particle is processed until its termination and a new particle is selected from the queue. -Within the third subcycle, the actual particle treatment is performed. +Within the third subcycle, the \changed{particle movement and any interactions are performed}. %The particle tracking is divided into two alternating steps. First, the particle is moved according to the electromagnetic fields in the source and the mean free path of the particle. Secondly, an interaction is performed. For each movement step, the mean free path $\lambda_\text{mfp}$ of the corresponding particle is calculated through \citep{hussein2010radiation} @@ -203,7 +205,9 @@ For each movement step, the mean free path $\lambda_\text{mfp}$ of the correspon \label{eq:mean_free_path} \lambda_\text{mfp} = \frac{1}{\sum_i \sigma_i(E) n_i} \commaeq \end{equation} -where $E$ is the kinetic energy of the particle in the \changed{center of mass} frame, $\sigma_i$ is the cross section of a specific interaction, and $n_i$ the particle number density of the \changed{target of the specific interaction}. In the lab frame, the neutral gas has a non-zero drift velocity. The cross sections are evaluated from predefined functions. The particle number density of the interaction partner is calculated either from a predefined function for background species, or from the density field for tracked species, see section~\ref{ssec:denstiy_fields} and \ref{sec:implementation} for more information. The actual moved distance $d$ is a statistical quantity, which \changed{is} derived from the MFP through +where $E$ is the kinetic energy of the particle in the \changed{center of mass} frame, $\sigma_i$ is the cross section of a specific interaction, and $n_i$ the particle number density of the target. \changed{All three of these quantities are with respect to the interaction partner of the i-th interaction.} In the lab frame, the neutral gas has a non-zero drift velocity. The cross sections are evaluated from predefined functions. \changed{The particle number density is either calculated during the simulation for particle species that are simulated or through user input at the beginning of the simulation for particle species that act as a constant background population}. +%The particle number density of the interaction partner is calculated either from a predefined function for background species, or from the density field for tracked species, see section~\ref{ssec:denstiy_fields} and \ref{sec:implementation} for more information. +The actual moved distance $d$ is a statistical quantity, which \changed{is} derived from the MFP through \changed{ \begin{equation} d = -\lambda_\text{mfp} \cdot \log \eta \commaeq @@ -215,9 +219,13 @@ where $\eta \in (0, 1]$ is an uniform random number. % %This is due to an assumed Poisson random process, that results in an exponential probability distribution. -The particle is then moved by this distance $d$ in dependence on the electromagnetic fields inside the source, see section~\ref{ssec:movement}. During this step the density fields of the corresponding specie are updated. +The particle is then moved by this distance $d$ \changed{taking} the electromagnetic fields inside the source \changed{into consideration}. %, see section~\ref{ssec:movement}. +During this step the density fields of the corresponding specie are updated. -After the movement step it is evaluated if the particle needs to be terminated, which is mainly a check if the particle has left the simulation domain, or has hit a wall, see~\ref{ssec:termination}. If the particle is still alive, a random interaction is selected from the list of available interactions, weighted by its probability to occur. The probability scales with the cross section of that interaction and the interaction partner particle density. The corresponding interaction is performed and the interaction products, which \changed{do} not \changed{include} the current particle are added to the particle queue. If the particle does no longer exist after the interaction (through recombination or clustering) it is terminated, otherwise the next movement step is performed. +After the movement step it is evaluated if the particle needs to be terminated, which is mainly a check if the particle has left the simulation domain.%, or has hit a wall, see~\ref{ssec:termination}. +If the particle is still alive, a random interaction is selected from the list of available interactions, weighted by its probability to occur. The probability scales with the cross section of that interaction and the interaction partner particle density. The corresponding interaction is \changed{then} performed and the interaction products, which \changed{do} not \changed{include} the current particle, are added to the particle queue. If the particle does no longer exist after the interaction (through recombination or clustering) it is terminated, otherwise the next movement step is performed. + +\changed{The details of the implementation of the described components are described later in section~\ref{sec:implementation}.} \begin{figure}[tbp] \centering @@ -230,9 +238,9 @@ After the movement step it is evaluated if the particle needs to be terminated, \subsection{Density fields} \label{ssec:denstiy_fields} -In a general Monte Carlo simulation, each event is assumed to be independent of the other. However, different particles types can in general interact with each other, for example electrons and ions through recombination. Therefore, each Monte Carlo event in our simulation must be dependent on the other events. This dependence is mimicked in the simulation by so-called density fields. These density fields determine the number density of each particle specie during the simulation. These fields are then used to determine the MFP and are used in the selection of the interaction type. +In a general Monte Carlo simulation, each event is assumed to be independent of the other. However, different particles types can in general interact with each other, for example electrons and ions through recombination. Therefore, each event in our simulation must be dependent on the other events. This dependence is mimicked in the simulation by so-called density fields. These density fields determine the number density of each particle specie during the simulation. These fields are then used to determine the MFP and are used in the selection of the interaction type. -In the simulation, the source is \changed{split} into evenly spaced intervals in longitudinal, radial and azimuthal direction, predefined by the user, see Figure~\ref{fig:segmentation} for a schematic representation \changed{of the segmentation}. In each iteration step of the particle queue, it is recorded how long a particle with index $i$ stays in one of the predefined segments, labelled by the time $t_i$. The number density $n_\alpha$ of a species $\alpha$ is then proportional to the total time of all particles of the corresponding species spent in the segment $\sum_i t_i$ and the volume $V$ of the segment. In case of recombination, an additional term has to be added corresponding to the number of recombination $N_\gamma$ of the recombination partner $\gamma$ in the segment, resulting in +In the simulation, the source is \changed{split} into evenly spaced intervals in longitudinal, radial and azimuthal direction, predefined by the user, see Figure~\ref{fig:segmentation} for a schematic representation \changed{of the segmentation}. In each iteration step of the particle queue, it is recorded how long a particle with index $i$ stays in one of the segments, labeled by the time $t_i$. The number density $n_\alpha$ of a species $\alpha$ is then proportional to the total time of all particles of the corresponding species spent in the segment $\sum_i t_i$ and the volume $V$ of the segment. In case of recombination, an additional term has to be added corresponding to the number of recombination $N_\gamma$ of the recombination partner $\gamma$ in the segment, resulting in \begin{equation} n_\alpha = \frac{\sum_i t_i}{t_\text{sim} V} - \frac{N_\gamma}{V} \commaeq \label{eq:target_field_density} @@ -257,7 +265,7 @@ The second main objective of the code is to determine the particle currents in t \begin{equation} j = \frac{N^+ - N^-}{A \, t_\text{sim}} \commaeq \end{equation} -where $N^+$ and $N^-$ is the number of particles crossing the faces in positive and negative direction respectively, $A$ is the area of the face and $t_\text{sim}$ the simulated time, see~Eq.~\ref{eq:simulated_time}. For convenience, the location of the virtual barriers are chosen to coincide with the segment boundaries, see Figure~\ref{fig:segmentation}, of the density field calculation, see section~\ref{ssec:denstiy_fields}. +where $N^+$ and $N^-$ are the number of particles crossing the faces in positive and negative direction respectively, $A$ is the area of the face and $t_\text{sim}$ the simulated time, see~Eq.~\ref{eq:simulated_time}. For convenience, the location of the virtual barriers are chosen to coincide with the segment boundaries, see Figure~\ref{fig:segmentation}, of the density field calculation.%, see section~\ref{ssec:denstiy_fields}. \section{Description of the implementation} \label{sec:implementation} @@ -274,7 +282,8 @@ The tracked specie class is composed of different classes, providing access to t \subsection{Movement} \label{ssec:movement} -The movement of particles is outsourced to the mover class. It moves the particle dependent on the E/B fields at the position of the particle, given the integrated distance a particle will move, see section~\ref{ssec:general_diagram}. The movement itself is divided into smaller steps. This way, it can be evaluated if the particle has left the simulation domain between the steps, which stops the movement. Apart from the simulation boundary, the movement is stopped if the particle leaves a segment or energy bin of the density fields, see section~\ref{ssec:denstiy_fields}. No interaction will be performed afterwards, but a new distance will be drawn from the MFP at the new position of the particle, see equation~\ref{eq:distance_from_mfp}. This procedure does not increase the mean distance a particle travels, if the traversed density stays the same. However, large gradients will be taken into account in the calculation. Hence, the distance a particle moves is not over- or underestimated when moving into higher or lower density regions respectively. However, the density fields need a higher resolution than the density difference, which increases the simulation time. Thus, the user needs to evaluate the trade off between simulation time and accuracy. +The movement of particles is outsourced to the mover class. It moves the particle dependent on the E/B fields at \changed{its} position, given the integrated distance a particle will move, see section~\ref{ssec:general_diagram}. The movement itself is divided into smaller steps. This way, it can be evaluated if the particle has left the simulation domain between the steps, which stops the movement. Apart from the simulation boundary, the movement is stopped if the particle leaves a segment or energy bin of the density fields.%, see section~\ref{ssec:denstiy_fields}. +\changed{In this case} no interaction will be performed , but a new distance will be drawn from the MFP at the new position of the particle, \changed{according to} equation~\ref{eq:distance_from_mfp}. This procedure does not increase the mean distance a particle travels, if the traversed density stays the same. However, large gradients will be taken into account in the calculation. Hence, the distance a particle moves is not over- or underestimated when moving into higher or lower density regions respectively. However, the density fields need a higher resolution than the density difference, which increases the simulation time. Thus, the user needs to evaluate the trade off between simulation time and accuracy. Stopping the movement if a particle has left a density field segment has an additional benefit: it can be easily evaluated how long a particle has stayed in the segment. Each movement step the particle is alive, a counter variable is increased by the time the movement step took. If the movement is stopped this counter variable can be added to the corresponding density field segment. @@ -282,12 +291,15 @@ Two different kinds of movers are implemented (Boris, drift), which differ in th \paragraph{Boris mover} -The Boris mover uses the Boris push algorithm \citep{Penn.2003} for the movement step described in the previous paragraph (see \citep{Kellerer2022_1000143868} for a in depth description of the Boris push algorithm). However, the steps are not chosen by a given length but a given timestep $\Delta t$, which is needed as an input for the Boris push algorithm. The moved distance is calculated after the movement algorithm. This moved distance is then subtracted from the total distance the particle has still to move. When this distance is smaller than zero the movement will be ended. +The Boris mover uses the Boris push algorithm \citep{Penn.2003} for the movement step described in the previous paragraph (see \citep{Kellerer2022_1000143868} for a in depth description of the Boris push algorithm). However, the steps are not chosen by a given length but a given timestep $\Delta t$, which is needed as an input for the Boris push algorithm. The moved distance is calculated after the movement \changed{step}. This distance is then subtracted from the total distance the particle has still to move. When this distance is smaller than zero the movement will be ended. -The timestep has to be provided by the user. It should be based on the highest gyro frequency possible in the simulation domain $\Omega_{g,\text{max}}$ and fulfil +The timestep has to be provided by the user. \changed{In order to resolve the gyro-motion of all particles of a species, the timestep should be chosen depending on the highest possible gyro frequency $\Omega_{g,\text{max}}$ of that specie. Thus } +%It should be based on the highest gyro frequency possible in the simulation domain $\Omega_{g,\text{max}}$ and fulfil \begin{equation} - \Delta t < \frac{1}{\Omega_{g,\text{max}}} \fullstop +\label{eq:boris_timestep_requirement} + \Delta t < \frac{1}{\Omega_{g,\text{max}}} \end{equation} +\changed{should be fulfiled.} This timestep is also used for the determination of the time a particle spends in a density field segment, see previous section. The Boris push algorithm was chosen, because it is numerically stable with high precision and efficiency \citep{Kilian.2015}. The method can be used for low relativistic particles, up to a gamma factor of $\gamma \approx 1000$ \citep{Vay.2008}. At the KATRIN experiment, only electrons of energies up to \SI{32}{keV} (Krypton conversion electrons) are created. This results in a gamma factor of $\gamma = 1.06$, which is well below the limit of the Boris push. @@ -296,7 +308,7 @@ The Boris push algorithm was chosen, because it is numerically stable with high The drift mover is based on the description of the movement of the particle around its gyrocenter and the drift movement of the gyrocenter, see \citep{Chen.1984}. In the current version of the code, the drift mover should only be used for a constant magnetic field. No magnetic field gradients are considered, because the magnetic field at KATRIN is constant over most parts of the source \citep{Kellerer2022_1000143868}. -In the drift mover, the movement is divided into smaller steps, given by the smaller value of the maximal step length $d_\text{max}$ (provided by the user) and the leftover distance the particle has still to move. The movement is ended, when the leftover distance is zero. Each movement step \changed{is} subdivided into the change of the particle position and the change of the velocity, both described in the following. +In the drift mover, the movement is divided into smaller steps \changed{of length $\Delta x$}, given by the smaller value of the maximal step length $d_\text{max}$ (provided by the user) and the leftover distance the particle has still to move. \changed{The distance $d_\text{max}$ should be chosen smaller than the smallest extent of a segment. Otherwise time spent in a new segment might not be correctly attributed or certain segments might even be skipped completely.} The movement is ended, when the leftover distance is zero. Each movement step \changed{is} subdivided into the change of the particle position and the change of the velocity, both described in the following. The position change is described by the movement around the gyrocenter $\Delta \mathbf{x}_\text{c}$, the movement of the gyrocenter parallel to the magnetic field $\Delta \mathbf{x}_\parallel$ and the drift movement of the gyrocenter $\Delta \mathbf{x}_\text{D}$. @@ -322,7 +334,7 @@ The position change around the gyrocenter is calculated in three steps. First, t \begin{equation} r_\text{g} = \frac{m \abs{\mathbf{v}_\perp}}{q \abs{\mathbf{B}}} \commaeq \end{equation} -from the magnitude of the perpendicular velocity, the particle mass $m$ and charge $q$, which in turn is then used to determine the vector from the particle to the gyrocenter $\mathbf{x}_\text{pc}$ +from the magnitude of the perpendicular velocity $abs{\mathbf{v}_\perp}$, the particle mass $m$ and charge $q$, which in turn is then used to determine the vector from the particle to the gyrocenter $\mathbf{x}_\text{pc}$ \begin{equation} \mathbf{x}_\text{pc} = - r_\text{g} \frac{\mathbf{v}_\parallel \times \mathbf{v}_\perp}{\abs{\mathbf{v}_\parallel \times \mathbf{v}_\perp}} \fullstop \end{equation} @@ -352,6 +364,23 @@ where $\mathbf{E}_\parallel$ is the electric field parallel to the magnetic fiel The rotation of the perpendicular velocity is again calculated using Rodriges' rotation formula with the axis of rotation $\mathbf{v}_\parallel$ and angle of rotation $\Delta \theta$. +\changed{ +\paragraph{Comparison} +The choice of which mover algorithm with which parameters should be used for which particle specie is a complex one. An estimate for when both algorithms should take the same amount effort can be made by comparing the distances moved by the particle during one movement step. If the distance for the Boris mover $d_\text{Boris}$ is larger than the user-defined distance $d_\text{Drift}$, then the Boris version has a better performance. +The distance $d_\text{Boris}$ can be estimated using the timestep $\Delta t$ and the typical velocity $v_{typ}$ of the considered particle species through +\begin{equation} +\label{eq:boris_distance_estimate} +d_\text{Boris} \approx v_{typ}\Delta t \overset{Eq. \ref{eq:boris_timestep_requirement}}{<} \frac{v_{typ}}{\Omega_{g, \text{max}}} \fullstop +\end{equation} +Using the requirement $d_\text{Drift} < d_\text{Boris}$ and the formula for the gyro-frequency one arrives at +\begin{equation} +\label{eq:magneticField_req_boris} +B_\text{max} < \frac{v_{typ} m}{q d_\text{Drift}} \commaeq +\end{equation} +as a threshold for the magnetic field for which the Boris mover outperforms the Drift mover. For electrons originating from a beta decay (approximately \SI{20}{\kilo eV}) and $d_\text{Drift} = \SI{1}{\mm}$ this leads to a value of $B_\text{max} \approx \SI{470}{\milli\tesla}$. For a thermal population of T$_2^+$ at \SI{80}{\kelvin} with the same value for $d_\text{Drift}$ the value is $B_\text{max} \approx \SI{21}{\milli\tesla}$, and for thermal electrons the value is even lower. Since the magnetic field in the KATRIN experiment is \SI{2.5}{\tesla}, the Drift mover is in any case the more efficient choice. +} + + \subsection{Termination} \label{ssec:termination} @@ -414,7 +443,7 @@ The elastic scattering class is initiated using the cross section, the target sp During evaluation of the scattering angle, the energy bin is determined and the corresponding angle distribution selected. The scattering angle is then drawn from \changed{this} angle distribution \changed{using a piecewise linear distribution}. -%Note: Somewhere the struture for input files has to be explained! +%Note: Somewhere the struture for input files has to be explained! -> explain in README, short desc. in text here In some cases, there is not enough data from one source alone, to cover the whole impact energy range. This is the case for the scattering of electrons with tritium molecules. At high energies, the scattering angle distribution is determined from external simulation \citep{Kellerer_2022}, at lower energies isotropic scattering can be assumed. \changed{For these cases, the scattering angle distribution can be composed using the known distributions and a threshold energy defining point of transition between the distributions.} %For these cases, the angle can be determined through the composition of two distributions. @@ -674,10 +703,6 @@ Ions on the other hand are created with thermal energies of the neutral gas and The spectrum shows very clearly that all processes for the particles interact in a non-trivial manner. It is therefore necessary to use a sophisticated tool like KARL to simulate their behaviour inside the KATRIN source. -\subsection{Comparison to other Monte Carlo tools} - -To our knowledge KARL is the only freely available Monte Carlo simulation for tritium based experiments. There are however other attempts to model the processes inside the KATRIN experiment - \section{Build instructions} In order to compile the source code of KARL, download the code on a Unix system and follow the instructions in the README file. The necessary dependencies are listed in the REQUIRED file. A sample configuration file (test\_parameter.json) can be found in the KARL folder simulation\_config.