computational plasma physics - tum · for plasma physics simulations. its aim is to introduce the...

79
Computational plasma physics S. Possanner and E. Sonnendr¨ ucker Max-Planck-Institut f¨ ur Plasmaphysik und Zentrum Mathematik, TU M¨ unchen Lecture notes Sommersemester 2019 July 12, 2019

Upload: others

Post on 09-Apr-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Computational plasma physics

S. Possanner and E. SonnendruckerMax-Planck-Institut fur Plasmaphysik

undZentrum Mathematik, TU Munchen

Lecture notes

Sommersemester 2019

July 12, 2019

Page 2: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Contents

1 Introduction 31.1 Scientific computing . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Plasmas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.3 Model equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.3.1 The N -body model . . . . . . . . . . . . . . . . . . . . . . . 71.3.2 Kinetic models . . . . . . . . . . . . . . . . . . . . . . . . . 81.3.3 Fluid models . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.4 Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2 Basic numerical tools for the Poisson equation 142.1 The 1D Poisson equation and boundary conditions . . . . . . . . . 142.2 The finite difference method . . . . . . . . . . . . . . . . . . . . . . 16

2.2.1 Higher order finite differences . . . . . . . . . . . . . . . . . 192.2.2 Convergence of finite difference schemes . . . . . . . . . . . 192.2.3 Finite difference methods in higher dimensions . . . . . . . . 23

2.3 The method of manufactured solutions . . . . . . . . . . . . . . . . 252.4 Fourier methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.4.1 Fourier series . . . . . . . . . . . . . . . . . . . . . . . . . . 262.4.2 The Fourier transform . . . . . . . . . . . . . . . . . . . . . 272.4.3 The Discrete Fourier Transform . . . . . . . . . . . . . . . . 272.4.4 Circulant matrices . . . . . . . . . . . . . . . . . . . . . . . 292.4.5 Stability of the discrete Laplacian with periodic boundary

conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.4.6 The Fourier pseudospectral method . . . . . . . . . . . . . . 32

2.5 The Finite Element Method . . . . . . . . . . . . . . . . . . . . . . 352.5.1 Principle of the method . . . . . . . . . . . . . . . . . . . . 352.5.2 The weak form of a boundary value problem . . . . . . . . . 392.5.3 Lagrange Finite Elements . . . . . . . . . . . . . . . . . . . 422.5.4 B-spline Finite Elements . . . . . . . . . . . . . . . . . . . . 452.5.5 Convergence of the Finite Element method . . . . . . . . . . 46

3 Numerical schemes for the Vlasov-Poisson system 503.1 The Vlasov-Poisson model for electrons . . . . . . . . . . . . . . . . 50

3.1.1 The Vlasov equation in a given potential . . . . . . . . . . . 513.1.2 Conservation properties . . . . . . . . . . . . . . . . . . . . 52

1

Page 3: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

3.2 The particle in cell (PIC) method . . . . . . . . . . . . . . . . . . . 543.2.1 Time scheme for the particles . . . . . . . . . . . . . . . . . 553.2.2 Particle mesh coupling for Finite Elements . . . . . . . . . . 553.2.3 Particle-Mesh coupling for point-based Poisson solvers . . . 563.2.4 Time loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573.2.5 Conservation properties at the semi-discrete level . . . . . . 58

3.3 Operator splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

4 The geometric electromagnetic PIC method 634.1 Compatible Finite Element discretisation of Maxwell’s equation . . 63

4.1.1 Weak formulation and commuting diagram in 3D . . . . . . 634.1.2 Construction of the Finite Element spaces in 1D . . . . . . . 664.1.3 Summary: semi-discrete 1D Maxwell equations . . . . . . . . 72

4.2 Coupling to the Vlasov equation . . . . . . . . . . . . . . . . . . . . 734.2.1 Recalling some PIC fundamentals . . . . . . . . . . . . . . . 734.2.2 The semi-discrete 1D2V Vlasov-Maxwell system . . . . . . . 75

2

Page 4: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Chapter 1

Introduction

1.1 Scientific computing

Understanding an experiment in physics relies on a model which is generally adifferential equation or a partial differential equation or a system involving manyof these. In sufficiently simple cases analytical solutions of these models exist andthen this can be used to predict the behaviour of a similar experiment. However inmany cases, especially when the model is based on first principles, it is so complexthat there is no analytical solution available. Then there are two options: thefirst is to simplify the model until it can be analytically solved, the second is tocompute an approximate solution using a computer. In practice both are usuallydone, the simplified models being used to verify that the code is working properly.Due to the enormous development of computer resources in the last 50 years, quiterealistic simulations of physical problems become now possible. A large amount oftheoretical work in physics and related disciplines, in particular in plasma physics,now relies quite heavily on numerical simulation.

Computational sciences have emerged next to theory and experiments as a thirdpillar in physics and engineering. Designing efficient, robust and accuratesimulation codes is a challenging task that is at the interface of the applicationdomain, plasma physics in our case, applied mathematics and computer science.The main difficulties are to make sure that the implemented algorithms providea good approximation of the physics model and also that the algorithms use ef-ficiently the available computer resources which are costly. Even though manybasic simulations can be performed nowadays on a laptop, state of the art compu-tations require huge super-computers that consists of many computing units andnowadays often heterogeneous computing elements (CPU, GPU, MIC, ...). Theserequire parallel algorithms and often, to achieve optimal efficiency, a very goodknowledge of the computer architecture.

This lecture will provide an introduction to the main numerical methods usedfor plasma physics simulations. Its aim is to introduce the process of developinga simulation code and some standard methods and numerical issues. The modelswe will consider come from plasma physics, but the models and even more so thetechniques and ideas will be useful for many other applications. Specific skills and

3

Page 5: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

methodologies for high performance computing that are also very important incomputational physics are beyond the scope of this lecture. We refer to [4] for anintroduction.

The first step is to find an appropriate model, which is often a set ofcoupled differential or partial differential equations. If the model is continuousthe solution lives in an infinite dimensional space which cannot be represented ona computer. The second step then will be to discretise it, i.e. represent theunknowns by a large but finite number of values, typically its values on a finitegrid or the coefficients of its expression on the basis of a a finite dimensional linearspace. Then from the equations of the starting models relations between the valuesrepresenting the discrete unknowns should be found. This yields a finite numberof linear or non linear equations that can be solved on a computer. Thiswill require methods of numerical linear algebra, which are introduced in [13] oriterative methods for linear or nonlinear equations, a good introduction of whichis available in [7]. We won’t focus on these either. They are generally taughtin Numerics Bachelor classes. They are generally available in numerical softwaretools like Matlab or Numpy and those programming in a low level language likeFortran, C or C++ can use efficient libraries, like LAPACK, ScaLAPACK, PETSc,Trilinos, to name a few, that are freely available.

There are many possible ways to discretise a differential or partial differentialequation. They are not all equal and many things need to be considered, whenchoosing an appropriate one. The most important is naturally that the discretemodel converges towards the initial model when the number of discretevalues goes to infinity. Because computer arithmetics is not exact, as real numberscannot be represented exactly on a computer, sensitivity to round-off errors is veryimportant. Then some algorithms need more operations than other. Optimally analgorithm dealing with an unknown vector of N points can use O(N) operations,but some can use O(N logN) or O(Nd) or even more, which will make a hugedifference for large values of N . Then again some algorithms will be easier toparallelise than others, which is an important issue when developing a simulationcode on a massively parallel computer.

Also, before choosing a discretisation, it is important to understand the struc-ture of the equations that are being discretised. Analytical theory plays an essen-tial role in this aspect. What are the conserved quantities? Are there analyticalsolution in some special cases? What is the evolution of the solution or some quan-tities depending on the solution? And so on. The more information is availablefrom analytical theory, the easier it will be to check whether the code is correctlyapproximating the analytical model. The process of verification of a computercode, consists precisely in checking that the code can reproduce as expected infor-mation available from the theory. Verification of a computer code is essential togain confidence in its correctness. Only once the computer code has been appro-priately verified, one can proceed with the validation process, which consists incomparing the code to actual experiments and checking that those can be repro-duced within the available error bars. If this is not the case, one needs to check theinitial model, including initial and boundary conditions and all external parame-

4

Page 6: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

ters that could have an influence on the results. Possibly one also needs to developmore verification tests to check that there is no error in the implementation. Thisprocess of Verification and validation (V & V) is essential for developing asimulation code with reliable predictive capabilities.

In this lecture, starting from a few classical models from plasma physics, wewill learn how to write a simulation code for solving them. This includes finding agood discrete model, implementing it and verifying it. This is the scope of appliednumerical mathematics. The physics exploitation of the code can start after thosesteps. We will cover most of the classical discretisation methods, finite differences,finite elements, finite volumes and also spectral methods.

1.2 Plasmas

When a gas is brought to a very high temperature (104K or more) electrons leavetheir orbit around the nuclei of the atom to which they are attached. This givesan overall neutral mixture of charged particles, ions and electrons, whichis called plasma. Plasmas are considered beside solids, liquids and gases, as thefourth state of matter.

You can also get what is called a non-neutral plasma, or a beam of chargedparticles, by imposing a very high potential difference so as to extract either elec-trons or ions of a metal chosen well. Such a device is usually located in the injectorof a particle accelerator.

The use of plasmas in everyday life has become common. This includes, forexample, neon tubes and plasma displays. There are also a number industrialapplications: amplifiers in telecommunication satellites, plasma etching in micro-electronics, production of X-rays.

We should also mention that while it is almost absent in the natural state onEarth, except the Northern Lights at the poles, the plasma is 99% of the massof the visible universe. In particular the matter in stars is mainly in the plasmastate and the energy they release comes from the process of fusion of light nucleisuch as protons. This is the process that is at the base of fusion energy, aimingat extracting a vast amount of energy from a plasma. This is an active subject ofresearch in plasma physics. More information on plasmas and their applicationscan be found on the web site http://www.plasmas.org.

1.3 Model equations

Since plasma is a gas of charged particles, one expects the equations of gas dy-namics (Euler, Navier-Stokes, Boltzmann) to play a role in the modeling of plasmaphenomena. In contrast to neutral gases, however, the dominant interaction isgoverned by the Lorentz force, which is long-range and leads to collective phe-nomena such as plasma waves. Moreover, external electric and magnetic fieldscan be used to accelerate and guide the plasma particles - this fact is used for in-stance in particle accelerators (https://home.cern/) or in magnetic fusion devices

5

Page 7: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

(https://www.iter.org/). An adequate description of plasmas is thus obtainedby coupling the equations of gas dynamics to equations for the electromagneticfields, namely Maxwell’s equations. A nice overview of plasma models, and anintroduction to Plasma Physics in general, can be found for instance in [2, 8].

Indeed, there exists a whole hierarchy of plasma models adapted to the variousscales of observation, ranging from the microscopic picture (atomistic view) to themacroscopic picture (fluid dynamical view). Their derivation and in-depth analysisgoes beyond the scope of this lecture. We shall present however a quick overviewof the the most prominent plasma models used in computer simulations:

1. Microscopic scale: the N-body modelEach of the N plasma particles is modeled by its proper equation of motion(Newton’s equations with Lorentz force).

2. Mesoscopic scale: kinetic modelsEach particle species s is modeled by a density fs(x,v, t) > 0, where t ∈ R istime and (x,v) ∈ R6 denotes a point in phase space, x being the position andv being the velocity. fs(x,v, t) d3x d3v is the phase space measure, yieldingthe number of particles contained in the box d3x d3v. fs satisfies a transportequation (Boltzmann, Vlasov) and the interaction is modeled via Maxwell’sequations.

3. Macroscopic scale, part 1: fluid modelsEach particle species is modeled by a set of fluid dynamical variables such asparticle density ns(x, t) > 0, mean velocity us(x, t) ∈ R3 and temperatureTs(x, t) > 0 (sometimes even more fluid variables such as the heat flux andthe pressure tensor are introduced). (n,u, T ) satisfy hydrodynamic equa-tions (Euler, Navier-Stokes, Braginskii) and the interaction is modeled viaMaxwell’s equations.

4. Macroscopic scale, part 2: magneto-hydrodynamic (MHD) modelsPlasma is modeled as a single, ”quasi-neutral” fluid with mass density τ(x, t) >0, mean velocity U(x, t) ∈ R3 and pressure p(x, t) > 0, coupled to the in-duction equation for the magnetic field B(x, t) ∈ R3.

TheN -body model is a system of coupled ordinary differential equations (ODEs),where in reality N can be extremely large, e.g. of the order N ∼ 1014 in a cubiccentimeter of a fusion plasma. All other models are (nonlinear) partial differen-tial equations (PDEs), which describe the evolution of statistical averages of the(exact) N -body model over small regions in phase- or configuration space. Fluidmodels are becoming a good approximation when the particles are close to ther-modynamic equilibrium, to which they return in long time do to the effects ofcollisions and for which the distribution of particle velocities is a Gaussian.

When choosing a model for a simulation code, one should try to take intoaccount accuracy and computational cost and take the model that will allow us tofind a solution that is accurate enough

6

Page 8: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

for the problem we are considering in the shortest possible time. In particularbecause of the very large number of particles in a plasma, kinetic models obtainedby statistical arguments are almost always accurate enough. The question willthen be if a further model reduction, which could diminish cost, can be performedat least for part of the plasma.

Let us have a brief look at these models to get a flavor of plasma modeling andto know what kind of equations one has to deal with in ”Computational PlasmaPhysics”.

1.3.1 The N-body model

At the microscopic level, plasma is composed of a number of charged particles thatevolve following the laws of classical or relativistic dynamics. So each particle,characterised by its position x, velocity v, as well as its mass m and charge q,obeys Newton’s law

d(γmv)

dt=∑

Fext,

where γ = (1 − |v|2c2

)−12 is the Lorentz factor (c being the speed of light). The

right hand side Fext is composed of all the forces applied to the particle, which inour case reduce to the Lorentz force induced by the external and self-consistentelectromagnetic fields. Other forces, as the weight of the particles, are in generalnegligible. Whence we have, labelling the different particles in the plasma,

d(γmivi)

dt=∑j 6=i

qi(Ej + vi ×Bj) + qi(Eext + vi ×Bext).

The sum on the right hand side is over all the particles in the plasma and Ej,Bj

denote the electric and magnetic fields fields generated by particle j. Moreover,Eext,Bext denote the external electric and magnetic fields fields, i.e. those that arenot generated by particles of the plasma itself. The latter could be for examplecoils in an accelerator or in a tokamak. On the other hand the velocity of a particlevi is linked to its position xi by

dxidt

= vi.

Thus, if the positions and velocities of the particles at time t = 0 are known aswell as the external fields, the evolution of the particles is completely determinedby the equations

dxidt

= vi , xi(0) = x0i ,

d(γmivi)

dt=∑j 6=i

qi(Ej + vi ×Bj) + qi(Eext + vi ×Bext) , vi(0) = v0i ,

where the sum contains the electric and magnetic field generated by each of theother particles as well as the external fields.

7

Page 9: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

1.3.2 Kinetic models

In a kinetic model, each species s in the plasma is characterized by a distributionfunction fs(x,v, t) which corresponds to a statistical mean of the repartition ofparticles in phase space for a large number of realisations of the considered physicalsystem. Note that phase space consists of the subspace of R6 containing all possiblepositions and velocities of the particles. For any volume V ,

∫Vfs dx dv is the

average number of particles of species s, whose position and velocity are in V .Normalising fs to one, fs becomes the probability density defining the probabilityof a particle of species s being at point (x,v) in phase space.

In the limit where the collective effects are dominant on binary collisions be-tween particles, the kinetic equation that is derived, by methods of statisticalphysics from the N -body model is the Vlasov equation which reads

∂fs∂t

+ v · ∇xfs +qsms

(E + v ×B) · ∇vfs =∑σ

Q(fs, fσ), (1.1)

in the non relativistic case. In the relativistic case it becomes

∂fs∂t

+ v(p) · ∇xfs + qs(E + v(p)×B) · ∇pfs =∑σ

Q(fs, fσ). (1.2)

We denote by ∇xfs, ∇vfs and ∇pfs, the respective gradients of fs with respectto the three position, velocity and momentum variables. The constants qs and ms

denote the charge and mass of the particle species. The velocity is linked to themomentum by the relation v(p) = p

msγs, where γ is the Lorentz factor which can be

expressed from the momentum by γs =√

1 + |p|2/(m2sc

2). On the right-hand-sideQ(fs, fσ) represents a bilinear collision operator modeling the collisions of speciess with all the other species of particles in the plasma, including s. Collisionshave the effect of bringing the plasma back to its thermodynamical equilibriumin which the velocity distribution is a Gaussian (also called Maxwellian in plasmaand gas dynamics). The Vlasov equation is a generalisation for charged particlesof the Boltzmann equation for neutral particles. Note that for many applicationson short time scales, the collisions can be neglected and the model becomes thenthe collisionless Vlasov equation often also called just Vlasov equation. From nowon we shall consider the Vlasov equation as collisionless.

Then, for a zero right-hand-side, the Vlasov equation expresses that the dis-tribution function fs is conserved along the trajectories of the particles which aredetermined by the mean electric field. We denote by fs,0(x,v) the initial valueof the distribution function. The Vlasov equation, when it takes into account theself-consistent electromagnetic field generated by the particles, is coupled to theMaxwell equations which enable to compute this self-consistent electromagnetic

8

Page 10: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

field from the particle distribution:

− 1

c2

∂E

∂t+ curl B = µ0 J, (Ampere)

∂B

∂t+ curl E = 0, (Faraday)

div E =ρ

ε0

, (Gauss)

div B = 0, (magnetic Gauss)

(1.3)

where the constants are c the speed of light, µ0 the permeability of free spaceand ε0 the permittivity of free space. The source terms for Maxwell’s equation,the charge density ρ(x, t) and the current density J(x, t) can be expressed fromthe distribution functions of the different species of particles fs(x,v, t) using therelations [

ρ(x, t)

J(x, t)

]:=∑s

qs

∫ [1

v

]fs(x,v, t) d3v, (1.4)

Note that in the relativistic case the distribution function becomes a function ofposition and momentum (instead of velocity): fs ≡ fs(x,p, t) and charge andcurrent densities verify[

ρ(x, t)

J(x, t)

]=∑s

qs

∫ [1

v(p)

]fs(x,p, t) d3p, (1.5)

In order to admit a unique solution (fs,E,B), the Vlasov-Maxwell system (1.1),(1.3), (1.4), or (1.2), (1.3), (1.5) in the relativistic case, needs to be supplementedwith suitable initial- and boundary conditions when restricted to a finite domain, asis the case in numerical experiments. A classical boundary condition for the electricfield is for example the perfect conductor boundary condition E× n = 0, where ndenotes the unit outgoing normal of the x-domain. No additional condition on B isneeded in that case. Finding and implementing appropriate boundary conditionsis usually among the hardest problems when constructing a numerical code.

An important reduced version of the Vlasov-Maxwell system is the Vlasov-Poisson model, which is electrostatic (in contrast to electromagnetic). One assumesB = 0 such that Maxwell’s equations become

− 1

c2

∂E

∂t= µ0 J , curl E = 0 , div E =

ρ

ε0

. (1.6)

Taking the divergence of the first equation, substituting the third equation andusing c−2 = ε0µ0 leads to the charge continuity equation

∂ρ

∂t+∇ · J = 0 . (1.7)

This equation also holds for B 6= 0 as ∇ · ∇× = 0 (or div curl = 0). It is asolvability condition on Maxwell’s equations, which is satisfied for ρ and J given

9

Page 11: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

by (1.4), as can be verified by direct computation under the assumptions (1.12)and (1.14) on the collision operators. Because equation (1.7) holds, the first andthe third equation in (1.6) are equivalent and one can neglect one or the other.Moreover, the second equation in (1.6) suggest that the electric field can be writtenas the gradient of a scalar function, called the electric potential φ, and one usuallywrites E = −∇φ. Therefore, the Vlasov-Poisson (VP) system reads

(VP)

∂fs∂t

+ v · ∇xfs −qsms

∇φ · ∇vfs =∑σ

Q(fs, fσ) ,

−∇ · ∇φ =1

ε0

∑s

qs

∫fs(x,v, t) d3v (Poisson) ,

supplemented with suitable initial and boundary conditions. This model featuressome interesting phenomena like plasma waves (Langmuir waves) and Landaudamping, the latter being a purely kinetic effect which cannot be captured withfluid models.

1.3.3 Fluid models

The idea of fluid models is to describe each plasma species in terms of macroscopicvariables, i.e. variables that do not depend on the velocity v, rather than the fulldistribution function fs. The most common such variables are the particle densityns, the mean velocity us and the total energy ws, defined by ns(x, t)

ns(x, t) us(x, t)

ws(x, t)

:=

∫ 1

v

ms|v|2/2

fs(x,v, t) d3v . (1.8)

With regards to numerics, it is often more convenient to work with the particleflux Γs := nsus instead of the mean velocity us as a fluid variable. The totalenergy can be written as the sum of the internal energy and a kinetic energy:

ws =ms

2

∫|v|2fs d3v

=ms

2

∫|v − us|2fs d3v +ms

∫v · u fs d3v − ms

2

∫|u|2fs d3v

=3

2nskBTs︸ ︷︷ ︸

internal energy

+nsms|us|2

2︸ ︷︷ ︸kinetic energy

.

(Remark that v · u = vTu denotes the inner product in R3.) Here, we definedthe species temperature Ts via 3nskBTs := ms

∫|v−us|2fs d3v, where kB denotes

the Boltzmann constant. The pressure of species s is given by ps = nskBTs. Bycomparing (1.8) to (1.4) we can see that the charge- and current densities can bewritten as [

ρ

J

]=∑s

qs

[ns

nsus

]. (1.9)

10

Page 12: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Fluid models consist of a closed set of equations for a suitable set of fluid variables,for instance (ns,us) or (ns, nsus, ws), which allows for a self-consistent couplingto Maxwell’s equations via (1.9). The dimensional reduction with respect to thekinetic approach, where fs(·, t) is defined on R6 whereas fluid variables are definedon R3, greatly reduces the computational complexity in numerical experiments.However, the fluid description is less accurate than the kinetic one; it relies onthe assumption of local thermal equilibrium, which means that fs is a Gaussian invelocity v:

local thermal equilibrium: fs(·, t) =Mns,us,Ts(·, t) ∀ t . (1.10)

The equilibrium distribution Mns,us,Ts is called Maxwellian and is defined by

Mns,us,Ts(x,v, t) := ns(x, t)

(ms

2πkBTs(x, t)

)3/2

exp

[−ms|v − us(x, t)|2

2 kBTs(x, t)

].

It can be readily checked by computing the Gaussian integrals that

∫ 1

v

ms|v|2/2

Mns,us,Ts d3v =

ns

nsus

ws

, (1.11)

such that each Maxwellian is uniquely determined by its first three velocity mo-ments (ns, nsus, ws). The fluid model follows from the following

Proposition 1. Suppose that fs satisfies the (non-relativistic) Vlasov equation (1.1).Under the assumption of local thermal equilibrium (1.10), and under the assump-tion that the intra-species collision operator Q(fs, fs) conserves mass, momentumand energy, and the inter-species collision operator Q(fs, fσ), s 6= σ, conservesmass,

∫ 1

v

|v|2

Q(fs, fs) d3v = 0 ,

∫Q(fs, fσ) d3v = 0 , s 6= σ , (1.12)

the moments of the Maxwellian (1.11) satisfy the following set of fluid equations:

∂ns∂t

+∇ · (nsus) = 0 ,

∂t(nsus) +∇ · (nsusuTs ) +

∇psms

=qsms

(nsE + nsus ×B) +Rs

ms

,

∂ws∂t

+∇ · [us(ws + ps)] = qsnsus · E + hs + us ·Rs .

(1.13)

Here, (uuT )i,j = uiuj is the outer product and Rs and hs denote the momentum

11

Page 13: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

exchange and the heat exchange with other particle species species σ 6= s,

Rs := ms

∑σ

∫vQ(fs, fσ) d3v , hs :=

ms

2

∑σ

∫|v − us|2Q(fs, fσ) d3v ,

∑s

Rs = 0 ,∑s

(hs + us ·Rs) = 0

(conservation of total momentum and energy during collisions) .(1.14)

Proof. This follows directly by integrating the Vlasov equation over (1,v,ms|v|2/2)and by inserting the assumption (1.10).

If one is able to express the momentum and heat exchanges Rs and hs in termsof the fluid variables (ns,us, ws) (or by neglecting inter-species collisions), thefluid system (1.13) together with (1.3) and (1.9) forms a closed set of equations forplasma with self-consistent electromagnetic interaction (Euler-Maxwell model).There are other variants of the fluid equations which take into account smalldeviations from the Maxwellian (compressible, incompressible Navier-Stokes) orthe effects of a very strong magnetic field (Braginskii equations).

Yet another popular fluid model in plasma physics is magneto-hydrodynamics(MHD), a theory that describes a multi-species plasma as a single fluid. The MHDvariables are the total mass τ , the total velocity U and the total pressure p of theplasma, defined by

MHD variables: τ :=∑s

msns , U :=1

τ

∑s

msnsus , p :=∑s

ps .

Under suitable assumptions (see for instance [6] for a nice introduction to MHD)one can derive from the fluid equations (1.13) the following set of MHD equations :

(MHD)

∂τ

∂t+∇ · (τU) = 0 ,

∂U

∂t+ U · ∇U +

∇pτ

=1

µ0

∇×B

τ×B ,

∂p

∂t+ U · ∇p+

5

3p∇ ·U = 0 ,

∂B

∂t= ∇× (U×B) , (Induction equation) .

This is a system for the unknowns (τ,U, p,B) which describes quasi-neutral plasma,ρ ≈ 0, as a single fluid. Maxwell’s equations were reduced to the induction equa-tion for B, and the electric field has been eliminated from the system (it actuallyreads E = −U×B).

Fluid models are popular, because they are intuitive and deal with quantitiesthat are measurable in experiments (easy to find boundary conditions). However,

12

Page 14: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

the distribution function fs contains much more information than a fluid descrip-tion as it includes information on the distributions of particle velocities at eachposition x. A kinetic description of a plasma is essential when the distributionfunction is far away from the Maxwell distribution Mns,us,Ts . This is the case ifcollisions are not frequent enough, as in rarefied gases, because collisions are themechanism that drives the distribution function towards local thermal equilibrium(H-theorem). In case of high collision frequency (dense gas or liquid) a fluid de-scription can be sufficient. In practice one often deals with a combination of kineticand fluid models for different parts of the plasma (hot and cold particles, core andedge regions in a tokamak). Such models are called kinetic-fluid hybrid. An un-derstanding of the transition from the kinetic to the fluid description is paramountfor these ideas.

1.4 Outlook

We have seen that mesoscopic (kinetic) and macroscopic (fluid) plasma models arenonlinear systems of PDEs. In this lecture we will learn about some basic strategiesof how to obtain approximate solutions of these equations on a computer, and howto verify if the constructed codes have been implemented correctly. The followingtopics will be covered in particular:

• finite difference (FD) and fast Fourier transform (FFT) methods for Poisson

• finite element (FE) methods for Poisson with Lagrange and B-spline elements

• finite volume (FV) methods for 1D advection problems

• FV methods for (nonlinear) systems of fluid equations

• particle-in-cell (PIC) methods for Vlasov-Poisson

• geometric PIC methods for Vlasov-Maxwell

• geometric FE methods for MHD

We will implement several toy models (1D) in the exercise class of this coursein order to apply the course material in practical examples.

13

Page 15: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Chapter 2

Basic numerical tools for thePoisson equation

2.1 The 1D Poisson equation and boundary con-

ditions

The Poisson equation is a fundamental equation in plasma physics, as it enablesthe computation of the electric potential φ for a given charge density ρ. It isalso the prototypical elliptic equation in many textbooks on PDEs. Consider anopen bounded and connected set Ω ⊂ Rn with smooth boundary ∂Ω. The Poissonequation reads

−∆φ(x) = ρ(x) , x ∈ Ω ⊂ Rn , (2.1)

where ρ : Ω → R is a given function and ∆ =∑n

i=1∂2

∂x2i

denotes the Laplace

operator. To obtain a unique solution, suitable boundary conditions on ∂Ω mustbe specified. Equation (2.1) is actually the strong form of the Poisson equation, asit holds point-wise in Ω. φ is then assumed twice continuously differentiable and ρis continuous, such that the above expression makes sense. Later, in the context offinite element methods, we will get to know also the weak form of Poisson, whereless regularity is demanded from the solution.

In order to get familiar with the basic discretization methods, we consider the1D Poisson equation (n = 1) in an interval Ω = (a, b) ⊂ R and assume φ ∈ C2(Ω)and ρ ∈ C0(Ω):

−φ′′(x) = ρ(x) , x ∈ (a, b) . (2.2)

For the problem to be well posed, boundary conditions are needed for x = a andx = b. We will consider here three classical types of boundary conditions:

1. Dirichlet boundary conditions: φ is given at x = a and x = b,

φ(a) = α , φ(b) = β . (2.3)

2. Neumann boundary conditions: φ′ is given at boundary. Note that wecan do this only at one end of the interval, otherwise the problem is ill-posed

14

Page 16: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

(see below):φ(a) = α , φ′(b) = β . (2.4)

3. Periodic boundary conditions. In this case the problem is actually de-fined on Ω = R but all functions are assume to be periodic of period L = b−a:

φ(x+ L) = φ(x) , ∀ x . (2.5)

Therefore we can restrict the interval of computation to [0, L]. Then, thereare mathematically no boundaries and no boundary conditions are needed.The terminology ”periodic boundary conditions” is somewhat misleading.Note however in this case that φ is only determined up to a constant, whichneeds to be set for a numerical computation.

Let us examine the existence and uniqueness of solutions to problem (2.2) withthe three types of boundary conditions (2.3), (2.4) and (2.5). The existence followsfrom the regularity of the right-hand-side. Because ρ ∈ C0(Ω) we can computeanti-derivatives (primitive functions):

φ′(x) = −∫ x

a

ρ(x1) dx1 + c1 ,

φ(x) = −∫ x

a

(∫ x1

a

ρ(x0) dx0

)dx1 + c1x+ c0 ,

where c1, c2 ∈ R are the constants of integration. The lower bound ’a’ in theintegration is not important and could be changed because we added c1 and c2.The uniqueness can be investigated by assuming that there exist two solutions φand ψ that satisfy (2.2) plus boundary conditions. The difference η := φ−ψ thensatisfies the Laplace equation −η′′ = 0 and hence is given by η(x) = c0+c1x, wherec0, c1 ∈ R have to be determined from the boundary conditions. For the problemto be well-posed one needs c0 = c1 = 0 because then φ = ψ and the solution isunique. In case of Dirichlet conditions one obtains

η(a) = c0 + c1a = 0

η(b) = c0 + c1b = 0

⇒ c1(a− b) = 0 ⇒ c1 = 0 ⇒ c0 = 0 ,

such that the problem is well-posed. In case of (2.4), with a Neumann conditionat x = b one has

η(a) = c0 + c1a = 0

η′(b) = c1 = 0

⇒ c0 = 0 ,

so that also this problem is well-posed. Had we assumed Neumann conditions atboth sides of the domain, the constant c0 could be chosen arbitrarily, leading to aninfinite amount of solutions. Similarly, for periodic boundary conditions we obtainfrom (2.5) only one equation,

η(x) = c0 + c1x = c0 + c1(x+ L) = η(x+ L) ,

15

Page 17: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

such that also in this case the constant c0 remains undetermined, and the problemis ill-posed. Moreover, integrating (2.2) on a period, e.g. [0, L] yields

0 = φ′(L)− φ′(0) = −∫ L

0

ρ(x) dx ,

as φ′(L) = φ′(0) because φ′ is L-periodic. So a necessary condition for a solution

to exist for the periodic case is∫ L

0ρ(x) dx = 0.

2.2 The finite difference method

We now make a first attempt at discretising the 1D Poisson equation (2.2). Letus assume for simplicity that a = 0 and b = L and let us consider a uniform meshof the 1D computational domain, i.e. of the interval Ω = [0, L]. The cell size orspace step is defined by h = L

Nwhere N is the number of cells in the mesh. The

coordinates of the grid points are then defined by xj = x0+jh = jh as x0 = 0. Thesolution of the numerical scheme will be defined by its values at xj for 0 ≤ j ≤ N ,hence at N + 1 grid points.

The principle of the Finite Difference (FD) method is to approximate deriva-tives of φ at grid points xj by differences of φ(xi) at well-chosen (neighbouring)grid points xi. The simplest way to do this is to use Taylor expansions aroundthe considered point xj. We do this for all points on the grid. The Taylor ex-pansion will also enable us to see the order of approximation of the derivative. Inparticular, assuming φ ∈ C4(Ω) we have

φ(xj+1) = φ(xj) + hφ′(xj) +h2

2φ′′(xj) +

h3

6φ(3)(xj) +

h4

24φ(4)(xj + θ+

j h),

φ(xj−1) = φ(xj)− hφ′(xj) +h2

2φ′′(xj)−

h3

6φ(3)(xj) +

h4

24φ(4)(xj − θ−j h).

We deduceφ(xj+1)− 2φ(xj) + φ(xj−1) = h2φ′′(xj) +O(h4) ,

so that

φ′′(xj) =φ(xj+1)− 2φ(xj) + φ(xj−1)

h2+O(h2) .

Plugging this into the Poisson equation at point xj, −φ′′(xj) = ρ(xj), we get

−φ(xj+1)− 2φ(xj) + φ(xj−1)

h2= ρ(xj) +O(h2) . (2.6)

Let us now define φj ∈ R such that for 1 ≤ j ≤ N − 1 we have

−φj+1 + 2φj − φj−1

h2= ρ(xj),

and let us use the boundary conditions to determine the additional unknowns φ0

and φN . Then (φj)Nj=0 will give an approximation of φ(xj) for all the points on the

16

Page 18: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

grid 0 ≤ j ≤ N .

Dirichlet: φ0 = φ(x0) = α, φN = φ(xN) = β. So there remain N − 1 unknownsφ1, . . . , φN−1 determined by the N − 1 equations

−φj+1 + 2φj − φj−1

h2= ρ(xj) , 1 ≤ j ≤ N − 1.

This can be written as a linear system AhΦh = Rh with

Ah =1

h2

2 −1 0−1 2 −1 0

0. . . . . . . . .. . . . . . . . . −1

0 −1 2

∈ R(N−1)×(N−1) , (2.7)

Φh =

φ1

φ2...

φN−1

∈ R(N−1) , Rh =

ρ(x1) + α

h2

ρ(x2)...

ρ(xN−1) + βh2

∈ R(N−1) .

Neumann: Because we need to set the constant for the potential at one point,we consider now the boundary conditions φ(0) = 0 and φ′(L) = β. In this case theunknown are φ1, . . . , φN . So there are N unknown. We can still use like before thefinite difference approximations of −φ′′(xj) = ρ(xj) at the N − 1 interior points.Then the missing equation needs to be obtained from the Neumann boundarycondition φ′(L) = β. This needs to be expressed from the point values. For thiswe can simply set

φN − φN−1

h= β .

This is only a first order approximation of the derivative at xN = L, but this isenough to keep the second order approximation on φ at the end (this is shown inthe exercise classes). Now we get the linear system AhΦh = Rh with

Ah =1

h2

2 −1 0−1 2 −1 0

0. . . . . . . . .. . . . . . . . . −1

0 −1 2 −10 −1 1

∈ RN×N ,

Φh =

φ1

φ2...φN

∈ RN , Rh =

ρ(x1)ρ(x2)

...ρ(xN−1)

βh

∈ RN .

17

Page 19: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Periodic: This case is the simplest as there is in principle no boundary. All pointsare interior points and can be used to express −φ′′(xj) = ρ(xj). Because of theperiodicity φ(xj+N) = φ(xj), only the values of φj for 0 ≤ j ≤ N − 1 need to becomputed, the others being deduced by periodicity. So there will be N unknownsin our system that are determined by the N approximations to −φ′′(xj) = ρ(xj).At interior points we have

−φj+1 + 2φj − φj−1

h2= ρ(xj) , 1 ≤ j ≤ N − 2.

Moreover, for j = 0 we have φj−1 = φ−1 = φN−1 so that the equation reads

−φ1 + 2φ0 − φN−1

h2= ρ(x0) ,

and for j = N − 1 we have φj+1 = φN = φ0 so that

−φ0 + 2φN−1 − φN−2

h2= ρ(xN−1).

In this case the system in Matrix form reads

AhΦh = Rh ,

with

Ah =1

h2

2 −1 0 0 −1−1 2 −1 0 . . . 0

0. . . . . . . . . 0

.... . . . . . . . . −1 0

0 −1 2 −1−1 0 −1 2

∈ RN×N , (2.8)

Φh =

φ0

φ1...

φN−1

∈ RN , Rh =

ρ(x0)ρ(x1)

...ρ(xN−1)

∈ RN .

We notice that each diagonal of Ah has everywhere the same term. We see alsothat the vector (1, . . . , 1)> is in the kernel of Ah as the sum of all the terms of eachline vanishes. This means that the matrix is not invertible. Its kernel has rank oneand invertibility can be recovered by assuming zero average, which in the discretecase reads

φ0 + · · ·+ φN−1 = 0.

In practice, to solve the system, one could replace the last row of the linear systemby the condition above. Another option, that we will come back to later, wouldbe to use the fact that the matrix Ah is circulant, and solve the system using aFast Fourier Transform (FFT), setting the zero mode to zero as is implied by thefact that φ has zero average.

18

Page 20: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

2.2.1 Higher order finite differences

A fourth order formula for the second derivative can be obtained by adding Taylorexpansions expressing in addition φ(xj+2) and φ(xj−2) with respect to φ(xj) andits derivatives at the point xj. Taking linear combinations of the four Taylorexpansions such that all terms up to h5, except of course the function values andthe second derivative vanish. We then get the formula

φ′′(xj) =−φ(xj+2) + 16φ(xj+1)− 30φ(xj) + 16φ(xj−1)− φ(xj−2)

12h2+O(h4) .

This can be used everywhere for periodic boundary conditions. In this case thematrix form of the Finite Difference problem reads

AhΦh = Rh

with

Ah =1

h2

3012

−1612

112

0 0 112

−1612

−1612

3012

−1612

112

0 . . . 0 112

112

−1612

. . . . . . . . . . . . 0...

0. . . . . . . . . . . . . . . 0

...

0. . . . . . . . . . . . 1

12

.... . . . . . . . . −16

12112

112

112−16

123012

−1612

−1612

112

0 112

−1612

3012

∈ RN×N

Φh =

φ0

φ1...

φN−1

∈ RN , Rh =

ρ(x0)ρ(x1)

...ρ(xN−1)

∈ RN .

For other types of boundary conditions a non centred formula of the same orderneeds to be applied at x1 and xN−1.

2.2.2 Convergence of finite difference schemes

Some theory on the convergence of finite difference schemes will help us understandwhat is needed for a good scheme and also provide verification tests for checkingthat the code implementing the scheme behaves correctly. In particular, checkingthe order of convergence of a scheme is a very good verification test that shouldbe used whenever some theoretical order exists.

In this lecture, we will use mostly the decomposition in eigenmodes for ourproofs. Sometimes easier and more general proofs exist, but understanding thebehaviour of the eigenmodes is in general very useful to understand a scheme. Somecontinuous and discrete norms are needed to define rigorously the convergence.

19

Page 21: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

We will use mostly the L1, L2 and L∞ (or max) norms defined as follows. In thecontinuous setting

‖f‖1 =

∫ b

a

|f(x)| dx, ‖f‖2 =

(∫ b

a

|f(x)|2 dx

)1/2

, ‖f‖∞ = maxa≤x≤b

|f(x)|.

In the discrete setting

‖v‖1 =N∑j=1

|vi|, ‖v‖2 =

(N∑j=1

|vi|2)1/2

, ‖v‖∞ = maxi

(|vi|).

Recall that in a finite dimensional space, all norms are equivalent. For example,the 2-norm and the max-norm can be compared via

‖v‖∞ ≤ ‖v‖2 ≤√N‖v‖∞, ∀ v ∈ RN . (2.9)

After discretisation with Finite Differences we obtained in each case a linear systemof the form AhΦh = Rh. If the matrix Ah is invertible, this enables to computethe solution vector Φh = (φj)j. For this to provide a good approximation of thetrue solution of the Poisson equation, we must compare Φh to the values of thetrue solution at the grid points, which we denote by Φ := (φ(xj))j and which wedon’t know in general. Our goal is is to verify that for some norm ‖ · ‖ we have

‖Φ− Φh‖ ≤ Chp

for some integer p ≥ 1 and a constant C independent of h (we then say that‖Φ − Φh‖ = O(hp)). For this we need to show two properties of the scheme,namely consistency and stability :

consistency: limh→0

Ah(Φ− Φh) = 0 ,

stability: ||A−1h || ≤ Cs ,

where Cs is independent of h. Consistency can be checked by inserting the truesolution into our scheme. Because of (2.6), we have that AhΦ = Rh + h2Sh,where Sh is the vector containing the rest term of the Taylor expansions. Thenas AhΦh = Rh, it follows that Ah(Φ − Φh) = h2Sh. Assuming that the fourthderivative of φ is bounded, it follows that

‖Sh‖∞ ≤ C = ( maxx∈[0,L]

|φ(4)(x)|)/12,

‖Ah(Φ− Φh)‖∞ ≤ Ch2,

where C is independent of h. We then say that the numerical scheme defined bythe matrix Ah is consistent of order 2 in the max-norm. For the 2-norm, we canuse the norm comparison (2.9) and h = L/N to get that

‖Ah(Φ− Φh)‖2 ≤ C1h3/2 , or equivalently

1√N‖Ah(Φ− Φh)‖2 ≤ C2h

2,

20

Page 22: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

where C1 and C2 are constants independent of h.Consistency gives us convergence of Ah(Φ−Φh) to zero. This is not yet enough

to prove that Φh converges to Φ. We also need stability, namely that the norm ofthe inverse of Ah, ‖A−1

h ‖, is bounded independently of h.

Definition 1. For a given vector norm ‖ · ‖, we define the induced matrix normby

‖A‖ := supx 6=0

‖Ax‖‖x‖

.

The consistency of a Finite Difference scheme comes directly from its derivationusing Taylor expansions. Its stability is often more difficult to verify. One possibleway to do it is to check its eigenvalues. This relies on the following proposition:

Proposition 2. Let A ∈ RN×N be diagonalisable in a basis of orthonormal eigen-vectors and let λ1, . . . , λN denote the eigenvalues of A. Then we have

‖A‖2 ≤ max |λi|, ‖A‖∞ ≤ max |λi|.

Proof. Any vector x 6= 0 in RN can be expressed in the basis of orthonormaleigenvectors of A, denote by e1, . . . , eN

x = x1e1 + · · ·+ xNeN .

Assuming that ei is the eigenvector of A associated to the eigenvalue λi, we have

Ax = λ1x1e1 + · · ·+ λNxNeN . (2.10)

Hence for the 2-norm, using the orthonormality of the ei

‖Ax‖22 = λ2

1x21 + + · · ·+ λ2

Nx2N ≤ max(λ2

i )‖x‖22.

From which it follows that ‖A‖2 ≤√

max(λ2i ) = max |λi|.

For the max-norm, we get from (2.10) that

‖Ax‖∞ = max |λixi| ≤ max |λi|‖x‖∞,

from which the result follows.

Hence if Ah is an invertible symmetric matrix, it is diagonalisable in a basisof orthogonal eigenvectors and its eigenvalues are real and different from zero.Denoting by P the matrix whose columns are the eigenvectors of Ah, we haveAh = PΛP>, where Λ is the diagonal matrix containing the eigenvalues. ThenA−1h = PΛ−1P>, where Λ−1 contains the inverse of the eigenvalues.

It follows that for the 2-norm and max-norm that we are interested in, we have

‖A−1h ‖ ≤

1

min |λi|.

21

Page 23: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

This leads us to the sufficient condition for stability that for all the eigenvalues λiof Ah we have

|λi| ≥ C, for some constant C independent of h.

Example: Let us now check this for the Poisson problem with Dirichlet bound-ary conditions. In the continuous case for homogeneous Dirichlet boundary con-ditions the eigenvectors and eigenvalues of the Laplace operator − d2

dx2 in 1D verify

−d2φkdx2

= λkφk, φ(0) = φ(L) = 0.

This is the equation of a harmonic oscillator for which the solutions read:

λk =k2π2

L2, φk(x) =

√2

Lsin

kπx

L, k ∈ Z .

In the case of second order finite differences, the corresponding discrete eigen-value problem reads AhΦk = λkΦk, with h = L/N and the (N − 1) × (N − 1)matrix from (2.7),

Ah =1

h2

2 −1 0−1 2 −1 0

0. . . . . . . . .. . . . . . . . . −1

0 −1 2

.

We can check that the components of the discrete eigenvectors (or eigenmodes),up to normalisation, are the values of the continuous eigenmodes at the grid points

(Φk)j =

√2

Nsin

kjπ

N, 1 ≤ k ≤ N − 1 ,

and the corresponding eigenvalues are

λk =4

h2sin2 kπ

2N=

4

h2sin2 khπ

2L.

As 0 < k < N , we have 0 < kπ/(2N) < π/2, so that the eigenvalues are positiveand in increasing order as sinus is increasing on this interval. It follows that λ1 isthe smallest eigenvalue. Moreover, as h→ 0, we have

λ1 =4

h2sin2 hπ

2L≈ 4

h2

h2π2

4L2→ π2

L2.

This corresponds to the continuous eigenvalue. Then because of the convergenceproperty there exists h0 = L/N0 such that for h ≤ h0 we have for all N ≥ N0 thatλ1 = λN1 ≥ (1/2)π2/L2, where we use the exponent N to show the dependency ofλN1 on N (or equivalently on h). Thus for any N ≥ 1, we have

λN1 ≥ C = min

(λ1

1, . . . , λN0−11 ,

1

2

π2

L2

),

where C is a constant independent on N which proves the stability.

22

Page 24: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

2.2.3 Finite difference methods in higher dimensions

In practical applications one is often interested in solving the Poisson equation(2.1) in a two-dimensional (2D) or 3D setting, hence with n = 2 or n = 3. Thefinite difference approach allows for the construction n-dimensional methods fromthe 1D method via tensor products. For simplicity, here we shall extend the finitedifference method to a 2D Cartesian grid (xi, yj)

N,Ni=0,j=0, which is a tensor product

of 1D grids (the 3D case can be treated analogously). We shall assume that the cellsize is uniform and equal in the two directions for simplicity, h = hx = hy, but thisis not required. We will see that the notion of tensor product enables to constructthe linear system directly from the 1D system, enabling easy implementation andalso extension of the analysis from the 1D case. For simplicity we will only considerhomogeneous Dirichlet boundary conditions. Other boundary conditions can beadapted from the 1D case in the same manner. Denoting (x, y) ∈ Ω ⊂ R2, theproblem reads

−∆φ(x, y) = ρ(x, y) (x, y) ∈ Ω , φ(x, y) = 0 (x, y) ∈ ∂Ω ,

where ∂Ω denotes the domain boundary and ρ ∈ C0(Ω) is given. The 2D Laplaceoperator is defined by

∆φ(x, y) :=∂2φ

∂x2(x, y) +

∂2φ

∂y2(x, y) .

Applying Taylor expansions as in (2.6) to each of the two 1D Laplacians yields

−∆φ(xi, yj) =−φ(xi+1, yj) + 2φ(xi, yj)− φ(xi−1, yj)

h2

+−φ(xi, yj+1) + 2φ(xi, yj)− φ(xi, yj−1)

h2+O(h2) .

Let us consider the natural numbering of the grid values of the approximate solu-tion Φh ∈ RN−1×N−1, which is now a matrix with entries φi,j ≈ φ(xi, yj) for theinterior grid points 1 ≤ i, j ≤ N − 1. Then, in the FD scheme there are (N − 1)2

unknowns satisfying the (N − 1)2 equations

−φi+1,j − φi−1,j + 4φi,j − φi,j+1 − φi,j−1

h2= ρ(xi, yj), 1 ≤ i, j ≤ N − 1. (2.11)

Introducing the right hand side matrix Rh = (ρ(xi, yj))1≤i,j≤N−1 and recalling the1D second-order Dirichlet matrix from (2.7),

Ah =1

h2

2 −1 0

−1 2 −1. . .

0. . . . . . . . . . . .. . . . . . . . . −1 0

. . . −1 2 −10 −1 2

,

23

Page 25: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

we notice that the matrix multiplication AhΦh applies the 1D finite difference sten-cil to the columns of Φh, which corresponds to the differentiation in y. Similarly,the left multiplication of Φh by Ah, ΦhAh, applies the 1D finite difference stencilto the lines of Φ which corresponds to the differentiation in x:

AhΦh =1

h2

2φ1,1 − φ2,1 2φ1,2 − φ2,2 . . .

−φ1,1 + 2φ2,1 − φ3,1 −φ1,2 + 2φ2,2 − φ3,2 . . .−φ2,1 + 2φ3,1 − φ4,1 −φ2,2 + 2φ3,2 − φ4,2 . . .

......

,

ΦhAh = (AhΦTh )T =

1

h2

2φ1,1 − φ1,2 −φ1,1 + 2φ1,2 − φ1,3 . . .2φ2,1 − φ2,2 −φ2,1 + 2φ2,2 − φ2,3 . . .2φ3,1 − φ3,2 −φ3,1 + 2φ3,2 − φ3,3 . . .

......

.

Then adding the two, yields at each matrix entry the 2D Laplacian stencil, so thatthe equations (2.11) can be written in matrix form

ΦhAh + AhΦh = Rh.

Denoting by Ih the identity matrix of the same size as Ah and Φh this readsequivalently

IhΦhAh + AhΦhIh = Rh. (2.12)

In order to solve such a matrix system it needs to be brought into the standardmatrix-vector multiplication form. The Kronecker product formalism does thatfor us. A detailed presentation can be found in the textbooks by Steeb [9, 10].A nice review article on the properties and applications of the Kronecker productwas written by Van Loan [14].

For our application, we first need to replace the matrix unknown Φh by acolumn vector, which is called vec(Φh) in the Kronecker product formalism and isobtained by stacking the columns of Φh or equivalently numbering the grid pointsline by line:

vec(Φh) := (φ1,1, φ2,1, . . . , φN−1,1, φ1,2, φ2,2, . . . , φN−1,2, φ3,1, . . . φN−1,N−1)>.

Moreover, for two matrices B ∈ Rm×n and C ∈ Rp×q their Kronecker productis defined by

B ⊗ C = (bm,n · C) :=

b11C . . . b1nC...

. . ....

bm1C . . . bmnC

∈ Rmp×nq .

Then, for X ∈ Rq×n we have the identity

CXB> = (B ⊗ C)vec(X) .

24

Page 26: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

This is all we need to rewrite our 2D discrete Poisson equation using Kroneckerproducts. As Ah is symmetric, (2.12) is equivalent to

(Ah ⊗ Ih + Ih ⊗ Ah)vec(Φh) = vec(Rh).

As the Kronecker product is available in numerical computing languages like Mat-lab or Python (numpy), this can be used directly to assemble the linear system in2D, which means that only the 1D Finite Difference matrices need to be assembledexplicitly.

As the eigenvalues of the Kronecker product of two square matrices is theproduct of the eigenvalues of each matrix, the stability of the 2D problem can alsobe studied using the eigenvalues of the 1D problems.

The tensor product ideas generalises to arbitrary dimensions and has the prop-erty of separating an nD problem into a sequence of 1D problem enabling to obtainsome very fast algorithms.

2.3 The method of manufactured solutions

A simple and standard way of checking the correctness of the code implementing anumerical method is to use a known analytical solution. This can be done by usinga known solution in a specific case or also by picking a solution and constructingthe problem around it. This is called the method of manufactured solutions.

For example, for periodic boundary conditions one can pick any periodic func-tion φ and apply the operator to it, in our case the Laplacian, to find the corre-sponding right hand side ρ, and then solve the problem with this ρ for differentmesh sizes and check the convergence order in some given norm.

For non periodic boundary conditions, one can pick a function satisfying ho-mogeneous Dirichlet or Neumann boundary conditions or on can pick any smoothfunction and determine the boundary conditions according to the function wechose. In any case it is important not to forget the boundary conditions whendefining the problem.

2.4 Fourier methods

Linear PDEs with constant coefficients can be ”diagonalised” on periodic domainsusing an expansion of the solution in Fourier modes, and using the Fourier trans-form in infinite domains. Hence Fourier series and transforms are an essentialtool for understanding the solution of linear PDEs. They can also be used thanksto their discrete representation, the discrete Fourier transform, for numerical ap-proximation or analysis of the data. This is often quite efficient thanks to a fastalgorithm, called Fast Fourier Transform (FFT), for computing the discrete Fouriertransform.

25

Page 27: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

2.4.1 Fourier series

Let f : R→ C be a periodic function of period L, that is integrable on [0, L]. ItsFourier coefficients can then be defined by

fk :=1

L

∫ L

0

f(x) e− i 2πLkx dx, k ∈ Z,

and the partial Fourier series associated to f can be defined by

SN(f) :=N∑

k=−N

fk e i 2πLkx.

Under adequate conditions the series SN(f) converges to the so-called Fourierseries of f when N → +∞:

Theorem 1 (Dirichlet). Assume f L-periodic and piecewise C0. Then its Fourierseries converges at any point x0 and

limN→+∞

SN(f)(x0) =1

2(f(x+

0 ) + f(x−0 )),

where f(x+0 ) and f(x−0 ) define respectively the right and left limit of f (which is

assumed only piecewise continuous) at x0.

Obviously, if f is continuous at a point x, it is equal to its Fourier series at x:

f(x) =+∞∑

k=−∞

fk e i 2πLkx.

An important identity related to Fourier series is the Parseval identity

1

L

∫ L

0

|f(x)|2 dx =+∞∑

N=−∞

|fk|2,

which follows from

1

L

∫ L

0

e i 2πLkx e i 2π

Lk′x dx =

1

L

∫ L

0

e i 2πL

(k−k′)x dx

=1

L

∫ L

0

[cos

(2π

L(k − k′)x

)+ i sin

(2π

L(k − k′)x

)]dx

= δk,k′ ,

where δk,k′ = 1 for k = k′ and zero otherwise (Kronecker delta).

26

Page 28: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

2.4.2 The Fourier transform

For non-periodic functions defined over the whole R (this can be extended toseveral dimensions), the Fourier transform provides a tool analogous to Fourierseries for periodic functions. The space of square integrable functions over Rtaking values in C,

L2(R) =

f : R→ C

∣∣∣ ∫ +∞

−∞|f(x)|2 dx < +∞

,

defines a Hilbert space with the scalar product

(f, g) =

∫ +∞

−∞f(x)g(x) dx.

For any function f ∈ L2(R) we can define its Fourier transform by

f(ξ) :=

∫ +∞

−∞f(x)e− iξx dx , ξ ∈ R ,

and its inverse Fourier transform by

f(x) =1

∫ +∞

−∞f(ξ)e iξx dξ.

Here, Parseval’s formula reads

(f, g) =

∫ +∞

−∞f(x)g(x) dx =

1

∫ +∞

−∞f(ξ)¯g(ξ) dξ =

1

2π(f , g) ,

which follows formally from∫ +∞

−∞ei(η−ξ)x dx = 2π δ(η − ξ) ,

where δ(·) denotes the Dirac delta distribution. In the special case when f = g weget the Plancherel formula

‖f‖2 = (f, f) =

∫ +∞

−∞|f(x)|2 dx =

1

2π‖f(ξ)‖2.

2.4.3 The Discrete Fourier Transform

Let FN ∈ CN×N be the symmetric matrix formed with the inverse powers of theN th roots of unity, the coefficients of which are given by

(FN)j,k :=(

e i 2πNk)−j

= e− i 2πNjk , 0 ≤ j, k ≤ N − 1 . (2.13)

Denoting by ωN = e i 2πN , we have (FN)jk = ω−jkN . The adjoint, or conjugate

transpose of FN is the matrix F∗N with coefficients (F∗N)jk = ωjkN . Notice that thecolumns of FN , i.e with k fixed and 0 ≤ j ≤ N − 1, are the vectors interpolatingthe functions x 7→ e− i(2π/L)kx at the grid points xj = jL/N of the interval [0, L].

27

Page 29: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Definition 2. Discrete Fourier Transform.

• The dicrete Fourier transform of a vector U = (u0, . . . , uN−1)> ∈ CN isthe vector U = (u0, . . . , uN−1)> := FNU . This can also be written componentby component

uk =N−1∑j=0

uj e− i 2πNjk , k = 0, . . . N − 1 . (2.14)

• The inverse discrete Fourier transform of a vector U ∈ CN is thevector U = F−1

N U = 1NF∗N U . This becomes component by component

uj =1

N

N−1∑k=0

uk e i 2πNjk , j = 0, . . . N − 1 .

Lemma 1. The matrix FN verifies FNF∗N = NIN , where IN is the identity matrixof dimension N .

Proof. We have

(FNF∗N)j,k =N−1∑l=0

ω−jlN ωlkN =N−1∑l=0

e i 2πNl(k−j) =

N−1∑l=0

(e i 2π

N(k−j)

)l.

For j = k the summation is trivial and yields N , while for j 6= k we have ageometric series such that

N−1∑l=0

(e i 2π

N(k−j)

)l=

1−(

e i 2πN

(k−j))N

1− e i 2πN

(k−j)=

1− e i2π(k−j)

1− e i 2πN

(k−j)= 0 , j 6= k .

Therefore, (FNF∗N)j,k = 0 if j 6= k and (FNF∗N)j,k = N if j = k.

Corollary 1. Let U, V ∈ CN and denote by U = FNU and V = FNV theirdiscrete Fourier transforms. Then we have

• the discrete Parseval identity:

(U, V ) = U>V =1

NU>

¯V =

1

N(U , V ), (2.15)

• The discrete Plancherel identity:

‖U‖ =1

N‖U‖,

where (., .) and ‖.‖ denote the usual euclidian dot product and norm in CN .

28

Page 30: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Proof. The scalar product in CN of U = (u0, . . . , uN−1)> and V = (v0, . . . , vN−1)>

is defined by

(U, V ) =N−1∑i=0

uivi = U>V .

Then using the definition of the inverse discrete Fourier transform, we have U =1NF∗N U , V = 1

NF∗N V , we get

U>V =1

N2(F∗N U)>F∗N V =

1

N2U>F∗NFN

¯V =

1

NU>

¯V,

as F∗>N = F∗N and F∗N = NF−1N . The Plancherel identity follows from the Parseval

identity by taking U = V .

Remark 1. The discrete Fourier transform is defined as a matrix-vector multipli-cation. Its computation hence requires a priori N2 multiplications and additions.But because of the specific structure of the matrix there exists a very fast algorithm,called Fast Fourier Transform (FFT) for performing it in O(N log2N) operations.This makes it particularly interesting for many applications, and many fast PDEsolvers make use of it.

2.4.4 Circulant matrices

An important class of matrices that occurr frequently in numerical discretizationsof PDEs on periodic domains are the so-called circulant matrices. Such matricesare characterised by one coefficient for each diagonal and are of the form

C =

c0 c1 c2 . . . . . . . . . cN−1

cN−1 c0 c1 cN−2

cN−2 cN−1 c0 cN−3...

. . . . . ....

c3. . . c0 c1 c2

c2 cN−1 c0 c1

c1 . . . . . . . . . cN−2 cN−1 c0

with c0, c1, . . . , cN−1 ∈ R.

Proposition 3. The eigenvalues of the circulant matrix C ∈ RN×N are given by

λk =N−1∑j=0

cj

(e i 2π

Nk)j

=N−1∑j=0

cj ωjkN , k = 0, . . . , N − 1 , (2.16)

where ωN = e i2π/N .

29

Page 31: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Proof. Let J be the circulant matrix obtained from C by taking c1 = 1 and cj = 0for j 6= 1, hence with entries Jj,k = δk,mod(j+1,N), where δk,k′ is the Kronecker delta.We note that the powers of J compute to

J2j,k =

N−1∑i=0

Jj,iJi,k =N−1∑i=0

δi,j+1Jk,i+1 = δk,j+2 ,

J3j,k =

N−1∑i=0

J2j,iJi,k =

N−1∑i=0

δi,j+2Jk,i+1 = δk,j+3 ,

Jnj,k = δk,mod(j+n,N) , n ≥ 1 .

Therefore, C can be written as a polynomial in J

C =N−1∑j=0

cjJj.

Moreover, as JN = I, the eigenvalues of J are the N-th roots of unity that aregiven by ωkN = e i(2π/N)k. Looking for the corresponding eigenvectors Xk ∈ CN ofJ such that JXk = ωkNXk, we find that

Xk =

1ωkNω2kN...

ω(N−1)kN

. (2.17)

We then have that

CXk =N−1∑j=0

cjJjXk =

N−1∑j=0

cjωjkNXk,

and so the eigenvalues of C associated to the eigenvectors Xk are

λk =N−1∑j=0

cj ωjkN .

Sidenote: the eigenvectors Xk in (2.17) of any circulant matrix C are the columnsof the conjugate transpose Fourier matrix F∗N defined in (2.13).

Proposition 4. Any circulant matrix C can be written in the form C = 1NF∗NΛFN

where FN is the discrete Fourier matrix from (2.13) and Λ = diag(λ0, . . . λN−1) isthe diagonal matrix of the eigenvalues of C. In particular, all circulant matriceshave the same eigenvectors (which are the columns of F∗N), and any matrix of theform F∗NΛFN is circulant.

Corollary 2. We have the following properties:

30

Page 32: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

• The product of two circulant matrix is circulant matrix.

• A circulant matrix whose eigenvalues are all non vanishing is invertible andits inverse is circulant.

Proof. The key point is that all circulant matrices can be diagonalized in the samebasis of eigenvectors. If C1 and C2 are two circulant matrices of length N , we haveC1 = 1

NF∗NΛ1FN and C2 = 1

NF∗NΛ2FN so that C1C2 = 1

NF∗NΛ1Λ2FN . Moreover,

if all eigenvalues of C = 1NF∗NΛFN are non vanishing, Λ−1 is well defined and

1

N2F∗NΛFNF∗NΛ−1FN = IN .

So the inverse of C is the circulant matrix 1NF∗NΛ−1FN .

2.4.5 Stability of the discrete Laplacian with periodic bound-ary conditions

For periodic boundary conditions, the matrix of the discrete Laplacian given in(2.8) is circulant, with c0 = 2/h2, c1 = −1/h2, cN−1 = −1/h2 and all the otherterms vanish. Hence formula (2.16) for computing its eigenvalues can be used toverify its stability. It yields

λk = c0 + c1ωkN + cN−1ω

(N−1)kN

=1

h2

(2− e i 2π

Nk − e i 2π

N(N−1)k

)=

2

h2

(1− cos

(2π

Nk

))=

4

h2sin2

( πNk), k = 0, . . . , N − 1 .

Here we used that cos(x + y) = cos(x) cos(y) − sin(x) sin(y). The matrix is notinvertible because for k = 0 we get λ0 = 0. In order to fix the constant, we assumethat φ0 = φ0 + · · · + φN−1 = 0, c.f. formula (2.14). This discards the eigenvalueλ0 = 0, so that the rest of the matrix is invertible and the smallest eigenvaluecorresponds to

λ1 = λN−1 =4

h2sin2

( πN

)=

4

h2sin2

(πh

L

).

We can now proceed like in the case of homogeneous Dirichlet boundary conditions.As sin x ∼ x for x close to 0, we find

limh→0

λ1 =4π2

L2,

which is strictly larger than 0, so that all eigenvalues are bounded from below bythe half of that number, after some small enough h0, and the others are a finitenumber of strictly positive values. This proves that for all N all eigenvalues of Ahare positive and bounded from below by a constant independent of h which provesstability.

31

Page 33: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

2.4.6 The Fourier pseudospectral method

This method is also called the Fourier spectral collocation method. See the books[12, 3] for a detailed description. The principle of spectral methods is to look foran approximation of the solution of some PDE as an N -term expansion in somewell chosen basis verifying the boundary conditions. In order to determine thebasis coefficients of this expansion, pseudospectral methods, also called spectralcollocation methods, rely on plugging this expansion along with its derivatives intothe PDE to be solved and make it be exact at N well chosen collocation points(which play a similar role as interpolation points), so as to get a square system ofequations to be solved for the basis coefficients.

For periodic problems a good choice of basis is the discrete Fourier basis, andthe collocation points are uniformly chosen in one period. In this case, the methodis the Fourier pseudospectral, or Fourier collocation method. Then for solving ina periodic domain a PDE of the form

Lu = f ,

where L is an arbitrary (nonlinear) differential operator, one approximates theexact solution u by

uN(x) =1

N

N/2−1∑k=−N/2+1

ak e i 2πLkx + a−N/2 cos

πNx

L

for x ∈ [0, L) , (2.18)

and solves for the N coefficients ak, assuming N even, such that

LuN(xj) = f(xj) , xj = jL

N, 0 ≤ j ≤ N − 1 .

The (xj)0≤j≤N−1 are the collocation points. It is important for the problem to bewell-posed that the number of expansion coefficients ak is equal to the number ofcollocation points N . Expressing uN at the collocation points, we get

uj := uN(xj) =1

N

N/2+1∑k=−N/2−1

ak e i 2πNkj + a−N/2(−1)j

.

Let us comment on the representation of the last term of uN in (2.18) as a cosinstead of using the k = N/2 or k = −N/2 modes. First of all we get real-valuedfunctions for a−k = ak. We also notice that on the grid we have

e i 2πNjN/2 = e iπj = (−1j) = e− i 2π

NjN/2 = cos(jπ) .

Therefore, the grid representations of the functions

x 7→ e i 2πLN2x , x 7→ e− i 2π

LN2x , x 7→ cos

(2π

L

N

2x

)

32

Page 34: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

are the same and we can use any of the three representations on the grid. On theother hand, the only instance when the continuous form (2.18) is needed and notthe grid representation is for computing the derivatives. For this, from the threeforms only the cos-representation has a good behavior. Indeed,

d

dx

(cos

(2π

L

N

2x

))x=xj

= −πNL

sin(πj) = 0 0 ≤ j ≤ N − 1 ,

d

dx

(e i 2π

LN2x)x=xj

=iπN

Le iπj = (−1)j

iπN

L0 ≤ j ≤ N − 1 ,

d

dx

(e− i 2π

LN2x)x=xj

=− iπN

Le− iπj = (−1)j

− iπN

L0 ≤ j ≤ N − 1 .

We notice that the three possibilities yield three different grid approximations ofthe derivatives. The problem with the exponentials lies in the fact that the gridderivative of these modes is not real (it is purely imaginary). And for this reasonthe derivative of a real grid function would not be a real grid function, which isnot acceptable.

Remark 2. Note that this problem appears for all odd derivatives but not for evenderivatives which always have the same grid representation for the three choices.

Finally we can summarise the computation of the derivatives as follows: Form even the mth grid derivative is given by

u(m)N (xj) =

N/2−1∑k=−N/2

(i2π

Lk

)mak e i 2π

Nkj , 0 ≤ j ≤ N − 1,

For m odd, the contibution of the N/2 mode vanishes and the mth grid derivativeis given by

u(m)N (xj) =

N/2−1∑k=−N/2+1

(i2π

Lk

)mak e i 2π

Nkj , 0 ≤ j ≤ N − 1 . (2.19)

Let us now apply this pseudospectral method for the L-periodic 1D Poissonproblem

−u′′(x) = f(x) ,

∫ L

0

u(x) dx = α ∈ R .

For this problem to be well posed the average of u has been set α.The pseudospectral method consists in looking for an approximation of the

periodic solution u of the form (2.18) and writing that

−u′′N(xj) = f(xj) , xj = jL/N , 0 ≤ j ≤ N − 1 . (2.20)

33

Page 35: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Denoting the right-hand side by fj = f(xj) and Rh = (f0, . . . , fN−1)>, with its

discrete Fourier transform given by FNRh = Rh = (f0, . . . , fN−1)>, we have fromLemma 1 that Rh = 1

NF∗NFNRh and can hence write

fj =1

N

N−1∑k=0

fk e i 2πNkj .

Then (2.20) becomes

1

N

N/2−1∑k=−N/2

(2π

Lk

)2

ak e i 2πNkj =

1

N

N−1∑k=0

fk e i 2πNkj

=1

N

N/2−1∑k=0

fk e i 2πNkj +

1

N

N−1∑k=N/2

fk e i 2πNkj .

Then, the index transformation k = k′ +N in the last leads to

1

N

N/2−1∑k=−N/2

(2π

Lk

)2

ak e i 2πNkj =

1

N

N/2−1∑k=0

fk e i 2πNkj +

1

N

−1∑k′=−N/2

fk′+N e i 2πNk′j .

Due to the orthogonality of the Fourier basis functions, we then get the solutionak by indentifying the coefficients in the two partial Fourier series:(

2kπ

L

)2

ak = fk, 0 < k ≤ N/2− 1,(2kπ

L

)2

ak = fk+N , −N/2 ≤ k ≤ −1.

This gives directly an expression for ak except for k = 0 for which we need to usethe known average value of u:

a0 = α.

The change of summation needs very often to be performed in computationsinvolving the Discrete Fourier Transform. It consists in shifting the switchingthe first N/2 modes with the others. This is done in Matlab using the functionfftshift. The corresponding algorithm then reads, given the grid function Rh =(f0, . . . , fN−1) and the average value α of u:

1. Perform FFT of Rh followed by fftshift

2. Compute ak from fk for k 6= 0, and set a0 = α

3. Perform an fftshift of the vector containing the ak and then an inverseFFT gives the result u.

34

Page 36: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

2.5 The Finite Element Method

2.5.1 Principle of the method

For solving a problem on a computer that can only store a finite amount of infor-mation, a discrete form of the problem is needed. In the Finite Difference methodone simply computes an approximation of the solution at a finite number of gridpoints and in Fourier methods one uses partial Fourier series. In the Finite Ele-ment method, which is mathematically more involved, the idea is to look for thesolution in a finite dimensional vector space, i.e. for some well chosen vector spaceVh, with basis (ϕi)0≤i≤N−1, the approximate solution has the form

uh(x) =N−1∑i=0

uiϕi(x).

The basis being given, the approximate solution uh is fully determined by itscoefficients ui in this basis, which need not be values of uh at some points in thecomputational domain, but can be in some cases.

The question now becomes how to choose Vh and determine the coefficients uisuch that uh is a good approximation of the solution u of the original problem, thatwe take as a start as the Poisson problem with homogeneous Dirichlet boundaryconditions:

−∆u(x) = f(x) , x ∈ Ω ⊂ Rd, u = 0, on ∂Ω.

The first idea, introduced by Ritz in his thesis in Gottingen in 1902, was to trans-form the boundary problem into an equivalent minimisation problem. Suppose wesearch for a solution u ∈ V is some Hilbert space V . We then write the weakformulation of the problem by multiplying the equation with a test functionv ∈ V and integrating over the domain. Integration by parts and application ofthe boundary condition gives∫

Ω

∇u · ∇v dx =

∫Ω

fv dx , ∀ v ∈ V . (2.21)

Remark that we search for u ∈ V such that this relation holds for all v ∈ V . Thespace V is chosen such that all of the above integrals make sense. We shall needin particular the following Hilbert spaces:

H1(Ω) = u ∈ L2(Ω), ∇u ∈ (L2(Ω))d ,H1

0 (Ω) = u ∈ H1(Ω), u = 0 on ∂Ω .

The scalar product associated to these Hilbert spaces is

(u, v)H1 =

∫Ω

∇u · ∇v dx+

∫Ω

uv dx.

Thus setting V = H10 would be a possible choice for our problem. It turns out that

the weak problem can be formulated as a variational problem (minimizationproblem):

35

Page 37: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Theorem 2. The problem

find u ∈ V :

J(u) = min

v∈VJ(v) ,

J : V → R , J(v) =1

2

∫Ω

|∇v|2 dx−∫

Ω

fv dx ,(2.22)

is equivalent to the problem (2.21) in the sense that u is a solution of (2.21) if andonly if it is a solution of (2.22).

Proof. Suppose first that u ∈ V is a solution of the variational problem (2.22),then

J(u) ≤ J(u+ εv) ∀ v ∈ V .

Therefore, the function ψ(ε) = J(u+ εv) has a minimum at ε = 0, hence

∣∣∣ε=0

=dJ(u+ εv)

∣∣∣ε=0

= 0 .

This corresponds to the definition of the Gateaux derivative of the functional Jat u,

J ′[u](v) := limε→0

J(u+ εv)− J(u)

ε=

dJ(u+ εv)

∣∣∣ε=0

. (2.23)

For J give in (2.22) we have

J(u+ εv) =1

2

∫Ω

|∇u+ ε∇v|2 dx−∫

Ω

f(u+ εv) dx

=1

2

(∫Ω

|∇u|2 dx+ 2ε

∫Ω

∇u · ∇v dx+ ε2

∫Ω

|∇v|2 dx

)−∫

Ω

fu dx− ε∫

Ω

fv dx.

(2.24)

From this we deduce, using the Gateaux formula (2.23), that

J ′[u](v) =

∫Ω

∇u · ∇v dx−∫

Ω

fv dx.

Note that J ′[u] being a linear form on V is defined by applying it to some vectorv ∈ V . Finally the solution of our minimisation problem is a solution of J ′[u] = 0or equivalently J ′[u](v) = 0 for all v ∈ V , which reads∫

Ω

∇u · ∇v dx =

∫Ω

fv dx ∀ v ∈ V.

Conversely, suppose u ∈ V solves (2.21). Then for arbitrary v ∈ V , from (2.24)we deduce

J(u+ εv) = J(u) +ε

[∫Ω

∇u · ∇v dx−∫

Ω

fv dx

]︸ ︷︷ ︸

=0

+ε2

2

∫Ω

|∇v|2 dx .

36

Page 38: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

As |∇v|2 ≥ 0 we have

J(u+ εv) ≥ J(u) ∀ v ∈ V .

Because of the original problem being transformed into a minimisation problem,it becomes quite natural to look for an approximation in a finite dimensionalsubspace Vh ⊂ V of the function space in which the minimisation problem isposed (in our case V = H1

0 (Ω)). This means means that the minimisation isperformed by considering only minima in a finite dimensional subspace Vh. Then,if the form of the finite dimensional space is chosen such that any function ofthe original space can be approximated to any given tolerance, by a function ofthe approximation space, we should be able to get a good approximation1. Thecorresponding weak formulation reads: find uh ∈ Vh such that∫

Ω

∇uh · ∇vh dx =

∫Ω

fvh dx ∀ vh ∈ Vh. (2.25)

Note that the weak formulation (2.21) expresses in some sense the orthogonalityof the residual u− uh to the space in which the solution is sought (here Vh), since∫

Ω

∇(u− uh) · ∇vh dx = 0 ∀vh ∈ Vh .

This is more general than Euler’s equation J ′ = 0 of minimisation problems asnoticed by Galerkin and has a wide range of applications. One can even extendthis concept by making the residual orthogonal to a different function space, thanthe one in which the solution lives. Such methods are called Petrov-Galerkinmethods and are beyond the scope of this lecture.

So the principle of the Galerkin Finite Element method is to look for a solutionuh ∈ Vh in a finite dimensional subspace Vh ⊂ V of the original space and touse the same variational formulation (2.21) defining the exact solution, but withtest functions in Vh. What remains to be done now is to choose Vh with goodapproximation properties. As we will see later, the stability of the Galerkin methodfollows directly from the well-posedness of the variational problem (2.21).

The space Vh is characterised by a basis (ϕ0, . . . , ϕN−1) so that finding thesolution of the weak problem (2.25) amounts to solving a linear system. Indeed,express the trial function uh and the test function vh on this basis:

uh(x) =N−1∑j=0

ujϕj(x), vh(x) =N−1∑i=0

viϕi(x) , (2.26)

and substitute these expressions in (2.25). This yields

N−1∑i=0

N−1∑j=0

ujvi

∫Ω

∇ϕi · ∇ϕj dx =N−1∑j=0

vi

∫Ω

fϕi dx.

1Ritz who was actually looking at solutions for the bilaplacian equation, chose as basis func-tions for Vh a finite number of eigenfunctions of his operator.

37

Page 39: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

This can be expressed in matrix form,

vThAhuh = vThbh , ∀ vh ∈ RN , (2.27)

where

uh = (u0, . . . , uN−1)T ∈ RN ,

vh = (v0, . . . , vN−1)T ∈ RN ,

bh =

(∫Ω

fϕ0 dx, . . . ,

∫Ω

fϕN−1 dx

)T∈ RN ,

and the matrix Ah ∈ RN×N whose entries are

(Ah)i,j =

∫Ω

∇ϕi · ∇ϕj dx , (2.28)

is called the stiffness matrix. This is equivalent to the linear system Ahuh = bhas the previous equality is true for all vh ∈ RN .

The finite dimensional space Vh is in general defined by its basis functions. Forthose, Ritz used eigenfunctions of the problem. But those are in general cumber-some to compute. Galerkin proposed to use general classes of simple functions,trigonometric functions or polynomials, that are know to be able to approximateany continuous function with a finite number of basis functions. Trigonometricpolynomials which are linked to Fourier series are very good in periodic domains,with a few simple extensions. Polynomials enjoy more widespread applications,however to get a good conditioning of the linear system that is obtained at theend, care needs to be taken in the choice of the basis functions. The monomialbasis (1, x, x2, . . . ) has very bad properties. Best approximations are provided bythe orthogonal Legendre polynomials or by the Chebyshev polynomials which areused in practice. Note that all the basis functions we have mentioned up to nowhave a global support in the computational domain and thus lead to full matricesin the linear system, which can be computationally expensive. Methods using suchbases are actually not known as Finite Element methods but rather as spectralmethods. We will come back to those later.

Another ingredient is needed to define what is known as Finite Element meth-ods. This was introduced by Courant in 1943 and consists in using basis func-tions with a small support in the computational domain, so that its productwith other basis functions vanishes for most of the other basis functions leadingto a very sparse matrix in the linear system, which can be solved very efficientlyon a computer. For this the computational domain is decomposed into small ele-ments, in general triangles or quads in 2D and the basis functions are chosen tobe relatively low order polynomials, on each of these elements. Convergence beingachieved by taking smaller elements like the cells in the Finite Difference method.In 1D a finite element mesh will look like a finite difference mesh. Some examplesof unstructured Finite Element meshes are displayed in Figure 2.1, which shows

38

Page 40: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Figure 2.1: Examples of unstructured finite element meshes.

the great flexibility in particular to handle complicated boundaries with finite el-ements, which finite differences do not provide. This is a key to its very wideusage.

The article by Gander and Wanner [5] provides a clear and well documentedoverview of the historical developments of the Finite Element method. For moretechnical historical developments of the Finite Difference and Finite Element meth-ods one can also consult [11].

2.5.2 The weak form of a boundary value problem

The weak form of a boundary value problem contains all its elements, which arethe partial differential equation in the interior of the domain and the boundaryconditions. There are two very distinct ways to handle the boundary conditionsdepending on how they appear when deriving the variational formulation:

• If they appear on the test function they are called essential boundary con-ditions and need to be included in the space where the solution is lookedfor.

• If they appear on the trial function, which will be the approximate solu-tion, they can be handled in a natural way in the weak formulation. Suchboundary conditions are called natural boundary conditions.

We will see on the examples of Dirichlet and Neumann boundary conditions howthis works in practice. In order to define the weak formulation, we will need thefollowing Green formula: For u ∈ H2(Ω) and v ∈ H1(Ω)

−∫

Ω

∆u v dx =

∫Ω

∇u · ∇v dx−∫∂Ω

∂u

∂nv dσ. (2.29)

Here H2(Ω) denotes the Hilbert space of the functions whose partial derivativesup to second order are in L2(Ω) and ∂u

∂n= ∇u ·n, where n is the outbound normal

at any point of the boundary.

39

Page 41: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Case of Neumann boundary conditions

Let f ∈ L2(Ω) and g ∈ H1(Ω). We consider the problem

(S)

−∆u+ u = f in Ω,

∂u

∂n= g on ∂Ω.

Assuming that u ∈ H2(Ω), we multiply by a test function v ∈ H1(Ω) and integrateusing the Green formula (2.29), which yields∫

Ω

∇u · ∇v dx−∫∂Ω

∂u

∂nv dσ +

∫Ω

uv dx =

∫Ω

fv dx.

Replacing ∂u∂n

by its value g on the boundary, we obtain the weak formulation

(W )

Find u ∈ H1(Ω) such that∫

Ω

∇u · ∇v dx+

∫Ω

uv dx =

∫Ω

fv dx+

∫∂Ω

gv dσ ∀ v ∈ H1(Ω) .

Note that the boundary condition does not appear in the function space H1(Ω),but rather in the equation - hence this is an example of a natural boundarycondition. The solutions of (W ) are called weak solutions of the original boundaryvalue problem. The solutions which are also in H2(Ω) are called strong solutions.Indeed we can prove the following:

Proposition 5. Provided u ∈ H2(Ω), the problems (S) and (W ) are equivalent.

Proof. We have already shown in the derivation of the weak formulation thatif u is a solution of (S), it also satisfies (W ). On the other hand, supposeu ∈ H2(Ω) ⊂ H1(Ω) is a solution of (W ). As H1

0 (Ω) ⊂ H1(Ω) one can first takeonly test functions ϕ ∈ H1

0 (Ω). Then as in the case of homogeneous Dirichletconditions it follows from the Green formula (2.29) that∫

Ω

(−∆u+ u)ϕ dx =

∫Ω

fϕ dx ∀ ϕ ∈ H10 (Ω) .

This implies, as H10 (Ω) is dense in L2(Ω), that −∆u + u = f in L2(Ω) and so

almost everywhere. It now remains to verify that we have the boundary condition

∂u

∂n= g on ∂Ω .

For that we start from (2.5.2) and apply the Green formula (2.29), which yields

−∫

Ω

∆u v dx+

∫∂Ω

∂u

∂nv dσ +

∫Ω

uv dx =

∫Ω

fv dx+

∫∂Ω

gv dσ ∀ v ∈ H1(Ω),

and as −∆u+ u = f , it remains∫∂Ω

∂u

∂nv dσ =

∫∂Ω

gv dσ ∀ v ∈ H1(Ω),

which yields that ∂u∂n

= g on ∂Ω.

40

Page 42: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Homogeneous Dirichlet boundary conditions

Let f ∈ L2(Ω) and consider the boundary value problem

(S)

−∆u = f in Ω,

u = 0 on ∂Ω .

Assume that u ∈ H2(Ω), we multiply by v ∈ H1(Ω) and integrate using the Greenformula (2.29), which yields∫

Ω

∇u · ∇v dx−∫∂Ω

∂u

∂nv dσ =

∫Ω

fv dx.

Here, only the derivative of u appears in the boundary integral, so we cannot applythe boundary condition directly. But in the end u will be in the same functionspace as the test function v, which appears directly in the boundary integral.Thus we take test functions v vanishing on the boundary and get the followingweak formulation:

(W )

Find u ∈ H1

0 (Ω) such that∫Ω

∇u · ∇v dx =

∫Ω

fv dx ∀ v ∈ H10 (Ω) .

As the boundary condition appears in the function space H10 (Ω), this is the case

of an essential boundary condition. Again we can show the equivalence of (S)and (W ) if u ∈ H2(Ω). In this case the Green formula (2.29) can be used, and asϕ vanishes on the boundary it yields

−∫

Ω

∆uϕ dx =

∫Ω

fϕ dx ∀v ∈ H10 (Ω).

This implies, as H10 (Ω) is dense in L2(Ω), that −∆u = f in L2(Ω) and so almost

everywhere. On the other hand as u ∈ H10 (Ω), u = 0 on ∂Ω. So u is a strong

solution.

Non-homogeneous Dirichlet boundary conditions (lifting)

Let f ∈ L2(Ω) and u0 ∈ H1(Ω). We consider the problem

−∆u = f in Ω,

u = u0 on ∂Ω.

As the value of u on the boundary cannot be directly put in the function space if itis not zero, as else the function space would not be stable by linear combinations,we need to bring the problem back to the homogeneous case. To this aim letu = u− u0. The function u0 is called lifting of the boundary data. We then showas previously that u is a solution of the weak problem

(W )

Find u ∈ H1

0 (Ω) such that∫Ω

∇u · ∇v dx =

∫Ω

fv −∫

Ω

∇u0 · ∇v dx ∀ v ∈ H10 (Ω) .

41

Page 43: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

This is the weak problem that needs to be solved for non-homogeneous Dirichletboundary conditions. As u0 will only have non zero entries on the boundary forstandard Finite Elements, the problem can be simplified in different manners inpractice.

2.5.3 Lagrange Finite Elements

Finite Elements are used to construct a finite dimensional space Vh with basisfunctions that have a small support so that the resulting matrix is sparse, i.e.most of its entries vanish. The simplest Finite Elements are determined by pointsvalues and related to Lagrange interpolation, hence their name. In order to con-struct a basis of Vh, one starts by decomposing the computational domain into nonoverlapping intervals in 1D (like the Finite Difference mesh), triangles or quadsin 2D, tetrahedra or hexahedra in 3D. This defines a mesh of the computationaldomain. Then the basis functions are defined locally on each cell (or element).

We also want Vh ⊂ V to be a subspace of the solution space of the continuousproblem, which is usually a Sobolev space Hk with k ≥ 0. The following propertyspeaks to the continuity of functions in Hk:

Lemma 2. Let Ω ⊂ Rn open, n ≥ 1, with sufficiently regular boundary, then

Hk(Ω) ⊂ Cm(Ω) if k > m+n

2.

This means in particular that for n = 1 functions of H1 are continuous onΩ, whereas this is not necessarily the case in two or three dimensions. However,functions in H2 are indeed continuous also for n = 2 and n = 3.

Let us start with a non-uniform 1D mesh of the domain Ω = [a, b] definedby the grid points a = x0 < x1 < · · · < xN = b and the solution space beingV = H1(ω). The elements of the mesh are here the intervals Ων := [xν , xν+1]such that ∪νΩν = Ω. The important point is that functions vh ∈ Vh ⊂ V will beconstructed as piece-wise polynomials on the elements Ων . Denoting the space ofpolynomials of degree k on Ων by Pk(Ων), a space Vh ⊂ H1(Ω) can be defined as

Vh :=vh ∈ C0([a, b]) : vh|Ων ∈ Pk(Ων)

.

Because of Lemma 2 we need to choose Vh as a subset of C0([a, b]). In order tomake this requirement easy to implement in practice it is convenient to define thebasis of Pk(Ων) as being defined by its value at k + 1 points in Ων , including theendpoints of the interval xν and xν+1. Such a basis is called a nodal basis and thenaturally associated basis functions are the Lagrange basis functions.

The basis restricted to each element is defined via a reference element, whichis conveniently chosen, for later Gauss integration, as the interval [−1, 1] and anaffine map

Fν : [−1, 1]→ [xν , xν+1]

x 7→ xν + xν+1

2+

(xν+1 − xν

2

)x.

42

Page 44: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Figure 2.2: Lagrange Basis functions of degree k = 2 on the three elements Ω1 =[−1, 1], Ω1 = [1, 3] and Ω1 = [3, 5].

As an affine mapping maps polynomials of degree k to polynomials of degree k,the basis can be defined on the reference element [−1, 1]. Given k+1 interpolationpoints −1 = x0 < x1 < · · · < xk = 1 the Lagrange shape functions (i.e. the basisfunctions on the reference element) of degree k denoted by lk,i, 0 ≤ i ≤ k, are theunique polynomials of degree k verifying

lk,i(xj) = δi,j 0 ≤ j ≤ k . (2.30)

Because of this property, any polynomial p ∈ Pk([−1, 1]) can be expressed as

p(x) =k∑j=0

p(xj) lk,j(x) .

Therefore, any polynomial p ∈ Pk([−1, 1]) is uniquely determined by its values atthe interpolation points xj, 0 ≤ j ≤ k. In order to ensure the continuity of thepiecewise polynomial at the cell interfaces xν it is enough that the values of thepolynomials on both sides of xν have the same value at xν . This constraint removesone degree of freedom in each cell, moreover for Dirichlet boundary conditions thetwo end points are known, which removes two other degrees of freedom so that thetotal dimension of Vh in this case is

dimVh = N(k + 1)− (N − 1)− 2 = Nk − 1 (Dirichlet) .

The functions of Vh are uniquely defined in each cell by their value at the degrees offreedom (which are the interpolation points) in all the cells. The basis functions ofVh are denoted by (ϕi)1≤j≤Nk−1 and are computed from (2.30) plus the continuityrequirements. An example of Lagrange basis functions for k = 2 is plotted inFigure 2.2.

Note that for k = 1, corresponding to P1 finite elements, the degrees of freedomare just the grid points. For higher order finite elements internal degrees of freedom

43

Page 45: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

are needed. For stability and convenience these are most commonly taken to bethe Gauss-Lobatto (GL) points on each cell. Quadrature rules for approximatingintegrals of a function f : [−1, 1]→ R are defined by∫ 1

−1

f(x) dx ≈n∑i=1

wif(xi) ,

where wi denote the weights and xi are the n quadrature points. In GL quadraturethe end points −1 and 1 are part of the quadrature points, which is necessary toimplement the continuity of Lagrange finite elements. For instance, for n = 4 theGL weights and points are given by

(x1, w1) = (−1, 1/6) , (x2, w2) = (−√

1/5, 5/6) ,

(x3, w3) = (√

1/5, 5/6) , (x4, w4) = (1, 1/6) .

GL quadrature is exact for polynomials of order 2n− 3. Once the basis functionshave been determined from GL points on the reference element and the mappingsFν to the actual elements, the FEM for Poisson proceeds as in (2.26)-(2.28).

A standard way to test the implementation of the mass matrix is via L2-projection of a function f ∈ V , f 7→ fh, where fh = Π(f) ∈ Vh. The orthogonalprojection Π : V → Vh is defined in the usual sense via the L2-scalar product:

(f − Π(f), ϕi)L2 = 0 ∀ ϕi ∈ Vh .

Expressing Π(f) in the basis (ϕi),

Π(f)(x) = fh(x) =∑j

fj ϕj(x) ,

leads to ∑j

fj

∫Ω

ϕi(x)ϕj(x) dx =

∫Ω

f(x)ϕi(x) dx ∀ i ,

Introducing the mass matrix Mh as

Mh =(∫

Ω

ϕi(x)ϕj(x) dx)i,j,

the coefficients fh = (fj)j can be determined from fh = M−1h bh, where bh was

introduced in (2.27). Note that because the GL quadrature rule is exact for poly-nomials of degree up to 2n−3, the mass matrix Mh can be computed exactly withthe GL quadrature rule.

Usually for Finite Elements the matrices Mh and Ah, i.e. the stiffness matrixfrom (2.28), are computed from the corresponding elementary matrices which areobtained by change of variables onto the reference element [−1, 1] for each cell. So∫

Ω

ϕi(x)ϕj(x) dx =n−1∑ν=0

∫ xν+1

ϕi(x)ϕj(x) dx,

44

Page 46: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

and doing the change of variable x = xν+1−xν2

x+ xν+1+xν2

, we get∫ xν+1

ϕi(x)ϕj(x) dx =xν+1 − xν

2

∫ 1

−1

ϕα(x)ϕβ(x) dx,

where ϕα(x) = ϕi(xν+1−xν

2x+ xν+1+xν

2). The local indices α on the reference element

go from 0 to k and the global numbers of the basis functions not vanishing onelement ν are j = kν +α. The ϕα are the Lagrange polynomials at the GL pointsin the interval [−1, 1]. They are represented by different colors in Figure 2.2 fork = 2.

Approximating the mass matrix M with the GL rule yields a diagonal matrix,as the products ϕα(x)ϕβ(x) vanish for α 6= β at the Gauss-Lobatto points bydefinition of the ϕα which are the Lagrange basis functions at these points. ThusM is diagonal and we have∫ 1

−1

ϕα(x)2 dx ≈k∑

β=0

wGLβ ϕα(xβ)2 = wGLα

using the quadrature rule, where wGLα is the Gauss-Lobatto weight at Gauss-Lobatto point (xα) ∈ [−1, 1]. So that finally M = diag(wGL0 , . . . wGLk ) is the matrixwith k + 1 lines and columns with the Gauss-Lobatto weights on the diagonal.

2.5.4 B-spline Finite Elements

Let us now construct a different kind of Finite Element discretization using B-Splines as basis functions.

In order to define a family of n B-splines of degree k, we need T = (xi)06i6n+ka non-decreasing sequence of points on the real line called knots in the splineterminology. There can be several knots at the same position. In the case whenthere are m knots at the same point, we say that the knot has multiplicity m.

Definition 3 (B-Spline). Let (xi)06i6n+k be a non-decreasing sequence of knots.Then the j-th B-Spline (0 ≤ j ≤ n− 1) denoted by Nk

j of degree k is defined by therecurrence relation:

Nkj (x) = wkj (x)Nk−1

j (x) + (1− wkj+1(x))Nk−1j+1 (x)

where,

wkj (x) =x− xj

xj+k − xjN0j (x) = χ[xj ,xj+1[(x)

We note some important properties of a B-splines basis:

• B-splines are piecewise polynomial of degree k,

• B-splines are non negative

• Compact support; the support of Nkj is contained in [xj, .., xj+k+1]

45

Page 47: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

• Partition of unity:∑n−1

i=0 Nki (x) = 1,∀x ∈ R

• Local linear independence

• If a knot xi has a multiplicity m then the B-spline is C(k−m) at xi.

A key point for constructing discrete Finite Element spaces for the Maxwellequation comes from the recursion formula for the derivatives:

Nki

′(x) = k

(Nk−1i (x)

xi+k − xi−

Nk−1i+1 (x)

xi+k+1 − xi+1

). (2.31)

It will be convenient to introduce the notation Dki (x) = k

Nk−1i (x)

xi+k−xi. Then the

recursion formula for derivative simply becomes

Nki

′(x) = Dk

i (x)−Dki+1(x). (2.32)

Remark 3. In the case where all knots, except the boundary knots are of multi-plicity 1, the set (Nk

i )0≤i≤n−1 of B-splines of degree k forms a basis of the splinespace defined by

Sk = v ∈ Ck−1([x0, xn]) |v|[xi,xi+1] ∈ Pk([xi, xi+1]) .

The boundary knots are chosen to have multiplicity k + 1 so that the spline be-comes interpolatory on the boundary in order to simplify the application of Dirich-let boundary conditions.

Then due to the definitions if follows immediately that (Dki )1≤i≤n−1 is a basis

of Sk−1. Note that if the first knot has multiplicity k + 1, Dk0 will have a support

restricted to one point and be identically 0.

Remark 4. Splines can be easily defined in the case of periodic boundary conditionsby taking a periodic knot sequence.

2.5.5 Convergence of the Finite Element method

The variational (or weak) formulation of PDEs we consider can be written in thefollowing abstract form:

Find u ∈ V such that a(u, v) = l(v) ∀ v ∈ V,

where V is a Hilbert space, a : V ×V → R is a symmetric continuous and coercivebilinear form and l : V → R a continuous linear form.

The most convenient tool for proving existence and uniqueness of the solutionof a variational problem is the Lax-Milgram theorem that we recall here:

Theorem 3 (Lax-Milgram). Let V a Hilbert space with the norm ‖.‖V . Let a :V ×V → R denote a continuous, symmetric and coercive bilinear form on V ×V ,i.e.

46

Page 48: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

1. (Continuity): there exists K such that for all u, v ∈ V

|a(u, v)| ≤ K‖u‖V ‖v‖V .

2. (Coercivity): there exists a constant α > 0 such that for all u ∈ V

a(u, u) > α‖u‖2V .

Moreover, let l : V → R be a continuous linear form on V , i.e. there exists C suchthat for all v ∈ V

|l(v)| ≤ C‖v‖V .

Then there exists a unique u ∈ V such that

a(u, v) = l(v) ∀ v ∈ V . (2.33)

The Ritz-Galerkin method consists in finding an approximate solution uh in afinite dimensional subspace of V . For convergence studies one needs to consider asequence of subspaces of V of larger and larger dimension so that they get closerto V . One then defines a sequence of problems parametrised by h that read:

Find uh ∈ Vh such that a(uh, vh) = l(vh) ∀ vh ∈ Vh, (2.34)

where Vh ⊂ V is a vector space of dimension N .

Let B = (ϕ1, . . . , ϕN) be a basis of Vh. An element uh ∈ Vh can then beexpanded as uh(x) =

∑Nj=1 ujϕj(x). Taking vh = ϕi and using the linearity of a

the equation (2.34) becomes

N∑j=1

uja(ϕj, ϕi) = l(ϕi) ∀ ϕi ∈ B .

Then using the symmetry of a, we notice that the discrete variational formula-tion(2.34) is equivalent to the linear system

AUh = L, (2.35)

where A = (a(ϕi, ϕj))1≤i,j≤N ∈ RN×N , L ∈ RN is the column vector with compo-nents l(ϕi) and Uh ∈ RN is the column vector with the unknowns ui that are thecoefficients of uh in the basis B.

Theorem 4. Assume that a : V ×V → R is a symmetric continuous and coercivebilinear form on a Hilbert space V and l : V → R is a continuous linear form onV . Then the system (2.35) is equivalent to the discrete variational form (2.34) andadmits a unique solution.

Proof. For vh ∈ Vh, we denote by V the vector of its components in the basis B.

47

Page 49: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

• Thanks to the bilinearity of a and the linearity of l the relation (2.34) canbe written equivalently

V TAUh = V TL ∀ V ∈ RN , (2.36)

which means that the vector AUh − L ∈ RN is orthogonal to all the vectorsof RN , and so is the zero vector. Conversely it is clear that (2.35) implies(2.36) and so (2.34).

• Let vh ∈ Vh. Then, as a is coercive, there exists α > 0 such that

V TAV = a(vh, vh) ≥ α‖vh‖2 ≥ 0,

and V TAV = 0 = a(vh, vh) ⇒ ‖vh‖ = 0, which implies that vh = 0 and soV = 0. So A is symmetric, positive definite and therefore invertible.

After making sure the approximate solution exists for some given space Vh,one needs to make sure the approximation converges towards the exact solution.This results from two properties: 1) The Galerkin orthogonality, which comes fromthe conforming Galerkin approximation, 2) The approximability property, whichconfirms that for any v ∈ V there exist vh in some finite dimensional space of thefamily which is close enough to v.

Lemma 3 (Cea). Let u ∈ V be the solution of (2.33) and uh ∈ Vh the solution of(2.34), with Vh ⊂ V . Then

‖u− uh‖ ≤K

αinfvh∈Vh

‖u− vh‖.

Proof. We have

a(u, v) = l(v) ∀ v ∈ V,a(uh, vh) = l(vh) ∀ vh ∈ Vh,

as Vh ⊂ V , we can take v = vh in the first equality and take the difference whichyields

a(u− uh, vh) = 0 ∀ vh ∈ Vh .This is the Galerkin orthogonality, which says that uh is the orthogonal projectionof u into Vh. It results that a(u − uh, u − uh) = a(u − uh, u − vh + vh − uh) =a(u− uh, u− vh), as vh− uh ∈ Vh and so a(u− uh, vh− uh) = 0. Then there existsα > 0 and β such that

α‖u− uh‖2 ≤ a(u− uh, u− uh) as a is coercive,

= a(u− uh, u− vh) ∀ vh ∈ Vh,≤ K‖u− uh‖‖u− vh‖ as a is continuous.

Whence ‖u− uh‖ ≤ Kα‖u− vh‖ for all vh ∈ Vh. We get the desired results taking

the infimum in Vh.

48

Page 50: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Let us now come to the approximability property. For simplicity we considerthe 1D case and assume v ∈ C0(I), with I = (a, b) ⊂ R some interval. Supposewe are given nodes a = x0 < x1 < . . . xN = b that are used to define a basisB = (ϕ0, . . . , ϕN) of Vh ⊂ C0(I). We then define the interpolation operator πh :C0(I)→ Vh by

πhv(xi) = v(xi) for all nodes xi of the partition x0, . . . , xN . (2.37)

The function πhv ∈ Vh is called the interpolant of v ∈ C0(I). In case that Bconsists of k-th order Lagrange polynomials lk,i the interpolant is just

πhv(x) =N∑i=0

v(xi) lk,i(x) .

Theorem 5. Let v ∈ Hk+1(I) ⊂ C0(I) (c.f. Lemma 2), for k ≥ 1 and let πhv ∈ Vhstand for its interpolant defined by (2.37), where Vh = span(Bk) with the basis Bkbeing composed of piece-wise polynomials of degree k. Denote by h = mini |xi+1−xi|the maximal grid spacing, then there exists a constant C independent of h suchthat

‖v − πhv‖H1 ≤ Chk|v|Hk+1 ,

where | · |Hk+1 denotes the semi-norm in Hk+1.

We then have the following a priori estimate for FEM solutions:

Theorem 6. Let u ∈ V , u : I → R with I = (a, b) ⊂ R, be the solution of (2.33)and denote by uh ∈ Vh the solution of the discrete problem (2.34), Vh ⊂ V with apiece-wise polynomial basis of degree k. Moreover, let u ∈ Hp+1(I) for suitable psuch that k ≤ p, then

||u− uh||H1 ≤ K

αChk|u|Hk+1 ,

where C is independent of h.

Proof. Cea’s lemma and Theorem 5 give

‖u− uh‖H1 ≤ K

αinfvh∈Vh

‖u− vh‖H1 ≤ K

α‖u− πhu‖H1 ≤ K

αChk|u|Hk+1 .

49

Page 51: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Chapter 3

Numerical schemes for theVlasov-Poisson system

3.1 The Vlasov-Poisson model for electrons

Suppose we want to describe non-magnetized plasma (B = 0) on time scales shortenough such that the ions can be considered stationary due to their larger mass(and thus inertia) compared to the electrons. Setting the physical constants toone and making sure to keep the right sign for the charge of electrons and ions,the appropriate model reads (c.f. section 1.3.2)

∂f

∂t+ v · ∇xf − E · ∇vf = 0 ,

−∆φ = 1− n, E = −∇φ,(3.1)

where f : R6 × R → R+ is the electron distribution function, φ : R3 × R → Rdenotes the electrostatic potential and the electron density n is defined by

n(x, t) =

∫f(x,v, t) dv .

The ion density has been set to one. The domain on which the system is posed isconsidered periodic of period one in x and the whole space R3 in velocity v.

Denoting by A = (v,−E)> the advection field in (x,v)-space, called the phasespace, the Vlasov equation can be written as an advection equation in phase spaceof the form

∂f

∂t+ A · ∇x,vf = 0 . (3.2)

Moreover, as ∇x,v ·A = 0, the Vlasov equation can also be written in the conser-vative form

∂f

∂t+∇x,v · (Af) = 0 .

50

Page 52: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

3.1.1 The Vlasov equation in a given potential

First verification tests for a numerical Vlasov-Poisson solver consist of consideringthe Vlasov equation in given potentials where the solution can be computed ex-actly with the method of characteristics. Let us denote by z = (x,v) the phasespace variable and consider the Vlasov equation in advective form (3.2) with givenpotential φ : R3 × R → R. Hence the advection field A : R6 × R → R3 is given;the Vlasov equation is also called the free transport equation (FTE) in this case.We then call the solution Z of the system

dZ

ds= A(Z, s) ,

Z(t) = z ,

the “characteristics” of the FTE. Supposing that A is sufficiently smooth, let ussay A ∈ C2 with bounded derivatives up to second order, the Cauchy-Lipschitztheorem guarantees a solution Z = Z(s; t, z). The application

Φst : z 7→ Z(s; t, z)

defines the flow of the characteristic equations. It is now easy to show that theFTE has a unique solution of the form

f(t, z) = f0(Z(0; t, z)) . (3.3)

This follows from the fact that f is constant along the characteristics,

d

dsf(s,Z(s)) = 0 . (3.4)

Indeed,

d

dsf(s,Z(s)) =

∂f

∂s+

dZ

ds· ∇zf =

∂f

∂s+ A(Z, s) · ∇zf

(3.2)= 0 .

Integration of (3.4) between 0 and t then yields

f(t,Z(t; t, z)) = f(t, z) = f(0,Z(0; t, z)) .

The flow Φst has the group property

Φt3t1 = Φt3

t2 Φt2t1 ,

and the inverse of Φst is given by Φt

s. Hence the dynamics of the FTE are reversible.Moreover, the flow Φs

t conserves phase space volume. This means that for anyvolume Ω(t) that is advected by the flow,

Ω(t) = z ∈ R6 : z = Φt0(z0) with z0 ∈ Ω0 ⊂ R6 ,

we haved

dt

∫Ω(t)

d6z =

∫Ω0

d

dt

∣∣∣∣det∂Φt

0

∂z

∣∣∣∣ d6z0 = 0 .

This follows Liouville’s theorem which says

∇ ·A = 0 ⇒ d

dtdet

∂Φt0

∂z= 0 ,

for the divergence-free free vector field A.

51

Page 53: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Examples of exact solutions

1. Consider the free streaming equation

∂f

∂t+ v

∂f

∂x= 0 .

In this case the characteristics satisfy

dX

ds= V (s) X(t) = x ,

dV

ds= 0 V (t) = v .

Thus we have V (s; t, x, v) = v and X(s; t, x, v) = x+ (s− t)v which gives usthe solution

f(t, x, v) = f0(x− vt, v) .

2. Uniform focusing in a particle accelerator (1D model). We then have E(x, t) =x and the Vlasov equation writes

∂f

∂t+ v

∂f

∂x− x∂f

∂v= 0 ,

with the cahracteristics satisfying

dX

ds= V (s) X(t) = x ,

dV

ds= −X(s) V (t) = v .

Hence we get

X(s; t, x, v) = x cos(s− t) + v sin(s− t) ,

V (s; t, x, v) = −x sin(s− t) + v cos(s− t) ,

form which we compute the solution

f(t, x, v) = f0(x cos t− v sin t, x sin t+ v cos t) .

3.1.2 Conservation properties

The Vlasov-Poisson system has a number of conservation properties that needspecial attention when developing numerical methods. In principle it is beneficialto retain the exact invariants in numerical methods and when it is not possible tokeep them all as is the case here, they can be used to monitor the validity of thesimulation by checking that they are approximately conserved with good accuracy.

Proposition 6. The Vlasov-Poisson system verifies the following conservationproperties:

• Maximum principle:

0 ≤ f(x,v, t) ≤ max(x,v)

(f0(x,v)).

52

Page 54: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

• Conservation of Lp, norms for p integer, 1 ≤ p ≤ ∞,

d

dt

(∫fp dx dv

)= 0 .

• Conservation of total momentum:

d

dt

∫vf dxdv = − d

dt

∫J dx = 0 .

• Conservation of total energy:

d

dt

[1

2

∫|v|2f dxdv +

1

2

∫|E|2 dx

]= 0.

Proof. The maximum principle follows directly from the exact solution (3.3), pro-vided that f0 > 0 in R6.

Multiplying the Vlasov equation (3.1) by fp−1 and integrating on the wholephase-space we obtain

d

dt

(∫fp dx dv

)= 0,

so that the Lp norms of f are conserved for all p ∈ N∗. Let us notice that theL∞-norm is also conserved thanks to the maximum principle (6).

Let us now proceed to the conservation of momentum. We multiply the Vlasovequation (3.1) by v and integrate in x and in v

d

dt

∫vf dxdv +

∫∇x · (v ⊗ vf) dxdv −

∫v∇v · (Ef) dxdv = 0 .

The second integral vanishes as the domain is periodic in x and in the last integralwe integrate by parts to obtain

−∫

v∇v · (Ef) dxdv =

∫Ef dxdv =

∫En dx .

Inserting in the last expression the Poisson equation n = 1−∇ · E and using∫E dx = −

∫∇φ dx = 0 ,∫

E(∇ · E) dx =

∫ [∇ · (E⊗ E) + E× (∇× E)− 1

2∇|E|2

]dx = 0 ,

where we applied the periodic boundary conditions as well as ∇×E = −∇×∇φ =0, it finally follows that

d

dt

∫vf dxdv = − d

dt

∫J dx = 0 .

53

Page 55: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

In order to obtain the energy conservation property, we start by multiplyingthe Vlasov equation by |v|2 and we integrate over phase space to obtain

d

dt

∫|v|2f dxdv +

∫∇x · (|v|2vf) dxdv −

∫|v|2∇v · (Ef) dxdv = 0.

As f is periodic in x, by integrating in x we get∫∇x · (|v|2vf) dxdv = 0

and integration by parts yields∫|v|2∇v · E dxdv = −2

∫v · (Ef) dxdv = 2

∫E · J dx .

Therefore,d

dt

∫|v|2f dxdv = 2

∫E · J dx = −2

∫∇φ · J dx. (3.5)

On the other hand, integrating the Vlasov equation (3.1) with respect to v, yieldsthe charge conservation equation ∂ρ

∂t+ ∇ · J = 0, where ρ = 1 − n. Then, again

integrating by parts leads to

−∫∇φ ·J dx =

∫φ∇·J dx = −

∫φ∂ρ

∂tdx =

∫φ∂∆φ

∂tdx = −1

2

d

dt

∫|∇φ|2 dx .

Plugging this equation in (3.5) and using that E = −∇φ, we get the conservationof energy.

3.2 The particle in cell (PIC) method

Due to its simplicity and its efficiency in high dimensions, the most popular methodfor Valsov-Poisson is still the particle in cell (PIC) method, which consists indrawing randomly a finite number of origins for the characteristics and follow themin time by solving the equations of motion. These need the electric field which inturn depends on the current position of the markers and needs to be computed ona grid, using any standard grid based method for the Poisson equation, in generalFinite Difference, Fourier spectral or Finite Element. The distribution function isthen approximated by a sum of Dirac masses

f(t,x,v) ≈ fh(t,x,v) =∑k

wk δ(x− xk(t)) δ(v − vk(t)) . (3.6)

Note that the charge density ρ = 1 − n, source of the Poisson equation, needs tobe computed from the particles. A crucial part is therefore the particle meshcoupling. In Finite Element methods, the Finite Element basis function pro-vide a natural way to express the electric fields everywhere in space and also theweak formulation of the right-hand-side is compatible with the expression of thedistribution function as a sum of Dirac masses.

54

Page 56: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

3.2.1 Time scheme for the particles

PIC solvers are initialzed by randomly drawing a set of N initial conditions, or ori-gins, (xk0,vk0) ∈ R6, k = 1, . . . , N , for the characteristics of the Vlasov equation.The so-called ”markers” (xk(t),vk(t)) then satisfy

dxkdt

= vk(t) , xk(0) = xk0 ,

dvkdt

= −E(xk(t), t) , vk(0) = vk0 .

A vital part for a PIC scheme is a good integrator for this system of ODEs. Thesystem being Hamiltonian, it should be solved using a symplectic time scheme inorder to enjoy long time conservation properties. The scheme which is used mostof the time is the Verlet scheme, which is defined as follows: assume the markerpositions xnk , velocities vnk and the electric En at time tn = n∆t to be known,where ∆t denotes the time step size, then we advance in time as

vn+ 1

2k = vnk −

∆t

2En(xnk), (3.7)

xn+1k = xnk + ∆tv

n+ 12

k , (3.8)

vn+1k = v

n+ 12

k − ∆t

2En+1(xn+1

k ). (3.9)

We notice that step (3.9) needs the electric field at time tn+1. It can be computedafter step (3.8) by solving the Poisson equation which uses as input ρn+1

h that needsonly xn+1

k and not vn+1k .

3.2.2 Particle mesh coupling for Finite Elements

The coupling between mesh and particles is obtained in a natural way in the FiniteElement method. Suppose that (Λj)

Ngj=1 is a basis of the FEM space Vh in which

the approximation φh of the electrostatic potential φ is searched, then

φ(t,x) ≈ φh(t,x) =

Ng∑j=1

φj(t) Λj(x) ∈ Vh .

At least locally on each cell the gradient of φh is well defined and so the electricfield at a particle position is directly approximated by

E(t,xk) ≈ Eh(t,xk) = −Ng∑j=1

φj(t)∇Λj(xk).

55

Page 57: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

On the other hand, using the approximation (3.6) for f as a sum of Dirac masses,the weak form of the Poisson equation reads∫

∇φh · ∇ψh dx =

∫ [1−

∫fh(t,x,v) dv

]ψh dx

=

∫ψh dx−

Np∑k=1

wkψh(xk) , ∀ ψh ∈ Vh .(3.10)

3.2.3 Particle-Mesh coupling for point-based Poisson solvers

The electric field Eh computed from a FEM Poisson solver can be evaluated atany point x in the simulation domain and can thus be directly used in the Verletscheme (3.7)-(3.9) for the markers. This is not the case for point-based Poissonsolvers like FD or Fourier spectral, where the electric field is only known at thegrid points xj, i.e. Ej ≈ E(xj). Conversely, the particle approximation fh ofthe distribution function does not naturally give an expression for this functionat the grid points xj. Thus for the coupling with the field solver which is definedon the mesh, a regularization step is necessary. To this aim we need to definea convolution kernels Sj = S(x − xj) which can be used for this regularizationprocedure.

On Cartesian meshes in 1D, B-splines Nm of degree m, c.f. section 2.5.4,are most commonly used as this convolution kernel, for instance Sj(x) = N3

j−2.In case of a periodic domain, all B-splines Nm

j look the same and we can writeSj(x) = Sm(x− xj), where Sm is used to denote the m-degree B-spline centeredat x = 0. Examples of Sm and its derivative are depicted in Figure 3.1. TheB-splines Sm verify the following important properties,∫

Sm(x) dx = 1 , ∆x∑j

Sm(x− xj) = 1 , Sm(−x) = Sm(x) ,

namely unit mean, partition of unity and symmetry. In 2D and 3D the convolutionkernel can be constructed via tensor products of the 1D case.

The electron density nh in the Poisson equation is defined from the numericaldistribution function fh. We apply the convolution kernel S to define nh at anypoint of space, and in particular at the grid points:

nh(x, t) =

∫Sm(x− x′)fh(t,x

′,v) dx′ dv =∑k

wkSm(x− xk) ,

nj(t) := nh(xj, t) =∑k

wkSm(xj − xk) . (3.11)

In order to get conservation of total momentum, when a regularization kernel isapplied to the particles, the same kernel needs to be applied to the field seenas Dirac masses at the grid points in order to compute the field at the particle

56

Page 58: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Figure 3.1: B-spline convolution kernels Sm for cell size ∆x = 1 centered at x = 0(left) and their derivatives (right) for different degrees k ∈ 0, 1, 2, 3.

positions. We then obtain

Eh(x, t) =∑j

Ej(t)Sm(x− xj) , (3.12)

where Ej(t) = E(xj, t). Note that in the case of degree one where m = 1 thisregularization is equivalent to a linear interpolation of the fields defined at thegrid points to the positions of the particles. However, for higher-order splinesthis is not an interpolation anymore and the regularized field at the grid points isnot equal to its original value Ej anymore, but for example in the case of S3, to16Ej−1 + 2

3Ej + 1

6Ej+1.

3.2.4 Time loop

Let us now summarize the main stages to go from time tn to time tn+1 in a point-based PIC solver:

1. We compute the charge density 1−nh on the grid using the relation relation(3.11).

2. We update the electromagnetic field using a classical mesh-based solver (FD,Fourier spectral, ....).

3. We compute the fields at the particle positions using relations (3.12).

4. Particles are advanced using a numerical scheme for the characteristics forexample Verlet (3.7)-(3.9).

57

Page 59: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

3.2.5 Conservation properties at the semi-discrete level

Conservation of mass. The discrete mass is defined as

Nh(t) :=

∫nh(x, t)dx =

∫fh(x,v, t) dxdv =

∑k

wk .

This is obviously conserved if no particle gets in or out of the domain, as the weightwk is conserved for each particle when the particles move.

Conservation of momentum. The total momentum of the system of particlesis defined as

Ph(t) :=

∫vfh(x,v, t) dxdv =

∑k

wkvk(t).

SodPhdt

=∑k

wkdvkdt

= −∑k

wkEh(xk, t).

In the case Eh is computed from a point-based solver, its value at the particleposition should be computed from (3.12) such that

dPhdt

= −∑k

wk∑j

Ej(t)S(xk − xj) .

Exchanging the sums and using (3.11) we get

dPhdt

= −∑j

Ej(t)∑k

wkS(xk − xj) = −∑j

Ej(t)nj(t) ,

so that the total momentum is conserved provided the field solver is such that∑j Ej(t)nj(t) = 0. This is in particular true for a Fourier spectral Poisson solver

in 1D for which

Ej =1

N

N/2−1∑m=−N/2+1

Emei 2πNjm , nj =

1

N

N/2−1∑m=−N/2+1

nmei 2πNjm .

where we note that the −N/2-component is zero because of (2.19). The Fouriersolver implies that Em = i nm

mfor m 6= 0 and E0 = 0 due to the Poisson equation.

Then, as E−m = Em because Ej is real, we can use the discrete Parseval identity(2.15) to obtain

∑j

Ejnj =1

N

N/2−1∑m=−N/2+1

Emnm =−i

N

N/2−1∑m=−N/2+1

mE2m = 0.

This is also true for the standard second order Finite Difference Poisson solverprovided the electric field is computed from the potential with a centered finite

58

Page 60: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

difference approximation. Indeed in this case∑j

Ejnj = −∑j

(φj+1 − φj−1)

2∆x

[1 +

(2φj − φj+1 − φj−1)

∆x2

]= −

∑j

(φj+1 − φj−1)

2∆x+

1

2∆x3

∑j

((φ2

j+1 − φ2j−1)− 2φjφj+1 + 2φjφj−1

)= 0 ,

using the periodicity of the grid and changing the indices in the last term.The Finite Element PIC solver we introduced above does not conserve total

momentum.

Remark 5. Note that the conservation of momentum is linked to the self-forceproblem that is often mentioned in the PIC literature. Indeed if the system isreduced to one particle. The conservation of momentum is equivalent to the factthat a particle does not apply a force on itself.

Conservation of energy. Classical point-based solvers based on Finite Differ-ence or spectral methods do not conserve total energy, but the semi-discrete FiniteElement solver does. Indeed consider, the equations of motion for the particles

dxkdt

= vk,dvkdt

= ∇φh(t,xk) ,

coupled with the finite element discretisation of the Poisson equation (3.10),∫∇φh · ∇ψh dx =

∫ψh dx−

∑k

wkψh(xk) ∀ ψh ∈ Vh .

Then the following semi-discrete energy is exactly conserved:

Eh(t) :=∑k

wk2|vk|2 +

1

2

∫|∇φh|2 dx.

Let us verify this by direct computation. First taking ψh = φh as a test function,using that φh has zero mean, and taking the time derivative, the weak Poissonequation yields

d

dt

∫|∇φh|2 dx = −

∑k

wk

(∂φh∂t

(t,xk) +dxkdt· ∇φh(t,xk)

). (3.13)

On the other hand taking ψh = ∂tφh(t,xk) in the weak Poisson equation, we alsohave that

−∑k

wk∂φh∂t

(t,xk) =

∫∇φh · ∇

∂φh∂t

dx =1

2

d

dt

∫|∇φh|2 dx,

59

Page 61: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

so that equation (3.13) becomes

1

2

d

dt

∫|∇φh|2 dx = −

∑k

wkdxkdt· ∇φh(t,xk) = −

∑k

wkvk · ∇φh(t,xk).

Now using this, we find

dEh(t)dt

=∑k

(wkmkvk ·

dvkdt− wkvk · ∇φh(t,xk)

)= 0

asdvkdt

= − qkmk

∇φh(t,xk) .

3.3 Operator splitting

In the Vlasov equation (3.2) the advection field in x, which is v, does not depend onx and the advection field in v, which is −E(x, t), does not depend on v. Thereforeit is often convenient to decompose these two parts, using the technique calledoperator splitting.

Let us consider the Vlasov-Poisson system (3.1). We shall split the Vlasovequation into the following two pieces:

∂f

∂t+ v · ∇x f = 0 , with v fixed , (3.14)

and∂f

∂t− E(x, t) · ∇v f = 0 , with x fixed . (3.15)

We then get two constant coefficient advection equations that can be easilysolved with high-order methods (in particular Fourier methods). This is obviousfor (3.14) as v does not depend on t and x. On the other hand, integrating (3.15)with respect to v, we get that ∂tn = 0, so that the charge density ρ = 1 − n andconsequently E do not change when this equation is advanced in time. Therefore,E(t,x) needs to be computed once from the initial f for this equation and dependsneither on t nor on v.

Remark 6. When the starting equation has some features which are importantfor the quality of the numerical solution, it is essential not to remove them whendoing operator splitting. In particular, if the initial equation is conservative, it isgenerally a good idea to split such that each of the split equation is conservative.

In order to analyze the error resulting from operator splitting, let us considerequations of the form

∂f

∂t= (A+B)f , (3.16)

where f = f(t,x) A and B are any two differential operators in x that are assumedconstant in time. The formal solution of this equation after time ∆t reads

f(t+ ∆t) = e∆t(A+B)f(t).

60

Page 62: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Let us split the equation (3.16) into

∂f

∂t= Af, (3.17)

∂f

∂t= Bf. (3.18)

The formal solutions of these equations taken separately are

f(t+ ∆t) = e∆tAf(t) and f(t+ ∆t) = e∆tBf(t).

The Lie-Trotter splitting method consists in solving successively on one timestep first (3.17) and then (3.18). Then after one time step we get

f(t+ ∆t) = e∆tBe∆tAf(t).

If the operators A and B commute, i.e. AB = BA, e∆tBe∆tA = e∆t(A+B) and thesplitting is exact. This is the case in particular when A,B do not depend on x, asfor instance in

∂f

∂t+ c1

∂f

∂x+ c2

∂f

∂y= 0 ,

with c1 = const. and c2 = const. Note that such an equation is also a good firsttest case to validate a Vlasov code. In the Vlasov equation we have

v · ∇x(E · ∇v)f 6= E · ∇v(v · ∇x)f ,

hence the operators do not commute and one introduces a splitting error.In the case when A and B do not commute, the splitting error can be decreased

by solving first (3.17) on a half time step, and then (3.18) on a full time step andagain (3.17) on a half time step. This method is known as the Strang splittingmethod. It corresponds to the formal solution

f(t+ ∆t) = e∆t2Ae∆tBe

∆t2Af(t).

The error committed at each time step by the operator splitting method whenthe operators do not commute is given by

Proposition 7. The Lie-Trotter splitting method has a global error in time ofO(∆t) and the Strang splitting method has a global error in time of O(∆t2).

Proof. In order to find the error we need to expand the matrix exponential. Onthe one hand we have

e∆t(A+B) = I + ∆t(A+B) +∆t2

2(A+B)2 +O(∆t3),

and on the other hand

e∆tBe∆tA =

[I + ∆tB +

∆t2

2B2 +O(∆t3)

] [I + ∆tA+

∆t2

2A2 +O(∆t3)

]= I + ∆t(A+B) +

∆t2

2(A2 +B2 + 2BA) +O(∆t3).

61

Page 63: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

But as A and B do not commute, we have (A + B)2 = A2 + AB + BA + B2.It follows that the local error is e∆t(A+B) − e∆tBe∆tA = O(∆t2), which leads to aglobal error of order O(∆t) after summation of the local error over all time steps.

For the Strang splitting method, we have

e∆t2Ae∆tBe

∆t2A =

[I +

∆t

2A+

∆t2

8A2 +O(∆t3)

] [I + ∆tB +

∆t2

2B2 +O(∆t3)

][I +

∆t

2A+

∆t2

8A2 +O(∆t3)

]=I + ∆t(A+B) +

∆t2

2(A2 +B2 +BA+ AB) +O(∆t3).

We thus obtain a local error of O(∆t3) and thus a global error of O(∆t2) for themethod of Strang.

Remark 7. It is possible to obtain splitting methods of order as high as desired bytaking adequate compositions of the two operators. Details on high order splittingmethods can be found in [15].

Remark 8. The Strang splitting method can also be generalized to more that twooperators. If A = A1 + · · ·+An, the following decomposition will be of global orderO(∆t2):

e∆t2A1 . . . e

∆t2An−1e∆tAne

∆t2An−1 . . . e

∆t2A1 .

62

Page 64: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Chapter 4

The geometric electromagneticPIC method

4.1 Compatible Finite Element discretisation of

Maxwell’s equation

4.1.1 Weak formulation and commuting diagram in 3D

The evolution of the electromagnetic fields E and B in the presence of charge-and current densities ρ and J is described by Maxwell’s equation, as stated in(1.3). Setting the physical constants to one, the general expression for the Maxwellequations on some domain Ω ⊂ R3 reads

−∂E

∂t+ curl B = J, (Ampere) (4.1)

∂B

∂t+ curl E = 0, (Faraday) (4.2)

div E = ρ, (Gauss) (4.3)

div B = 0, (magnetic Gauss) (4.4)

Initial and boundary conditions are needed in addition to fully determine thesolution. Note that taking the divergence of (4.1) yields

∂∇ · E∂t

= −∇ · J =∂ρ

∂t

using the continuity equation ∂ρ∂t

+∇·J = 0 from (1.7), which is a condition that thesource terms ρ and J need to satisfy for the Maxwell equations to be well-posed.Hence if (4.3) is satisfied at time t = 0 it will be satisfied at all times. In the sameway, taking the divergence of (4.2), we get that ∂∇·B

∂t= 0, so that if div B = 0 at

the initial time it will remain so for all times. It is essential for the stability ofnumerical Maxwell solvers that (4.3) and (4.4) remain satisfied in someapproximate sense over very long times.

63

Page 65: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

For a Finite Element discretisation of Maxwell’s equation, we need a variationalformulation. Because of the differential operators div = ∇· and curl = ∇×, naturalfunction spaces arising here are

H(curl,Ω) = u ∈ L2(Ω)3, ∇× u ∈ L2(Ω)3 ,

H(div,Ω) = u ∈ L2(Ω)3, ∇ · u ∈ L2(Ω) .

Rather than taking E,B ∈ H1(Ω)3, in order to get a stable discretisation with goodlong time conservation properties one should choose either E ∈ H(curl,Ω) and B ∈H(div,Ω) or the other way round. Both yield good but different discretisations.Let us choose here, the less standard way E ∈ H(div,Ω) and B ∈ H(curl,Ω).Then taking the dot product of (4.1) with an arbitrary function F ∈ H(div,Ω)and integrating, we get∫

Ω

(∂E

∂t− curl B

)· F dx = −

∫Ω

J · F dx, ∀ F ∈ H(div,Ω).

Note that as B ∈ H(curl,Ω), this is well defined without integration by parts, andas it is true for all F ∈ H(div,Ω), it is equivalent to

∂E

∂t− curl B = −J, in H(div,Ω) .

For Faraday’s equation we take the dot product with an arbitrary function C ∈H(curl,Ω) and integrate by parts assuming periodic boundary conditions to avoidthe boundary term. Then we get∫

Ω

∂B

∂t·C dx +

∫Ω

E · curl C dx = 0, ∀ C ∈ H(curl,Ω).

The two Gauss laws (4.3)-(4.4) are satisfied automatically if they are satisfied atthe initial time.

Finally the variational formulation reads: Find E ∈ H(div,Ω) and B ∈H(curl,Ω) such that∫

Ω

(∂E

∂t− curl B

)· F dx = −

∫Ω

J · F dx, ∀ F ∈ H(div,Ω) ,∫Ω

∂B

∂t·C dx +

∫Ω

E · curl C dx = 0, ∀ C ∈ H(curl,Ω) .

It now remains to define appropriate Finite dimensional Finite Element spacescontained in these continuous spaces. It has been proven for example in [1], thatstability and convergence of the scheme is guaranteed if the discrete spaces Vn,n ∈ 0, 1, 2, 3, verify the following diagram:

H1(Ω) H(curl,Ω) H(div,Ω) L2(Ω)

V0 V1 V2 V3

Π0

grad

Π1

grad

Π2 Π3

curl

curl

div

div

64

Page 66: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Here Πn, n ∈ 0, 1, 2, 3 denotes a projector from the continuous to the discretespace. As in the infinite dimensional case, the discrete spaces Vn satisfy the exactsequence property:

Im gradV0 = Ker curlV1 , Im curlV1 = Ker div V2 .

Moreover, the projectors need to be chosen such that the diagram commutes,hence

Π1 grad = grad Π0 , Π2 curl = curl Π1 , Π3 div = div Π2 .

Using the continuous variational formulation with the corresponding finite dimen-sional subspaces, we get the following discrete formulation: Find Eh ∈ V2 andBh ∈ V1 such that∫

Ω

(∂Eh

∂t− curl Bh

)· Fh dx = −

∫Ω

Π2J · Fh dx, ∀ Fh ∈ V2, (4.5)∫Ω

∂Bh

∂t·Ch dx +

∫Ω

Eh · curl Ch dx = 0, ∀ Ch ∈ V1. (4.6)

As in the continuous case, we get from (4.5), that we have the strong equality

∂Eh

∂t− curl Bh = −Π2J , in V2 .

This implies in particular, by taking the divergence, which is well defined forelements of V2

∂div Eh

∂t= −div Π2J = −Π3div J =

∂Π3ρ

∂t.

So by using the commuting diagram property and the continuous continuity equa-tion, we first find the corresponding discrete continuity equation

∂Π3ρ

∂t+ div Π2J = 0 ,

and the fact that the discrete Gauss law div Eh = Π3ρ is verified for alltimes provided it is verified at time t = 0.

On the other hand taking Ch = ∇φh for φh ∈ V0 yields a function in V1 thatcan be used in (4.6). This yields∫

Ω

∂Bh

∂t· ∇ϕh dx = 0 , ∀ ϕh ∈ V0 .

We can take ϕh independent of t, typically one would take all the basis functionsof the V0 space. This implies that

∫Ω

Bh · ∇ϕh dx = 0 for all t provided it is zeroat time t = 0. This is the exact conservation of a discrete version of div B = 0 inweak form.

65

Page 67: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

4.1.2 Construction of the Finite Element spaces in 1D

Let us start with the one dimensional case (1D). We consider Maxwell’s equations(4.1)-(4.4) and assume that variations of E and B occur only with respect to x,hence

grad ≡

∂∂x

00

, curl E =

0−∂Ez

∂x∂Ey∂x

, div E =∂Ex∂x

.

Moreover, let us assume Ez = Bx = By = 0 and denote E := Ey, J := Jy andB := Bz. Maxwell’s equations then read

∂Ex∂t

= −Jx (Ampere first component) ,

∂E

∂t+∂B

∂x= −J (Ampere second component) ,

∂B

∂t+∂E

∂x= 0 (Faraday) ,

∂Ex∂x

=%

ε0

(Gauss) .

(4.7)

We assume the domain to be Ω = (a, b) and suppose homogeneous Dirichlet bound-ary conditions for E and periodic conditions for Ex. In order to obtain a weakformulation of (4.7) we multiply by test functions Fx, F , C and D and integrateover Ω: ∫ b

a

∂Ex∂t

Fx dx = −∫ b

a

JxFx dx ,∫ b

a

∂E

∂tF dx+

∫ b

a

∂B

∂xF dx = −

∫ b

a

J F dx ,∫ b

a

∂B

∂tC dx+

∫ b

a

∂E

∂xC dx = 0 ,∫ b

a

∂Ex∂x

D dx =

∫ b

a

%D dx .

(4.8)

There are multiple possibilities to use this for a weak formulation of (4.8). As oppo-site to the Poisson equation, only first order derivatives are involved in Maxwell’sequations. How should then the variational formulation be derived? Which in-tegration by parts should be performed? One at least is needed to include theboundary conditions in the variational formulation (at least for non periodic do-mains). It was found out that the best solution to keep the structural propertiesof the Maxwell equations, is to integrate by parts either one of the equations but

66

Page 68: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

not both. We choose the following: find (Ex, E,B) ∈ H1 ×H10 × L2 such that∫ b

a

∂Ex∂t

Fx dx = −∫ b

a

JxFx dx ∀Fx ∈ H1 , (4.9)∫ b

a

∂E

∂tF dx−

∫ b

a

B∂F

∂xdx = −

∫ b

a

J F dx ∀F ∈ H10 ,∫ b

a

∂B

∂tC dx+

∫ b

a

∂E

∂xC dx = 0 ∀C ∈ L2 ,∫ b

a

∂Ex∂x

D dx =

∫ b

a

%D dx ∀D ∈ H1 . (4.10)

Remark that we integrated by parts in the second equation in order to obtain awell defined weak formulation. The problem (4.9)-(4.10) contains only first orderderivatives. Our aim is to choose solution spaces that satisfy a commuting diagram.A simpler 1D version of the above diagram reads as follows:

H10 (Ω) L2(Ω)

V0 V1

Π0

∂∂x

Π1∂∂x

Here, the projectors Π0 : H10 → V0 and Π1 : L2 → V1 must be chosen such that

the diagram is commuting. For the discrete solution spaces we have V0 ⊂ H10 and

V1 ⊂ L2 with dimV0 = N <∞ and dimV1 = N + 1 <∞. The basis functions willbe denoted by (ϕ0

i )1≤i≤N and (ϕ1i+1/2)0≤i≤N , respectively. For periodic boundary

conditions we consider a similar diagram with the appropriate spaces and denoteeverything with a tilde, for example, V0. The semi-discrete version of problem(4.9)-(4.10) reads: find (Ex,h, Eh, Bh) ∈ V0 × V0 × V1 such that∫ b

a

∂Ex,h∂t

Fx,h dx = −∫ b

a

(Π0Jx)Fx,h dx ∀Fx,h ∈ V0 ,(4.11)∫ b

a

∂Eh∂t

Fh dx−∫ b

a

Bh∂Fh∂x

dx = −∫ b

a

J Fh dx ∀Fh ∈ V0 ,∫ b

a

∂Bh

∂tCh dx+

∫ b

a

∂Eh∂x

Ch dx = 0 ∀Ch ∈ V1 ,∫ b

a

∂Ex,h∂x

Dh dx =

∫ b

a

(Π1%)Dh dx ∀Dh ∈ V1 . (4.12)

Any function Eh ∈ V0 can be expanded in the basis (ϕ0i )1≤i≤N , thus

Eh(x) =N∑i=1

ei ϕ0i (x) . (4.13)

67

Page 69: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Figure 4.1: Lagrange basis of degree k = 2 for N = 7: N basis functions forhomogeneous Dirichlet boundary conditions (up) and N + 1 basis functions forperiodic boundary conditions (down), where the first blue piece and the last greenpiece are glued together to guarantee periodicity.

Here, the vector e = (ei)1≤i≤N ∈ RN holds the (time dependent) coefficients withrespect to the basis. We shall introduce the node vector x = (xi)0≤i≤N+1 ∈ RN+2,holding the nodes that define N + 2 basis functions (ϕ0

i )0≤i≤N+1, including theboundaries x0 = a and xN+1 = b. This could be for instance Lagrange basis func-tions, which would be defined by ϕ0

i (xj) = δi,j. For Dirichlet boundary conditions,one would cut the first and the last basis function to arrive at the N -dimensionalbasis for V0, c.f. Figure 4.1

Going back to our diagram, the first projector Π0 will be just interpolationat the points (xi)1≤i≤N :

Π0 : H10 → V0, defined by (Π0E)(xi) = E(xi) ∀ i ∈ 1, . . . , N .

68

Page 70: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Writing Π0E = Eh in the form (4.13) we have

N∑i=1

ei ϕ0i (xj) = E(xj) j = 1, . . . , N .

The matrix (ϕ0i (xj))i,j ∈ RN×N is called the interpolation matrix (or collocation

matrix ). It positive definite and symmetric and hence invertible to yield a well-posed linear system that can be solved for the coefficients e = (ei)i.

For Bh ∈ V1 we write

Bh(x) =N∑i=0

bi+1/2 ϕ1i+1/2(x) . (4.14)

We construct the basis of V1 such that that

ϕ1i+1/2 ∈ span(∂xϕ

00, . . . , ∂xϕ

0N+1) (4.15)

in order to achieve the lower vertical line of our diagram. This can be easily donefor Lagrange and for Spline basis functions, using for instance the relation (2.32)for Splines and choosing the Dk

i (x) as basis for V1. Then, in the second projectorof our diagram we use histopolation:

Π1 : L2 → V1,

∫ xi+1

xi

(Π1B)(x) dx =

∫ xi+1

xi

B(x) dx ∀ i ∈ 0, . . . , N .

Remark that these integrals are well defined because B ∈ L2 is piece-wise con-tinuous. Denoting Π1B = Bh from equation (4.14), the above definition of thehistopolant yields

N∑i=0

bi+1/2

∫ xj+1

xj

ϕ1i+1/2(x) dx =

∫ xj+1

xj

B(x) dx ∀ j ∈ 0, . . . , N . (4.16)

The matrix (∫ xj+1

xjϕ1i+1/2 dx)i,j ∈ R(N+1)×(N+1) is called the histopolation matrix.

It positive definite and symmetric and hence invertible to yield a well-posed linearsystem that can be solved for the coefficients b = (bi+1/2)i.

69

Page 71: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Proposition 8. (Commuting diagram property.) We have Π1∂∂xE = ∂

∂xΠ0E

for each E ∈ H10 (Ω).

Proof. First we realize that both sides of the equality are in V1; the left-hand sideis obvious and the right-hand side is due to (4.15). Moreover, each element inBh ∈ V1 is uniquely characterized by the integrals

∫ xj+1

xjBh dx, as follows from the

invertability of the histopolation matrix in (4.16). We have∫ xj+1

xj

∂xΠ0E dx = Π0E(xj+1)− Π0E(xj) = E(xj+1)− E(xj) ,

where the last equality follows from the definition of Π0. On the other hand,∫ xj+1

xj

Π1∂

∂xE dx =

∫ xj+1

xj

∂xE dx = E(xj+1)− E(xj) ,

where the first equality follows from the definition of Π1. As these integralsuniquely defined an element in V1 we have proved the statement.

Faraday’s law (strong)

Let us come back to the discrete system (4.11)-(4.12). In what follows we assumeuniform grid spacing ∆x = xj+1−xj for all j. Faraday’s law is satisfied in a strongsense because we did not integrate by parts. This means that

∂Bh

∂t+∂Eh∂x

= 0 in V1 . (4.17)

Using for instance the B-Splines Nki = ϕ0

i as the basis for V0 and the functionsDki+1 = ϕi+1/2 defined in (2.31) as the basis for V1, from (2.32) we obtain

Eh(t, x) =N∑i=1

ei(t)Nki (x) ⇒ ∂Eh

∂x(t, x) =

N+1∑i=1

[ei(t)− ei−1(t)]Dki (x) ,

where e = (ei)1≤i≤N ∈ RN and eN+1 = 0 are the FEM coefficients of Eh ∈ V0.Moreover,

Bh(t, x) =N+1∑i=1

bi(t)Dki (x) ,

with b = (bi)1≤i≤N+1 ∈ RN+1 are the FEM coefficients of Bh ∈ V1. Introducingthe gradient matrix G ∈ R(N+1)×N ,

G :=

1−1 1

−1 1. . . . . .

−1 1−1 1

−1

,

70

Page 72: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

we can write (4.17) compactly as

db

dt+ Ge = 0 .

This form is independent of the chosen polynomial degree k in the B-Spline basis.

Ampere’s law (y-component, weak)

Let us now consider the y-component of Ampere’s law, where we integrated byparts: ∫ b

a

∂Eh∂t

Fh dx−∫ b

a

Bh∂Fh∂x

dx = −∫ b

a

J Fh dx ∀Fh ∈ V0 . (4.18)

We write

Fh(x) =N∑i=1

fiNki (x) ,

∂Fh∂x

(x) =N+1∑i=1

[fi+1 − fi]Dki (x) ,

with f = (fi)1≤i≤N ∈ RN and define

j = (ji)1≤i≤N ∈ RN with ji(t) :=

∫ b

a

J(t, x)Nki (x) dx , .

Inserting this into (4.18) yields

N∑i,j=1

deidt

fj

∫ b

a

ϕ0i ϕ

0j dx︸ ︷︷ ︸

=M0i,j

−N1−1∑i,j=0

bi+1/2[fj+1 − fj]∫ b

a

ϕ1i+1/2 ϕ

1j+1/2 dx︸ ︷︷ ︸

=M1i,j

= −N∑i=1

ji fi .

Introducing the mass matrices M0 = (M0i,j)i,j ∈ RN×N and M1 = (M1

i,j)i,j ∈RN1×N1 , we can write this compactly as

de>

dtM0 f − b>M1G f = −j> f ∀ f ∈ RN .

Canceling f leads to the linear system

M0 de

dt−G>M1b = −j .

Ampere’s law (x-component, strong) and Gauss’ law (strong)

The x-component of Ampere’s law (4.11) is given in strong form, hence

dexdt

= −jx in V0 ,

where ex = (ex,i)0≤i≤N ∈ RN+1 and jx = (jx,i)0≤i≤N ∈ RN+1 are the coefficientsin the basis of V0 (the ’tilde’ indicates periodic boundary conditions), denoted

71

Page 73: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

(ϕ0i )0≤i≤N , and jx holding the coefficients of Π0Jx. Moreover, discrete Gauss law

(4.12) readsG ex = % in V1 ,

where % holds the FEM coefficients of Π1% and we introduced the gradient matrixG ∈ R(N+1)×(N+1) for periodic functions,

G :=

1 −1−1 1

. . . . . .

−1 1−1 1

.

4.1.3 Summary: semi-discrete 1D Maxwell equations

In summary, the system (4.11) - (4.12) for the coefficients (ex, e,b) ∈ RN+1×RN×RN+1 reads

dexdt

= −jx ,

M0 de

dt−G>M1b = −j ,

db

dt+ G e = 0 ,

G ex = % .

(4.19)

Applying the matrix G to the first equation and inserting Gauss law yields

d%

dt+ G jx = 0 , (4.20)

which is the discrete conservation of charge. On the other hand, taking the timederivative of the discrete Gauss law leads to

d

dt

(G ex − %

)= −

(G jx +

d%

dt

)= 0 .

This means that the discrete Gauss law holds at all times provided it holds at theinitial time. It is interesting to note that (4.20) corresponds to the projection ofthe exact charge conservation law on the discrete space V1:

0 = Π1

(∂%

∂t+∂Jx∂x

)=∂(Π1%)

∂t+

∂x(Π0Jx) .

This is a consequence of the commuting diagram property.

72

Page 74: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

4.2 Coupling to the Vlasov equation

4.2.1 Recalling some PIC fundamentals

Maxwell’s equations are coupled to the plasma by means of the charge density %and the current density J. The plasma dynamics can be described for example byVlasov equations for each particle species s:

∂tfs + v · ∇xfs +

qsms

(E + v ×B) · ∇vfs = 0 ,

fs(t = tin) = fs,in(x,v) .

Here, fs = fs(t,x,v) is the particle distribution function of species s, x stands forthe particle position, v denotes the particle velocity, qs and ms denote the species’charge and mass, respectively, and fin stands for an initial condition. The chargeand current densities are defined by

%(t,x) :=∑s

qs

∫R3

fs(t,x,v) d3v ,

J(t,x) :=∑s

qs

∫R3

v fs(t,x,v) d3v .

In our 1D test case we consider only variations with respect to x, vx and vy, hencefs = fs(t, x, vx, vy). We assume periodic boundary conditions in x. Moreover,Ez = Bx = By = 0 has been assumed, such that

∂tfs + vx

∂xfs +

qsms

(Ex + vyB)∂

∂vxfs +

qsms

(E − vxB)∂

∂vyfs = 0

fs(t = tin) = fs,in(x, vx, vy) .

(4.21)

We will solve the Vlasov equation (4.21) by means of a particle-in-cell (PIC)method. In a PIC method, the distribution function is approximated by a sum ofDirac masses,

fs,N(t, x, vx, vy) =

Nk∑k=1

w0k δ(xk(t)− x) δ(vx,k(t)− vx) δ(vy,k(t)− vy) , (4.22)

where k = 1, . . . , Nk indicates a so-called marker and w0k denotes the marker’s

weight, which is a positive number. The marker trajectories satisfy the character-istic equations of (4.21):

dxkdt

= vx,k xk(t0) = x0k ,

dvx,kdt

=qsms

[Ex(t, xk) + vy,kB(t, xk)] vx,k(t0) = v0x,k ,

dvy,kdt

=qsms

[E(t, xk)− vx,kB(t, xk)] vy,k(t0) = v0y,k .

73

Page 75: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

In FEEC, the sum of Dirac masses in (4.22) is problematic, because the projectorsΠ0 and Π1 are not well defined for the corresponding charge and current densities.In order to make the projections well-defined we need to smooth these quantities.For this, we introduce a positive smoothing kernel S = S(x) ≥ 0, which is nor-malized,

∫R S(x) dx = 1, symmetric, S(−x) = S(x) and has compact support, c.f.

section 3.2.3. We apply it to the quantities to be projected, Jx and % in our case,and define

%N(t, x) :=∑s

qs

∫R

∫R2

S(x′ − x) fs,N(t, x′, vx, vy) dvx dvy dx′

=∑s

qs

Nk∑k=1

w0k S(xk(t)− x) ,

Jx,N(t, x) :=∑s

qs

∫R

∫R2

S(x′ − x) vx fs,N(t, x′, vx, vy) dvx dvy dx′

=∑s

qs

Nk∑k=1

w0k S(xk(t)− x) vx,k(t) .

Remark that for S(x) → δ(x) (Dirac delta distribution) we obtain the non-smoothed quantities. With these definitions, we have conservation of charge:

∂%N∂t

+∂Jx,N∂x

= 0 .

Applying the projector Π1 we get (4.20) due to the commuting diagram property,which means that the discrete Gauss law will be satisfied at all times and wedon’t need to implement it explicitly in our solver. There is no need to applythe smoothing kernel to the current density in y-direction, for which we keep theconventional expression and define

JN(t, x) :=∑s

qs

∫R2

vy fs,N(t, x, vx, vy) dvx dvy

=∑s

qs

Nk∑k=1

w0k δ(xk(t)− x) vy,k(t) .

74

Page 76: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

The sources % = (%i+1/2)0≤i≤N , jx = (jx,i)0≤i≤N and j = (ji)1≤i≤N in the discreteMaxwell equations (4.19) are now well-defined by the projections:

Π1 : %i+1/2(t) =

∫ xi+1

xi

%N(t, x) dx

=∑s

qs

Nk∑k=1

w0k

∫ xi+1

xi

S(xk(t)− x) dx for [xi, xi+1] ∈ Ωk ,

Π0 : jx,i(t) = Jx,N(t, xi) =∑s

qs

Nk∑k=1

w0k S(xk(t)− xi) vx,k(t) ,

no proj.: ji(t) =

∫ b

a

JN(t, x)ϕ0i (x) dx =

∑s

qs

Nk∑k=1

w0k ϕ

0i (xk(t)) vy,k(t) .

Remark that the last integral is well-defined because the basis functions ϕ0i have

compact support.

4.2.2 The semi-discrete 1D2V Vlasov-Maxwell system

Let us put together the semi-discrete system we derived thus far. We assume thatthere is only one particle species and omit the index s (and the sums over s) inthe following. Provided that the discrete Gauss law G ex = % is satisfied at theinitial time, the semi-discrete problem reads:

Find (ex, e,b,Z) ∈ RN0+1×RN0 ×RN1 ×R3Nk , where Z = (zk)1≤k≤Nk holds allthe marker coordinates in phase space, such that

dexdt

= − jx ,

M0 de

dt−G>M1b = − j ,

db

dt+ G e = 0 ,

dxkdt

= vx,k , xk(tin) = x0k ,

dvx,kdt

=qsms

[N0∑i=0

ex,i S(xk − xi) + vy,kBh(t, xk)

], vx,k(tin) = v0

x,k ,

dvy,kdt

=qsms

[Eh(t, xk)− vx,kBh(t, xk)] , vy,k(tin) = v0y,k .

In the equations for vx,k the electric field has been replaced by a smoothed version,using the smoothing kernel S. This is done for the sake of energy conservation, asdemonstrated below.

75

Page 77: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Proposition 9. The following energy is exactly conserved by this discretization:

H :=1

2

(e>x ex + e>M0e

)+

1

2b>M1b +

∑s

ms

2

Nk∑k=1

w0k (v2

x,k + v2y,k) .

Proof. Using that the mass matrices are symmetric, the time derivative can becomputed to be

dH

dt=

(e>x

dexdt

+ e>M0 de

dt

)+ b>M1 db

dt+∑s

ms

Nk∑k=1

w0k

(vx,k

dvx,kdt

+ vy,kdvy,k

dt

)= −e>x jx − e>j + e>G>M1b− b>M1G e

+∑s

qs

Nk∑k=1

w0k

[vx,k

(N0∑i=0

ex,i S(xk − xi) + vy,kBh

)+ vy,k

(N0−1∑i=0

ei ϕ0i (xk)− vx,kBh

)]= 0 .

Here, we used that

e>x jx =

N0∑i=0

ex,i∑s

qs

Nk∑k=1

w0k S(xk − xi) vx,k ,

and

e>j =

N0−1∑i=0

ei∑s

qs

Nk∑k=1

w0k ϕ

0i (xk) vy,k .

76

Page 78: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

Bibliography

[1] Douglas Arnold, Richard Falk, and Ragnar Winther. Finite element exteriorcalculus: from Hodge theory to numerical stability. Bulletin of the Americanmathematical society, 47(2):281–354, 2010.

[2] R. Balescu. Transport Processes in Plasmas - 1. Classical Transport Theory.Elsevier Science Publishers, 1988.

[3] John P Boyd. Chebyshev and Fourier spectral methods. Courier Corporation,2001.

[4] Victor Eijkhout. Introduction to High-Performance Scientific Computing.http://pages.tacc.utexas.edu/~eijkhout/istc/istc.html.

[5] Martin J Gander and Gerhard Wanner. From Euler, Ritz, and Galerkin toModern Computing. SIAM Review, 54(4):627–666, 2012.

[6] Johan Peter Goedbloed and Stefaan Poedts. Principles of magnetohydrody-namics: with applications to laboratory and astrophysical plasmas. Cambridgeuniversity press, 2004.

[7] C. T. Kelley. Iterative Methods for Linear and Nonlinear Equations. Num-ber 16 in Frontiers in Applied Mathematics. SIAM, Philadelphia, 1995.

[8] Dwight R Nicholson. Introduction to plasma theory. Wiley New York, 1983.

[9] Willi-Hans Steeb. Kronecker product of matrices and applications. BI-Wissenschaftsvlg, 1991.

[10] Willi-Hans Steeb. Matrix calculus and Kronecker product with applicationsand C++ programs. World Scientific, 1997.

[11] Vidar Thomee. From finite differences to finite elements: A short history ofnumerical analysis of partial differential equations. Journal of Computationaland Applied Mathematics, 128(1):1–54, 2001.

[12] Lloyd N Trefethen. Spectral methods in MATLAB, volume 10. Siam, 2000.

[13] Lloyd N Trefethen and David Bau III. Numerical linear algebra, volume 50.Siam, 1997.

77

Page 79: Computational plasma physics - TUM · for plasma physics simulations. Its aim is to introduce the process of developing a simulation code and some standard methods and numerical issues

[14] Charles F. van Loan. The ubiquitous Kronecker product. J. Comput. Appl.Math., 123:85–100, November 2000.

[15] H. Yoshida. Construction of higher order symplectic integrators. Phys. Lett.A, 150:262, 1990.

78