Viele Kleinigkeiten - primär von Patricio - behoben

This commit is contained in:
2021-02-04 22:56:40 +01:00
parent ea9d967bee
commit 66faa689a9
5 changed files with 61 additions and 57 deletions
+55 -51
View File
@@ -41,9 +41,11 @@ $x_i$, as shown in Figure~\ref{fig:num:rot_yee}.
%This view of computational electrodynamics is rather recent but has proven
%useful when designing field solvers on unstructured grids \cite{Rabina_2014, Na_2018}.
The staggered arrangement of components looks complicated as first and the
reader might fear that it will require a lot of re-interpolation. But the
contrary is true as we will see in a moment. We start our consideration from
The staggered arrangement of components
%looks complicated as first and the reader might fear that it will require a lot of re-interpolation.
is non-trivial and it looks as if interpolation is needed to calculate derivatives
at the correct positions.
But the contrary is true as we will see in a moment. We start our consideration from
Maxwell's equation in CGS units. These are still customarily used in
Particle-in-Cell codes as they make the magnitude of electric and magnetic
components similar. Since we treat all material effects due to the plasma
@@ -57,7 +59,7 @@ and $\vec{B}$.
\nabla \cdot \vec{B} &= 0 \label{eq:num:monopol}
\end{align}
Gauss's Law in Eq.~\eqref{eq:num:gauss} is the corner stone for electrostatic
Particle-in-cell codes, but we will ignore it for now. It's equivalent for the
Particle-in-cell codes, but we will ignore it for now. Its equivalent for the
magnetic field, Eq.~\eqref{eq:num:monopol}, that describes the absence of
monopoles is mostly relevant as an initial condition. Faraday's Law and Ampere's
law can be rewritten as evolution equations:
@@ -66,7 +68,7 @@ law can be rewritten as evolution equations:
\frac{\partial \vec{E}}{\partial t} &= \phantom{-} c \nabla \times \vec{B} - \frac{4 \pi}{c} \vec{\jmath} \label{eq:num:Eevolution}
\end{align}
The time evolution given by these equations will not violate Eqs.~\eqref{eq:num:gauss} and \eqref{eq:num:monopol} if they were satisfied initially.
Eqs.~\eqref{eq:num:Bevolution} and \eqref{eq:num:Eevolution} implie that the curl of the electric field does not have to be known at
Eqs.~\eqref{eq:num:Bevolution} and \eqref{eq:num:Eevolution} imply that the curl of the electric field does not have to be known at
the location of the electric field, but rather at the location of the dual,
magnetic field.
@@ -168,7 +170,7 @@ The one instability that plagues electromagnetic Particle-in-Cell codes and is
the main driver to go beyond the simple and robust field solver described above
is the Numerical Cherenkov Instability (NCI). This long known instability (see
\cite{Godfrey_1974}) occurs when particles move close to the speed of light
and couple to light waves. In reality this only happens when then influence of
and couple to light waves. In reality this only happens when the influence of
a medium reduces the speed of light below the vacuum value and particle can
reach the local phase velocity. Numerically this can happen when the numerical
scheme introduces a dispersion error which reduces the speed of light. The
@@ -290,7 +292,7 @@ are converted to ordinary equations in Fourier space. This eliminates finite ste
but requires a global FFT \cite{Haber_1973, Jalas_2017}. For constant current density
Maxwell's equations can be integrated analytically in time leading to pseudo-spectral
analytic time domain (PDATD) schemes that are completely free of numerical dispersion.
Since global FFTs require a lot of communication and can limited scalability, there
Since global parallel FFTs require a lot of communication and can limited scalability, there
have been some attempts to avoid them and instead use local FFTs to build field
solvers (\cite{Vay_2013}).
@@ -385,8 +387,8 @@ of an interpolation that we will discuss next.
Fig.~\ref{fig:num:interpolation} illustrates how the interpolation from grid
quantities (magnetic field $B_z$ in this case) to the particle location is
done. As discussed in the last chapter the numerical macroparticle represents
a sample of the phase space with finite extent and a macro factor, or (statistical) weight) given by the number of physical particles it represents.
done. As discussed in the last scetion the numerical macroparticle represents
a sample of the phase space with finite extent and a macro factor, or (statistical) weight given by the number of physical particles it represents.
%The computational macro-particle represents a large number of physical
%particles and is thus seen as a chunk of phase space with a density
%distribution over a finite extend.
@@ -415,7 +417,7 @@ cell we can write the two-dimensional interpolation as
Many different choices for the shape function $S$ are possible and different
codes make different design choices here. Some properties are however required.
The shape function does not include the statistical weight of the macro pareticle, but rather has to be normalized, i.e.
The shape function does not include the statistical weight of the macro particle, but rather has to be normalized, i.e.
$\int_{-\infty}^{\infty}S(x)\,\mathrm{d}x = 1$ and should be symmetric, i.e.
$S(-x) = S(x)$. To allow efficient evaluation of
Eq.~\eqref{eq:num:Bzinterpol}, the shape function should have compact support,
@@ -601,7 +603,7 @@ Similar to the leap-frog procedure for the electromagnetic fields the particle's
\vec{x}(t+\Delta{t})\phantom{/2} &= \vec{x}(t)\phantom{-\Delta{t}/2}\,\,\, + \vec{v}(t+\Delta{t}/2)\cdot\Delta{t} \quad . \label{eq:num:posupdate}
\end{align}
When the force depends only on position, this can be solved straight forward.
When the force depends only on position, this can be solved straightforwardly.
For velocity dependent forces - magnetic fields are the most important case -
there is dependence on $\vec{x}(t)$, which is not known. The interpolation
$\vec{v}(t) \approx 1/2\left(\vec{v}(t-\Delta{t}/2)+\vec{v}(t+\Delta{t}/2)\right)$, but
@@ -672,7 +674,7 @@ This produces only the correct gyro radius, not the correct gyro angle.
The Lorentz factor $\gamma$ in Eq.~\eqref{eq:num:tanrotation} is approximated by
$\gamma = \sqrt{1 + \vec{u}_1\cdot\vec{u}_1 / c^2}$, which according to
\cite{Vay_2008} can lead to spurious forces
\cite{Vay_2008} can lead to spurious forces.
%and he suggests a more complicated expression.
%
% He therefor suggests to use
@@ -786,10 +788,10 @@ violations of Gauss' Law is completely eliminated.
Somewhat more widely implemented in the scheme by \cite{Villasenor_1992}. The
downside of this scheme is the need to treat the particle motion differently
depending how many cell interfaces the particle interacts with. The need to
branch to different sub-algorithms for each particle is computationally not
optimal on pipelined CPUs or GPUs where divergent branches incur large costs.
Additionally this scheme is tedious to extend to shape functions beyond CIC.
depending how many cell interfaces the particle interacts with. Since this
scheme needs to branch to different algorithms its use especially on GPU is
disadvantageous as branching computationally more expensive there.Additionally
this scheme is tedious to extend to shape functions beyond CIC.
% \begin{figure}[htbp]
% \begin{center}
@@ -812,7 +814,7 @@ Additionally this scheme is tedious to extend to shape functions beyond CIC.
\includegraphics[width=\textwidth]{currentassignment_umeda.pdf}
\caption{Current deposition using the Zig-Zag algorithm by \cite{Umeda_2003}. As the particle closes from one cell to another
%(across the solid black line indicating the cell interface)
, it's trajectory is modified to go via the midpoint.}
, its trajectory is modified to go via the midpoint.}
\label{fig:num:currentassignment_umeda}
\end{subfigure}
\caption{Charge conserving current deposition}
@@ -840,13 +842,14 @@ point has its motion split into a motion from the starting position to the mid
point, followed by a separate motion from the midpoint to the final location,
resulting in a Zig-Zag trajectory %that gave the scheme it's name.
as illustrated in Fig.~\ref{fig:num:currentassignment_umeda}% illustrates this motion and the
resulting current for the same particle trajectory as used before.
~resulting current for the same particle trajectory as used before.
%Finding the midpoints for the fraction of particles that does not stay in the same cell
%requires some conditional code, but the upside is that the current deposition
%inside each cell is slightly simpler. Overall the computational cost and
%noise-properties between the two deposition schemes is similar.
Although the method requires some conditional code the computational cost and
noise-properties between the two deposition schemes is similar
Although the method requires some code depending on conditional branching the
computational cost and noise-properties between the two later deposition schemes
is similar.
% \begin{figure}[htbp]
% \begin{center}
@@ -899,7 +902,7 @@ case we can pick the initial position of the particle at random using
\begin{equation}
\vec{x} = \left(L_x\cdot \mathcal{U}(0,1), L_y \cdot \mathcal{U}(0,1), L_z \cdot \mathcal{U}(0,1)\right) \quad,
\end{equation}
where the random generator function $\mathcal{U}$ produces three independent (pseudo-)random numbers, uniformly distributed between zero and one. The expected number of \textit{particles per cell} (\textit{ppc}) is Poisson distributed. Since the number of macroparticles is significantly smaller than the number of real particles, the statistical density fluctuations are higher in the simulation than in the reality. One easy step to remedy this to some extent is to create exactly the expected number of macro particles per cell and only choose
where the random generator function $\mathcal{U}$ produces three independent (pseudo-)random numbers, uniformly distributed between zero and one. The expected number of \textit{particles per cell} (\textit{ppc}) is Poisson distributed as we have a discrete probability distribution with independent probability. Since the number of macroparticles is significantly smaller than the number of real particles, the statistical density fluctuations are higher in the simulation than in the reality. One easy step to remedy this to some extent is to create exactly the expected number of macro particles per cell and only choose
the position inside the cell at random. This also makes it easy to represent
spatially changing densities, by computing the number of particles in each cell
from a known analytic function $n(\vec{x})$. This works well as long as the
@@ -926,7 +929,7 @@ deviation is set by the thermal speed
v_{th} = \sqrt{\frac{k_B T}{m}} \quad .
\end{equation}
Note that there is a second popular definition of the thermal speed that
includes a factor of two. When comparing with other codes and results this is a
includes a factor of square root two. When comparing with other codes and results this is a
point worth double-checking. Different species of different masses will have
different thermal speeds at the same temperature.
%The extension of this method
@@ -957,11 +960,11 @@ interaction with existing fields in the domain \cite{Cartwright_2000}.
% particle splitting and merging
In many simulations particles are created once and afterwards their number
never changes. It can however be useful to split particles in regions of
(phase-)space, where there is a low number of particles, to get better
statistics and reduce noise. Many of those particles however leave the
interesting region again and need to be merged together again to avoid a
ballooning of the computational cost.
never changes. It can however be useful to split particles into particles with
smaller macrofactor. in regions of (phase-)space, where there is a low number
of particles, to get better statistics and reduce noise. Many of those particles
however leave the interesting region again and need to be merged together again
to avoid a ballooning of the computational cost.
Splitting particles in a way that conserves mass, momentum and energy is
straight forward, as we can simply pick a source particle, split it into two
@@ -1006,7 +1009,7 @@ codes. One has to handle both the fields and the particles there and should do
so in a consistent way to avoid problems.
Numerically easiest are periodic boundary conditions where the cell at the
upper end of a coordinate is logically wrapped around to be just below the
upper end of a coordinate is logically wrapped around (for $N$ cells cell number 0 is right of cell $N-1$) to be just below the
lower end of the coordinate. Particles that leave through one side are
reinjected unmodified at the other end. Periodic boundary conditions mimic
infinite space reasonably well, as there are no fixed walls or ends to the
@@ -1058,7 +1061,7 @@ electron emission.
While physically not a boundary condition, moving simulation domains are often
implemented in terms of boundary conditions. One example is the moving window
in the XOOPIC code \cite{Bruhwiler_2001}. Here the Eulerian mesh it not moving,
in the XOOPIC code \cite{Bruhwiler_2001}. Here the Eulerian mesh is not moving,
but instead new grid cells are created on one side and populated with
background magnetic field and fresh thermal particles. On the other side the
grid is truncated and particles are removed. If the window happens to move at the
@@ -1126,7 +1129,7 @@ schemes that allow for the injection of realistic laser pulses
\subsection{Diagnostics}
\label{subsec:num:diag}
As much fun as it can be to write and run a Particle-in-Cell code, the ultimate
Designing and using a Particle-in-Cell code is interesting by itself, the ultimate
goal is to produce output that can be used to gain understanding of the
physical system. This requires the calculation of diagnostic quantities and
storing them in a way that persists beyond the duration of the simulation.
@@ -1148,19 +1151,19 @@ the energy content in the simulation in several rough categories, such as
the energy in the electric field, the energy in the magnetic field and in
the particles. The diagnostic is also very valuable to check conservation of total energy in a PiC code that conserves momentum by construction.
Another obvious candidate for output are gridded quantities, such as
electric and magnetic field as well as current density. These quantities do not
require any extra calculation.
The two most widely used choices are dumping the memory of every
MPI domain to a separate binary file or writing a global view to a structured
format such as HDF5. The first choice has the advantage of low
overhead. The downside is that the separate views of the different domains
need to be combined for further analysis. The overhead of creating many
files at once and the tedious
file handling make this alternative a poor choice for more than a few hundred cores. Parallel I/O to HDF5 requires
slightly more complicated I/O code and introduces some overhead, but allows for
the inclusion of meta-data and easy loading into analysis tool, independent of
programming language and CPU architecture.
Another obvious candidate for output are gridded quantities, such as electric
and magnetic field as well as current density. These quantities do not
require any extra calculation. The two most widely used choices are dumping
the memory of every MPI domain to a separate binary file or writing a global
view to a structured format such as HDF5\footnote{other formats are available,
but HDF5 is widely supported by many post-processing tools}. The first choice
has the advantage of low overhead as nearly no metadata is saved. The downside
is that the separate views of the different domains need to be combined for
further analysis. The overhead of creating many files at once and the tedious
file handling make this alternative a poor choice for more than a few hundred
cores. Parallel I/O to HDF5 requires slightly more complicated I/O code and
introduces some overhead, but allows for the inclusion of meta-data and easy
loading into analysis tool, independent of programming language and CPU architecture.
Other field data that need to be computed just for diagnostic purposes such as
the mass density, charge density, average bulk velocities, or components of the
@@ -1179,7 +1182,7 @@ possible to output a downsampled grid. Care should be taken to apply a digital
low-pass filter -- such as a Kaiser window \cite{Kaiser_1980} -- before the
decimation to avoid aliasing.
In some cases it is necessary to restart the code, either due to reaching a
In some cases it is necessary to restart the simulation, either due to reaching a
wallclock limit, or due to a compute node crashing. Also some analysis can
only be performed as post-processing, either due to poor scalability or because
it is actively being developed based on the simulation results. In this case,
@@ -1202,7 +1205,7 @@ possibilities are endless here and a large fraction of the development time of
a mature code will be invested in providing user friendly, scalable, efficient
diagnostics.
One special diagnostic that is of interest in astrophysical applications in the
One special diagnostic that is of interest in astrophysical applications is the
calculation of radiation spectra. This is different from the spectrum of the
field inside the simulation domain that is limited to frequencies that are
explicitly resolved. Often there is synchrotron or inverse-Compton radiation at
@@ -1222,12 +1225,13 @@ Compared to fluid codes that easily develop instabilities e.g. through
negative densities or numerical instabilities, PiC codes are rather robust.
This numerical stability is sometimes mistaken as physical plausibility.
It is therefore important that the researcher employs a healthy skepticism
towards the code and that the code is tested. Other communities have a large
number of test cases for which analytic solutions are known, or at least
results from other codes are available. In the Particle-in-Cell community
validation efforts (making sure that the employed plasma model is adequate
and that the underlying assumptions are met), benchmarking (comparison with
other codes) and validation (testing proper implementation) are relatively new
towards the code and that the code is tested. Other communities like the
fluid simulation community. have a large number of test cases for which
analytic solutions are known, or at least results from other codes are
available. In the Particle-in-Cell community validation efforts (making
sure that the employed plasma model is adequate and that the underlying
assumptions are met), benchmarking (comparison with other codes) and
validation (testing proper implementation) are relatively new
and rare. One of the reasons is that the number of test problems with known,
analytic solutions is rather small.