From 965aeb6c298ac65cbc04826a22e894367661273c Mon Sep 17 00:00:00 2001 From: Felix Spanier Date: Wed, 7 Dec 2022 22:18:19 +0100 Subject: [PATCH] NumMeth-22: Beginn MHD --- nummeth-ws22/fig_chapter5/cweno4.pdf | Bin 0 -> 1655 bytes nummeth-ws22/skript.tex | 1470 ++++++++++++++++++++++++++ 2 files changed, 1470 insertions(+) create mode 100644 nummeth-ws22/fig_chapter5/cweno4.pdf diff --git a/nummeth-ws22/fig_chapter5/cweno4.pdf b/nummeth-ws22/fig_chapter5/cweno4.pdf new file mode 100644 index 0000000000000000000000000000000000000000..41cf8a5f2a87ccdda0c8c50aae606a8bac92e771 GIT binary patch literal 1655 zcmZWq2~ZPP7`E!5tb%|7r84s5aJY9jCs9NOk^topL*zybWPu=LF}slf3M!5k+nS() zltG4CFIuaJRq!aNz=(x!Du9YJWHccpl1Vw?n`Qr397hcWqe#|Q#7Xx`LadiD!G;KbIMSky|}RI$D3<2`fd9i zljnH-0t#Lm>dONRX)887d|2PDond&ui_v;^HSs%kULVo%=CLf6{ilvCRJ)a*^=^Czpx=%;pm&ojKI)ayL@ViQ8w z5&ZAnDq9R)Ex(!j&Zt;nf5yzi;zGQwiJ#G)jv>b@o%bHkO~`E5TG6$gq27EH}IFF6q8zM{G`u=zyviFD`v z{Lx2^U*tr)z16yJd9C=$O>n%Wp1<41!RoqSXc7_zmN&JVdx$7pgON>q&<-HTUlFo9hNoryebn-Kt<5OWf!R0yYIU{9&Om85pK!>^qWYb1gSf z5zuKrYS}G{jd@Xiy4kVj{oJG!VdBvGXh~fOHp|$_x2J9W zruX*TtrtV5{#1$eDT5t@&s!Vs?)iP)i~PsBHYw|6{Ssd-Cr_BJ$48$HbM)dtPb)ss zb5uMSTD*VTKF(l-NZM1rB$aI`)%*XI*|YIZ-1NHn;d#4Un{%e6uMtLtYPK)nJxC0$ zEvi`>ydlaw_^j=~spegr6>LcCD>uv}$x?{^8m|4C2 z+@W4yvrfI9ynpPjQQ*a1*=Yw)^Tq1Sd*g&))WY5IM5yY$NfbbX6>Mx^Z8D#1^qp5KxC+6~+MDT~*j#iLLA?$&`S-6;mVK^qhI5>~XVX<7` zZm3APIvMs!=YX)4ARvvTXewEy$f5z)lZ&}bT8BnOq#zg&AlUm0@VHzy7o>o33}^A6 z5at5P2@Hd~^C5-_aH#4d48!5!`Uvw9K;u5daEvSX1j9LSXFiH!~n$`leX#*LjKik7M9F}*ljAV8d)M9am\tau_{grid}$ information at grid index $j$ must have +arrived from beyond the adjacent grid points which, however, is not +considered in the equation for the update (using only next neighbor +information). Therefore a time step $\Delta t>\tau_{grid}$ must generate +a meaningless and erroneous result which is reflected in this scheme +becoming unstable for $\Delta t>O\left(\tau_{grid}\right)$ leading +to exponential growth of any perturbation. This concept is formalized +in a stability analysis where the growth or damping of a perturbation +is analyzed for the chosen numerical method. + +Although there is no general proof that consistency of the discretization +and stability of the method insure that the numerical solution converges +to the exact solution of the system of PDE's, they are strong arguments +for a sound methodology. Also, convergence of the numerical solution +to a singly solution for successive refinements of the grid and time +steps can be used to demonstrate convergence to the actual solution. +There are a few more pitfalls that one should be aware of for MHD +simulations: Time independency and diffusion/viscosity is part of +MHD so the methodology must be appropriate to solve not only the hyperbolic +aspects of the MHD equations part also the steady state and dissipative +aspects of the MHD equations in a stable manner. Here, complications +for nonlinear steady state problems include multiple solutions for +given boundary conditions, or for slowly changing boundary conditions. +Also solutions may approach bifurcation points where they can cease +to exist and/or develop singularities. Furthermore, even small modifications +such as the inclusion of the Hall terms can require very small integration +steps, in this case because the Hall term enables the fast propagating +Whistler wave. Similarly, modifications of the basic equations that +include elliptic terms can require very small iteration steps to generate +a solution, a property that is addressed as stiffness. + +Additional insight on properties of a discretization can be obtained +through an expansion of the discretized algebraic equations which +in the case of the advection equation assume a general form $\partial f/\partial t+u\partial f/\partial x=\sum_{i=1}c_{i}\Delta x^{i-1}\partial^{i}f/\partial x^{i}$. +Clearly consistency requires $c_{1}=0$ otherwise the equation is +altered from the original PDE. However, the expansion demonstrates +the presence of 2nd and higher order even derivatives that act as +numerical dissipation (diffusion). Similarly odd order derivatives +cause numerical dispersion. Both effects are largest on the grid scale +and are more strongly localized for higher order accurate schemes, +i.e., where $c_{i}=0$ for a range of low values of i. In general, +more accurate discretizations do not eliminate issues with numerical +diffusion and dispersion. Although numerical diffusion is bad because +it diffuses structures and widens plasma boundaries, numerical diffusion +is unavoidable and acceptable if it is sufficiently localized. In +fact, numerical diffusion is required to balance effects of numerical +dispersion. Numerical dispersion of sharp plasma boundaries leads +to large and growing oscillations on the grid scale. Such oscillations +can easily cause the termination of any simulation because of locally +negative density or pressure. Such grid oscillations are avoided if +numerical diffusion is present to suppress them. Therefore, numerical +diffusion should be a lower order error than the dispersion. This +principle is actually employed in so-called flux corrected transport +(fct) schemes which attempt to avoid issues that can occur with the +presence or evolution of shocks. Since shocks develop as real discontinuities +in ideal MHD, they can never be resolved with a finite grid. Therefore +fct schemes typically use a multistep discretization where a low order +finite difference approach is combined with a high order scheme. The +low order discretization is retained and applied in locations where +the high order scheme generates large dispersion errors due to discontinuous +plasma conditions (e.g., \cite{Fletcher}). + +There are many tests that can be used to examine any particular MHD +simulation scheme. Clearly wave propagation of different MHD waves +(slow, fast and Alfven waves) provides an important test. A similarly +interesting test is the simulation of the corresponding MHD discontinuities +and shocks. Particularly fast shocks are important for the interaction +of the super fast solar wind plasma with the magnetosphere. Slow shocks +and rotational discontinuities are of important for problems of magnetic +reconnection where much of the plasma acceleration but also dissipation +can occur at slow shock structures. + +In order to examine more general properties of simulations concerning +nonlinear MHD physics, a number of macroscopic instabilities are sufficiently +well understood to serve as test cases for MHD simulations. Specifically, +instabilities based on strong velocity shear (Kelvin Helmholtz modes), +magnetic shear (tearing modes and reconnection), and gravity driven +plasma interchange (Rayleigh-Taylor modes) are quite well understood +(e.g., \cite{chan61,otto91a,Otto_fairfield2000}) and can be +used to examine properties and behavior of MHD simulations. + +Particularly for problems involving magnetic flux, mass, momentum, +and energy transport, tests using the general conservation properties +of MHD equations can be instructive. For instance, tests may evaluate +the change of total mass, momentum and energy considering the actual +flux at the the boundary of the respective domain. For ideal MHD, +magnetic line conservation (or the frozen-in condition) can be examined +by using tracers that move with the simulated fluid velocity and that +originally started on the same field line. Their separation after +any finite time and travel distance can provide a measure of how well +fluid elements are frozen to a particular magnetic field line. Magnetic +flux tube properties can also be used to examine mass conservation +in a moving geometry. Since magnetic field lines move by necessity +with the fluid in ideal MHD, the mass on a flux tube with a differential +cross section can alter only due to in- or outflow at the ends of +a field line. The mass of a differential flux tube is expressed as +the integral $M_{B}=\int_{B}nds/B$ along a magnetic field line between +fixed points $a$ and $b$ where $n$ is number or mass density, $ds$ +is the line element along the field line, and $B$ is the magnitude +of the local magnetic field. By considering in- and out-flow we can +determine how well flux tube mass is conserved. With these definitions +we can address the quantity $V_{B}=\int_{B}ds/B$ as the differential +flux tube volume of a field line between two points $a$ and $b$ +along this field line. + +Conservation of $M_{B}$ can be demonstrated using the continuity +equation for $n$. By the same notion it can be demonstrated that +$S_{B}=\int_{B}\left(p^{1/\gamma}\right)ds/B$ is conserved in the +absence of in- or outflow at the ends of a field lines (for ideal +MHD). If velocities are small such that the system is in an approximate +equilibrium, pressure $p$ is approximately constant along the field +line such that $S_{B}=p^{1/\gamma}V$ can be considered as a flux +tube entropy measure which is conserved in ideal MHD. As mentioned +before a local measure of this quantity is $s\equiv p^{1/\gamma}/n$ +which is constant along the the path of a fluid element in ideal MHD +and provides an easy test for mass and entropy conservation in MHD +simulations. Obviously, all of these conservation laws are not exactly +satisfied in numerical simulations. However, they have to be satisfied +sufficiently well on the time scale of a simulation such that a numerical +solution can distinguish between actual transport through reconnection +or diffusion and numerical violation of conservation laws. + +Finally, it is important to understand that the ideal MHD equations +have no intrinsic scale. They are valid from galactic down to small +laboratory scales such that the actual evolution of a system is scale +independent. Therefore the MHD equations are often solved in a normalized +form, where magnetic field, density, and length scales are measured +in typical values, i.e., $B_{0}$, $n_{0}$, and $L_{0}$. With this +choice the natural scale for velocity and pressure become $u_{0}=B_{0}/\sqrt{\mu_{0}m_{0}n_{0}}$ +and $p_{0}=B_{0}^{2}/\mu_{0}$. + +\section{Initial and Boundary Conditions} + +\label{sec:3_chp1} + +Boundary conditions for MHD simulations are notoriously difficult. +Boundary conditions depend on the particular application and initial +conditions. Particularly a boundary with non-uniform plasma conditions +can be challenging. Also the question of whether there is a plasma +in- or outflow plays a major role. Sometimes it is claimed that a +boundary uses so-called open boundary conditions, implying that it +allows in- or outflow just as the system demands. It should be noted +that in case of nonuniform boundaries there is no simple open boundary +condition. Strictly plasma out- and inflow that is caused by dynamics +within the simulation domain can be computed through the characteristics +of the system. They determine where and how perturbations from within +the simulation demand in- or outflow at the boundaries. However, while +this is can be done in principle, MHD has 3 different anisotropic +wave modes, such that this approach is extremely difficult in two- +or three-dimensional MHD. Therefore, such boundary conditions often +represents a guess that when it works, is likely the best one can +achieve for a boundary condition. Sometimes it may be necessary to +choose boundary locations far from the actual physical process to +insure that the boundary has no influence on the evolution of this +process. + +In the following we will introduce and discuss boundary and initial +conditions for several applications of numerical simulations presented +in Section 4. Specifically, we consider 3 different applications. +An example of a relatively simple and periodic instability is the +Kelvin-Helmholtz (KH) instability provided in Sections 4.1. Shock +physics is addressed in in section 4.2 with an example that applies +to Hot Flow Anomalies (HFAs) at the bow show. A more involved boundary +is introduced in section 4.3 presenting a magnetotail simulation of +current sheet thinning. The corresponding initial and boundary conditions +are summarized in the next subsections. + +\subsection{Kelvin Helmholtz Instability} + +\label{subsec:KH1} + +The first magnetopause application is the Kelvin-Helmholtz wave, a +straightforward and well understood instability driven by sufficiently +fast shear flow across a plasma boundary. The instability has been +studied extensively in two and three dimensions (e.g., \cite{miur82,Otto_fairfield2000,Nykyri_otto2001,Hasegawa_fujimoto2004,ma2014a}). +This instability operates in two dimensions and our geometry uses +the $x$ direction normal to the boundary, and $y$ along the boundary. +The initial conditions use for the velocity +\[ +u_{y}\left(x\right)=u_{0}\tanh x/L_{0} +\] +and $u_{x}=u_{z}=0$, for density $\rho=\rho_{0}$, for the magnetic +field components $b_{x}=0$, \textbf{$b_{y}=b_{y0}$}, $b_{z}=b_{z0}$, +and for pressure $p=p_{0}$, where all quantities with an index 0 +are assumed constant. Note that instead of a constant magnetic field +along $y$ and $z$ we could have chosen some $x$ dependent profiles +with the only condition that pressure has to be chosen such that $p+b_{y}^{2}+b_{z}^{2}=const$ +such that the configuration is in a steady (time independent) state. +For the results in section 4 we have chosen $\rho_{0}=1$, $p_{0}=1$, +$u_{0}=1$, $b_{y0}=0.1$, $b_{z0}=1$, and $L_{0}=1$. None of these +values is critical except that the Alfven speed associated with $b_{y0}$ +must be smaller than $u_{0}$ for the instability to operate. + +The most reliable and straightforward boundary conditions for MHD +applications are given by symmetry conditions or configurations that +are periodic in space. Simple applications where periodic conditions +can be applied are for instance macro-instabilities, such as magnetic +tearing modes, or flow driven Kelvin-Helmholtz modes. Therefore the +simulation here uses periodic conditions along the $y$ direction. + +The method used for the applications here is 2nd order accurate and +uses 3 grid points to evaluate 1st and 2nd order derivatives. Therefore, +our simulation grid only requires one layer of guard cells around +the physical cell boundaries to apply von Neumann derivative boundary +conditions, such that $j=2$ and $j=n_{y}-1$ correspond to physical +boundary cells and $j=1$ and $j=n_{y}$ to the mathematic boundary +cell to apply boundary conditions. Thus periodicity at the y minimum +boundary implies $f_{j=1}=f_{j=n_{y}-2}$, and $f_{j=2}=f_{j=n_{y}-1}$ +for all $x$ indices $i$. + +Boundary condition at $x_{min}$ and $x_{max}$ use all 0 derivatives +normal to the boundary, which explicitly implies for instance at the +$x_{min}$ boundary$f_{i=1}=f_{i=3}$ for all quantities with one +exception. The normal magnetic field derivative that determines $b_{x,i=1}$ +and $b_{x,i=n_{x}}$ computes these values using the tangential field +and $\nabla\cdot\mathbf{b}=0$. Note that $\nabla\cdot\mathbf{b}=0$ +is required for the initial configuration and should be conserved +through the integration method. However, it still leaves the possibility +that a nonzero divergence is carried into the system through boundaries. +This is avoided by employing $\nabla\cdot\mathbf{b}=0$ at the boundaries +where possible. + +A zero normal derivative boundary condition is used for the tangential +velocity, density, and pressure because they are non-zero in the initial +condition at the $x$ boundaries (and almost constant). The normal +velocity component can use the same conditions or make use of a $\nabla\cdot\mathbf{v}=0$. +Finally, we note that the conditions at the $x$ boundaries is not +an exact symmetry situation and it is difficult to formulate a condition +that represents truly free flow for this boundary. Therefore, the +actual location of the x boundary is chosen at a large distance from +the location of the instability such that the detailed boundary conditions +do not have a significant influence on the instability. This can be +numerically slightly more expensive but the applied scheme uses a +nonuniform grid with larger grid spacing away from the $x=0$ plane +where the KH instability operates. + +\subsection{Fast Shock Simulation} + +\label{subsec:BS1} + +This 2nd application examines the interaction of a fast shock with +a magnetic flux tube with a lower density than the surrounding upstream +plasma. The physical motivation for this set up is the occasional +observation of HFAs upstream of the Earth's bow shock, during which +the plasma is strongly (and non-adiabatically) heated and strongly +decelerated, sometimes so much that it is actually streaming sunward. +Observations of so-called density cavities show that the upstream +plasma contains sometimes flux tubes with much lower density than +the ambient material. Such flux tubes must cause large perturbations +at the bow shock of the Earth. These simulations are also two-dimensional. +Here $x$ is the direction normal to the original fast shock into +the downstream region and $y$ is the transverse direction. Fast shock +simulations with application to HFAs have been conducted with hybrid +simulations (e.g., \cite{thomw91a,liny97,omids07}). + +The initial state is the superposition of two configurations. First +the simulation uses the solution to the fast shock jump conditions +as given by +\begin{eqnarray*} +\left(u_{u}^{2}-Xu_{A}^{2}\right)^{2}\left[Xc_{s}^{2}+\frac{1}{2}u_{u}^{2}\cos^{2}\theta\left\{ X\left(\gamma-1\right)-\left(\gamma+1\right)\right\} \right]\\ ++\frac{1}{2}u_{A}^{2}u_{u}^{2}X\sin^{2}\theta\left[\left(\gamma+X\left(2-\gamma\right)\right)u_{u}^{2}-Xu_{A}^{2}\left(\left(\gamma+1\right)-X\left(\gamma-1\right)\right)\right] & = & 0 +\end{eqnarray*} +(e.g., \cite{prie87}) where $X=\rho_{d}/\rho_{u}$ is the +shock compression, $u_{u}$ is the upstream velocity, $u_{A}$ and +$c_{s}$ are the upstream Alfven- and Sound speed, $\theta$ is the +angle of the upstream magnetic field with the shock normal, and $\gamma=5/3$ +is the ration of specific heats. The resulting initial condition can +be expressed as +\begin{equation} +f=f_{u}+0.5\Delta_{f}\left[1+\tanh\left(x/\delta\right)\right] +\end{equation} +with $f$ representing density $\rho$, velocity components $u_{x}$ +and $u_{y}$, magnetic field component $b_{y}$, and pressure $p$. +Here $\Delta_{f}=f_{d}-f_{u}$ represents the jump from the down to +the upstream value, for instance, $\Delta_{\rho}=\text{\ensuremath{\rho_{d}-\rho_{u}=\rho_{u}\left(X-1\right)}}$. +Note this choice centers the fast shock at $x=0$ and the width of +the step function $\delta$ adjusts itself immediately after turning +on the simulation because it really is determined by the dissipation +either of a physical resistivity and viscosity or a corresponding +numerical dissipation. In order to examine the interaction of a density +depleted flux tube with such a shock we superpose a density depletion +with a shape of $\rho_{\delta}=1-0.5\rho_{\delta0}\left[\tanh\left(\left(y_{2}-y\right)/\delta_{y}\right)+\tanh\left(\left(y-y_{1}\right)/\delta_{y}\right)\right]$. +For $\delta_{y}>0$ and $y_{2}-y_{1}>2\delta_{y}$, this function +is 1 everywhere except between $y_{1}$ and $y_{2}$ where it assumes +a value of $1-\rho_{\delta}$. So by multiplying the initial condition +(13) with $\rho_{\delta}$ in the upstream region we can generate +a reduced density region between $y_{1}$ and $y_{2}$. Note that +$y_{1}$ and $y_{2}$ are dependent on the $x$ coordinate because +we need the depleted density region within a flux tube which is inclined +with the boundary normal by an angle $\theta_{bn}$. Note that basic +free parameters for this type of study are the shock Mach number, +the plasma $\beta$, and the angle of the incident magnetic field +with the shock normal. Other parameters that can be adjusted are the +relative magnitude of the density depletion and the width of the density +depleted flux tube. + +Initial conditions for this case are relatively straightforward for +the boundaries in $x$. Since $x$ points into the downstream direction, +the boundary conditions at the $x_{min}$ boundary are given by Dirichlet +conditions where all boundary values are set to the respective upstream +region values defined in the initial conditions. One exception is +density where the boundary values are computed from the superposition +of upstream density and depleted flux tube values. Note that in the +normal incident frame where $u_{y}$ in the upstream region is 0, +a flux tube marked by a lower density moves along the $y$ direction +when observed at a fixed $x$ coordinate. Therefore the depleted density +region must move along $y$ at the $x_{min}$ boundary with a speed +that depends on the upstream velocity and the angle $\theta_{bn}$ +of the magnetic field. Boundary conditions in the downstream region +can be chosen in a similar manner, i.e., as Dirichlet conditions based +on the analytic values from the shock jump conditions. There will +always be some reflection because one has to expect at least small +deviations of the numerical shock solution from the exact analytic +values. However, worse are the conditions caused by the interaction +of the low density flux tube with the shock. These represent large +perturbations relative to the original Dirichlet conditions. Therefore +the downstream system size is chosen large enough that these perturbations +cannot travel back to the shock region on the considered time scales. +Since truly free boundary conditions are very difficult to achieve, +the boundary conditions in the $y$ direction are assumed periodic. +The density depleted flux tube size is small compared to the system +size in $y$, such that periodic conditions in $y$ should be close +to open boundary conditions. + +\subsection{Magnetotail Simulation} + +\label{subsec:Tail1} + +This is an example of a three-dimensional simulation of a section +of the Earth's magnetotail. The physical motivation for this simulation +is the examination of the formation of very thin current sheets in +the near Earth tail region. Such current sheets can be associated +with the onset of major instabilities that release large amounts of +stored magnetic energy and cause geomagnetic substorms and the associated +aurora. Different from the prior two examples this simulation does +not strictly use an analytic initial condition. Rather it uses an +initial condition that is based on a typical magnetic field of the +magnetotail. This magnetic field is used with a numerical relaxation +to obtain force balance and to generate a three-dimensional magnetotail +equilibrium. Coordinates used for this simulation are so-called GSM +(general solar magnetic) coordinates with $x$ pointing sunward, $z$ +northward, and $y$ along the cross tail direction. + +It has been hypothesized that different from a compression of the +magnetotail lobes, also the removal of closed magnetic flux in the +near Earth tail can lead to the formation of strong current sheets. +In order to test and demonstrate this hypothesis it is required to +use a sufficiently realistic magnetic field of the near Earth tail +and apply convection from the nigh- to the dayside. We use a meso-scale +section of the magnetotail extending from $x=-5$ $R_{E}$ to about +$x=-50$ $R_{e}$ on the tailward side. In order to apply this convection +we need to modify the Earthward boundary to enable sunward flow in +the tail region. As mentioned such boundary conditions can be very +tedious. Our system extends from $z=0$ (equatorial plane) to $z=20$ +(lobes) where units are in Earth radii $R_{e}$, and symmetry is used +such that only the northern half of the magnetotail is simulated. +In the $y$ direction the system extends from $y=-20$ to $y=20$ +such that the boundary does not cross the magnetopause where flow +becomes fast. + +Note that the sunward outflow condition has to be applied not only +at $z=0$ but everywhere at our Earthward boundary. Assuming that +magnetic field lines must be transported smoothly through this boundary +we actually integrate magnetic field lines from each boundary coordinate +into the system and determine the location where they cross the equatorial +plane. We can then assume a hypothetical smooth convection profile +in the near Earth equatorial plane and associate each field line with +such a convection, i.e., map the assumed convection from the equatorial +plane to the Earthward boundary. The physical motivation for this +shape of convection is that magnetic flux transport should follow +approximately contours of constant flux tube entropy, i.e., be mostly +azimuthal. Various test of this approach indicate that the exact details +do not play an important role. Assuming that flux tubes are sort of +rigidly convected, i.e., with a constant angular velocity, their azimuthal +velocity is given by the mapped velocity and radial distance of the +respective boundary point. Thus it is possible to determine a unique +value for the $x$ and $y$ velocity components of each point at the +Earthward boundary. Note that the hypothetical equatorial convection +is used only to compute flow at the Earthward boundary and not applied +in the equatorial plane where plasma motion develops selfconsistently. +The assumed connvectionn pattern and the resulting flow in the equatorial +plane are illustrated in Fig.~\ref{fig:2_chp1} This boundary condition for +slow adiabatic convection proved quite +stable and reliable to generated the desired sunward outflow. Several +simulation studies have addressed this problem of a slow evolution +of the near Earth tail \cite{hsieo14,hsieo15,ottoh15} + +\begin{figure}[b] +\begin{center} +\includegraphics[scale=0.3]{./01-MHD/fig2a}\includegraphics[scale=0.58]{./01-MHD/fig2b} +\par\end{center} +\caption{ Left: Illustration of the assumed equatorial +convection in order to compute flow conditions at the Earthward (right) +simulation boundary indicated in red. Right: Convection in the equatorial +plane in response to the applied Earthward boundary condition in the +simulation.} +\label{fig:2_chp1} % Give a unique label +\end{figure} + +Finally, the boundary condition in the equatorial plane at $z=0$ +is an excellent example of a symmetry condition which uses the symmetry +of the northern and southern hemisphere. Note, that this applies only +if the $y$ component of the magnetic field in the equatorial plane +is 0. The specific conditions used are symmetry $f\left(i_{z}=1\right)=f\left(i_{z}=3\right)$ +for density $\rho,$ pressure $p$ magnetic field component $b_{z}$, +and velocity components $u_{x}$ and $u_{y}$, and antisymmetry (zero +derivative) $f\left(i_{z}=1\right)=-f\left(i_{z}=3\right)$ for the +magnetic field components $b_{x}$ and $b_{y}$, and the velocity +component $u_{z}$. The remaining conditions at the lateral boundaries +in $y$, at the lobe boundary at $z_{max}$, and the tailward boundary +at $x_{min}$ use symmetry $f\left(i=i_{b}+1\right)=f\left(i=i_{b}-1\right)$ +or Dirichlet conditions and allow flow tangential to the respective +boundary. The normal magnetic field component is again used to satisfy +$\nabla\cdot\mathbf{b}=0$. + +\section{Examples of MHD Simulations} + +\label{sec:4_chp1} + +The used simulation code for the following examples employs a leapfrog +and DuFort-Frankel scheme using a finite difference approximation. +This finite difference approximation is of 2nd order accuracy and +a small 2nd order diffusion term is applied where numerical dispersion +can occur. The finite difference leapfrog approximation is also subject +to a time step limitation similar to the one described in section +2, however, it is noted that this limitation is also required for +sufficient accuracy. A time step longer than allowed by the stability +condition would imply a low accuracy for the propagation of the respective +MHD waves. + +\subsection{Kelvin Helmholtz Simulations} + +\label{subsec:KH2} + +The KH instability has also the advantage that the linear evolution +for sufficiently simple situations is reasonably well understood by +analytic models in the limit of incompressible flow. The mode is unstable +for sufficiently large flow shear compared to the stabilizing influence +of the magnetic field aligned with the k vector of the mode, i.e., +\[ +\left[\left(\mathbf{u}_{1}-\mathbf{u}_{2}\right)\cdot\mathbf{k}\right]^{2}>\frac{\rho_{1}+\rho_{2}}{\mu_{0}\rho_{1}\rho_{2}}\left[\left(\mathbf{u}_{A1}\cdot\mathbf{k}\right)+\alpha_{2}\left(\mathbf{u}_{A2}\cdot\mathbf{k}\right)\right] +\] +\cite{chan61} where the indices 1 and 2 indicate the two sides of +the boundary and $\mathbf{u}_{A}$ refers to the Alfven speed. The +setup for the initial and boundary conditions for KH simulations as +described in section 3 is quite straightforward. Therefore, the KH +mode is a good test case for numerical simulations. The simulations +can actually be conducted by two-dimensional and fairly low resolution +models. The results shown in Fig.~\ref{fig:3_chp1} use a resolution +of 203 by 203 grid points, however, a few 10 grid points in each direction +are sufficient to resolve the early evolution. Higher resolution allows +for more details and longer accurate simulation later in the nonlinear +evolution although boundaries within the nonlinear KH wave become +eventually arbitrary thin within a finite time limiting also high +resolution simulations. + +\begin{figure}[b] +\begin{center} +\includegraphics[scale=0.38]{./01-MHD/fig3a}\includegraphics[scale=0.38]{./01-MHD/fig3b}\includegraphics[scale=0.38]{./01-MHD/fig3c} +\par\end{center} +\caption{ Results from two-dimensional KH simulations. +From left to right the figures show magnetic field, density and velocity +arrows, and current density.} +\label{fig:3_chp1} % Give a unique label +\end{figure} +Fig.~\ref{fig:3_chp1} illustrates that the magnetic field which was +initially uniform is strongly twisted within a few turnover times +causing large changes of the magnetic field both in the simulation +plane and perpendicular to it. Density boundaries become very thin, +and the strong magnetic field deformation causes very large local +current densities even for an initially uniform magnetic field. Any +initial current is strongly modulated and amplified, and the nonlinear +evolution can cause magnetic reconnection at the strong current layers +within the KH vortex. More detailed results for two-dimensional KH +studies and comparisons with observations can be found in the respective +literature (e.g., \cite{miur84,Otto_fairfield2000,Nykyri_otto2001,Nykyri_otto2006,nakaf06}). + +The nonlinear and three-dimensional evolution have provided interesting +new results for the transport of plasma and magnetic flux at the magnetospheric +boundaries over the past two decades. The nonlinear KH mode provides +a number of different mechanisms for this transport. In a simple two +dimensional approach the nonlinear KH wave generates a very strong +current layer associated with the strong twisting of the magnetic +field. Similarly, the nonlinear KH can modify and intensify a pre-existing +current layer. These very thin and strong current layers are easily +tearing mode unstable and can undergo magnetic reconnection which +causes direct plasma transport across the boundary. This very small +width enables ions to easily cross these boundaries causing enhance +mixing and diffusion. Another potential mechanism is the excitation +of kinetic or inertial Alfven waves through mode conversion which +again can cause significant plasma transport across such boundaries +(e.g., \cite{Wing_johnson2015}). + +In three dimensions the evolution of the KH mode depends on the variation +along the direction perpendicular to the plane shown in Fig.~\ref{fig:3_chp1}. +For instance, the magnetospheric boundary is KH unstable in the equatorial +plane for strongly northward interplanetary magnetic field (IMF) as +illustrated in Fig.~\ref{fig:4_chp1}. + +\begin{figure} +\begin{center} +\includegraphics[scale=0.5]{./01-MHD/fig4a}\includegraphics[scale=0.6]{./01-MHD/fig4b} +\par\end{center} +\caption{Sketch of the KH associated magnetic field twisting +in the equatorial (left) and parallel current and electric field for +a locally unstable KH wave (integrated along the direction of the +velocity shear).} +\label{fig:4_chp1} % Give a unique label +\end{figure} + +However, the field geometry renders +the mode stable in the northern and southern hemisphere at sufficient +distance from the equatorial plane. Therefore twisting is expected +to occur only locally similar to a candy-wrapper. This implies that +very large currents form at the boundaries of the KH unstable regions. +These currents have a predominant orientation such that the associated +parallel electric field (in the presence of resistivity) tends to +decouple the magnetic field as illustrated in Fig.~\ref{fig:4_chp1}. +It has been demonstrated that this provides a powerful transport mechanism +that can quantitatively explain the plasma transport during extended +periods of northward \cite{Ma_delamere2017} and southward IMF \cite{ma2014a,ma2014b}. + +Recent new satellite observations from high temporal resolution particle +measurements by the magnetospheric multi-scale mission (MMS) indeed +show evidence of multiple reconnection processes at locations consistent +with the reconnection sites from simulations, i.e., close to the equatorial +plane, and in the northern and southern hemispheres \cite{Eriksson_lavraud2016,Li_andre2016}. +Nonlinear KH modes may also be the dominant instability mechanisms +at the boundaries of the fast rotating giant magnetospheres \cite{Ma_stauffer2015,Zhang_delamere2018}. + +\subsection{Simulations of Sunward Moving Plasma at the Earth's Bow Shock} +\label{subsec:bs2} +Although KH simulations can include some shock physics for sufficiently +fast jetting plasma, typically shocks associated with KH modes are +weak. However, shock physics is important for bow shock transients +such as hot flow anomalies (HFAs). For many applications such as KH +simulations or slow magnetotail evolution the MHD equations can be +closed using an energy equation like the form of equation (13). This +has the additional advantage that entropy is explicitly conserved +by this formulation in ideal MHD. However, for the fast shock simulations +illustrated here, the MHD equations must use total energy conservation +presented in equation (12) because otherwise properties of strong +shocks will not be correctly addressed in the simulation. This also +applies to slow shocks in cases of very low plasma $\beta$. + +HFAs are events upstream of the Earth's bow shock and are characterized +by a very hot plasma that is streaming much slower than the solar +wind or sometimes has a velocity component toward the sun. Originally +HFAs were addressed as diamagnetic cavities \cite{schwc85,thomg86,thomg88,pasch88} +and believed to be associated with a TD in the interplanetary magnetic +field (e.g., \cite{schwk88,schws95}). This was expressed by +the original terminology 'active current sheet', but found support +also through early hybrid simulation studies \cite{thomb88,thomw91a}. +However, frequently HFAs can occur without the presence of a TD, and +often HFAs do not show a motional electric field toward the TD as +predicted by hybrid simulations \cite{zhans13a,zhaoz15,zhaoz17}. + +\begin{figure} +\begin{center} +\includegraphics[scale=0.31]{./01-MHD/fig5a}\includegraphics[scale=0.31]{./01-MHD/fig5b}\includegraphics[scale=0.31]{./01-MHD/fig5c} +\par\end{center} +\caption{Time sequence of the interaction of a density +depleted magnetic flux tube with a fast shock. The top plots show +velocity (arrows, temperature (color) and magnetic field (lines), +and the bottom plots show density.} +\label{fig:5_chp1} % Give a unique label +\end{figure} + +One of the most surprising properties of HFAs is their strong deflection +of the solar wind momentum. In shock physics such a deflection can +easily occur if upstream conditions change this momentum, for instance, +through a significantly lower density. Lower density regions are actually +observed and associated with the foreshock regions. These density +depletions are termed foreshock cavities. The example in Fig.~\ref{fig:5_chp1} +illustrates the evolution if a low density flux tube interacts with +a fast shock. Since the fast mode speed is much higher in the low +density medium, the effective mach number based on the original shock +conditions is much lower for the low density region. This implies +that there must a new shock forming, which moves rapidly into the +upstream direction as illustrated by the results shown in Fig.~\ref{fig:5_chp1}. + +The resulting structure is an excellent example of shock physics. +At the leading edge the new fast shock is heating the material to +temperatures higher than the magnetosheath. In the new structure the +pressure is higher than ion the solar wind but lower than in the original +magnetosheath. Therefore the structure expands into the solar wind +yielding a wedge-like shape. Material from the magnetosheath is streaming +into the structure from behind as illustrated in the sketch in Fig.~\ref{fig:6_chp1}. +The Figure also illustrates the evolution of strong current sheets +in the newly formed structure and regions of different entropy. Note +that the different colored entropy regions are all resulting from +fast shocks. The upstream region just represents the original solar +wind and the density depleted flux tube. The downstream regions have +the original magnetosheath (colored in cyan), the shocked plasma at +the forward edge of the wedge (yellow), and two shoulders with a moderately +increased entropy (red), because the expansion into the solar wind +generates also fast shocks. + +\begin{figure} +\begin{center} +\includegraphics[scale=0.37]{./01-MHD/fig6a}\includegraphics[scale=0.37]{./01-MHD/fig6b}\includegraphics[scale=0.37]{./01-MHD/fig6c} +\par\end{center} +\caption{From left to right the plots show a sketch of +the newly formed shock structure caused by the low density flux tube, +plot of the velocity (arrows) current density (color) and field lines +of the newly formed structure, and plot of the entropy as defined +as $p^{1/\gamma}/\rho$.} +\label{fig:6_chp1} % Give a unique label +\end{figure} + +The structure in Fig.~\ref{fig:5_chp1} appears stationary because the +simulation is in the deHoffmann-Teller frame where the electric field +is 0, i.e., convection is magnetic field-aligned. In the normal incident +frame the structure is moving into the negative $z$ direction with +a velocity that depends on $\theta_{bn}$, i.e., the angle of the +magnetic field with the shock normal and on the magnitude of the solar +wind (upstream velocity). It is worth noting that these simulation +results suggest larger and slower moving structures for small $\theta_{bn}$, +i.e., quasi parallel shock conditions. +Note, however, that particularly for parallel conditions MHD is not + +a good approximation for fast shocks. Nevertheless one would expect + +that some basic properties from the MHD simulations should be observable. + +In any case, it is remarkable that the MHD simulations seem to capture + +a number of the observed HFA properties quite well. + +\subsection{Earth's Magnetotail Simulations} + +\label{subsec:Tail2} + +The final example addresses the slow evolution of a three-dimensional + +system that is close to equilibrium sometime also addressed as quasi-static + +evolution indicating that the system satisfies force balance at all + +times. This type of evolution is important to understand the transition + +from a stable configuration to an unstable state. Examples for such + +an evolution include solar prominences and, in the present case, the + +magnetotail during the growth phase of a substorm \cite{schib82,schib93,birnh98}. + +It is well established that the onset of a substorm involves very + +thin current layers in the near Earth tail \cite{sergt90,ohtat92,sergn14}. + +These current sheets can be generated by various mechanisms, for instance + +instabilities and other dynamics processes as illustrated by the prior + +examples. In terms of a quasi-static evolution it has been suggested + +that a slow compression of the lobes of the magnetotail can cause + +thin current sheet formation. Boundary conditions for this type of + +evolution play a somewhat different role than in the other examples. + +While in the other examples boundary conditions just need to be consistent + +with the initial conditions and the evolutions, here boundary conditions + +provide a major constraint and a slow driver for the change of the + +equilibrium. So in this example boundary conditions cause the evolution + +of the system which is slow up to the point where some critical state + +is reached. + +\begin{figure} + +\begin{center} + +\includegraphics[scale=0.41]{./01-MHD/fig7a}\includegraphics[scale=0.4]{./01-MHD/fig7b}\includegraphics[scale=0.36]{./01-MHD/fig7c} + +\par\end{center} + +\caption{Evolution of the magnetic field component $B_{z}$ + +in the near Earth equatorial plane shown at times 0 and 50 minutes + +into the evolution and cross tail current density component $j_{y}$ + +at time = 50 min. In the chosen normalization, length units correspond + +to 1 Earth radius and magnetic field is normalized to 20 nT.} + +\label{fig:7_chp1} % Give a unique label + +\end{figure} + +The simulation results in Fig.~\ref{fig:7_chp1} use a magnetic flux + +transport rate of about 50 kV well comparable to a typical cross polar + +cap potential during the growth phase of a substorm. The initial magnetic + +field $B_{z}$ component in the equatorial plane represents a typical + +magnetotail field because it is based on the Tsyganenko model magnetic + +field \cite{tsyg96}. During 50 minutes of sunward convection out + +of the near Earth magnetotail, the closed magnetic field in the near + +Earth region is strongly reduced in some regions to values below 1 + +nT. The larger values close to the Earthward boundary at $z=-6R_{E}$ + +are close to 100 nT initially and are reduced to about 60 nT after + +50 minutes of slow convection. The last plot in Fig.~\ref{fig:7_chp1} + +presents the cross tail current density component in the equatorial + +plane at time = 50 min. It illustrates a concentrated and amplified + +current density in the region where the magnetic field $B_{z}$ is + +reduced. + +\begin{figure} + +\begin{center} + +\includegraphics[scale=0.5]{./01-MHD/fig8a} + +\par\end{center} + +\begin{center} + +\includegraphics[scale=0.5]{./01-MHD/fig8b} + +\par\end{center} + +\caption{Illustration of the cross tail current density + +at times 0 and 50 minutes corresponding to the times shown in Fig.~\ref{fig:7_chp1} + +for the equatorial $B_{z}$.} + +\label{fig:8_chp1} % Give a unique label + +\end{figure} + +In order to demonstrate that the evolution is quasi-static, i.e. a + +sequence of equilibrium configurations, we have run tests with higher + +and lower values of the magnetic flux transport rate. The evolution + +was almost identical but faster for higher potential and slower for + +lower potential. The state of the near Earth magnetosphere was determined + +by the amount of magnetic flux that was removed from the region and + +not by the flux removal rate or by the specific time of the evolution. + +More details and other results on this type of simulation are provided + +by \cite{hsieo14,hsieo15,ottoh15}. Note that very similar results + +have been obtained using the rice convection model \cite{zhoua09} + +and global simulations \cite{gords17b}. + +Fig.~\ref{fig:8_chp1} presents the cross tail current density in the + +midnight meridian in order to demonstrate that the quasi-static evolution + +in this example indeed leads to very thin and strong current layers. + +The current density in this region is as high as 10 $nA/m^{2}$ and + +about an order of magnitude larger than typical equilibrium current + +densities. The process that is illustrated here has been termed current + +sheet formation through magnetic flux depletion in order to distinguish + +it from the typical assumption that current sheet formation is caused + +by lobe compression due to additional magnetic flux in the lobe region + +of the magnetotail. Note that during a typical growth phase both processes + +should operate. Dayside reconnection generates open magnetic flux + +that is convected to the nightside and added to the lobes. Dayside + +reconnection also causes a reduction of flux on the dayside that is + +compensated by convection from the night side as can be seen from + +typical polar cap convection patterns. We also note that observations + +of current sheets agree well with the presented model results \cite{petrb09,petra15,artea16b}. + +\section{Summary and Conclusions} + +\label{sec:5_chp1} + +The examples illustrated here demonstrate various aspects of numeric + +simulations of the MHD equations. It is emphasized that all numerical + +solutions to the MHD have errors that in many cases can be addressed + +as numerical diffusion or dispersion. These errors limit the validity + +of numerical simulations and in general any application has to insure + +that numerical errors are sufficiently small in order to identify + +the important physics in a numerical simulation. We have illustrated + +a number of tests such as magnetic line conservation as well as mass, + +momentum, energy, and entropy conservation. The conservation laws + +can be employed in different ways to test numerical MHD simulations. + +Further tests can be conducted using known analytic properties, such + +as the growth rate of instabilities, e.g., the KH wave, or the jump + +conditions associated with fast or slow shocks. Note that this approach + +is somewhat different from tests of global simulations which frequently + +use observed magnetospheric states and ask the question of how well + +a given simulation can reproduce the observed properties. + +Local or meso-scale MHD simulations are frequently used to examine + +clearly defined local processes and instabilities. They have the advantage + +of providing much higher resolution and are ideally suited to examine + +a sensitive dependence on plasma or boundary conditions for a physical + +process. Because of their much higher resolution, local models often + +provide better conservation laws than global processes where by necessity + +a KH mode or magnetic reconnection are only resolved by a very limited + +number of grid points or nodes. Typical applications of local MHD + +but also kinetic models frequently address processes at the magnetospheric + +boundaries, at the bow shock, and in the magnetototail of planetary + +magnetospheres similar to the examples and references provided in + +this chapter. Similar local or mesoscale simulations are used in solar + +and astrophysical simulations (e.g., \cite{ottob07,sant11,adamb13}). + +Usually it is assumed that higher order approximations are better + +than low order approximations. This is in general true, particularly, + +if higher order derivatives are important in the basic equations. + +However, this advantage truly applies only if the grid resolution + +is similar for higher and lower order approximations. We note that + +1st order approximations are generally not acceptable because of the + +large numerical diffusion. Given that it is more complicated to formulate + +a higher order scheme and that it is much more involved to formulated + +consistent boundary conditions, it really depends on the application + +which type of scheme is advantageous. + +A similar remark applies to implicit schemes. Implicit schemes are + +great because they may remove or reduce time step limitations and + +can improve stability. However, it should also be kept in mind that + +the choice of a time step must also consider accuracy, and for many + +applications accuracy and stability imply a very similar choice of + +the time step for explicit codes. Numerical techniques in space physics + +include a large number of finite difference (e.g., the examples and + +references provided here) and finite volume methods (e.g., \cite{gords17b,merks15,Zhang_2019}). + +In contrast finite element seem to play no role space plasma MHD simulation, + +and spectral or pseudo-spectral methods are relatively rare (e.g., + +\cite{kus97}). Finite element methods have the advantage that + +they are particularly useful to model more complicated shapes of obstacles + +or the system domain. Spectral methods suffer from the difficulty + +of the formulation of boundary conditions which need to be consistent + +with the chosen base functions. The difficulty of formulating boundary + +conditions has been illustrated particularly by our example 3. + +Finally, numerical simulations are sometimes used like a black box, + +i.e., without consideration of the numerical limitations for a code + +in a given application. Clearly when this happens, there can be little + +confidence in the results. Any applications of a numerical simulations + +should keep in mind the capabilities of the simulation method and + +use consistency checks to generate confidence in the results. Further + +reading and additional information on MHD simulations and methods + +is provided also in the respective chapters of this volume on 'Adaptive + +Global MHD Simulations' and 'Higher-order magnetohydrodynamic numerics'. + %- Finite Differenzen