Merge branch 'master' of masterduck.fspanier.de:fspanier/teaching into master

This commit is contained in:
2022-11-10 14:26:45 +01:00
9 changed files with 310 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

+84
View File
@@ -0,0 +1,84 @@
\documentclass[12pt,a4paper]{uebungen}
\usepackage{german}
\usepackage[utf8]{inputenc}
\usepackage{epsfig}
\usepackage[amssymb]{SIunits}
\usepackage{wrapfig}
\usepackage{graphics}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pgf}
\usepackage{listings}
\lstset{language=[ANSI]C++,basicstyle=\ttfamily,commentstyle=\itshape,
keywordstyle=\bfseries,extendedchars=true,backgroundcolor=\color{gray}}
%------------------------------------------------------------------------------
%\graphicspath{{../../../GALLERY/}}
%------------------------------------------------------------------------------
\setlength{\topmargin}{-2.5cm}
\setlength{\textheight}{26.0cm}
\setlength{\textwidth}{17cm}
\setlength{\oddsidemargin}{-0.5cm}
\setlength{\evensidemargin}{-0.5cm}
\setlength{\parskip}{0pt}
\setlength{\parindent}{0pt}
\pagestyle{empty}
%------------------------------------------------------------------------------
\newcommand{\vt}[1]{\vec{#1}}
\newcommand{\mt}[1]{\underline{\underline{#1}}}
\newcommand{\dt}[1]{\left\vert\underline{\underline{#1}}\right\vert}
\newcommand{\mo}{\!\!\!\!\!-1}
%------------------------------------------------------------------------------
\def\bbbr{{\rm I\!R}}
%------------------------------------------------------------------------------
\begin{document}
%------------------------------------------------------------------------------
\thispagestyle{myheadings}
\begin{center}
{\bf \underline{\Large Exercises in ``Numerical Methods in Plasma Astrophysics''}}\\
%\hfill\\
%{\bf \large }\\
\hfill\\
{\bf \large Winter 2022/23 \hfill Exercise 3}\\
\end{center}
\noindent
%
\section*{\large Exercise 3: Pierce diode}\vspace*{-0.0cm}
%
\begin{center}
\includegraphics[width=12cm]{diode.png}
\end{center}
Given is a one-dimensional vacuum tube (so-called \emph{Pierce diode}), which is provided with electrodes at both ends. The two electrodes are short-circuited and earthed, so that the
electrical potential at the edge is kept at $\Phi(0) = \Phi(L) = 0$.
From the left electrode, mono-energetic electrons ($E_e$) are injected at a constant rate $n$. If an electron hits one of the two electrodes ($x = 0$ or $x = L$), it is discharged to the ground.
Due to the motion of the ion background, the gas in the tube is quasi-neutral ($\left<\rho\right> = 0$), thus the mean electric potential $\left<\Phi\right>=0$, and only local fluctuations occur.
\bigskip
\textbf{a)} Simulate the behaviour of the Pierce diode using an
electrostatic 1D PiC code. Observe how, above a critical
electron injection rate, chaotic behaviour breaks out in the Pierce diode.\\
It is sufficient to use the CIC scheme to perform the charge assignment.
\medskip
The electric field can be calculated either by solving Poisson's equation
\begin{equation}
\Delta \phi = - 4 \pi \rho
\end{equation}
or directly by discretisation of
\begin{equation}
\nabla \cdot \vec{E} = 4 \pi \rho
\end{equation}
\vspace{7cm}
No rubber ducks were harmed in the making of this exercise.
\end{document}
%------------------------------------------------------------------------------
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.
Binary file not shown.
+226 -1
View File
@@ -2713,7 +2713,232 @@ simulations, as shown in \cite{Riva_2017}.
\chapter{Hyperbolische Erhaltungssätze}
\chapter{Hyperbolic conservation laws}
A large number of physics problems can be cast into a hyperbolic conservation law of the type
\begin{align}
\diffp{u(x,t)}{t} + \diffp{f(u(x,t))}{x} = 0
\end{align}
or in more than one dimension
\begin{align}
\diffp{u(x,t)}{t} + \nabla f(u(x,t)) = 0
\end{align}
As the name promises, something is conserved. Here $u$ is conserved and $f$ is the flux of this quantity. Whenever something behaves vaguely like a fluid this type of equation comes into play. The most simple form of this conservation law is the advection equation. As we will discuss later, the advection equation has - in its simple form - an analytic solution. If this was the case for all hyperbolic conservation laws there would be no need for numerical simulations. Unfortunately most hyperbolic conservation laws are similar to the Burgers equation, which includes a nonlinearity on the RHS (Navier-Stokes, MHD, etc.). And then there is no analytic solution.
We still need to understand how solutions look like for hyperbolic conservation laws to develop numerical schemes and decide, which solution is correct.
One point we have to discuss is the fact that we deal with PDEs now rather than ODEs before. We may solve a conservation law using, e.g., a Runge-Kutta 3rd order scheme
\begin{align}
u^\prime &= u^n +\Delta t \diffp{u^n}{x}\\
u^{\prime\prime} &= \frac{3}{4} u^n + \frac{1}{4}u^\prime +\frac{1}{4}\diffp{u^\prime}{x}\\
u^{n+1} &= \frac{1}{3} u + \frac{2}{3} u^{\prime\prime} - \frac{2}{3}\diffp{u^{\prime\prime}}{x}
\end{align}
Looks simple? It isn't. As we will figure out, the derivatives with respect to $x$ cannot just be cast into a finite difference.
\section{Advection equation}
The advection equation
\begin{align}
\partial_t u + a \partial_x u &= 0\\
u_0(x,t=0) &= u_0(x)
\end{align}
describes how the quantity $u$ is advected with a constant velocity $a$. When everything moves at constant speed, we can easily find the analytic solution
\begin{align}
u(x,t) = u_0(x- a t)
\end{align}
The solution is constant along the line $x_0 = x-at$. These lines are called characteristics.
\begin{figure}
\begin{center}
\pgfimage[width=.8\textwidth]{fig_chapter5/linear-advection}
\end{center}
\end{figure}
Characteristics are a fundamental concept for first order differential equations and we will make use of this concept for the more complicated conservation schemes.
The characteristic fulfills $x^\prime(t)=a$ and $x(0)=x_0$. When differentiating $u$ along the characteristic we find
\begin{align}
\diff{}{t} u(x(t),t) &= \diffp{}{t} u(x(t),t) + \diffp{}{x} u(x(t),t) x^\prime(t)\\
&= u_t + a u_x = 0
\end{align}
As pointed out before: $u$ is a constant along the characteristic.
Now we may take a more general approach: let the advection speed be a function of $x$
\begin{align}
\partial_t u + \partial_x (a(x) u) = 0
\end{align}
where $a(x)$ is a smooth function.
\begin{align}
\partial_t u + a(x)\partial_x u = -a^\prime(x) \Leftrightarrow\left(\diffp{}{t}+a(x)\diffp{}{x} \right) u(x,t) = -a^\prime(x) u(x,t)
\end{align}
The evolution of $u$ along
\begin{align}
x^\prime(t) = a(x(t)),\quad x(0) = x_0
\end{align}
is given by the ODE
\begin{align}
\diff{}{t} u(x(t),t) = -a^\prime(x(t)) u(x(t),t)
\end{align}
We have found a characteristic again, but this is no longer a constant.
On which points does the solution depend? For the linear advection equation the answer is simple: It is the point $x_0$ through which the characteristic goes. The concept is called \emph{Domain of Dependence} $\mathcal{D}(x,t) = \{x_0\}$. It is not completely unexpected that $\mathcal{D}$ is not necessarily a single point. For hyperbolic systems we can at least conclude that $\mathcal{D}$ is a bounded interval. The length of the interval will increase with time
\begin{align}
\mathcal{D} \subset \{x:|x-\bar x| \leq a_\text{max} \bar t\}
\end{align}
Vice versa this means that starting from a single given point only a given area $ \{x:|x- x_0| \leq a_\text{max} t\}$ will be influenced (\emph{Range of Influence}). Hyperbolic systems have a limited velocity of propagation.
\subsection{Non-smooth data}
We have implictly assumed that $u_0$ is differentiable. For the characteristic differentiable functions are not essential. Even for $u_0$ with singularities we may define a solution. The singularity will move along the characteristic.
For non-differentiable $u_0$ the solution $u$ is no longer a classic solution (since the differential equation requires\dots differentiation\dots). The solution fulfills, however, the integral conservation law (i.e., the fundamental physics behind this).
A different approach to this would be: Let $u_0^\epsilon$ be a series of differentiable functions with $\lim_{\epsilon\to 0} = u_0$
\begin{align}
\| u_0 - u_0^\epsilon \|_1 < \epsilon, \quad \| \cdot \|_1 \Rightarrow \| v\|_1= \int_{-\infty}^{+\infty} |v(x)| \dd x
\end{align}
The $u_0^\epsilon$ lead to differentiable, classic solutions $u^\epsilon(x,t)$
\begin{align}
u^\epsilon(x,t) = u_0^\epsilon(x - at) \Rightarrow u(x,t) = \lim_{\epsilon\to 0} u_0^\epsilon(x-at) = u_0(x- at)
\end{align}
This works totally fine when talking about the linear case. When we move on to a non-constant advection speed we change from the advection equation to the diffusion advection equation
\begin{align}
\partial_t u + a \partial_x u = \epsilon \partial_x^2 u
\end{align}
in the limit of vanishing viscosity $\epsilon$. Let $u^\epsilon(x,t)$ be a solution to this equation. This solution is always differentiable since we have moved from a hyperbolic to a parabolic equation. From that point we can move to $\lim_{\epsilon\to 0}$ - the so-called vanishing viscosity solution. We will discuss this for non-linear equations in the next section.
\section{Burgers equation}
Let's move on to real nonlinear equations. We will consider equations of the type
\begin{align}
\partial_t u + \partial_x f(u) = 0
\end{align}
where $f(u)$ is a convex function with $\partial_x^2 f(u) > 0$. The simplest case is the Burgers equation with $f(u) = 1/2 u^2$
\begin{align}
\partial_t u + u\partial_x u = 0
\end{align}
It should be pointed out that the original Burgers equation in fact includes a dissipation term $\epsilon \partial_x^2 u$ on the RHS.
One may find the exact solution to this equation using the Cole-Hopf transformation that transforms the Burgers equation to heat transfer equation. But this is too theoretical. We are interested in the characteristics
\begin{align}
x^\prime (t) &= u(x(t),t)\\
\diff{}{t} u(x(t),t) &= \diffp{}{t} u(x(t),t) + \diffp{}{x} u(x(t),t) x^\prime(t)\\
&= u_t + u u_x
\end{align}
Since $u$ is constant along the characteristic the gradient of the characteristic does not change, i.e. the gradients are straight lines (cf. Fig. \ref{fig:burgers1}).
\begin{figure}
\begin{center}
\pgfimage[width=.8\textwidth]{fig_chapter5/burgers1}
\end{center}
\caption{Solution to the Burgers equation with characteristics. Due to the nonlinearity the peak moves faster and becomes steeper.}
\label{fig:burgers1}
\end{figure}
For small times $t$ the characteristics do not cross each other, one may calculate
\begin{align}
x &= \zeta + u(\zeta,0) t\\
u(x,t) &= u(\zeta,0)
\end{align}
For increasing times $t$ the characteristic come close to each other (cf. \ref{fig:burgers2}) until at some time $T_b$ two characteristic cross each other. This leads to a non-unique solution.
\begin{figure}
\begin{center}
\pgfimage[width=.8\textwidth]{fig_chapter5/burgers2}
\end{center}
\caption{Solution to the Burgers equation for non-smooth data. As in Fig. \ref{fig:burgers1} the peak becomes faster.}
\label{fig:burgers2}
\end{figure}
This process is somewhat like wave-breaking. As seen in Fig. \ref{fig:burgers3} we would have a three valued function for $t>T_b$ (don't be fooled by the breaking wave analogy: the process is similar, but $u$ is not a wave shape).
\begin{figure}
\begin{center}
\pgfimage[width=.8\textwidth]{fig_chapter5/burgers3}
\end{center}
\caption{Following the evolution of \ref{fig:burgers1} would result in a non-well defined solution. For some points three solutions exist. This is clearly unphysical}
\label{fig:burgers3}
\end{figure}
As pointed out before we may make use of viscosity to find the correct solution (the vanishing viscosity solution).
\subsection{Weak solutions}
So how do we find the solution for the inviscid equation without demanding differentiability? We will take a step back and consider the integral formulation (the integral includes the fundamental physical background of conservation).
Let's consider a test function $\varphi \in C_0^1 (\mathbb{R}\times \mathbb{R})$ which is continuously differentiable with compact support (i.e., 0 outside the interval). We will now multiply the equation $u_t + f_x = 0$ with $\varphi(x,t)$
\begin{align}
\int_0^\infty \dd t \int_{-\infty}^{+\infty} \dd x (\varphi \partial_t u + \varphi \partial_x f(u)) &= 0
\end{align}
Using integration by parts we can show that this is
\begin{align}
\left(\int_{-\infty}^{+\infty}\dd x \varphi u \right)|_0^\infty - \int_0^\infty \dd t\int_{-\infty}^{+\infty} \dd x \varphi_t u + \varphi_x f(u)
\end{align}
The function $u(x,t)$ is called weak solution when for all functions $\varphi \in C_0^1 (\mathbb{R}\times \mathbb{R})$ the following equation holds
\begin{align}
\int_0^\infty \dd t\int_{-\infty}^{+\infty} \dd x \varphi_t u + \varphi_x f(u) = -\int_{-\infty}^{+\infty} \dd x \varphi(x,0) u(x,0)
\end{align}
The concept of weak solutions is not something that is used in real life, it is a theoretical concept to prove the correctness of solutions. The following solutions all fulfil the weak solution concept.
\section{The Riemann problem}
The connection of a conservation problem and a piecewise constant initial value yields a so called Riemann problem. The Riemann problem is essentially a template for the general solution. We will again consider the Burgers equation as conservation law and
\begin{align}
u(x,0) = \begin{cases} u_l & x<0 \\ u_r & x>0 \end{cases}
\end{align}
We will assume $u>0$ for the sake of simplicity.
\subsection{Case 1}
For $u_l> u_r$ we will find the following solution
\begin{align}
u(x,t) = \begin{cases} u_l & x < s t\\ u_r & x > s t\end{cases}
\end{align}
with the shock speed $s=1/2(u_l+u_r)$. When viscosity is included, this will result in the traveling wave solution.
\begin{figure}
\begin{center}
\pgfimage[width=.8\textwidth]{fig_chapter5/riemann1}
\end{center}
\caption{The case $u_l>u_r$}
\label{fig:riemann1}
\end{figure}
Fig. \ref{fig:riemann1} shows the solution of a moving shock where the characteristic converge \emph{into} the shock.
\subsection{Case 2}
For $u_l < u_r$ there are infinitely many weak solutions. The upper solution in Fig. \ref{fig:riemann2} includes again a shock with speed $s$. The difference to the previous case is that the characteristics come out of the shock. This is an entropy violating solution, which is unstable against perturbations.
The correct solution is a rarefaction wave (shown in the lower part of Fig. \ref{fig:riemann2})
\begin{align}
u(x,t) = \begin{cases} u_l & x < u_l t\\ x/t & u_l t \leq x \leq u_r t \\ u_r & x> u_r t \end{cases}
\end{align}
\begin{figure}
\begin{center}
\pgfimage[width=.8\textwidth]{fig_chapter5/riemann2}
\end{center}
\caption{The case $u_l<u_r$}
\label{fig:riemann1}
\end{figure}
\subsection{Shock speed}
The shock solution is only a weak solution, when $s=1/2(u_l+u_r)$. For any other speed the solution is not a weak solution. For $M > s t$
\begin{align}
\diff{}{t} \int_{-M}^{+M}\dd x u(x,t) &= f(u_l) - f(u_r) \\
&= \frac{1}{2} (u_l+u_r)(u_l-u_r)\\
\int_{-M}^{+M}\dd x u(x,t) &= (M+st) u_l + (M-st) u_r\\
\Rightarrow \diff{}{t}\int_{-M}^{+M}\dd x u(x,t) &= s(u_l-u_r)
\end{align}
In the general case the $f(u)$ can be derived from the Rankine-Hugoniot jump conditions
\begin{align}
f(u_l) - f(u_r) = s(u_l-u_r)
\end{align}
In the scalar case
\begin{align}
s = \frac{f(u_l) - f(u_r)}{u_l-u_r} = \frac{[f]}{[u]}
\end{align}
where $[\cdot]$ is the difference over the shock. When $f$ and $u$ are vectors, $s$ is still a scalar. Jumps are, therefore, only allowed for when $f(u_l) - f(u_r)$ and $u_l-u_r$ are linear dependent.
- Finite Differenzen
- Finite Volumina