\chapter{Simulation of Particle Distributions with KARL} \label{ch:karl} The density and its energy distribution of all species defines the plasma in the \acs{katrin} source. The specific density distribution is dependent on the cross section of each interaction, the particle movement and the geometry of the source. Initially only beta electrons are created. Subsequent interactions with the surrounding gas create multiple other electrons and ions with varying energy. This scenario is best simulated using the Monte Carlo method. This method was implemented in the newly developed \ac{karl} computer code. This chapter focuses on the description of the algorithm and its first results. First, the simulation method will be described, where special focus will be laid on the particle movement and particle interactions. Second, the algorithm is used to provide a first insight into the density distributions of ions and electrons in the source. This first simulation will be performed without any electric background field. The electric field distribution is a priori unknown and will be determined later on. Third, simulation results will be presented, where the electric field was derived from a rear wall potential, see section~\ref{ssec:katrin:E_bg}, and from previous simulations with \acs{karl}. Parts of this chapter are submitted for publication in a separate paper together with F.~Spanier, see preprint \citep{ArxivKellerer.2021}. With the kind permission of F.~Spanier, a verbatim quotation was omitted in this chapter for better legibility. The initial idea of the algorithm was developed by F.~Spanier and a first version of \acs{karl} was created in collaboration with C.~Reiling in his master's thesis \citep{MasterReiling2019}. The computer code was extended, revised and tested in the context of this thesis. Differences in the description of the algorithm and its results between \citet{MasterReiling2019} and this work stem from corrections of erroneous calculations and additional extensions. \section{Simulation Method} \label{sec:karl_simulation_method} The \acs{karl} code uses a special approach of the Monte Carlo method. A sketch of the simulation procedure can be found in figure~\ref{fig:Chapter4_KARL/simulation_setup.pdf}. Each particle chain starts at the beta decay (particle injection), where the position of the new electron and corresponding ion is sampled from a neutral particle density distribution. The neutral density distribution is approximated from the simulated distribution from section~\ref{sssec:density_distribution}. The energy is sampled from the known Fermi spectrum of the beta decay, see Introduction. The beta decay particles are then added to the particle queue, and the simulation starts its iterative cycle. In each iteration step, a particle is selected randomly from the particle queue. The mean free path is determined from the interacting partner densities at the position of the particle and the energy of the particle. The particle is then moved according to the mean free path and the electromagnetic fields, see section \ref{ssec:karl_particle_movement}. If the particle hits the simulation boundaries, it will be deleted. Otherwise, an interaction is selected randomly from the available interactions, see section \ref{ssec:karl_particle_interactions}. The interaction products are added to the particle queue and the iteration starts from the beginning. The particle loop is repeated until there are no more particles in the particle queue. Then, new beta decay particles are created and processed until the specified target decay number is reached. \xfigure{tb}{1.}{Chapter4_KARL/simulation_setup.pdf}{Simulation procedure of KARL.}{Beta electrons are injected to the particle queue. A particle is picked from the queue and processed. The iteration step either ends in a particle interaction or through termination at the simulation boundaries. The particle queue is processed until no particle is left in the queue and a new beta particle is injected. The particle densities are determined during simulation.} The simulation is evaluated using two methods: virtual current borders and density fields, which provide energy dependent particle currents, and particle densities in relation to the position in the source, see sections \ref{ssec:karl_virtual_current_borders} and \ref{ssec:karl_density_fields}. The densities and currents are recorded for each particle specie during simulation. Thus, they can also be used to evaluate the interaction probability between two simulated particle species. In this way, two different particle species can interact with each other. The simulation of recombination of electrons and ions is therefore also possible. \FloatBarrier \subsection{Particle Movement} \label{ssec:karl_particle_movement} The particle movement is a central part of the simulation. Particles are moved from the original position to a new position depending on the mean free path and the electromagnetic fields in the source. The mean free path is calculated from the density of the target particles and the cross section of the interaction. The electromagnetic fields are provided prior to the simulation, and are considered constant over time. The movement of the particle is performed using the drift approximation algorithm, see equations~\ref{eq:drift_approx_x}, \ref{eq:drift_approx_y}, and \ref{eq:drift_approx_vperp}. In this algorithm, the motion of the particle is compound by a motion of the guiding center and the circular gyro motion around it. It is only applicable to systems where the magnetic field does not change during the particle movement. In the context of the \acs{karl} simulation, it is assumed that the magnetic field is constant over the whole source. Thus, the conditions to apply the drift approximation algorithm are met. A better approximation would be given by the Boris push algorithm, see also section~\ref{ssec:boris_push}. Caused by higher computational costs, this needs deeper investigation and could be part of future research. The movement of the particles is bound by the geometry of the source. For simulation, the \acs{katrin} source tube is approximated by a cylinder with an open end. Electrons are reflected there, which corresponds to the reflection of electrons at the \acs{dps} dipole electrodes or at the main spectrometer potential. All ions are removed at the \acs{dps} side. All other boundaries of the cylinder are considered perfect electric conductors. Thus, all particles hitting the cylinder walls will be removed directly from the simulation. \paragraph{Travelled Distance} Prior to the movement, it has to be determined how far a particle will travel before it will interact. The travelled distance $L$ is subject to random fluctuations, described by equation~\ref{eq:mean_free_path_probability}. This randomness is reflected in the code by a pseudo random number $\eta \in (0,1)$ and the mean free path $\lambda$. The travelled distance is calculated by \begin{equation} L = - \lambda \cdot \log \eta \fullstop \end{equation} The mean free path is determined through equation \ref{eq:mean_free_path} depending on the cross section of the interaction and density of the target particles. The mean free path of multiple competing interaction channels $i$ is given by \begin{equation} \lambda = \frac{1}{\sum_i \sigma_i n_i} \comma \end{equation} where $\sigma_i$ is the cross section and $n_i$ the density of the target particles. The cross section is dependent on the energy of the incident $E_i$ and target particle $E_t$. The transformation into the target frame is dependent on the incident angle $\theta$ of the interaction and its distribution $f(\theta)$. Thus, each contribution to the mean free path can be formulated as \citep{MasterReiling2019} \begin{equation} \sigma_i n_i = \frac{1}{\pi} \iint \mathop{dE_t} \mathop{d\theta} f(\theta) \sigma_i(E_t, E_i, \theta) \frac{dn_t}{dE_t}(E_t) \fullstop \label{eq:karl:movement_tmcs} \end{equation} In simulation it is assumed that the incident angle is isotropically distributed to reduce calculation effort. Furthermore, small and large incident angles are neglected. The transformation to the target frame can result in a vanishing energy otherwise, which in turn would result in an overestimation of the cross section toward lower energies. The energy distribution of the target density is collected in discrete bins. Therefore, the integral is not computed directly but replaced through a sum over all possible energy bins. The actual movement of the particle is subdivided into smaller steps with length $\Delta x$. This has two different reasons. First, the drift approximation algorithm assumes that the electric field does not change radically during the movement, see also next paragraph. Second, for the calculation of the mean free path, it was assumed that the density of the interaction partners does not change during the particle movement. The former can be guaranteed through a constraint on the step length $\Delta x$. It is required, that the step size is smaller than the step size of the electric field data. The latter is more difficult to incorporate in the algorithm. It would mean that the travelled distance is dependent on the difference in density during movement, which in turn is dependent on the travelled distance itself. This effect is negligible where the mean free path is much smaller than the typical distances where the density changes. This is the case for most particles with low energies in the center of the source. The cross section as well as the density is high enough in this case. The mean free path of beta electrons and particles near the \acs{dps} or rear wall is high enough, that the change of density is relevant. This issue can be addressed by considering the random nature of the movement. Any particle with the same velocity within a homogeneous cloud of other particles has the same chance to interact within a certain distance as the others. This probability is independent of the prior movement of the particles. So in simulation, the travelled distance will be determined anew, if the particle has moved to another section of the source, where the density is higher. A good measure for the position, where density has changed enough are the bin borders of the density fields, see section~\ref{ssec:karl_density_fields}. Thus, if a particle crossed from one density bin to another, the travelled distance will be determined again. This procedure also provides a limit on the step size $\Delta x$. It has to be smaller than the bin width of the density fields. \paragraph{Drift Approximation Algorithm} In the drift approximation algorithm, the movement of the particle can be described by the superposition of the movement of the guiding center and the gyro motion of the particle around the guiding center. The particle is moved in total by the distance $L$. Its motion is subdivided into small spatial steps $\Delta x$. Assuming that the magnetic field is directed in $z$-direction, the discretization of the spatial dimension can be translated into a discretization of the time domain to \begin{equation} \Delta t = \frac{\Delta x}{|\vec{v}^{i}|} \comma \end{equation} where $|\vec{v}^{i}|$ is the absolute velocity of the particle before moving. The position $z$ in longitudinal direction is then calculated by \begin{equation} z^{i+1} = z^{i} + v_\parallel^i \Delta t \comma \end{equation} where the index $i$ denotes the timestep at which the quantity is given and $v_\parallel^i$ is the velocity of the particle perpendicular to the magnetic field. The electric field during the motion is approximated by the mean of the field value at the original position and at the new position \begin{equation} \vec{E} = \frac{\vec{E}(z^{i+1}) + \vec{E}(z^{i})}{2} \fullstop \end{equation} This field is used to calculate the movement perpendicular to the magnetic field and used to determine the new velocity $v_\parallel^{i+1}$. The perpendicular particle position changes to \begin{eqnarray} x^{i+1} &= x^{i} + v_{\perp,x} \Delta t \label{eq:drift_approx_x}\\ y^{i+1} &= y^{i} + v_{\perp,y} \Delta t \label{eq:drift_approx_y}\comma \end{eqnarray} where $\vec{v_\perp}$ is given by \begin{equation} \vec{v_\perp} = \frac{\vec{E} \times \vec{B}}{B^2} \label{eq:drift_approx_vperp} \fullstop \end{equation} The parallel velocity changes corresponding to the Lorentz force to \begin{equation} v_\parallel^{i+1} = v_\parallel^i + \frac{q E_\parallel}{m} \Delta t \comma \end{equation} where $E_\parallel$ is the electric field strength parallel to the magnetic field, $m$ is the mass of the particle and $q$ its charge. \subsection{Particle Interactions} \label{ssec:karl_particle_interactions} After the particle is moved to a new position, an interaction will occur. The interaction type depends on the type of particle. Four different particles species can be distinguished in the simulation: electrons $\ce{e-}$, tritium ions \ce{T+}, tritium molecule ions \ce{T2+} and tritium cluster ions \ce{T3+}. Higher order cluster ions can in principle be used as well, but are not used in the current version of the code because of missing cross section data. Furthermore, it can be assumed from rate constant measurement, see section \ref{sec:particle_interactions_in_the_katrin_source}, that the density of higher order clusters is significantly lower than the density of \ce{T3+}. Thus, the impact of these ions on the simulation results should be small. Nevertheless, this should be further investigated outside this work's context. Each of the particle species have multiple different interaction channels, see section \ref{sec:particle_interactions_in_the_katrin_source}. The specific interaction channel at each interaction point is determined randomly, corresponding to the probability of the interaction channel. A measure for the probability that a specific channel is chosen is given by the inverse mean free path of the channel. The higher the inverse value, the higher the probability of that interaction. In \acs{karl}, a random number $\eta$ is drawn from the interval $[0, \sum_i \sigma_i, n_i]$, where $i$ denotes the different interaction channels. A specific interaction channel $j$ is used, where \begin{equation} \eta \geq \sum_i^j \sigma_i n_i \end{equation} is fulfilled. After the interaction channel is determined, the chosen interaction is performed.The interaction is represented either by a change in velocity, in position, or by addition of new particles. The implementation of the interaction depends on its type. The different variants will be presented in the following. \subsubsection{Elastic Scattering} \label{sssec:karl_elastic_scattering} Elastic scattering is the dominant interaction channel for all particle species. The velocity changes its direction but not its absolute value in the interaction. It can therefore be described by a rotation of the velocity vector. The rotation is characterized in spherical coordinates by the azimuth angle $\theta$ and polar angle $\phi$. The angle $\theta$ is given by the differential cross section $\frac{d\sigma}{d\theta}$, which is dependent on the particle type and the energy of the particle. Isotropic scattering is assumed for all ion interactions, and for all electron interactions below \SI{10}{eV}. The azimuth angle at higher energies is sampled from the differential cross section using the \acs{elsepa} code \cite{Salvat.2005}. Large and small scattering angles are suppressed in this case. The polar angle is sampled from a uniform distribution in the interval $[0,2\pi)$. This represents the polar symmetry of the interaction. The new velocity vector is derived through the following procedure: \begin{itemize} \item Roll the energy of the target particle from the density field at the position of the interacting particle. \item Convert the energy of the target particle to a velocity vector (isotropic distribution with an additive drift velocity). \item Transform the velocity of the primary particle to the center of mass frame. \item Roll azimuth angle $\theta$ and roll polar angle $\phi$. \item Rotate the primary velocity in the center of mass frame. \item Transform the velocity back to the laboratory frame. \end{itemize} The rotation of the velocity is performed using the procedure provided by Haghighat \cite{Haghighat.2014}, which is shortly summarized in the following. \newpage The initial velocity $\vec{v}$ can be expressed by \begin{equation} \vec{v} = v_x \vec{e_x} + v_y \vec{e_y} + v_z \vec{e_z} = |\vec{v}| (n_x \vec{e_x} + n_y \vec{e_y} + n_z \vec{e_z}) \comma \end{equation} where $n_i$ are the normal vector entries of the velocity. The normal vector can be transformed to a new basis, where the new $z$-axis is aligned with the unit vector. The new eigenvectors are \begin{align} \vec{e^\prime_x} &= \vec{e^\prime_y} \times \vec{e^\prime_z} \\ \vec{e^\prime_y} &= \frac{\vec{n} \times \vec{e_z}}{|\vec{n} \times \vec{e_z}|} \\ \vec{e^\prime_z} &= \vec{n} \fullstop \end{align} In this new base, the rotation can be performed trivially through \begin{align} \vec{n^\prime} = \sin \theta \cos \phi \, \vec{e^\prime_x} + \sin \theta \sin \phi \, \vec{e^\prime_y} + \cos \theta \, \vec{e^\prime_z} \comma \end{align} where $\vec{n^\prime}$ is the rotated unit vector. The reverse basis change then results in \begin{equation} \vec{n^\prime} = n_x^\prime \vec{e_x} + n_y^\prime \vec{e_y} + n_z^\prime \vec{e_z} \end{equation} with \begin{align} n_x^\prime &= -\left(\frac{n_x n_z}{\sqrt{n_x^2 + n_y^2}} \cos \phi + \frac{n_y}{\sqrt{n_x^2 + n_y^2} \sin \phi }\right) \sin \theta + n_x \cos \theta \\ n_y^\prime &= -\left(\frac{n_y n_z}{\sqrt{n_x^2 + n_y^2}} \cos \phi - \frac{n_x}{\sqrt{n_x^2 + n_y^2} \sin \phi }\right) \sin \theta + n_y \cos \theta \\ n_z^\prime &= \sqrt{n_x^2 + n_y^2} \cos \phi \sin \theta + n_z \cos \theta \fullstop \end{align} The new velocity vector in the original base is finally given by \begin{equation} \vec{v^\prime} = \vec{n^\prime} |\vec{v}| \fullstop \end{equation} With this procedure, the new velocity vector can hence be determined from the scattering angles and the initial velocity vector. The position of the primary target does not change through elastic scattering. Nevertheless, the guiding center of the movement changes its position during interaction. Thus, this change of the guiding center has to be reflected in the simulation as well. If the particles are moved by an algorithm, where the motion of the particle is resolved directly, like the Boris push algorithm, this effect is already included because the algorithm resolves each gyro motion of the particle. If the particle movement is described by the drift approximation algorithm, an additional change of the guiding center has to be added. This shift will be described in the following. Assume that the guiding center is located at the position $\vec{x}$. The new position of the guiding center $\vec{x^\prime}$ will be shifted after the interaction by the length $\Delta x$ with \begin{equation} \Delta x = 2 r_L \sin \left(\frac{\theta}{2}\right) \comma \end{equation} where $r_L$ is the gyro radius and $\theta$ the scattering angle, see figure \ref{fig:Chapter4_KARL/elastic_scattering_guiding_center.pdf}. The direction of the shift is in general dependent on the polar angle $\phi$ of the gyration. In the context of this thesis, it is assumed that there are many gyro motions between interactions, see section~\ref{ssec:characteristic_length_comparison}. Thus, the polar angle is determined randomly before the interaction from a random number $\eta \in [0,1)$. The new position is then given by \begin{equation} \vec{x^\prime} = (x + \Delta x \sin 2 \pi \eta ) \, \vec{e_x} +(y + \Delta x \cos 2 \pi \eta ) \, \vec{e_y} + z \, \vec{e_z} \end{equation} \xfigure{h}{1.}{Chapter4_KARL/elastic_scattering_guiding_center.pdf}{Change of the guiding center position during elastic scattering.}{The inital position $\vec{x}$ is moved to the new position $\vec{x^\prime}$. The absolute distance between the points is dependent on the Larmor radius $r_\text{L}$, and the scattering angle $\theta$, which is spanned between the two normal vectors of movement $\vec{n}$ and $\vec{n}^\prime$.} \subsubsection{Electron Impact Ionization} In the ionization process, an electron hits a neutral gas particle and creates another electron and an ion molecule (\ce{T2+}). This ion molecule can be stable, or it can dissociate spontaneously to \ce{T+}, see also section~\ref{ssec:electron_intreactions}. The cross section and threshold energy depends on the type of ionization process. \citet{Janev.2003} identified three different ionization channels. These channels are incorporated in \acs{karl}. \citet{Kim.1994} developed another effective model for the ionization process. The created ion in this case is considered stable. This model was also implemented for test purposes. In the interaction, two new particles are created alongside the original electron: an electron and an ion. The position of all three particles is considered to be the same position as the original electron. The velocity vector of the particles is however determined differently for the electrons and the ion. The velocity of the ion is sampled from the velocity distribution of the neutral gas. No recoil energy is added to the ion, due to the large mass difference of the ion and the electrons. The velocity of the electrons is determined in two steps. First, the energy of the electrons is calculated. Second, the scattering angles are established. There is a threshold energy for the reaction, the ionization energy. The remaining collision energy $T$ has to be divided between both electrons. The energy of the primary electron $E_p$ is sampled from the theoretical works of \citet{Kim.1994}, while the energy of the secondary electron follows directly from the energy of the primary and the collision energy ($E_s = T-E_p$). The scattering angles of the primary and the secondary electron are sampled from the semi empirical studies by \citet{Grosswendt.1978}. The polar angle $\phi_p$ of the primary electron is assumed to be uniformly distributed, while the polar angle of the secondary electron is given by $\phi_p - \pi$. The azimuth angle range of the primary electron is dependent on the energy. For small energies ($<\SI{100}{eV}$) it can be assumed that the angle is uniformly distributed in the range of $[0, \pi / 4)$. Similarly, the azimuth angle range of the secondary is dependent on the energy. For small energies ($E<\SI{50}{eV}$), it can be assumed that the angle is uniformly distributed in the range of $[0,\pi)$. In total, the new velocity vector of both electrons is determined from the generated energy and scattering angles. \newpage \subsubsection{Electron Impact Excitation} \label{sssec:karl:particle_interactions:excitation} Electrons can excite electrons of neutral gas particles, and both vibrational and rotational states of the gas molecules, see section \ref{sec:particle_interactions_in_the_katrin_source}. The excitation depends on the initial state of the neutral gas molecule. The different excitation states differ in their cross section and the energy loss. In \acs{karl}, it can be distinguished between the \begin{itemize} \item \num{15} channels of electronic excitation measured by \citet{Janev.2003}. \item experimental cross section of electronic excitation measured by \citet{Yoon.2008} \item first two vibrational excitations, measured by \citet{Janev.2003}. \item experimental cross section of vibrational excitation measured by \citet{Yoon.2008} \item first rotational excitation, measured by \citet{Janev.2003} \end{itemize} The interaction process itself, is reduced to an energy loss of the electron. The direction of motion, as well as the particle position, is assumed to stay constant. \subsubsection{Recombination} Recombination processes between ions and electrons need to be modelled explicitly. In all processes before, the particles interacted with the neutral gas particles. The reservoir of neutral particles is considered to be infinite, such that the interactions of electrons and ions with the gas do not change the gas flow and its properties. This is no longer valid for recombination. Each time an electron recombines, not only the electron density needs to be reduced, but also the ion density. Therefore, each event in the Monte Carlo method is no longer independent of the others. Direct particle interaction is impossible to model in the context of the classical Monte Carlo method. In \acs{karl}, this discrepancy is resolved through the density fields presented in section \ref{ssec:karl_density_fields}: Each time an electron recombines with an ion, the electron is deleted from the particle queue and a counter in the corresponding ion bin is increased. Thus, the electron can no longer travel the source and can no longer contribute to the density. The ion density is reduced by the counter. In total, both species have reduced densities without direct interaction. The same procedure is applied, when the primary particle is the ion. In this case, the ion will be deleted and the corresponding counter of the electron is increased. In the limit of many interactions, both electrons and ions will show the same total number of recombination. As a result of the small cross section, only \ce{T2+} and \ce{T3+} ions recombine, while \ce{T+} ions do not take part in this process in \acs{karl}. The cross section of \ce{T2+} and \ce{T3+} ions is evaluated from the formula provided by \citet{Janev.2003}. Due to the deletion of the particles, no new position and new velocity vector has to be evaluated. \subsubsection{Ion Cluster Formation} Ions can form clusters through attachment of molecules to the existing ion, see section \ref{sec:particle_interactions_in_the_katrin_source}. The cross section of the interaction depends on the initial cluster size. Three different cluster sizes are distinguished here: \ce{T+}, \ce{T2+} and \ce{T3+}. Higher order clusters are neglected here, due to their predicted low density and missing cross section data for fragmentation processes. The cross section of cluster formation for \ce{T+} ions is calculated from the rate coefficient measurement of radiative and ternary association \cite{Plasil.2012}, see also section~\ref{sec:particle_interactions_in_the_katrin_source}. The new \ce{T3+} ion of this reaction is initialized with the same velocity and position as the initial \ce{T+} ion, due to missing information on the differential cross section. \ce{T2+} ions show a large cross section for cluster formation, see section \ref{sec:particle_interactions_in_the_katrin_source}. In \acs{karl}, the cross section of the reaction is taken from the works of \citet{Janev.2003}. Again, due to missing information on the differential cross section, the velocity and position of the new ion are initialized by the velocity and position of the initial \ce{T2+} ions. \subsubsection{Ion Charge Transfer} Ion molecules (\ce{T2+}) do not scatter elastically from neutral gas but take part in the charge transfer reaction, see section \ref{sec:particle_interactions_in_the_katrin_source}. One electron of the target neutral gas molecule is transferred to the ion. Thus, a new ion is created. In \acs{karl}, the cross section of the reaction is taken from the works of \citet{Janev.2003}. For simplicity, the estimation of the new velocity vector is performed similar to the calculations of elastic scattering, see section~\ref{sssec:karl_elastic_scattering}. Input for these calculations are the velocity of the initial ion, the scattering angles $\phi$ and $\theta$, and the velocity of the target molecule. The scattering angles are sampled from the intervals $\phi \in [0,2\pi)$ and $\theta \in [0, \pi)$. The velocity of the target molecule is sampled from the velocity distribution of the neutral gas particles. Similarly, the calculation of the position of the new ions follows the same argumentation of elastic scattering. In principle, the position of the particle does not change in the ion charge transfer process. Due to the change of the gyro center however, the position has to be adapted. In the end, the calculation is performed analogue to the calculations of elastic scattering, see section~\ref{sssec:karl_elastic_scattering}. \subsection{Density Fields} \label{ssec:karl_density_fields} Energy and position dependent particle densities have two major functions in the algorithm: they are used in the Monte Carlo method itself (for the calculation of the cross section and interactions), and are the prime output of the simulation itself. The density of each particle specie is tracked individually. An exception is the density and velocity distribution of the neutral gas. The gas density is high enough, that it can be assumed that the neutral gas flow is not influenced by charged particle interactions. Therefore, it can be specified at the beginning of the simulation. This section however focuses on the densities, which are determined during simulation. In the simulation, the source is segmented longitudinally, radially and azimuthally. In each iteration step of the particle queue, it is recorded how long a particle stays in one segment. The density of a species $\alpha$ is then proportional to the total time of all particles of the species spent in the segment and the volume $V$ of the segment. In case of recombination, an additional term has to be added corresponding to the number of recombinations of the recombination partner $\gamma$ in the segment \begin{equation} n_\alpha = \frac{\sum_i t_i}{t_\text{sim} V} - \frac{N_\gamma}{V} \comma \end{equation} where $t_\text{sim}$ is the simulated time (formula adapted from \citep{MasterReiling2019}). The simulated time is determined by the number of decays $N_\beta$ and the total activity $a$ of the source \begin{equation} t_\text{sim} = \frac{N_\beta}{a} \fullstop \label{eq:simulated_time} \end{equation} The activity of the source is calculated relatively to the activity at nominal conditions. The activity at a tritium inlet density of $n_{T_2,0} = \SI{1E15}{\per\centi\metre\cubed}$ is approximately $A_0 \approx \SI{1E11}{\becquerel}$ \citep{PhDKuckert2016}. So, the activity at another inlet density $n_{T_2}$ is calculated by \begin{equation} A = \frac{n_{T_2}}{n_{T_2,0}} \cdot A_0 \fullstop \end{equation} This approximation ignores that the density profile changes, when the inlet density changes. Nevertheless, a thorough calculation would need gas simulations at each used injection density. It is therefore set aside here. The density can also be determined depending on the energy of the particle. These densities are then binned to a predefined energy scale. Thus, the density fields can be used in equation~\ref{eq:karl:movement_tmcs}, and also used for sampling of an interaction partner. The sampling is performed in three different steps: sample particle energy, roll velocity direction, copy position of primary particle. First, the energy of the interaction partner is sampled from the energy distribution of the target field at the position of the primary particle. Secondly, a velocity direction is picked at random. The velocity of the new particle is then scaled according to the energy and mass of the particle. Finally, the new particle is generated with this velocity and the position of the primary particle. \subsection{Simulation Output and Diagnostics} \label{ssec:karl_virtual_current_borders} The Monte Carlo approach of the simulation needs statistics with a high number of samples. The statistic is determined by the number of generated beta-decay events $N_\beta$. Each of these events produces multiple secondary particles. Recording each position and particle would result in an overwhelming amount of data. Thus, it was decided to use three different output methods: density fields, absolute particle numbers of conversion and termination and particle currents through virtual barriers. \textbf{Density Fields:} The density fields of the previous section are recorded each time after a specified number of generated beta-decay events. The last output is performed after $N_\beta$ decays. This output is used for the final determination of the particle densities of the simulation, which is one of the main objectives of \acs{karl}. The other outputs are only used for diagnostics of the computer code. \textbf{Interaction Counter:} Special counters are implemented to track each time a particle is terminated at the simulation boundary, converted to another particle flavor or recombines. The termination counter is selective on the boundary type: rear wall, tube wall or DPS. These counters can be used for diagnostics or for tests of the computer code. \textbf{Virtual Current Borders: } The second main objective of \acs{karl} is to determine the particle currents in the source. This task is performed through virtual barriers. Similar to the segmentation of the density fields, the source is segmented longitudinally, radially and azimuthally. Each particle is registered, when it crosses from one segment to another. The total current through the segment faces is then given by \begin{equation} j = \frac{N^+ - N^-}{A \, t_\text{sim}} \comma \end{equation} (formula from \citep{MasterReiling2019}) where $N^+$ and $N^-$ is the number of particles crossing the faces in positive and negative direction, $A$ is the area of the face and $t_\text{sim}$ the simulated time, see equation~\ref{eq:simulated_time}. The current through the faces can be determined from the energy and type of species crossing the faces. This is performed through a selective binning to a predefined energy scale during simulation. The absolute current is then given by the sum over all energy bins. \paragraph{Statistical Uncertainty} The accuracy of the simulation depends on the number of decays $N_\beta$. This number is inserted directly in the calculation of the current and the density, but it also contributes indirectly through the production of secondary particles. The specific contributions are difficult to calculate directly because of the multitude of different interactions. Hence, the accuracy of the simulation was determined through multiple simulations with the same number of decays but with different random number generator seeds. The mean of the normalized standard deviation of each energy bin was calculated. For a counting experiment, it is expected that the standard deviation scales with $1/\sqrt{N_\beta}$, which was found to be in good agreement with the test simulation results. For a statistical uncertainty of \SI{0.1}{\percent}, it is therefore necessary to simulate at least \num{1E6} beta decays. Such a simulation (without electric background field) takes up to \SI{24}{\hour} on \num{1392} CPU cores. This is a reasonable amount of calculation effort for the reached accuracy. \section{Validation} \label{sec:karl:validation} The algorithm of \acs{karl} was tested thoroughly, including a comparison of specific simulations with expectations. These were formulated for scenarios, where an analytical expression of the simulation output can be derived. For these simulations, each interaction was investigated detached from the others. The corresponding tests are summarized in the following. \subsection{Ionization} \label{ssec:karl:validation:ionization} Ionization was tested through an injection of monoenergetic electrons. All interactions, except ionization, were disabled. The energy of the electrons was chosen in such a way ($E_\text{inj} = \SI{30}{eV}$), that only one ionization could occur as a result of the energy loss. The energy distribution of the ionization products were compared to the expected energy distribution. The expected distribution is generated from the input differential cross section and an additional energy dependent factor. This factor comprises a factor for logarithmic binning \begin{align} \frac{\mathrm{d}\sigma}{\mathrm{d}E} = \frac{\mathrm{d}\sigma}{\mathrm{d}\log E} \frac{\mathrm{d}\log E}{\mathrm{d}E} = \frac{\mathrm{d}\sigma}{\mathrm{d}\log E} \frac{1}{E} \comma \end{align} and a factor, that converts the generated spectrum to the spectrum in the source. Faster electrons, leave the source faster than slower electrons. Thus, the generating spectrum has to be divided by $\sqrt{E}$. In total, the generating spectrum has to be multiplied with $\sqrt{E}$ to gain the simulated spectrum in the source. A comparison of the spectrum of a test simulation and the expected spectrum is shown in figure~\ref{fig:Chapter4_KARL/Validation/ionization_spectrum.pdf}. It can be seen, that expectation and simulation agree well. Small differences are expected as a result of statistical uncertainty. \xfigure{tb}{1.}{Chapter4_KARL/Validation/ionization_spectrum.pdf}{Test simulation with ionization only.}{Comparison of the simulated spectrum and the generating ionization spectrum with conversion factor $\sqrt{E}$.} The ionization process can occur either through a dissociative or non-dissociative process. Thus, the number of \ce{T+} ions in relation to the \ce{T2+} ions should match the relation between the cross sections of the reactions. In the tests, the number of \ce{T2+} was found to be $\approx \num{77.5}$ higher than the number of \ce{T+}. At \SI{30}{eV}, the relative cross sections of the two ionization processes is $\approx \num{77.1}$, which corresponds well to the simulated ratio. \subsection{Elastic Scattering} \label{ssec:karl:validation:elastic_scattering} Elastic scattering was tested through an injection of monoenergetic particles into a neutral gas reservoir with a Maxwell-Boltzmann velocity distribution. The temperature was set to $T = \SI{80}{K}$. All interactions, except elastic scattering, were disabled. If elastic scattering is implemented correctly, then these particles will adopt the energy distribution of the neutral gas independently of the initial energy, multiplied with the conversion factor of $\sqrt{E}$, see section~\ref{ssec:karl:validation:ionization}. In the first simulation, the cross section of elastic scattering was set to a fixed value to avoid a difference towards the Maxwell-Boltzmann distribution. The corresponding spectrum can be found in figure~\ref{fig:Chapter4_KARL/Validation/MB_fit_energy.pdf} alongside a least-squares fit of the Maxwell-Boltzmann distribution. It can be seen, that the data of the simulation can be described well by the Maxwell-Boltzmann distribution. This observation is underlined by the good agreement of the estimated temperature of the fit $T = \SI{80.57+-0.04}{K}$ with the gas temperature. Small derivations between data and fit are discernible at energies below $E < \SI{1E6}{eV}$. They can be attributed towards the statistical nature of the Monte Carlo method. \xfigure{tb}{1.}{Chapter4_KARL/Validation/MB_fit_energy.pdf}{Test simulation with elastic scattering only.}{Simulated spectrum with gas temperature of $T = \SI{80}{K}$ and fixed elastic cross section. Least-squares fit of Maxwell-Boltzmann distribution with conversion factor. Deviations at low energies arise from statistical fluctuations.} In the previous simulation, the electrons were injected with an energy of $\SI{20}{meV}$. If elastic scattering is implemented correctly, then the spectrum will be independent of the injection energy. In the second test, three different simulations were compared, each with a different injection energy. The injection energies were chosen, such that they are below and above the most probable energy of the Maxwell-Boltzmann distribution ($E = \SI{6.897}{meV}$). The temperature of the source was again set to $T = \SI{80}{K}$. In order to test the final behavior of the algorithm, it was decided to use the true energy dependent cross section of elastic scattering. The corresponding spectra of the simulations can be found in figure~\ref{fig:Chapter4_KARL/Validation/dndE_multiple_injections.pdf}. \xfigure{tb}{1.}{Chapter4_KARL/Validation/dndE_multiple_injections.pdf}{Test simulation with elastic scattering only.}{Comparison of three simulations with different injection energies $E_\text{inj}$ but with energy dependent cross section. Expected Maxwell-Boltzmann distribution in case of fixed cross section for comparison.} It can be seen, that all three simulations show the same shape of the distribution. Only the scale of the densities is different between the simulations. After a normalization, these differences disappear (not shown). Thus, the test requirements were met, from which we can conclude that the simulation is independent on the injection energy. The test simulation also shows, that an energy dependent elastic cross section produces a spectrum, that is different from the pure Maxwell-Boltzmann distribution. The difference is most pronounced in the low-energy regime, where the cross section for elastic scattering is smaller than at higher energies. Thus, more particles will stay at their small energies than before because of the reduced scattering probability. Nevertheless, this result does not invalidate the tests from above, but shows the importance of the energy dependent cross section. \subsection{Excitation} Excitation (vibrational, rotational and electronic) was tested through an injection of monoenergetic electrons. In the excitation processes, electrons lose energy depending on the excitation state while keeping all other properties, see section~\ref{sssec:karl:particle_interactions:excitation}. Thus, a comparison of the initial and final energy will result in energy loss through excitation. The simulated energy results were found to be in agreement with their expectation. \FloatBarrier \xfigure{h}{1.}{Chapter4_KARL/Validation/comparison_recombination.pdf}{Test simulation with recombination only.}{Top: The same amount of electrons and ions is injected at the right side. The particles move to the left. Some of the particles recombine, which reduces the density. Bottom: The simulated densities for each position is compared to each other. A fit was performed to investigate the expectation of equation~\ref{eq:karl:validation:recombination}.} \subsection{Recombination} Recombination was tested through an injection of monoenergetic ions and electrons at one end of the simulation domain with energies $E_e$ and $E_i$ for electrons and ions respectively. The injection position was chosen to be located at the \acs{dps} side, while the injection velocity is directed towards the rear wall. The energies of the particles were chosen in such a way, that the density of electrons and ions show the same value as in a simulation without recombination. All other interactions were disabled and a magnetic field in z direction was applied. Thus, there exists no dependence on the x and y position. The expected density of the ions $n_i(z, t)$ and electrons $n_e(z, t)$ can be calculated from the coupled continuity equation of electrons and ions with a particle sink. The differential equations in this case then read as \begin{align} \frac{\partial n_e}{\partial t} &= v_e \frac{\partial n_e}{\partial z} + \sigma(E_e) n_e n_i v_e \comma \\ \frac{\partial n_i}{\partial t} &= v_i \frac{\partial n_i}{\partial z} + \sigma(E_i) n_i n_e v_i \fullstop \end{align} The cross sections are given in the frame, where the target particle is at rest. So, $\sigma(E_e)$ describes the case, where the ion is at rest and $\sigma(E_i)$ describes the case, where the electron is at rest. In the limit of large time values, it is expected that the density does not change. So this coupled differential equation can be solved by the linear equation \begin{equation} n_e(z) = \frac{\sigma(E_e)}{\sigma(E_i)} n_i(z) + c \comma \label{eq:karl:validation:recombination} \end{equation} where $c$ is an integration constant. Thus, a linear relation between electron and ion density is expected. In an ideal case, where electrons and ions both stream at the same time in the same direction, the transformation between $\sigma(E_e)$ and $\sigma(E_i)$ will result in the same value. Therefore, the ratio of the cross sections is one. The simulation is slightly off from the ideal case, since the calculation of the microscopic cross section comprises the assumption of an isotropic distributed velocity vector. The conversion to the laboratory frame therefore results in slightly different values of the cross section. Hence, small deviations from unity are expected. Additionally, the ion density spectrum is considered to follow the Maxwell-Boltzmann distribution, which provides an additional energy contribution. This contribution is minimized by choosing a small temperature of the distribution ($T = \SI{1E-4}{K}$), but cannot be erased completely. The test simulation was performed with the injection of \num{1E5} electrons and ions. The resulting densities can be found in figure~\ref{fig:Chapter4_KARL/Validation/comparison_recombination.pdf}. It can be seen, that the density of both electrons and ions decreases from the injection position (right side) towards the rear wall (left side). This is expected, because all particles, which recombine, can no longer contribute to the density. The slope of the density is the highest at the injection position. This is caused by the increased recombination probability at this point due to the larger density. The densities of electrons and ions can be plotted versus each other, see also figure~\ref{fig:Chapter4_KARL/Validation/comparison_recombination.pdf}, to investigate the expectation of equation~\ref{eq:karl:validation:recombination}. It can be seen that there is indeed a linear relation between the densities. A linear fit to the data shows that the slope has a value of $\num{1.056 +- 0.005}$. This value is close to the expected unity. The small deviation was expected, see above. In the case, where electrons and ions have the same velocity, they induce the same density in a simulation without recombination. Therefore, in a simulation with recombination it is expected that the number of simulated electrons, which recombine is similar to the number of the simulated ions, which recombine. It could be shown that they agree: $N_e \approx \num{8.9E4}$ and $N_i = \num{9.5E4}$. Similar to the expected value of the cross section ratio, also the number of recombined particles can be slightly different, because of the finite temperature of the ions and the isotropically distributed velocity. \section{Electromagnetic Field-Free Simulation} \label{sec:karl:field_free_simulation} A starting point of the simulation cycle with \acs{acronym} and \acs{karl} is a simulation with \acs{karl}. Ab initio, there is no knowledge of the electric field, and it is therefore set to zero. The magnetic field of the superconducting magnets is not influenced significantly by the plasma due to its extremely high strength. It is therefore included in the first simulation, and set to $B = \SI{2.5}{T}$ throughout the whole source. The tritium gas density was approximated according to \citet{Kuckert2018}. No adjustment needed to be made in the rear wall region, due to the small difference between the density at the rear and front end of the source, see figure~\ref{fig:Chapter2_KATRIN/Density/nT2_vs_z.pdf}. Six linear functions were used to approximate the density to save computation time, see figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/nT2_vs_z.pdf}. The temperature of the gas was set to $T = \SI{80}{K}$, and the maximal density was set to \SI{6.3E14}{cm^{-3}}. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/nT2_vs_z.pdf}{Approximate neutral gas density.}{The data was taken from \citet{Kuckert2018} and mirrored at the inlet position. Six linear functions were used to approximate the density in the simulation. The vertical lines show positions of the pump ports.} The drift velocity of the neutral gas was obtained from the results of \citeauthor{Kuckert2018}, see figure~\ref{fig:Chapter2_KATRIN/DriftVelocity/vz_vs_z.pdf}. As a starting point, the drift velocity was set to zero in the regions between the rear wall and the central source tube of the \acs{wgts}. The drift velocity was implemented through a numerical table, because of its significant radial and longitudinal structure. The source tube was approximated by a cylinder with radius $R=\SI{4.5}{cm}$ and a height of $H=\SI{16}{m}$. The center of the source was set at $\SI{8}{m}$ away from the rear wall for simplicity. The source was segmented into 32 z bins and 15 radial bins. No segmentation was used in the azimuth direction due to the expected azimuthal symmetry of the result. Density and currents were recorded at 100 energy bins with logarithmic subdivision. \subsection{Electron Spectrum} \label{ssec:karl:field_free_simulation:electron_spectrum} The electron spectrum was recorded for \num{32} segments at different positions in the source. Three distinct segments are compared here: one, which is directly connected to the tritium inlet, a second, which is next to the rear wall and a segment, and a third, which is connected to the \acs{dps}. The corresponding spectra can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/densities_e_vs_E.pdf}. For comparison with generating or theoretical spectra, an additional factor of $\sqrt{E}$ needs to be taken into account, see section~\ref{ssec:karl:validation:ionization}. The factor takes a conversion to logarithmic energy binning and the difference between generating and simulated density spectra into account. For simplicity, in the following this factor will be used implicitly in the description and not discussed any further. Three different energy regions can be identified: a so-called thermal region ($E < \SI{5E-2}{eV}$), where the electrons reached thermal equilibrium with the neutral gas, a so called beta-decay region ($E > \SI{E2}{eV}$), where the distribution is directly created by the Fermi distribution of beta-decay and a so-called secondary region in between the other two regions. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/densities_e_vs_E.pdf}{Electron spectrum of three different segments in the source.}{Mid: central segment connected to the inlet, rear wall: segment in front of the rear wall, DPS: segment next to the DPS. The magnetic field was set to $B = \SI{2.5}{T}$, the maximum tritium density was set to $n_\text{max} = \SI{6.3E14}{cm^{-3}}$, and the temperature to $T = \SI{80}{K}$.} \paragraph{Beta Region} The energy distribution in the beta region is generated by the beta decay and subsequent streaming of the beta electrons. The scattering probability of high-energy electrons is small enough that at least half of the electrons did not scatter once in the source \citep{PhDMachatschek2021}. Hence, the spectrum at the high-energy region is similar to the beta spectrum. Deviations arise from electron-neutral scattering. The spectrum in the beta-decay region shows little deviation between the three different segments. Thus, the beta-electrons either travel the source unobstructed, or loose the main portion of their energy through ionization and subsequent scattering. Nevertheless, there is a slight difference at the lower end of the beta-region between the rear wall and the other two positions. Electrons which reach the rear wall segment can have traveled at maximum two times through the source through reflection at the spectrometer, while electrons at the \acs{dps} traversed the source only once. Therefore, more beta-electrons have scattered before reaching the rear wall segment, which reduces the density at this energy range. \paragraph{Thermal Region} The energy distribution in the thermal region is generated mostly by elastic collisions with the neutral gas. Thus, the electrons adapt the energy distribution of the gas, a Maxwell-Boltzmann distribution. The spectrum shows slightly higher values at the low-energy tail of the spectrum, than expected from the Maxwell-Boltzmann distribution. This is caused by the energy dependent cross section of elastic scattering, see section~\ref{ssec:karl:validation:elastic_scattering}. The spectral shape in the thermal region is the same for each segment. The similarity to the expected Maxwell-Boltzmann distribution with energy dependent cross section shows, that recombination is only a secondary effect. Otherwise, there would be much fewer particles at low energies, where the cross section of recombination is increased, see figure~\ref{fig:Chapter2_KATRIN/ParticleInteractions/eTI_overview.pdf}. The absolute density is the largest in the center, while it decreases towards both sides. In the center, there are many collisions, which results in increased electron density there. The density at the DPS is higher than at the rear wall. This is caused by the reflection of electrons at the DPS and neutral gas density differences. \paragraph{Secondary Region} The energy distribution in the secondary region is created by the interplay between the interaction types in the source. Therefore, a full description by a theoretical distribution is not possible. Nevertheless, it is possible to compare the observed features with the cross sections of the interactions. The secondary region shows two distinct features. A power law from \SI{5E-2}{eV} to \SI{1E1}{eV} and an edge at \SI{1E1}{eV}. The energy of the edge is consistent with the threshold energy for ionization and electronic excitation. Electrons with a lower energy can no longer take part in these interactions. The power law arises as a combination between elastic scattering and rotational and vibrational excitation. The rotational excitation has a threshold energy of \SI{5E-2}{eV}, which is consistent with the end of the power law. The absolute values of each region are different from each other. Similar to the thermal region, there are more scatterings in the center than at the sides. So the density is higher there. The electrons are reflected at the \acs{dps}. Therefore, the density is higher in that region at the rear wall side. \subsection{Charged Particle Densities} \label{ssec:karl:field_free_simulation:particle_densities} The density of each particle specie can be obtained by marginalization of the density spectrum. The corresponding distribution along the source tube can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/densities_all_vs_z.pdf}. It can be seen that the density profile of each specie is different from each other. The absolute charge density is non-zero in this simulation, despite the fact that electrons and ions are created in pairs. This is not surprising because electrons scatter less and are moving faster, and therefore leave the source tube faster than the ions. Therefore, their density value is strictly smaller than the density of the ions. In the experiment, it can be assumed in first approximation that there exists quasineutrality in the source. Thus, the density differences between electrons and ions will induce an electric field, which will ensure the quasineutrality. This field will be calculated in a separate simulation. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/densities_all_vs_z.pdf}{Longitudinal particle densities.}{Tritium is injected at \SI{8}{m} distance to the rear wall. The magnetic field was set to $B = \SI{2.5}{T}$, the maximum tritium density was set to $n_\text{max} = \SI{6.3E14}{cm^{-3}}$, and the temperature to $T = \SI{80}{K}$.} The electron density is dominated by the thermal part of the spectrum. Beta and secondary electrons make up only \SI{4E2}{cm^{-3}} (not shown). The electron distribution has its maximum in the center of the source and falls off to both sides. The probability of scattering is the highest in the center of the source, hence the electron density is the largest here. The scattering probability is decreased to both sides as the neutral gas density decreases. The electron density is asymmetric towards the inlet, despite the symmetric shape of the density. This is caused by the reflection of electrons at the DPS, which increases the density in this region. Nevertheless, the density before the \acs{dps} is not increased drastically, which suggests that electrons can pass the high density region of the inlet. The ion distribution is different for the three different ion species. The most abundant ions are \ce{T3+} ions. This is expected due to the high conversion cross section of \ce{T+} and \ce{T2+} towards \ce{T3+}. The density of the \ce{T3+} ions is governed by ionization through electron impact and by elastic scattering with the neutral gas. Ionization is most probable in the center, where the neutral gas density is the highest. The resulting density of ionization is superposed by the streaming process, caused by the elastic scattering. The motion of ions is aligned with the bulk velocity of the gas. Thus, the ions are transported to both sides of the source, increasing the density in these regions. The density drops in the region in front of the rear wall and in front of the DPS. This is caused by the reduction of the neutral gas density and the drop out of the neutral gas drift. The density of \ce{T+} is distributed similarly to the density of \ce{T3+}. The shape of the spectrum is created by the same effects as of \ce{T3+}, namely elastic scattering with neutral gas and particle transport. The density of \ce{T+} is lower than the density of \ce{T3+}. In this simulation, \ce{T+} can only be created through dissociative ionization. The cross section of this reaction is significantly lower than for non-dissociative ionization. Therefore, less \ce{T+} is created in comparison to \ce{T3+}, which is created through the efficient conversion of \ce{T2+}. Additionally, \ce{T+} can be converted to \ce{T3+} through ternary association, which lowers the density of \ce{T+} in comparison to the density of \ce{T3+}. The density of \ce{T2+} is significantly different from the other two ion species. The shape is almost constant, and the density is significantly lower. The cross section of cluster formation is higher than the cross section for charge transfer. Therefore, \ce{T2+} ions mostly exist only for short time between creation and their first interaction. Thus, the density of \ce{T2+} is significantly lower. The probability for cluster formation is dependent on the tritium density, while the creation mechanism through beta decay and ionization is also dependent on the tritium density. The \ce{T2+} density therefore shows no large longitudinal variation. Nevertheless, there is a slight decrease of the density in front of the rear wall and the DPS. The mean free path of the particles has increased enough that some particles can leave the source, which reduces the density. \subsection{Charged Particle Currents} \label{ssec:karl:field_free_simulation:particle_currents} The longitudinal particle current was determined through \num{33} virtual planes in longitudinal direction. The planes were aligned in such a way that the first and last longitudinal plane coincide with the rear wall and the passage to the DPS. The corresponding longitudinal current profile can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/Iz_vs_z.pdf}. The shape of the electron current is as expected. Electrons are reflected at the DPS and the corresponding current is therefore zero. Electrons are most likely to be terminated at the rear wall. Thus, the electron current is the highest here. The electron current decreases continuously from the rear wall towards the DPS. Hence, the electrons can move from the upstream side towards the downstream side and are not hindered from passing by the neutral gas flow. The ions are created in the center and stream to both sides. There is no driving force of the ions towards the other side of the inlet. Thus, the ion current at the inlet (\SI{8}{m}) is zero. The current heading towards the DPS and towards the rear wall is almost identical. The differences can be explained by the accessory tritium gas between the first pump and the rear wall. The sum of the ion current leaving the source at the DPS and at the rear wall is below the electron current leaving at the rear wall. This can only be explained through an ion current, which is directed towards the beam tube. The corresponding current was detected through a radial virtual plane located at the beam tube walls. The corresponding current can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/tube_current_vs_z.pdf}. This current is caused by the change of position of the guiding center after elastic scattering. The difference in position is dependent on the Larmor radius of the particle, which in turn scales with the square root of the mass. Additionally, the cross section of ion scattering is much higher than for electron scattering. Therefore, more collisions occur, which shift the guiding center. Thus, the radial ion current is expected to be significantly higher than the radial electron current. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/Iz_vs_z.pdf}{Longitudinal particle currents.}{The sign of the current corresponds to the direction of the particle flow multiplied with the sign of the particle charge. Tritium is injected at \SI{8}{m} distance to the rear wall.} \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/tube_current_vs_z.pdf}{Source tube currents.}{Absolute radial particle current towards the beam tube in longitudinal direction. The plateaus mark the longitudinal bin width, where the total current flows through. Tritium is injected at \SI{8}{m} distance to the rear wall. The magnetic field was set to $B = \SI{2.5}{T}$, the maximum tritium density was set to $n_\text{max} = \SI{6.3E14}{cm^{-3}}$, and the temperature to $T = \SI{80}{K}$.} \FloatBarrier The absolute current to the tube is also influenced by the density profile of electrons and ions. There is no analytic expression of the radial currents. It can be seen that the shape of the current towards the beam tube is similar to the shape of the neutral particle density. This is caused by the increased elastic scattering probability in the center due to the increased neutral gas density. The \ce{T+} current is below the \ce{T3+} current, which is caused by the density difference and the different Larmor radius of the two ion species. The current of \ce{T+} is in the same order of magnitude than the current of the electrons, even though the masses of both species are significantly different. This behavior is caused by the large difference in density. There is a contribution of \ce{T2+} to the radial current. This means that there must be a non-negligible amount of charge transfer reactions, or that enough \ce{T2+} is created close to the beam tube walls. The shape of the \ce{T2+} current does not coincide perfectly with the tritium density. Thus, it must be assumed in first order that both effects play a role. \subsection{Influence of External Parameters} A specific choice of parameters was made in the simulation presented above. The parameters were chosen to be as close to the current measurement settings as possible. Nevertheless, the simulation allows for a simple comparison of different parameter settings in the source. Three different parameters were investigated here: the tritium gas density, the tritium gas temperature and the magnetic background field strength. \subsubsection{Tritium Gas Density} The tritium density can be changed in the experiment. In KNM1, for example, the density was set to approximately \SI{22}{\percent} of the nominal value and in KNM2 to \SI{84}{\percent} of the nominal value \citep{PhDMarsteller2020}. This change of density can also be investigated by simulation. The tritium density is an important input parameter for the simulation. It has various effects on the charged particle behavior. It acts as an interaction partner as well as a source for high-energy electrons. Because of the intricate connection between the different interactions of the charged particles, it is beneficial to use the simulation to investigate the different behavior. Three different density settings are compared quantitatively: The nominal case, where the density is set to the current maximum of the column density, a case with half the maximum density, and another case with \SI{10}{\percent} of the maximum density. The corresponding electron spectra can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/comparison_densities.pdf}. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/comparison_densities.pdf}{Spectrum at different gas densities.}{\SI{100}{\percent} corresponds to an inlet density of $n_\text{in} = \SI{6.34E14}{cm^{-3}}$. The source temperature was set to $T = \SI{80}{K}$, and the magnetic field strength to $B = \SI{2.5}{T}$. The spectra were recorded at \SI{8}{m} distance to the rear wall.} It can be seen that there is no significant difference between the case of nominal density and half nominal density. The absolute density is lower, but the spectral shape is preserved. The more drastic difference can be seen in the simulation with \SI{10}{\percent} injection density. Here, the shape of the thermal region is significantly changed to the other two simulations. No clear distinction between the thermal and the secondary region is discernible. Also, the maximum of the left-over thermal region is no longer at the thermal energy, but is shifted to the right. Hence, the electrons do no reach thermal equilibrium any longer with the neutral gas and can travel the source more freely. This is a first indication that the plasma will behave differently at \SI{10}{\percent} than at the other two settings. Nevertheless, a thorough investigation with the electric field has to be conducted to reach a finial conclusion. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/comparison_temperatures.pdf}{Spectrum at different gas temperatures.}{The injection density was set to $n_\text{in} = \SI{6.34E14}{cm^{-3}}$, and the magnetic field strength to $B = \SI{2.5}{T}$. The spectra were recorded at \SI{8}{m} distance to the rear wall.} \FloatBarrier \subsubsection{Tritium Gas Temperature} The gas temperature can be changed in the experiment in the region of \SIrange{28}{37}{K} and \SIrange{80}{115}{K} \citep{Aker.352021}. The temperature can have an influence on the charged particle motion, since elastic scattering is the most probable interaction for most energies. Therefore, three different temperature settings are compared here: a setting with \SI{30}{K}, with \SI{80}{K} and with \SI{100}{K}. The corresponding electron spectra can be found in figure \ref{fig:Chapter4_KARL/ZeroElectricFieldCase/comparison_temperatures.pdf}. It can be seen that the general shape of the three spectra does not change significantly. Only the maximum of the thermal region shifts to the corresponding energy $(E_\text{th} = k_\text{B} T)$. It is not expected that the plasma will behave significantly different from these three cases. \subsubsection{Magnetic Background Field} \label{sssec:karl:field_free_simulation:external_parameters:magnetic} The magnetic field strength can be adjusted in the experiment. In most of the previous measurement runs, the field value is set to $B = \SI{2.5}{T}$ \citep{Aker.352021}. Nevertheless, the field strength can be lowered for commissioning measurements. Simulations showed that the magnetic field strength has no significant influence on the electron spectrum. Nevertheless, it can have an influence on the radial movement of charges in elastic scattering and therefore on the particle currents. The movement in radial direction is governed by the movement per collision, which is dependent on the gyro radius. The gyro radius in turn is influenced by the magnetic field. When there are sufficient scatterings with the neutral gas, then the density and current can be described by classical diffusion \citep{Cap.1994}. In the case of classical diffusion, the diffusion constant can be calculated as \begin{equation} D = \nu r_L^2 \comma \label{eq:classical_diffusion} \end{equation} where $r_L$ is the Larmor radius and $\nu$ the collision frequency. It is therefore expected that the diffusion constant scales inversely quadratical with the magnetic field. To test the hypothesis of classical diffusion, three different simulations were performed: a simulation with the nominal magnetic field of \SI{2.5}{T} and two simulations with lower magnetic field (\SI{2}{T} and \SI{1}{T}). The resulting radial ion current and radial ion density can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/comparison_j_n_vs_r.pdf}. It can be seen that the magnetic field has an influence on the density, as well as on the radial particle current of ions. A quantitative analysis is shown in the following through the use of the diffusion constant. \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/comparison_j_n_vs_r.pdf}{Radial ion currents and densities.}{Simulated at different magnetic field strength. The values are taken at \SI{5}{m} distance to the rear wall.} The diffusion constant can be evaluated in the simulation through the use of Fick's first law of diffusion \begin{equation} j = D \cdot \frac{\partial n}{\partial x} \fullstop \label{eq:ficks_first_law} \end{equation} In the simulation, the density is evaluated in bins and the current is recorded for planes between those bins. Therefore, the derivative of the density can be replaced with the finite difference. The diffusion constant was derived through a linear fit. The simulated diffusion constants can be found in table~\ref{tab:Chapter4_KARL/classical_diffusion.tex} \xtable{tb}{Chapter4_KARL/classical_diffusion.tex}{Fit values of simulated classical diffusion constants.}{Density and currents were evaluated at \SI{5}{m} distance to the rear wall. The diffusion constant was derived through linear fit with equation~\ref{eq:ficks_first_law}.} It can be seen that the simulated diffusion constant scales as expected for classical diffusion. The derived value of the diffusion constant can also be compared to the expected value, see equation~\ref{eq:classical_diffusion}. The expected value cannot be specified directly but in a value range, because of the longitudinal bin width. Here it is assumed that the density of the longitudinal bin lies between \SIrange{2.3E13}{3.5E13}{cm^{-3}} and the magnetic field is $B = \SI{2.5}{T}$. With the Larmor radius of $r_L \approx \SI{1E-3}{cm}$ the diffusion constant follows as $D \approx \SIrange[range-phrase=-]{3.6E-5}{5.5E-5}{\metre\squared\per\second}$. It is apparent that the simulated value lies in this range. In total, it can be concluded that the radial movement of the ions in the center can be described by classical diffusion. Nevertheless, this observation might change, when considering the electric field in simulation. \subsection{Comparison to Previous Study} The electron spectrum was derived in a previous study in \num{2005} by \citet{Nastoyashchii2005}. They also derived an electron spectrum of the \acs{katrin} source through a Monte Carlo simulation. The spectrum was derived through an evaluation of the overall time spent in the simulation domain. It was therefore derived independently of the position in the source and can only be construed in first order as a mean spectrum of the electrons in the source. The implemented interactions (ionization, electronic excitation, vibrational and rotational excitation, and elastic scattering) were taken from \cite{Tawara.1990} for hydrogen. Since then, new cross section data is available \cite{Janev.2003}, which is included in \acs{karl}. There is no mention in the paper of \citeauthor{Nastoyashchii2005}, which cross sections were used and how the cross sections were parametrized. Thus, there is no comparison possible between the used cross sections of \acs{karl} and the computer code of \citeauthor{Nastoyashchii2005}. The temperature of the source was set to $T = \SI{30}{K}$ in the simulation of \citeauthor{Nastoyashchii2005}, the former nominal value. Also, the maximal density was set to the former nominal value of $n_\text{inj} = \SI{1E15}{cm^{-3}}$. There is no explicit mention of the used magnetic field in the paper, but at that time the nominal value was set to $B = \SI{3.6}{T}$. So, in the following, the presented simulation results were also performed at that field value. The spectrum can be found in figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/comprarison_ndE_Nastoyashchii.pdf} \xfigure{tb}{1.}{Chapter4_KARL/ZeroElectricFieldCase/comprarison_ndE_Nastoyashchii.pdf}{Spectrum comparison with previous study.}{The data from \citet{Nastoyashchii2005} is compared to the spectrum gained from \acs{karl} at two positions in the source, a segment next to the rear wall and a segment directly at the inlet. The simulation was performed at the same settings ($T = \SI{30}{K}$, $B = \SI{3.6}{T}$ and $n_\text{inj} = \SI{1E15}{cm^{-3}}$). The results of \citeauthor{Nastoyashchii2005} were scaled, such that the spectrum at the high-energy region coincides with the simulation results of \acs{karl}.} It can be seen that the distribution of \citeauthor{Nastoyashchii2005} shows similar features as the simulation with \acs{karl}: a thermal region, a beta-region and a secondary region. The general shape of these regions is similar to the simulation at hand. Nevertheless, there exist differences, which will be discussed in the following. The results of \citeauthor{Nastoyashchii2005} only provide a mean particle density of the source. It can be seen in the results from the \acs{karl} simulation that there exist significant differences of the spectrum at the different positions in the source. It is expected that electrons close to the rear wall scatter less than in the central part of the source. Therefore, the density of these electrons is reduced. This is not applicable to the high-energy electrons, which scatter seldom. Thus, their density is less susceptible to the position inside the source. The spatial differences of the spectrum might change the model of the plasma. \citeauthor{Nastoyashchii2005} for example, assume implicitly in their calculation of the plasma potential that the electron density of the high-energy electrons can be neglected, whereas our simulations show, that this assumption is not true for all positions in the source. Especially close to the rear wall, the relative energy density of high-energy electrons and low-energy electrons is comparable. Thus, a different plasma description is necessary for this region, which also includes high-energy electrons. There exists a spike (one data point) at \SI{10}{eV} in the results of \citeauthor{Nastoyashchii2005}, which is not existent in the \acs{karl} simulation results. The existence of this peak is important, because there might be plasma instabilities linked to it. The slope of the electron spectrum is positive here, which is a first indicator of an instability through the Penrose criterion \citep{Penrose.1960}. \citeauthor{Nastoyashchii2005} do not specify the origin of this peak and provide no information on the statistics of the simulation. In the \acs{karl} simulation, this peak does not occur, even at different random number seeds. A physical explanation was not found for this peak. Therefore, it is assumed that it originated from statistical uncertainty. The thermal region of \citeauthor{Nastoyashchii2005} shows a slightly higher maximum than the simulation results of \acs{karl}, and a slightly different shape: there are fewer electrons with lower energies in the simulation of \citeauthor{Nastoyashchii2005} than in the \acs{karl} simulation. It is unclear, how this difference is formed. A first guess is, that the cross section of elastic scattering was set to a fixed value for low energies in the \citeauthor{Nastoyashchii2005} simulation. Thus, the difference in the spectrum is similar to the difference in the test simulations of elastic scattering, see section~\ref{ssec:karl:validation:elastic_scattering}. Nevertheless, the test simulation of elastic scattering of \acs{karl} reinforces the trust in the thermal region of the \acs{karl} simulation results. Hence, the simulation results of \acs{karl} show clear superiority to the state of the art. \section{Simulation with Electric Background Field} The simulation results of the previous section were performed without any electric field in the source. The density distribution of electrons and ions, see figure~\ref{fig:Chapter4_KARL/ZeroElectricFieldCase/densities_all_vs_z.pdf} suggests, that there are electric fields, which enforce quasineutrality in the source. Additionally, it is expected that there is a boundary layer electric field in the source, see section~\ref{ssec:debye_length}. This field is also not taken into account in the previous simulation. In context of this thesis, the \acs{acronym} simulation tool is developed to provide a precise view on the electric field given an input electron spectrum and ion currents. These simulations will be described in the following chapter. Nevertheless, at this point it is possible to investigate the influence of an electric field on the simulation results without the use of \acs{acronym} by either providing an external field from first principles or by deriving an electric field from the density data of \acs{karl}. Both paths will be investigated in the following. First, it will be analyzed how a given rear wall potential influences the simulation result. Secondly, the density results of \acs{karl} will be used to calculate an electric field, which is then used to investigate the behavior of the particles under this field. \subsection{Rear Wall Field} \label{ssec:karl:with_E_field:rear_wall_field} The contact potential differences between the rear wall and the source tube can produce an electric field, see section~\ref{ssec:katrin:E_bg}. A power supply, connected to the rear wall, can apply an additional potential to compensate for the contact potential differences. There is no direct in situ measurement possible at the moment to determine the electric field in front of the rear wall. Hence, it is of interest to investigate the charged particle behavior at different rear wall potentials through simulation. In the following three different cases are compared: $U_\text{rw} = \SI{20}{meV}$, \SI{-20}{meV} and \SI{0}{meV}. The values are chosen to reflect the case, where the absolute rear wall potential is slightly higher than the thermal energy of the particles ($E_\text{th} \approx \SI{6.9}{eV}$). The potential is investigated at positive and negative values. The corresponding longitudinal densities can be found in figure~\ref{fig:Chapter4_KARL/WithField/comparison_density_potential.pdf}. \xfigure{tb}{1.}{Chapter4_KARL/WithField/comparison_density_potential.pdf}{Charged particle density with rear wall potential.}{The rear wall potential was set to value $U$. The magnetic field was set to $B = \SI{2.5}{T}$, the maximum tritium density was set to $n_\text{max} = \SI{6.3E14}{cm^{-3}}$, and the temperature to $T = \SI{80}{K}$. The density of the electrons is denoted as $e^-$. The density of the different ion species is combined in the total density, denoted as $i^+$.} It can be seen, that the influence of the rear wall potential is dependent on the particle type and sign of the potential. In the following, the major differences between the simulations with and without rear wall potential are discussed. In the simulation with positive rear wall potential, a fraction of the ions is reflected by the potential. The reflected ions travel towards the center of the source. The probability of ion-neutral collision increases towards the center. Until a certain point, the ions are reflected back towards the rear wall, through the stream of outgoing gas. The ions can gain energy through the scattering process. Thus, they might cross the potential wall at some point. Additionally, the guiding center of the ions can change position in each collision with the neutral gas. Hence, trapped ions can move perpendicular to the magnetic field lines and neutralize at the beam tube. In total, the density of ions is increased between the rear wall and the first pump port. The density in the rest of the source is not influenced by the potential of the rear wall, because the stream of neutral particles reduces the stream of reflected ions into the central part of the source to a bare minimum. The electron density is not significantly influenced by the positive rear wall potential. This is expected, because they already move in the direction of the rear wall. The positive potential accelerates the electrons towards the rear wall even further. The acceleration region is only present close to the rear wall. Thus, the reduction of the density through the acceleration is therefore not resolved here. In the simulation with a negative rear wall potential, a fraction of the electrons is reflected by the potential. In contrast to the positive rear potential case, they do not only accumulate in front of the rear wall, but throughout the source. The scattering probability for electrons is much lower than for ions. Thus, they are not reflected as much by the neutral gas flow. Therefore, the density in the whole source increases. While travelling the source, the electrons can gain energy through scattering. Hence, they can pass the potential barrier at the rear wall at some point. The shape of the ion density stays the same at negative rear wall potentials. The same argument, for the electrons in the positive rear wall potential case, applies here. The ion movement is only influenced in front of the rear wall, which is not resolved in this simulation. In both cases, the density of the charged particles increases, because the particles stay longer in the source. In contrast, the overall longitudinal current does not change (not shown). Almost the same amount of electrons and ions is produced through ionization. Thus, these particles will move towards the rear wall eventually. Only those ions and electrons, which have scattered much, leave through the beam tube walls. In total, it could be shown that a rear wall potential has a significant influence on the motion and density of charged particles. It is apparent, that a potential at the rear wall alone does not reinstate quasineutrality in the source. Nevertheless, it seems that a negative potential wall is likely to occur at the rear wall region as a result of the observed reduced space charge density in the simulation with negative potential. \subsection{Field from Density Data} The density generated by the field free simulations shows a large difference between the density of the electrons and the ions. Such a particle distribution will generate an electric field, which in turn will influence the particle distribution itself. A starting point for the simulations with an electric field can be obtained by the use of a Poisson solver. This solver will generate an electric field from the density of the field free simulation. The results can be used in future simulations with \acs{karl}. Thus, new particle distributions are produced, and an iterative cycle can be started. In the following, the Poisson solver used will be presented first. In a second step, the solver will be applied to the data of the field free simulation and a new simulation with the generated field will be performed. \subsubsection{Poisson Solver} \label{ssec:karl:poisson_solver} The density data of the \acs{karl} simulation can be used to solve for the electrostatic potential $U$ in the source through the Poisson equation \begin{equation} \nabla^2 U = - 4 \pi \rho \fullstop \label{eq:karl:poisson_equation} \end{equation} The charge density $\rho$ is directly calculated from the number densities \begin{equation} \rho = e\cdot (n_i - n_e) \fullstop \end{equation} It is assumed that the potential has an azimuthal symmetry. The Poisson equation in cylinder coordinates then reads as \begin{equation} \frac{1}{r} \frac{\partial U}{\partial r} + \frac{\partial^2 U}{\partial r^2} + \frac{\partial^2 U}{\partial z^2} = -4 \pi \rho \fullstop \end{equation} This equation can be used for all cases, where the radius is non-zero. In the limit of zero radius, the first summand tends to \begin{equation} \lim_{r\to 0} \frac{1}{r} \frac{\partial U}{\partial r} = \frac{\partial^2 U}{\partial r^2} \comma \end{equation} through the use of L'Hôpital's rule. The data of the \acs{karl} simulations is not available continuously, but in discrete bins. So the Poisson equation has to be transformed into discrete coordinates \begin{eqnarray} r &= i \Delta r \comma \\ z &= j \Delta z \comma \end{eqnarray} with the step size $\Delta r$ and $\Delta z$ in radial and longitudinal direction respectively. Additionally, the bins of the simulation stretch over multiple positions. In the following, it is therefore assumed that the density of a bin is known at its center. On the other hand, the potential values of the rear wall and the tube wall are given at the corners of the bins. For simplicity of the algorithm, it was therefore decided to extrapolate the density to the bin corners, see figure~\ref{fig:Chapter4_KARL/PoissonSolver/coordinates_poisson_solver.pdf}. The density at the bins corners $(i,j)$, which are surrounded by four cells, is calculated through the mean of the surrounding cells $(i^\prime,j^\prime)$. The density at the corners with $i = 0$ is calculated from the mean of the two adjacent bins, while the density at the boundaries of the simulation domain is set to the mean of the two surrounding bins. \xfigure{tb}{1.}{Chapter4_KARL/PoissonSolver/coordinates_poisson_solver.pdf}{Indexing of discrete values for the Poisson solver.}{The simulated density of \acs{karl} $n^\prime$ is assumed to be located in the center of the bin. The density is extrapolated to the bin corners (unprimed variables). The field and potential values are calculated on the unprimed grid. In a post processing step, the electric field is extrapolated back into the center of the bin.} With the new indices of the potential and density, it is possible to rewrite Poisson's equation with the method of central differences. In the end, the potential at a specific position inside the source can be calculated from the neighboring potential values and the density through \begin{align} \begin{split} \label{eq:karl:poisson_solver_r} U_{i,j} = {}& \frac{1}{\frac{2}{\Delta r^2} + \frac{2}{\Delta z^2}} \cdot \left( 4 \pi \rho_{i,j} + \frac{U_{i+1,j}}{\Delta r^2} \left( 1 + \frac{1}{2i} \right) + \frac{U_{i-1,j}}{\Delta r^2} \left( 1 - \frac{1}{2i} \right) \right.\\ & \left. \hspace{7cm} + \frac{1}{\Delta z^2} \left( U_{i,j-1} - U_{i,j+1}\right) \right) \comma \end{split} \\ U_{0,j} &= \frac{1}{\frac{4}{\Delta r^2} + \frac{2}{\Delta z^2}} \cdot \left( 4 \pi \rho_{0,j} + \frac{4}{\Delta r^2} U_{1,j} + \frac{1}{\Delta z^2} \left( U_{0,j-1} + U_{0,j+1}\right) \right) \fullstop \label{eq:karl:poisson_solver_r0} \end{align} Thus, the potential at each position can be solved through an iterative approach given correct boundary conditions. This model is subject to the following to conditions: the Dirichlet boundary and the Neumann boundary. The Dirichlet boundary is used, when the potential at specific points is known. In the following, these points include the beam tube surface and the rear wall surface, where the potential is set to zero, and $U_{\text{rw}}$ respectively. The Neumann boundary is used, when the first derivative of the potential is known, namely the electric field. The electric field is in general not known for the source tube. Nevertheless, it can be assumed that the electric field at large distances from the source is zero. Thus, this boundary condition is used at the transition towards the \acs{dps}. In total, the approach can be summarized by the following steps: \begin{enumerate} \item Initialize the potential to zero. \item Set the corresponding values of the Dirichlet boundary condition to the specified locations. \item Loop over all possible inner potential values and determine their values through equations \ref{eq:karl:poisson_solver_r} and \ref{eq:karl:poisson_solver_r0}. \item Redo step 3. for a specified number of times. \item Determine the difference between of the calculated potential and the density through equation~\ref{eq:karl:poisson_equation} for all positions. \item If the sum of the absolute differences is below a certain threshold, return the calculated potential array, otherwise go to step 3. \end{enumerate} The resulting potential cannot be used directly as input for the \acs{karl} simulations, because it takes only electric fields as input. Thus, the electric field must be calculated from the derived potential in a separate step. The calculation of the electric field follows two steps. First, the electric field ($E_r$ and $E_z$) between two points ($i,j$) is calculated from the potential difference in longitudinal and radial direction, see also figure~\ref{fig:Chapter4_KARL/PoissonSolver/coordinates_poisson_solver.pdf}. Second, the electric field values are extrapolated onto the position $(i^\prime,j^\prime)$ in the center of the density bins. \subsubsection{Simulation with Self Generated Field} For the simulation of \acs{karl} with self generated field, first the potential and field values are calculated from the data without electric field, see also section~\ref{sec:karl:field_free_simulation}. The potential and electric field of that calculation can be found in figure~\ref{fig:Chapter4_KARL/WithField/comparison_iteration_potential.pdf}. It can be seen, that the potential values are large in comparison to the thermal energy of the particles. This is expected, because the ion density is much larger, than the electron density. Thus, there is a large positive space charge, which produces such a large field. The shape of the potential follows mostly the shape of the ion density. The corresponding electric field shows regions with positive as well as negative values. So, the charged particles will pass through multiple sections, where they are accelerated and decelerated. \xfigure{tb}{1.}{Chapter4_KARL/WithField/comparison_iteration_potential.pdf}{Density, field and potential with and without electric background field.}{Both simulations were performed with a magnetic field of $B = \SI{2.5}{T}$, a maximum tritium density of $n_\text{max} = \SI{6.3E14}{cm^{-3}}$, and a gas temperature of $T = \SI{80}{K}$. The derived electric field of the simulation without background field (No field) was used as an input for the simulation with field (It. 1). The density of the electrons is denoted as $e^-$. The density of the different ion species is combined in the total density, denoted as $i^+$.} The electric field values are too large, to be used directly in the simulation. Electrons and ions, would be accelerated too much, and some of them would be trapped inside the simulation domain. Nevertheless, the shape of the field can be used as a first approximation for further simulations. The measurement results with Krypton \citep{PhDMachatschek2021} show, that the scale of the potential variation is on the order of $\mathcal{O}$(\SIrange{10}{100}{meV}). A factor $c_p$ is used to transform the shape of the potential of the \acs{karl} simulation towards this scale. In the following simulation, the factor was set to $c_p = \num{1E-3}$. The corresponding potential, electric field and density distribution can be found in figure~\ref{fig:Chapter4_KARL/WithField/comparison_iteration_potential.pdf}. It can be seen, that the field has an influence on the particle densities, which is different for ions and electrons. For the ions, the density did not change significantly. Especially in the center of the source, the density distribution shows only a slight difference. This behavior can be explained by the collisionality of the ions. In the center, they collide very often. Hence, the low field values do not suffice to dominate the movement of the ions. At the sides, the ion density shows different values than before, caused by the reduced collision frequency and interaction with the electric field. It pushes the ions out of the source, which reduces their density. For the electrons, larger differences between the two simulations are observable. It is noticeable in an increased density, and a change of the shape, which can also be explained by the collisionality of the electrons. The electron movement is only partly dominated by collisions with neutral gas. Thus, the field can shape the density distribution. The field is a product of the different electron and ion densities and tries to reinstate quasineutrality. This process can be observed in the alignment of the electron and ion density shape in the center of the source. Nevertheless, the density of electrons and ions is still significantly different close to the rear wall and \acs{dps}. This difference to the quasineutrality shows that the field used in the simulation is not the true field inside the source. It has to be refined in future simulations. A starting point might be the field generated by the densities of electrons and ions in the simulation with electric field. The resulting potential and electric field is also displayed in figure~\ref{fig:Chapter4_KARL/WithField/comparison_iteration_potential.pdf}. It can be seen that the overall shape of the potential changed slightly to lower values. Nevertheless, the values are still larger than the measured field values. Thus, it must be concluded that the field did not reach an equilibrium state and further simulations are necessary. \xfigure{tb}{1.}{Chapter4_KARL/WithField/comparison_iteration_spectrum.pdf}{Electron spectrum with and without electric background field.}{Both simulations were performed with a magnetic field of $B = \SI{2.5}{T}$, a maximum tritium density of $n_\text{max} = \SI{6.3E14}{cm^{-3}}$, and a gas temperature of $T = \SI{80}{K}$. The derived electric field of the simulation without background field (No field) was used as an input for the simulation with field (It. 1). The spectrum was evaluated at three positions inside the source.} The electric background field also influences the spectrum of the electrons. In figure~\ref{fig:Chapter4_KARL/WithField/comparison_iteration_spectrum.pdf}, the spectrum at different positions in the source is shown for the simulation with and without electric field. It can be seen, that the influence of the electric field is dependent on the position inside the source, and the energy region. The different observations will be described in the following. The shape of the spectrum changed significantly in the thermal region. There are fewer electrons with low-energy than before. This is expected, because all low-energy electrons have been accelerated by the electric field and therefore have gained additional energy. Nevertheless, the overall shape of the thermal region is maintained. This is caused by the scatterings with neutral gas, which is still the dominant interaction channel for the electrons. The difference towards the thermal spectrum is most noticeable at the rear wall. Collisions with neutral gas are infrequent here and thus, changes of the spectrum through the field are most pronounced. However, the potential difference in the simulation between the rear wall and the center are on the order of $\mathcal{O}(\SI{1}{meV})$. Thus, large changes fail to appear. This might change in the future with more precise evaluations of the potential. Simulations with \acs{acronym} indicate that larger potential differences are to be expected, see chapter~\ref{ch:pic_at_katrin}. The shape of the high-energy tail of the spectrum (beta and transitional region) is not influenced by the electric field. This is expected, because the energy of these particles is much greater than the energy gained through the electric field. Again, this observation is only valid for potential differences on the order of $\mathcal{O}(\SI{1}{meV})$ and might change in the future. Until now, the potential was derived after completion of a \acs{karl} simulation, and it was then used for following simulations. This procedure is rather slow, because subsequent iterations are blocked by the previous. It is conceivable, that an integration of the Poisson solver directly into \acs{karl} will produce faster results. In this case, the Poisson solver will be used after a given number of beta decays and the field will then be used directly in the simulation for further decays. This procedure is untested until now and up for future endeavors. In total, the simulations with electric field have shown that even a small electric field has a significant influence on the shape of the density distributions of the particles. The results indicate that quasineutrality will be reinstated with that field, especially in the center of the source. In the regions with low tritium density, there is still a significant difference between the densities. Thus, more elaborate simulations should be performed in the future. \section{Conclusion} \label{sec:karl:conclusion} In this chapter, a new simulation tool name \acs{karl} was presented. By using the Monte Carlo method, it simulates the density and the velocity distribution of charged particles in the \acs{katrin} source. The distributions were obtained through tracking single particles in the source until they are destroyed. The single particles can interact indirectly with each other through density fields. Therefore, this approach allows for the simulation of electron-ion interactions alongside electron-neutral and ion-neutral interactions. The algorithm was tested in multiple test simulations. It could be shown, that the implemented interactions can represent the empirical phenomena. The \acs{karl} simulation tool was used to investigate the spectrum of the electrons in simulations without electric background field. There, the simulated electron spectra showed a trisection: a beta region, a thermal region and a transitional region. The relative density of these regions was found to be dependent on the position in the source. Additionally, the density of electrons and ions depending on the position in the source was determined. Significant differences were found between the densities of the different species. As expected, \ce{T3+} was the most abundant specie. \ce{T2+} and \ce{T+} only played a secondary role in the total ion density. The shape of the electron density was significantly different from the ion density. So, electrons scattered less and were less influenced by the neutral gas. Additionally, the electron density in front of the rear wall was found to be lower, than the density in the center of the source. Hence, electrons can travel through the center of the source and do not accumulate in front of the \acs{dps} section. In total, the simulation showed, that electrons cannot be treated as collisional in the center of the source, while ions can be treated this way. In front of the rear wall and \acs{dps}, both electrons and ions have to be described as non-collisional. Additionally, the particle current were determined depending on their position in the source through virtual barriers. A non-negligible ion current towards the beam tube was found. The simulated ion current provides a first explanation of the non-zero measured total current without any use of an electric field. Furthermore, the behavior of the density and spectrum under change of external measurement parameters was investigated. It was found that the spectrum and particle densities are only influenced marginally by the temperature of the neutral gas. The neutral particle density, however, can have a significant influence on the spectrum. When, the density was reduced to \SI{10}{\percent} of the nominal value, the spectrum changed significantly. The trisection of the spectrum was no longer observed, and the low-energy part of the spectrum could no longer be described by the Maxwell-Boltzmann distribution. Also, the influence of the magnetic field strength was investigated. It was found, that in the field free case, the ion current towards the beam tube can be described through classical diffusion. In the end, the influence of an electric field was explored. This influence was first simulated by a contact potential difference between rear wall and tube wall. It was found that a rear wall potential has a significant influence on the charged particle motion, and on the density of the charged particles. A negative potential difference reduced the space charge density. Thus, it was hypothesized, that also the real plasma will show a negative potential towards the rear wall. Secondly, the density distribution of the field free simulation was used to determine an electric field generated by the particles themselves. The field was used as an input for a continuative simulation. Therefore, a Poisson solver was constructed. The resulting potential and electric field showed large values, due to the large total charge density. The field was therefore reduced by a scaling factor in the subsequent simulation to represent more realistic values. The simulation showed, that the field partially reinstates quasineutrality in the center of the source. However, large density differences were still observed in front of the rear wall. Thus, more elaborate simulations are necessary in the future. These simulations might include an internal Poisson solver, which calculates the electric field during the simulation.