From 4daee58146cf54d9f0a9560a3603bb0e563ae12d Mon Sep 17 00:00:00 2001 From: Felix Spanier Date: Sat, 30 Mar 2019 22:07:10 +0100 Subject: [PATCH] Yee shortened --- numerics.tex | 119 ++++++++++++++++++++++++++------------------------- theory.tex | 15 ------- 2 files changed, 61 insertions(+), 73 deletions(-) diff --git a/numerics.tex b/numerics.tex index 4fcfe94..79c50df 100644 --- a/numerics.tex +++ b/numerics.tex @@ -1,4 +1,4 @@ -F\section*{Numerical Implementation} +\section*{Numerical Implementation} Particle-in-Cell codes are semi-Lagrangian in that they follow a Lagrangian description of phase space samples represented as macro particles coupled to @@ -39,7 +39,7 @@ Maxwell's equation in CGS units. These are still customarily used in Particle-in-Cell codes as the make the magnitude of electric and magnetic components similar. Since we treat all material effects due to the plasma explicitly by having particles react to the fields $\vec{E}$ and $\vec{H}$, -there can use them interchangably with the respective flux densities $\vec{D}$ +there can use them interchangeably with the respective flux densities $\vec{D}$ and $\vec{B}$. \begin{align} \nabla \times \vec{E} &= - \frac{1}{c} \frac{\partial \vec{B}}{\partial t} \label{eq:num:faraday}\\ @@ -60,41 +60,42 @@ This implies 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. -\begin{figure}[h!] - \centering - \includegraphics[width=0.5\hsize]{figure/numerics/rotation_yee.png} - \caption{Finite difference approximation in Yee scheme} - \label{fig:num:rot_yee} -\end{figure} +%%\begin{figure}[h!] + %%\centering + %%\includegraphics[width=0.5\hsize]{figure/numerics/rotation_yee.png} + %%\caption{Finite difference approximation in Yee scheme} + %%\label{fig:num:rot_yee} +%%\end{figure} +%% +%%As figure \ref{fig:num:rot_yee} illustrates, there is an elegant finite +%%difference approximation for the curl of the electric field at the location of +%%the magnetic flux, based on the four edges that surround the magnetic flux at +%%the center of the face. If we write this approximation carefully it reads +%%\begin{align} + %%\left(\nabla \times \vec{E}\right)_x&(i\Delta{x},(j+1/2)\Delta{y},(k+1/2)\Delta{z}) \approx \nonumber \\ + %%&\frac{E_y(i\Delta{x},(j+1/2)\Delta{y},k\Delta{z}) - E_y(i\Delta{x},(j+1/2)\Delta{y},(k+1)\Delta{z})}{\Delta{z}} + \nonumber \\ + %%&\frac{E_z(i\Delta{x},(j+1)\Delta{y},(k+1/2)\Delta{z}) - E_z(i\Delta{x},j\Delta{y},(k+1/2)\Delta{z})}{\Delta{y}} \quad . \label{eq:num:rot_yee_long} +%%\end{align} +%%This expression is of course rather unwieldy, so customarily the edge length as +%%well as the offsets required to center components along edges and on faces are +%%suppressed and Eq.~\eqref{eq:num:rot_yee_long} is simply written as +%%\begin{equation} + %%\left(\nabla \times \vec{E}\right)_x(i,j,k) \approx + %%\frac{E_y(i,j,k) - E_y(i,j,k+1)}{\Delta{z}} + + %%\frac{E_z(i,j+1,k) - E_z(i,j,k)}{\Delta{y}} \quad . \label{eq:num:rot_yee} +%%\end{equation} +%%When presented with such an expression the reader needs to know that the use of +%%the electric field at locations $k\Delta{z}$ and $(k+1)\Delta{z}$ implies that +%%the magnetic flux (where the curl is used) is located at $(k+1/2)\Delta{z}$. +%%This can make reading papers tedious, but is much more compact and closer to +%%the actual implementation where the array indices into the arrays holding the +%%values of the field components are naturally integers. +%% -As figure \ref{fig:num:rot_yee} illustrates, there is an elegant finite -difference approximation for the curl of the electric field at the location of -the magnetic flux, based on the four edges that surround the magnetic flux at -the center of the face. If we write this approximation carefully it reads -\begin{align} - \left(\nabla \times \vec{E}\right)_x&(i\Delta{x},(j+1/2)\Delta{y},(k+1/2)\Delta{z}) \approx \nonumber \\ - &\frac{E_y(i\Delta{x},(j+1/2)\Delta{y},k\Delta{z}) - E_y(i\Delta{x},(j+1/2)\Delta{y},(k+1)\Delta{z})}{\Delta{z}} + \nonumber \\ - &\frac{E_z(i\Delta{x},(j+1)\Delta{y},(k+1/2)\Delta{z}) - E_z(i\Delta{x},j\Delta{y},(k+1/2)\Delta{z})}{\Delta{y}} \quad . \label{eq:num:rot_yee_long} -\end{align} -This expression is of course rather unwieldy, so customarily the edge length as -well as the offsets required to center components along edges and on faces are -suppressed and Eq.~\eqref{eq:num:rot_yee_long} is simply written as -\begin{equation} - \left(\nabla \times \vec{E}\right)_x(i,j,k) \approx - \frac{E_y(i,j,k) - E_y(i,j,k+1)}{\Delta{z}} + - \frac{E_z(i,j+1,k) - E_z(i,j,k)}{\Delta{y}} \quad . \label{eq:num:rot_yee} -\end{equation} -When presented with such an expression the reader needs to know that the use of -the electric field at locations $k\Delta{z}$ and $(k+1)\Delta{z}$ implies that -the magnetic flux (where the curl is used) is located at $(k+1/2)\Delta{z}$. -This can make reading papers tedious, but is much more compact and closer to -the actual implementation where the array indices into the arrays holding the -values of the field components are naturally integers. +The classical solution to store electric and magnetic fields on the grids that yields the curl of the fields at the required position is the Yee grid. Here e.g. $B_y$ is stored at cell face $(i+1/2,j,k+1/2)$, while $E_y$ is stored at $(i,j+1/2,k)$. Not only does this process result in curls calculated at the correct position without interpolation, but the curl is calculated in second order immediately. -With the spatial derivatives neatly handled using second order accurate finite -difference approximations, we still need to handle the temporal derivative in -Eqs.~\eqref{eq:num:Bevolution} and \eqref{eq:num:Eevolution}. The customary -solution is to leaf-frog the fields, i.e. use the curl of the electric field at +The temporal derivative in Eqs.~\eqref{eq:num:Bevolution} and \eqref{eq:num:Eevolution} can be solved using the second-order spatial derivatives. The customary +solution is to leap-frog the fields, i.e. use the curl of the electric field at time $t\Delta{t}$ to update the magnetic field from time $(t-1/2)\Delta{t}$ to $(t+1/2)\Delta{t}$ and then use the curl of the magnetic field at that time to update the electric field to $(t+1)\Delta{t}$. This leads to a scheme that is @@ -108,29 +109,31 @@ the magnetic field and use \vec{E}^{t+1\phantom{/2}} &= \vec{E}^{t\phantom{-1/2}} + c \cdot \Delta t \cdot \nabla \times \vec{B}^{t+1/2} - 4 \pi \Delta t \cdot \vec{\jmath}^{t+1/2} \label{eq:num:Eupdate} \quad . \end{align} -This solver works well and is implemented in many codes. However the -electromagnetic fields can be rather noise in Particle-in-cell simulations. -There is a limited number of options to combat this. Increasing the number of -macro particles to bring it close to the number of physical particles works, -but is rather expensive as the noise level only goes down as $1/sqrt{N}$. -Another commonly used method is to filter the the source term -$\vec{\jmath}^{t+1/2}$. -%FIXME do that below and reference here -The third option is to make use of the fact that most of that noise is -concentrated at high $k$ and modify the field solver to damp those modes. This -is exactly what the method described in \cite{Friedman_1990} does. It replaces -Eqs.~\eqref{eq:num:B1update} and \eqref{eq:num:B2update} by -\begin{align} - \vec{B}^{t+1/2} &= \vec{B}^{t-1/2} - c \cdot \Delta t \cdot \nabla \times \left[\left(1+\frac{\theta}{4}\right)\vec{E}^t-\frac{1}{2}\vec{E}^{t-1}+\left(\frac{1}{2}-\frac{\theta}{4}\right)\vec{\bar{E}}^{t-2}\right]\quad , \label{eq:num:Bupfriedman}\\ - \vec{\bar{E}}^{t-2} &= \left(1-\frac{\theta}{2}\right)\vec{E}^{t-1} + \frac{\theta}{2}\vec{\bar{E}}^{t-3} \quad . -\end{align} -If desired Eq.~\eqref{eq:num:Bupfriedman} can be split into two steps to get -access to $\vec{B}^t$. The method allows tuneable damping by selecting $\theta$ -between 0 and 1 at the extra expense of storing and updating $\vec{\bar{E}}$. -The damping rate $\gamma$ is given by -\begin{equation} - \gamma\Delta{t} = - \frac{8\,\theta}{(2-\theta)^2} \left(\frac{c\,\Delta{t}}{\Delta{x}}\right)^4\sin^4\left(\frac{k\,\Delta{x}}{2}\right) \quad . -\end{equation} +This solver is the most common method and is accurate to second order with respect to given current. Since small numbers of macroparticles leads to an increased noise, solvers that remove the noise. Increasing particles numbers is typically not an option as the noise level decreases as $1/\sqrt{N}$. Either the source term $\vec{\jmath}^{t+1/2}$ can be filtered or the noise can be damped. The latter is possible since noise is concentrated at high $k$ values. This low-pass filtering is described in \cite{Friedman_1990} and changes Eqs.~\eqref{eq:num:B1update} and \eqref{eq:num:B2update}. + +%%This solver works well and is implemented in many codes. However the +%%electromagnetic fields can be rather noisy in Particle-in-cell simulations. +%%There is a limited number of options to combat this. Increasing the number of +%%macro particles to bring it close to the number of physical particles works, +%%but is rather expensive as the noise level only goes down as $1/\sqrt{N}$. +%%Another commonly used method is to filter the the source term +%%$\vec{\jmath}^{t+1/2}$. +%%%FIXME do that below and reference here +%%The third option is to make use of the fact that most of that noise is +%%concentrated at high $k$ and modify the field solver to damp those modes. This +%%is exactly what the method described in \cite{Friedman_1990} does. It replaces +%%Eqs.~\eqref{eq:num:B1update} and \eqref{eq:num:B2update} by +%%\begin{align} + %%\vec{B}^{t+1/2} &= \vec{B}^{t-1/2} - c \cdot \Delta t \cdot \nabla \times \left[\left(1+\frac{\theta}{4}\right)\vec{E}^t-\frac{1}{2}\vec{E}^{t-1}+\left(\frac{1}{2}-\frac{\theta}{4}\right)\vec{\bar{E}}^{t-2}\right]\quad , \label{eq:num:Bupfriedman}\\ + %%\vec{\bar{E}}^{t-2} &= \left(1-\frac{\theta}{2}\right)\vec{E}^{t-1} + \frac{\theta}{2}\vec{\bar{E}}^{t-3} \quad . +%%\end{align} +%%If desired Eq.~\eqref{eq:num:Bupfriedman} can be split into two steps to get +%%access to $\vec{B}^t$. The method allows tuneable damping by selecting $\theta$ +%%between 0 and 1 at the extra expense of storing and updating $\vec{\bar{E}}$. +%%The damping rate $\gamma$ is given by +%%\begin{equation} + %%\gamma\Delta{t} = - \frac{8\,\theta}{(2-\theta)^2} \left(\frac{c\,\Delta{t}}{\Delta{x}}\right)^4\sin^4\left(\frac{k\,\Delta{x}}{2}\right) \quad . +%%\end{equation} 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 diff --git a/theory.tex b/theory.tex index 62c747a..9edfee6 100644 --- a/theory.tex +++ b/theory.tex @@ -106,21 +106,6 @@ The mathematical viewpoint is clear: PiC is a method, where the phase space dist -Just read \cite{Hockney_1981} - -%Pure Particle simulations (Molecular dynamics) are exact -%MD is not reasonable -%Plasma can be described - -Vlasov equation -\begin{align} - \frac{\partial f}{\partial t} &= f - \label{eq:theory:vlasov2} -\end{align} - -Wo ist die Vlasov-Gleichung? Da \eqref{eq:theory:vlasov} ist sie ja! Gute Gleichung. Brav! - - %Kinetische Plasmen können über verschiedene Methoden beschrieben werden. %Die Haupteigenschaft des kinetischen Plasmas ist der Mangel an Stößen. %Eine völlig korrekte Beschreibung ist die direkte Wechselwirkung aller Teilchen miteinander