diff --git a/docs/paper/the-karl-code/paper.tex b/docs/paper/the-karl-code/paper.tex index 494c84f..90fb605 100755 --- a/docs/paper/the-karl-code/paper.tex +++ b/docs/paper/the-karl-code/paper.tex @@ -88,12 +88,12 @@ \author[a]{Jonas Kellerer} \author[b]{Christian Sendlinger} - \author[c]{Felix Spanier \corref{author}} + \author[b]{Felix Spanier \corref{author}} \cortext[author] {Corresponding author.\\\textit{E-mail address:} felix@fspanier.de} \address[a]{Institut f\"ur Astroteilchenphysik, KIT, Hermann-von-Helmholtz-Platz 1, 76344 Eggenstein-Leopoldshafen, Germany} - \address[bc]{Institut f\"ur Theoretische Astrophysik, Universit\"at Heidelberg, Albert-Ueberle-Str. 2 und Philosophenweg 12, + \address[b]{Institut f\"ur Theoretische Astrophysik, Universit\"at Heidelberg, Albert-Ueberle-Str. 2 und Philosophenweg 12, 69120 Heidelberg, Germany} \begin{abstract} @@ -127,12 +127,12 @@ A new parallelized simulation code is presented, which uses a semi classical Mon {\em Programming language:} C++ \\ {\em Computer:} any workstation or cluster that has a modern C++ compiler (e.g. g++ 8.2 or later) an MPI implementation and the required external libraries \\ {\em Operating system:} Linux / Unix \\ - {\em RAM:} depending on problem size and number of resolved species between 100 MB and 2 GB; some scratch space + {\em RAM:} depending on problem size and number of resolved species between 100 MB and 2 GB; some scratch space \\ {\em Number of processors used:} depending on problem size between one and a few hundred processors \\ {\em Keywords:} semi-classical Monte Carlo \\ {\em Classification:} 19.1 Atomic and Molecular Processes \\ %Classify using CPC Program Library Subject Index, see ( % http://cpc.cs.qub.ac.uk/subjectIndex/SUBJECT_index.html) {\em External routines/libraries:} C++ compiler (tested with g++ 8.2 and 9.4.0), MPI 1.1 (tested with OpenMPI 3.1), HDF5 with support for parallel I/O (tested with version 1.10.0), Blitz++ (tested with version 1.0.2), Jansson (tested with version 2.12 and 2.13)\\ - {\em Nature of problem:} In the KATRIN experiment (and other experiments alike that feature large vessels filled with tritium) electrons from beta decay. These electrons interact with the ambient gas to produce secondary electrons through ionization. Subsequent processes including excitation, secondary ionization and collisions. The resulting electron and ion differential energy spectrum at various positions is relevant for further plasma analysis and the current of charged particles to the ends of the experiments is an observable. \\ + {\em Nature of problem:} In the KATRIN experiment (and other experiments alike that feature large vessels filled with tritium) electrons are created from beta decay. These electrons interact with the ambient gas to produce secondary electrons through ionization. Subsequent processes include excitation, secondary ionization and collisions. The resulting electron and ion differential energy spectrum at various positions is relevant for further plasma analysis, and the current of charged particles to the ends of the experiments is an observable. \\ {\em Solution method:} Semi-classical Monte Carlo \\ {\em Restrictions:} The geometry of the experiment is currently limited to the KATRIN experiment, but this may easily be changed.\\ {\em Unusual features:} The configuration is stored in JSON files. \\ @@ -144,22 +144,22 @@ A new parallelized simulation code is presented, which uses a semi classical Mon \section{Introduction} \label{sec:intro} -The KATRIN experiment is designed to measure the electron neutrino mass to unprecedented sensitivity down to \SI{0.2}{eV} \citep{KATRIN2005}. At the experiment, the mass is inferred from the shape of the $\upbeta$-decay spectrum of tritium. The contribution of the mass on the shape is most dominant in the endpoint region. The experiment can be divided into two parts: the source section and the detector section. In the source section, tritium gas is circulated which provides a high luminous stream of beta electrons. These electrons are magnetically guided to the detector section. There they are separated by their kinetic energy: one small stream being recorded by the detector, the other larger one reflected back to the source. +The KATRIN experiment is designed to measure the electron anti-neutrino mass to unprecedented sensitivity down to \SI{0.2}{eV} \citep{KATRIN2005}. At the experiment, the mass is inferred from the shape of the $\upbeta$-decay spectrum of tritium. The contribution of the mass on the shape is most dominant in the endpoint region. The experiment can be divided into two parts: the source section and the detector section. In the source section, tritium gas is circulated which provides a high luminosity stream of beta electrons. These electrons are magnetically guided to the detector section. There they are separated by their kinetic energy: one small stream being recorded by the detector, the other larger one reflected back to the source. -Both the initial and reflected stream of electrons interact with the gas in the source. For high energy electrons these interactions include mostly elastic scattering, but also ionization. Hence, much more electrons, and therefore also ions, are created in the source than from beta decay alone. The charged particle density is high enough, that a plasma forms in the source \citep{Kuckert.2016}. This plasma influences the high energy spectrum through its self generated, ab initio inhomogeneous potential. A precise knowledge of the electron and ion spectrum and density is necessary for any plasma analysis. +Both the initial and reflected stream of electrons interact with the gas in the source. For high energy electrons these interactions include mostly elastic scattering, but also ionization. Hence, many more electrons, and therefore also ions, are created in the source than from beta decay alone. The charged particle density is high enough, that a plasma forms in the source \citep{Kuckert.2016}. This plasma influences the high energy spectrum through its self generated, ab initio inhomogeneous electric potential. A precise knowledge of the electron and ion energy spectrum and density is necessary for any plasma analysis. The electron spectrum for high energy electrons is comparably simple to describe, as it follows the Fermi statistics of beta decay \citep{Fermi:1934aa}. However, it is much more complicated to describe for secondary electrons, leading to a Markov chain of events, with further branching event chains. First, new particles are created through ionization on the whole energy range. This creates a multitude of new possible branches with their own characteristics. Also other interactions become more dominant at lower energies, namely elastic scattering and excitation processes of the tritium molecules through electronic, rotational and vibrational excitation. All of these interactions create new branches with feedback to the initial branches. Additionally, electrons can also recombine the existing ions in the source. This process is not only dependent on the electron spectrum, but the ion spectrum as well. There are many different types of ions, which are created by clustering processes with the neutral gas. The neutral gas density, which is the dominant interaction partner for both electrons and ions, is not constant in the source, but ranges over more than three orders of magnitude over \SI{16}{m} \citep{Kuckert.2018}. Additionally, it has a position dependent mean drift velocity, also covering two orders of magnitude \citep{Kuckert.2018}. 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. The first method impresses with a high resolution but is very computational intensive, especially with many different interaction types and species. Thus, it was rejected for the simulation of the problem at hand. The Monte Carlo method seems preferable, but in a classical Monte Carlo scheme each of the simulated events is independent on the others. This is not the case for events for electron and ions tracks because of recombination. This problem is addressed in the KARL code, which is presented in the following paper. -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 is rolled from a list of available interactions. During movement it is recorded how long a particle stays within a predefined segment of the source. The density of the particle specie in this segment is then proportional to the cumulated time in that segment. Thus, the density can be determined during simulation. It can therefore also be used to evaluated the likeliness of recombination. +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 is drawn from a list of available interactions. During movement it is recorded how long a particle stays within a predefined segment of the source. The density of the particle specie in this segment is then proportional to the cumulated time in that segment. Thus, the density can be determined during simulation. It can therefore also be used to evaluated the likeliness of recombination. The KARL code is customized to the special conditions in the KATRIN source. Hence, special care is taken to ensure correct movement of particles through the large density gradient. Additionally, all relevant interactions in a tritium gas atmosphere are included for both electrons and ions. \section{Description of the method} \label{sec:method} -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 first, before new decay particles are added. 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. A detailed description of the simulation flow can be found in section~\ref{ssec:general_diagram}. The simulation ends until a predefined number of decays has been processed. During the simulation it is recorded how long a specific particle resides in predefined sections of the source and how often a particle crosses from one section to another. Both quantities can be used to calculate the particle density and particle currents in the source, see section~\ref{ssec:denstiy_fields} and \ref{ssec:current_collection}, which make up the result of the simulation. +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 first, before new decay particles are added. 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. A detailed description of the simulation flow can be found in section~\ref{ssec:general_diagram}. The simulation ends once a predefined number of decays has been processed. During the simulation it is recorded how long a specific particle resides in predefined sections of the source and how often a particle crosses from one section to another. Both quantities can be used to calculate the particle density and particle currents in the source, see section~\ref{ssec:denstiy_fields} and \ref{ssec:current_collection}, which make up the result of the simulation. \subsection{General diagram} \label{ssec:general_diagram} @@ -193,7 +193,7 @@ After the movement step it is evaluated if the particle needs to be terminated, 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 the simulation, the source is segmented into evenly spaced segments in longitudinal, radial and azimuthal direction, predefined by the user, see figure~\ref{fig:segmentation} for a schematic representation. 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 segmented into evenly spaced intervals in longitudinal, radial and azimuthal direction, predefined by the user, see figure~\ref{fig:segmentation} for a schematic representation. 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 \begin{equation} n_\alpha = \frac{\sum_i t_i}{t_\text{sim} V} - \frac{N_\gamma}{V} \commaeq \label{eq:target_field_density} @@ -234,7 +234,7 @@ 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 subdivided into in 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 rolled 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 underrated 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 the position of the particle, given the integrated distance a particle will move, see section~\ref{ssec:general_diagram}. The movement itself is subdivided into in 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 underrated 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. @@ -315,7 +315,7 @@ The rotation of the perpendicular velocity is again calculated using Rodriges' r \subsection{Termination} \label{ssec:termination} -The termination of particles is addressed by the terminator class. It checks for three different conditions. First it checks, if the particle has left the simulation geometry. For the KATRIN experiment the geometry can be approximated by a cylinder. However, the radius and height can provided by the user for special analysis. Second, the terminator class checks if the particle has exceeded the user defined number of maximal interactions. This counter was added, to ensure that no trapped particles are tracked by the simulation. Otherwise the simulation would not end. This trap can occur for example through opposite neutral gas flow and reflection by electric fields. Third, the terminator class checks if the particle has exceeded the user defined lifetime. This counter ensures, that particles are not stored indefinitely. This could occur through special configuration of magnetic and electric fields. +The termination of particles is addressed by the terminator class. It checks for three different conditions. First it checks, if the particle has left the simulation geometry. For the KATRIN experiment the geometry can be approximated by a cylinder. However, the radius and height can be provided by the user for special analysis. Second, the terminator class checks if the particle has exceeded the user defined number of maximal interactions. This counter was added, to ensure that no trapped particles are tracked by the simulation. Otherwise the simulation would not end. This trap can occur for example through opposite neutral gas flow and reflection by electric fields. Third, the terminator class checks if the particle has exceeded the user defined lifetime. This counter ensures, that particles are not stored indefinitely. This could occur through special configuration of magnetic and electric fields. In addition to the terminator class, the user can choose to add a deletion logger to the specie class. This class is evoked if the particle is deleted. It stores information on the type of deletion, namely if the particle has hit a wall, recombined, formed a cluster, or exceeded the maximum time alive or maximum number of interactions. These values are also added to the output of the simulation. So, the can either be used for debugging, but they can also be used for physical results. For example, the number of recombinations provides an insight if recombination is a dominant process. @@ -324,13 +324,13 @@ In addition to the terminator class, the user can choose to add a deletion logge Interactions of particles are processed in the interaction class. Additionally, it is used to provide access to the cross section of the interaction and the macroscopic cross section, which can be used in the calculation of the MFP and in the selection of the interaction, see section~\ref{ssec:general_diagram}. The interaction class itself is an interface class. The details of the interaction are implemented in the derived classes. This way it is easy to add more types of interactions in the future. All interactions are initiated using a given cross section and target specie. For the cross section, we decided to use a one dimensional functional. This way the user can either specify an implemented cross section to be used, or can also provide an own function in the configuration file, see section~\ref{ssec:initialization}. The target specie can either be a tracked or background specie. This allows for a high flexibility of the interaction class. -Currently there are seven types of interactions implemented: elastic scattering, clustering, recombination, free movement, charge exchange, excitation, ionization. In general, all types can the added to all species. However, the user has to decide if the specific use is sensible. In the following, the implementation of each interaction will be described. For the physical explanation, please refer to \citep{Kellerer_2022}. +Currently there are seven types of interactions implemented: elastic scattering, clustering, recombination, free movement, charge exchange, excitation, ionization. In general, all types can be added to all species. However, the user has to decide if the specific use is sensible. In the following, the implementation of each interaction will be described. For the physical explanation, please refer to \citep{Kellerer_2022}. \paragraph{Elastic scattering} -The elastic scattering class is initiated using the cross section, the target specie and a scattering angle distribution. This distribution can be used to roll a scattering angle, given the energy of the incoming particle. It can be set to an isotropic distribution, to a distribution provided by a file and a composite of distributions. For the distribution from a file, the angle distribution has to be provided given an energy binning. During evaluation of the scattering angle, the corresponding energy bin is determined and the corresponding angle distribution selected. The composite of distributions is used in cases, where there is data for a certain energy range, but not in the other. This is the case for the scattering of electrons of tritium molecules. At high energies, the scattering angle distribution is determined from external simulation \citep{Kellerer_2022}, at lower energies isotropic scattering is assumed. +The elastic scattering class is initiated using the cross section, the target specie and a scattering angle distribution. This distribution can be used to draw a scattering angle, given the energy of the incoming particle. It can be set to an isotropic distribution, to a distribution provided by a file and a composite of distributions. For the distribution from a file, the angle distribution has to be provided given an energy binning. During evaluation of the scattering angle, the corresponding energy bin is determined and the corresponding angle distribution selected. The composite of distributions is used in cases, where there is data for a certain energy range, but not in the other. This is the case for the scattering of electrons of tritium molecules. At high energies, the scattering angle distribution is determined from external simulation \citep{Kellerer_2022}, at lower energies isotropic scattering is assumed. -The interaction itself is performed in multiple steps. First, the velocity of a target particle is determined. It is compound of the drift velocity of the species and a velocity, which is rolled from the underlying velocity distribution. For the tritium gas, the drift velocity is determined in external simulation and the velocity distribution is given by a Maxwell-Boltzmann distribution \citep{Kellerer_2022}. For tracked particles the drift velocity is assumed to be zero and the velocity distribution is given by the density field. The velocity of the target particle is used to determine the impact energy in the laboratory frame. This energy is then used for the evaluation of the azimuthal scattering angle $\theta$. A second scattering angle is rolled in the interval $[0, 2\pi)$, responsible for the change of momentum in polar direction. Both angles and the target velocity are then used to rotate the velocity vector of the impact particle in the centre of mass frame, see \citep{Kellerer_2022} for the full calculation. This rotated velocity is then used as the new velocity of the impact particle. +The interaction itself is performed in multiple steps. First, the velocity of a target particle is determined. It is compound of the drift velocity of the species and a velocity, which is rolled from the underlying velocity distribution. For the tritium gas, the drift velocity is determined in external simulation and the velocity distribution is given by a Maxwell-Boltzmann distribution \citep{Kellerer_2022}. For tracked particles the drift velocity is assumed to be zero and the velocity distribution is given by the density field. The velocity of the target particle is used to determine the impact energy in the laboratory frame. This energy is then used for the evaluation of the azimuthal scattering angle $\theta$. A second scattering angle is drawn in the interval $[0, 2\pi)$, responsible for the change of momentum in polar direction. Both angles and the target velocity are then used to rotate the velocity vector of the impact particle in the centre of mass frame, see \citep{Kellerer_2022} for the full calculation. This rotated velocity is then used as the new velocity of the impact particle. \paragraph{Clustering} The clustering class is initiated using the cross section, the target specie and the specie, which is the result of the clustering process. In the interaction itself it is assumed that the new particle follows the direction of movement of the target particle, but with different absolute velocity. The new absolute velocity is calculated from the velocity of a target particle and the new particles mass. The velocity of a target particle is determined analogue to its calculation in elastic scattering. @@ -350,11 +350,11 @@ The excitation class is initiated using the cross section, the target specie and \paragraph{Ionization} The ionization class is initiated using the cross section, the target specie, the new electron specie, the new ion specie, the ionization energy and distribution and the scattering angle distribution. It is developed for ionization of the target specie by impact of a particle, which is much lighter than the target. However, the code does not check for this condition. -In the interaction, first the velocity of a target particle is determined analogue to its calculation in elastic scattering. Then, the impact energy in the laboratory frame $E_\text{i}$ is calculated. If the impact energy is below the ionization energy $E_\text{ion}$, no ionization could occur and a new target particle velocity is rolled. This procedure can take a long time. However, the cross section of ionization decreases significantly before the ionization energy. Thus, very few particles with energies close to the ionization energy will undergo ionization, which will therefore not increase the simulation time significantly. When a suitable target particle velocity is determined, the impact energy is used in the ionization energy distribution to roll the impact energy after collision $E_\text{i}^\text{new}$. The energy of the new electron $E_\text{e}$, also called ejected electron in the following, then follows through +In the interaction, first the velocity of a target particle is determined analogue to its calculation in elastic scattering. Then, the impact energy in the laboratory frame $E_\text{i}$ is calculated. If the impact energy is below the ionization energy $E_\text{ion}$, no ionization could occur and a new target particle velocity is drawn. This procedure can take a long time. However, the cross section of ionization decreases significantly before the ionization energy. Thus, very few particles with energies close to the ionization energy will undergo ionization, which will therefore not increase the simulation time significantly. When a suitable target particle velocity is determined, the impact energy is used in the ionization energy distribution to draw the impact energy after collision $E_\text{i}^\text{new}$. The energy of the new electron $E_\text{e}$, also called ejected electron in the following, then follows through \begin{equation} E_\text{e} = E_\text{i} - E_\text{ion} - E_\text{i}^\text{new} \fullstop \end{equation} -Next, the direction of movement has to be determined. For both the impact particle and the ejected electron, the direction of movement is calculated as a rotation of the impact velocity in the laboratory frame by the polar and azimuthal angle, with scaling of their kinetic energy respectively. The polar angle of the impact particle $\phi_\text{i}$ is rolled in the interval $[0,2\pi)$. The ejection direction of the new electron is set to the opposite direction. Thus, the polar angle of the ejected electron $\phi_\text{e}$ is calculated from +Next, the direction of movement has to be determined. For both the impact particle and the ejected electron, the direction of movement is calculated as a rotation of the impact velocity in the laboratory frame by the polar and azimuthal angle, with scaling of their kinetic energy respectively. The polar angle of the impact particle $\phi_\text{i}$ is drawn from the interval $[0,2\pi)$. The ejection direction of the new electron is set to the opposite direction. Thus, the polar angle of the ejected electron $\phi_\text{e}$ is calculated from \begin{equation} \phi_\text{e} = \phi_\text{i} - \pi \fullstop \end{equation} @@ -363,7 +363,7 @@ The azimuth angle of both particles is calculated, using the derivation of Gross \subsection{Calculation of fields} \label{ssec:field_calculation} -The density fields are implemented as a class. Each specie holds its own member of this class, which simplifies the evaluation of the fields during the simulation, for example for the calculation of the MFP. The class holds its information in member variables, which are the time particles of the species have spend in a segment of the source, the number of recombination in this segment and the derived density itself. They are represented as four dimensional arrays. The fastest axis (third axis) is used for the different energy bins. This reduces the calculation time of the determination of the density in a segment, which is mainly a sum over all energy bins. It is evoked multiple times during the particle update, which requires a fast calculation. The use of the other axis follows the consideration of how often the bin changes in longitudinal, azimuthal and radial direction. The magnetic field is most commonly aligned in longitudinal direction. Thus, the particles mostly travel in longitudinal direction. Therefore, the second fastest axis is used for the longitudinal direction. The other two directions are similar in their usage. Because of the magnetron drift in radial inhomogeneous magnetic fields, it was decided to use the azimuthal direction next, followed by the radial direction. +The density fields are implemented as a class. Each specie holds its own member of this class, which simplifies the evaluation of the fields during the simulation, for example for the calculation of the MFP. The class holds its information in member variables, which are the time particles of the species have spent in a segment of the source, the number of recombination in this segment and the derived density itself. They are represented as four dimensional arrays. The fastest axis (third axis) is used for the different energy bins. This reduces the calculation time of the determination of the density in a segment, which is mainly a sum over all energy bins. It is evoked multiple times during the particle update, which requires a fast calculation. The use of the other axis follows the consideration of how often the bin changes in longitudinal, azimuthal and radial direction. The magnetic field is most commonly aligned in longitudinal direction. Thus, the particles mostly travel in longitudinal direction. Therefore, the second fastest axis is used for the longitudinal direction. The other two directions are similar in their usage. Because of the magnetron drift in radial inhomogeneous magnetic fields, it was decided to use the azimuthal direction next, followed by the radial direction. The size of the arrays is derived from the user input. It is calculated from the desired number of segments and a build in under- and overflow. This way, if a particle can not be classified into one of the segments, the information is still recorded in the simulation. The energy bins are created in logarithmic scale with one bin each for under- and overflow. It can be set differently for each specie. Thus, important effects for each specie can be resolved more easily. In longitudinal direction, the bins are divided evenly with one bin each for under- and overflow. In general, these under- and overflow bins should not be filled during the simulation, because this would mean that a particle has left the simulation domain and is still alive. Hence, they can be used for debugging purposes. In radial direction, there is only an overflow bin, because the radius is lower bound to zero. In azimuthal direction no over- and underflow bins are used, due to the circular nature of the problem. @@ -375,7 +375,7 @@ The current collector is structured similar to the density field class. The diff \subsection{Injection} \label{ssec:injection} -The injection of new particles to the particle queue is managed by the injector class. It is initiated by providing the event position distribution, the mother drift velocity and a list of species, with their energy and injection angle distribution. The event position distribution is used to determine the position, at which the new particles are to be injected. For each injected specie, the kinetic energy is rolled through the energy distribution. The corresponding velocity vector is rolled from the injection angle distribution and scaled by the kinetic energy. This velocity is then boosted by the mother drift velocity, which represents the movement of the decaying gas. +The injection of new particles to the particle queue is managed by the injector class. It is initiated by providing the event position distribution, the mother drift velocity and a list of species, with their energy and injection angle distribution. The event position distribution is used to determine the position, at which the new particles are to be injected. For each injected specie, the kinetic energy is drawn from the energy distribution. The corresponding velocity vector is drawn from the injection angle distribution and scaled by the kinetic energy. This velocity is then boosted by the mother drift velocity, which represents the movement of the decaying gas. In the case of the KATRIN source, the injected species are electrons, with an isotropic injection angle distribution and a Fermi energy distribution \citep{Fermi:1934aa} and T$_2^+$ ions, also with an isotropic injection angle distribution, but with a Maxwell-Boltzmann energy distribution. The mother drift velocity is provided by the drift velocity of the neutral tritium gas. @@ -387,7 +387,7 @@ After the injection of particles, the timer class is provided with a time, which \subsection{Parallelization} \label{ssec:parallelization} -In order to obtain reasonable and robust results of the simulation, high statistics is necessary. This is especially the case, if also improbable effects like the excitation by rotation, should be visible in the results. The goal of high statistics can be reached by parallel computation. For the code, a simple parallelization strategy was used. The desired number of decays are distributed evenly on the cores, and each CPU core follows the simulation loop (see section~\ref{ssec:general_diagram}) independent from the others. The general setup of the simulation stays the same between CPU cores. However, a asset of the code is, that the Monte Carlo events of each particle track can be dependent on the other, for example in the case of recombination. In order to obtain this strong point, the number of desired events per CPU core are further subdivided into cycles with a fixed length. After each cycle, a synchronization step between the CPU cores is initiated. During the synchronization step, the data on the density fields is shared among all CPU cores. Since the simulation is set up the same for all CPU cores, this step only needs an additive operation on the array of cumulated times, see section~\ref{ssec:denstiy_fields}, and an additive step, to share the passed time. Additionally to the density field synchronization, also the data of the current borders and deletion loggers are synchronized, which is not strictly necessary, but keeps the data congruent on all CPU cores and makes the output step easier, see section~\ref{ssec:output}. +In order to obtain reasonable and robust results of the simulation, high statistics is necessary. This is especially the case, if also improbable effects like the excitation by rotation, should be visible in the results. The goal of high statistics can be reached by parallel computation. For the code, a simple parallelization strategy was used. The desired number of decays are distributed evenly on the cores, and each CPU core follows the simulation loop (see section~\ref{ssec:general_diagram}) independent from the others. The general setup of the simulation stays the same between CPU cores. However, an asset of the code is, that the Monte Carlo events of each particle track can be dependent on the other, for example in the case of recombination. In order to obtain this strong point, the number of desired events per CPU core are further subdivided into cycles with a fixed length. After each cycle, a synchronization step between the CPU cores is initiated. During the synchronization step, the data on the density fields is shared among all CPU cores. Since the simulation is set up the same for all CPU cores, this step only needs an additive operation on the array of cumulated times, see section~\ref{ssec:denstiy_fields}, and an additive step, to share the passed time. Additionally to the density field synchronization, also the data of the current borders and deletion loggers are synchronized, which is not strictly necessary, but keeps the data congruent on all CPU cores and makes the output step easier, see section~\ref{ssec:output}. The benefit of this parallelization scheme lies in its simplicity. It is easy to include more CPU cores for the calculation. Only the synchronization step takes slightly longer. However, the main simulation effort lies in the movement and interaction step. Thus, the synchronization does not play a significant role. Further more, there is no need of a CPU core, which directs tasks to the other CPU cores. Hence, little communication and data exchange is necessary between CPU cores, which saves calculation time. @@ -411,7 +411,7 @@ The output of the simulation is written to a single HDF5 file \citep{hdf5}, whic \subsection{Initialization} \label{ssec:initialization} -The initialization of the simulation it administered by the simulation class using generators which are available for classes, which need special user input. The specific build instructions have to be provided in a JavaScript Object Notation (JSON) file. Due to its hierarchical structure, it is easy to read, test and extend by the user, even with little programming experience. We use the Jansson library \citep{jansson} to read in the file. +The initialization of the simulation it administered by the simulation class using generators which are available for classes, requiring special user input. The specific build instructions have to be provided in a JavaScript Object Notation (JSON) file. Due to its hierarchical structure, it is easy to read, test and extend by the user, even with little programming experience. We use the Jansson library \citep{jansson} to read in the file. The JSON file is structured, such that each of the sections corresponds to one main idea of the code or class. Subsections are used, when the class is a composite of other classes. This way the parameter file stays extensible in the face of new methods and classes, which will be added in the future. A collection of JSON files for each generator is provided together with the code for easy usage. A selections of generators will be discussed in the following. @@ -437,8 +437,8 @@ The velocity distribution represents the idea, that a velocity vector can be sam There are three different energy distributions available in the code, the electron energy distribution of tritium decay (\textit{TritiumBetaDecay}), the Maxwell Boltzmann distribution (\textit{MaxwellBoltzmann}) and a constant distribution (\textit{Constant}). \begin{itemize} - \item \textit{TritiumBetaDecay}: The energy is rolled using the known Fermi distribution \citep{Fermi:1934aa} and the rejection method. - \item \textit{MaxwellBoltzmann}: The energy is rolled using the built in gamma distribution and an user defined temperature. + \item \textit{TritiumBetaDecay}: The energy is drawn using the known Fermi distribution \citep{Fermi:1934aa} and the rejection method. + \item \textit{MaxwellBoltzmann}: The energy is drawn using the built-in gamma distribution of the C++ standard library and an user defined temperature. \item \textit{Constant}: A single energy is returned for all calls to the class. \end{itemize} @@ -451,8 +451,8 @@ In the output section, it is defined, where the output file is stored and with w \begin{itemize} \item \textit{Interval}: Defines how often an output should occur. This can either be set to \textit{EachSync}, so each time the CPUs are synced the output is performed, or to a positive integer value. This value specifies the rate of output. So the number two would correspond to an output every second CPU synchronization step. - \item \textit{OverwriteLast}: Defines if each output should be stored on disk, or if each new output overwrites the last - \item \textit{Species}: Defines for which specie the output should be performed. It can either set to \textit{all}, or to a list of species given their specie name in the parameter file, eg. $[\text{electron}, \text{T2+}]$ + \item \textit{OverwriteLast}: Defines if each output should be stored on disk, or if each new output overwrites the last. + \item \textit{Species}: Defines for which specie the output should be performed. It can either set to \textit{all}, or to a list of species given their specie name in the parameter file, eg. $[\text{electron}, \text{T2+}]$. \end{itemize} \paragraph{RandomNumbers}