From d1391efd456ffe225f96ea477e46cd8cd16bbfcd Mon Sep 17 00:00:00 2001 From: fspanier Date: Mon, 22 Apr 2019 23:27:54 +0200 Subject: [PATCH] Shortened Test Cases, Diagnostics --- numerics.tex | 181 +++++++++++++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 77 deletions(-) diff --git a/numerics.tex b/numerics.tex index 2a1ab07..41af429 100644 --- a/numerics.tex +++ b/numerics.tex @@ -1072,46 +1072,48 @@ with these boundary conditions is that they rely on fixed waves speeds. The presence of the plasma changes the wave speed. %from the speed of light to a lower speed that might depend on wavelength, %incident angle and plasma parameters such as the magnetizations -This makes is -very hard to absorb all wave modes that reach the boundary sufficiently well. +This makes it very hard to absorb all wave modes that reach the boundary sufficiently well. A great step forward was the development of the \textit{Perfectly Matched Layer} (PML) by \cite{Berenger_1994}. This layer is technically not a boundary condition, but rather a region of space with modified permeability and -permitivity. These material properties are choosen such that the impedance of -the material is identical to the adject free space. Therefore the refractive -index does not change from free space to the material layer and now waves are +permittivity. These material properties are chosen such that the impedance of +the material is identical to the adjacent free space. Therefore the refractive +index does not change from free space to the material layer and no waves are reflected. Inside the material the wave is however damped, attenuating before it reaches the actual boundary. There a simple boundary condition such as PEC -can be chosen. And wave that does reach the boundary and gets reflected is +can be chosen. Any wave that does reach the boundary and gets reflected is attenuated a second time on the way out, greatly improving performance of this -scheme. Several different formulations of PML have been developed such as -split-PML (where each electric and magnetic field component inside the boundary -is split into two independent, unphysical fields that are damped separately), -uniaxial PML (UPML) and more general stretched-coordinate PML wave been -developed. One version known as convolutional PML (CPML) has been used -successfully in multiple coes. The book \cite{Berenger_2007} explains the +scheme. +%Several different formulations of PML have been developed such as +%split-PML (where each electric and magnetic field component inside the boundary +%is split into two independent, unphysical fields that are damped separately), +%uniaxial PML (UPML) and more general stretched-coordinate PML wave been +%developed. +One implementation known as convolutional PML (CPML) has been used +successfully in multiple cases. The book \cite{Berenger_2007} explains the different methods and their connections. -Even before the development of these methods was completed, PML conditions were -used in Particle-in-Cell simulations, see e.g. \cite{Pasik_1999, Pukhov_1999}. -PML boundary conditions are often combined with particle boundaries that absorb +%Even before the development of these methods was completed, PML conditions were +%used in Particle-in-Cell simulations, see e.g. \cite{Pasik_1999, Pukhov_1999}. +PML boundary conditions are often combined with boundaries that absorb outgoing particles and replace them in some scheme to simulate the presence of a thermal plasma bath outside the simulation domain that can act as the source of -unperturbed upstream. This has been used in particular in the simulation of +unperturbed upstream. This has been used in the simulation of magnetic reconnection, where the removal of plasma in the outflow regions and the injection of fresh upstream with not-yet-reconnected magnetic flux allows -for the study of larger systems and long time effects (see \cite{Daughton_2006, +for the study of larger systems (see \cite{Daughton_2006, Klimas_2008, Ohtani_2009}). -Besides the injection of thermal plasma on the boundary it is also possible to +%Besides the injection of thermal plasma on the boundary +It is also possible to inject electromagnetic waves to study their propagation. This can either be achieved by the means of an artificial current, acting as an antenna or by -manipulating the electromagnetic field directly. More complicated inject +manipulating the electromagnetic field directly. More complicated injection schemes that allow for the injection of realistic laser pulses (\cite{Thiele_2016}), of oblique waves with arbitrary envelops (\cite{Perez_2018}) or of magnetized plasma without unwanted numerical noise -(\cite{Kilian_2018}) are possible as well, but require a bit of care. +(\cite{Kilian_2018}) are possible as well.%, but require a bit of care. % Eliasson_2002.pdf outflow condition for fourier transformed vlasov-poison system @@ -1121,50 +1123,48 @@ schemes that allow for the injection of realistic laser pulses As much fun as it can be to write and run a Particle-in-Cell code, 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. As -tempting as it might be to simply save the complete state of the simulation and -use later post-processing to produce higher-level diagnostics and plots, it is -usally a bad idea from a performance standpoint. Whenever possible the -simulation code should calculate diagnositics as close to the final plots and -output only them. After all, a simple histogram for a velocity distribution -might only be a few kilobytes, where the dump of all particles is serval -terabytes. Saving the simulation state for later analysis or restart might -still be necessary but should be performed as rarely as possible. +storing them in a way that persists beyond the duration of the simulation. +%As tempting as it might be to simply save the complete state of the simulation and +%use later post-processing to produce higher-level diagnostics and plots, it is +%usually a bad idea from a performance standpoint. +Simply storing the full state of the simulation is typically impossible for +performance reasons. +Whenever possible the simulation code should calculate diagnostics as close +to the final plots and output only them. After all, a simple histogram for +a velocity distribution might only be a few kilobytes, where the dump of all +particles is several terabytes. Saving the simulation state for later analysis or restart might still be necessary but should be performed as rarely as possible. There are of course many high-level diagnostics and it is impossible to cover all of them. This section will therefore mostly cover general-purpose output -that can be postprocessed further. +that can be postprocessed further. To gain high-level insight into the +simulation at low I/O cost it is often useful to calculate a breakdown of +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. -To gain high-level insight into the simulation at low I/O cost it is often -useful to calculate a breakdown of 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. - -Another obvious candidate for output are all the gridded quantities, such as -electric and magnetic field as well as current density. These quantites do not -require any extra calculation, but there size prohibits writing them out as -text files. The two most widely used choices are dumping the memory of every +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, but their size requires a binary output. 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 very little -overhead, even is a small header is included. The downside is that the separate -views of the different doamins need to combined for further analysis. The -overhead of creating many files in the same directory at once and the tedious -file handling make this alternative an increasing poor choice once the -simulation used more than a few hundred cores. Parallel I/O to HDF5 requires +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 inclusing of meta-data and easy loading into analysis tool, independend of +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 pressure tensor can also be good choices for grid based output. Even if many of -these quantities are required it is typically cheaper to computer the +these quantities are required it is typically cheaper to compute the diagnostics during the parallel simulation instead of dumping the full particle information and doing post-processing. In many cases not all of the three-dimensional field data is required. Averaging over one or two dimensions to obtain line profiles or two-dimensional -selections is an option. Alternatively lineouts or two-dimensional cuts can be +selections is an option. Alternatively line-outs or two-dimensional cuts can be useful. If points of interest are known beforehand or can easily be computed on the fly it is interesting to output time histories of those points at high cadence. If a global overview is needed, but not the full resolutions, it is @@ -1173,76 +1173,103 @@ 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 -wallclock limit, or due to a compute node crashing (this is actually an -increasing problems with supercomputers pushing the 10000 limit and -mean-time-between-failures measured in days at best). Also some analysis can +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, -the pull particle information needs to be stored. Again direct binary dumps or +the full particle information needs to be stored. Again direct binary dumps or higher-level self-describing formats are the two main possibilities. Some codes even implement both, the high-level format for scientific analysis and binary dumps that are overwritten periodically as faster checkpoints that are only used for restarts. Many other diagnostics have been developed and the following list of examples -is certainly incomplete: one-dimensional histogramms of particle quantities -such as speed or energy, two-dimensional cuts in phasespace showing e.g. -$x-v_x$-densities, fourier transforms of other quantites such as +is certainly incomplete: one-dimensional histograms of particle quantities +(speed, energy), two-dimensional cuts in phase space showing e.g. +$x-v_x$-densities, Fourier transforms of other quantities such as $\tilde{B}(|k|)$, time averages of other quantities to remove high-frequency noise, trajectories of specially selected particles of interest, often together with local field quantities at the position of the tracer particles, -reconstruction of the particle phasespace density on a six-dimensional grid, -discrete estimates of the entropy based on a binned phasespace. The -possibilities are endless here and a large fraction of the delevopment time of -a mature code will be invested in probiding userfriendly, scalable, efficient +reconstruction of the particle phase space density on a six-dimensional grid, +discrete estimates of the entropy based on a binned phase space. The +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 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 -much higher frequenies that can be calculated separately. See +much higher frequencies that can be calculated separately. See \cite{Pausch_2018} on how to implement and properly test such radiation diagnostics. Some recent codes include the production of gamma rays and electron-positron pairs \cite{Nerush_2017}. This is especially relevant for the nascent field of pulsar magnetosphere simulations, where the back reaction -of the radiation processes on the energetic particles in the similation needs +of the radiation processes on the energetic particles in the simulation needs to be included \cite{Kalapotharakos_2018}. -\subsection*{Test Cases} +\subsection{Test Cases} -Unlike hydro codes that tend to develop negative densities or pressures when -numerical problems occure Particle-in-Cell codes are relatively robust. This -can be a good, but brings the risk of obtaining a plausible but wrong result. -It is therefore important that the researcher employs a healthy scepticism -towords the code and that the code is tested. Other communities have a large +\label{subsec:num:test} + +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 -effort into validation (making sure that the employed plasma model is adaquate -and that the underlying assumptions are met), benchmarking (comparisson with -other codes) and valdidation (testing proper implementation) are relativly new +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 low. +analytic solutions is rather small. -But there some test cases that can be recommended. The paper by -\cite{Jacobs_2006} introduced a discontinuous galerkin code on unstructured + +%Unlike hydro codes that tend to develop negative densities or pressures when +%numerical problems occur Particle-in-Cell codes are relatively robust. This +%can be a good, but brings the risk of obtaining a plausible but wrong result. +%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 +%effort into validation (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 low. + +%But there some test cases that can be recommended. The paper by +%\cite{Jacobs_2006} introduced a discontinuous Galerkin code on unstructured +%mesh, but also includes several useful test cases. The study of +%Kelvin-Helmholtz instability in Saturn's magnetopause in \cite{Delamere_2011} +%has been used by several hybrid codes. Code description paper such as the one +%for the Apart-T code \cite{Melzani_2013} or the SHARP code \cite{Shalaby_2017} +%lists several test problems that are solvable with that code and offers +%opportunity for benchmarking. Papers that investigate new hybrid codes such as +%\cite{Amano_2014,Munoz_2018} contain testproblems to demonstrate the new +%method, but many of them are also accessible to PiC codes. The paper by +%\cite{Kilian_2017} contains a list of wave modes and suggested parameters that +%are accessible to different plasma models that can be implemented by PiC codes. + +But there are some test cases that can be recommended. The paper by +\cite{Jacobs_2006} introduced a discontinuous Galerkin code on unstructured mesh, but also includes several useful test cases. The study of -Kelvin-Helmholtz instability in saturns magnetopause in \cite{Delamere_2011} +Kelvin-Helmholtz instability in Saturn's magnetopause \cite{Delamere_2011} has been used by several hybrid codes. Code description paper such as the one for the Apart-T code \cite{Melzani_2013} or the SHARP code \cite{Shalaby_2017} lists several test problems that are solvable with that code and offers opportunity for benchmarking. Papers that investigate new hybrid codes such as -\cite{Amano_2014,Munoz_2018} contain testproblems to demonstrate the new +\cite{Amano_2014,Munoz_2018} contain test problems to demonstrate the new method, but many of them are also accessible to PiC codes. The paper by \cite{Kilian_2017} contains a list of wave modes and suggested parameters that are accessible to different plasma models that can be implemented by PiC codes. Physical setups for which analytic solutions exist include the study of plasma waves \cite{Aastroem_1950, Bernstein_1958, Andre_1985, Swanson_2003} and the -thermal excitation of fluctuations oin density \cite{Dougherty_1960} or +thermal excitation of fluctuations in density \cite{Dougherty_1960} or electromagnetic fields \cite{Akhiezer_1975, Yoon_2017}. For complicated distribution function that do not admit analytic solutions for the dispersion -relation of plasma waves comparisson with numeric dispersion solver +relation of plasma waves comparison with numeric dispersion solver \cite{Roennmark_1982, Xie_2016} is useful. The study of Landau damping has a long tradition \cite{Dawson_1961} and can be useful to test the long term stability of the code \cite{Manfredi_1997}. @@ -1250,6 +1277,6 @@ stability of the code \cite{Manfredi_1997}. The comparison between different code types such as in \cite{Dimits_2000, Munoz_2015} can be useful to find the limits of applicability. This kind of comparison is especially popular in the Fusion power community -\cite{Falchetto_2008}. The expected scaling behaviour when improving numerical +\cite{Falchetto_2008}. The expected scaling behavior when improving numerical resolution can also be used to test the code, even without outside reference simulations, as shown in \cite{Riva_2017}.