particle in cell methods - university of new...

101
Particle In Cell Methods With Application to Simulations in Space Weather Giovanni Lapenta Centrum voor Plasma Astrofysica Katholieke Universiteit Leuven

Upload: others

Post on 04-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Particle In Cell MethodsWith Application to Simulations in Space

Weather

Giovanni LapentaCentrum voor Plasma Astrofysica

Katholieke Universiteit Leuven

Page 2: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather
Page 3: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Contents

1 Physical Derivation of the PIC method page 11.1 Types of interacting systems 21.2 Description of interacting systems 51.3 Computer simulation 61.4 Finite size particles 81.5 Particle in Cell Method 9

2 Mathematical Derivation of the PIC method 122.1 Numerical Approach 132.2 Selection of the particle shape 142.3 Derivation of the equations of motion 16

2.3.1 Moment 0 172.3.2 Moment 1x 182.3.3 Moment 1v 192.3.4 Equations of motion for the com-

putational particles 202.4 Field Equations 212.5 Discretization of the equations of motion 232.6 Recapitulation 25

3 Practical Considerations in using the PIC method 283.1 Stability 283.2 Conservation Laws 293.3 Diagnostics 29

iii

Page 4: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

iv Contents

3.4 Normalisation and non-dimensional units 303.5 Initial Loading 323.6 Boundary Conditions 333.7 Exercises 33

4 Explicit Particle Simulations of Space Weather 354.1 Derivation of the Particle Method 37

4.1.1 Discretisation of the DistributionFunction 39

4.1.2 Selection of the particle shapes 414.1.3 Derivation of the equations of motion 434.1.4 Equations of motion for the com-

putational particles 464.2 Explicit Temporal Discretisation of the

Particle Methods 484.2.1 Stability of Explicit Time Differ-

encing 504.3 Space-Time Discretisation of the Field

Equations 514.3.1 Space Resolution and Finite Grid

Instability 554.3.2 Time Discretisation of Maxwell’s

equations 574.4 Recapitulation of the explicit particle

methods 61

5 Implicit Particle Methods for Space Weather 635.1 Fully Implicit Particle Methods 675.2 Semi Implicit Methods 71

5.2.1 Field Solver 755.2.2 Particle mover 765.2.3 Stability of the semi-implicit meth-

ods 775.3 Adaptive Gridding 795.4 Practical use of particle simulation in

space weather 82

Page 5: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Contents v

5.4.1 Scaling of massively parallel im-plicit PIC 82

5.4.2 Computational Costs of ParticleModeling in Space Weather 83

Appendix 1 MATLAB program for 1D electrostaticPIC 88

Bibliography 90

Page 6: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather
Page 7: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

1Physical Derivation of the PIC method

The classical or relativistic description of the natural worldis based on describing the interaction of elements of mattervia force fields. The example that will guide the discussion isthat of a plasma composed of charged particles but the dis-cussion would be similar and easily replicated for the caseof gravitational forces. In the case of a plasma, the systemis composed by charged particles (for example negative elec-trons and positive ions) interacting via electric and magneticfields.

If we identify each particle with a label p and their chargewith qp, position with xp, position with vp, the force acting onthe particles is the combination of the electric and magnetic(Lorentz) force:

Fp = qpE(xp) + vp ×Bp(xp) (1.1)

The force acting on the particles is computed from the elec-tric and magnetic fields evaluated at the particle position.

The electric and magnetic fields are themselves created bythe particles in the system and by additional sources outsidethe system (for example magnets around the plasma or ex-ternal electrodes). The fields are computed by solving theMaxwell’s equations:

1

Page 8: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2 Physical Derivation of the PIC method

∇ ·E =ρ

ε0∇×E = −∂B

∂t

∇ ·B = 0 ∇×B = µ0J+ µ0ε0∂E

∂t

(1.2)

1.1 Types of interacting systemsA key point in the derivation of the particle in cell method isthe consideration of how the sources in the Maxwell’s equa-tions ought to be computed. In principle since the systemis made of a collection of particles of infinitesimal size, thesources of the Maxwell’s equations are distributions of con-tributions one for each particle.

Figure 1.1 summarises visually the situation. Let us con-sider a system made by a collection of particles, each car-rying a charge situated in a box with the side of the Debyelength, λD (the box is 3D but is depicted as 2D for conve-nience). We choose the Debye length because a basic prop-erty of plasmas is to shield the effects of localized chargesover distances exceeding the Debye length. Of course theshielding is exponential and the effect is not totally cancelledover one Debye length, but such a length provides a con-ventional reasonable choice for the interaction range. Theelectric field in each point of the box is computed by the su-perposition of the contribution of each particle.

Let us conduct an ideal thought experiment based on us-ing a experimental device able to detect the local electricfield in one spatial position. Such an experimental deviceexists, but the determination of the local electric field re-mains a difficult but not impossible task. At any rate we tryto conduct a thought experiment where in no step any law ofphysics is violated but where the difficulties of experimentalwork are eliminated.

Page 9: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

1.1 Types of interacting systems 3

Fig. 1.1. A strongly coupled system.

If we consider the configuration in Fig. 1.1, we note thatwithin the domain there are few particles and the measure-ment obtained by our fantastic electric field meter would bevery jumpy. The particles in the box move constantly, in-teracting with each other and agitated by their thermal mo-tion. As a particle passes by the detector, the measurementdetects a jump up and when a particle moves away it de-tects a jump down. On average at any given time very fewparticles are near the detector and their specific positionsare key in determining the value measured. The effect of agiven particle on the electric field at the location of measure-ment decays very rapidly with the distance and only whenthe particle is nearby the effect is strong.

The same effect is detected by each of the particles in thesystem. The electric field each particle feels is a the sum ofthe contributions of all others but only when another par-ticle passes by the electric field would register a jump: incommon term this event is called a collision. The particle

Page 10: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4 Physical Derivation of the PIC method

trajectories would then be affected by a series of close en-counters registered as jumps in the trajectory.

The system described goes in the language of kinetic the-ory as a strongly coupled system, a system where the evolu-tion is determined by the close encounters and by the rela-tive configuration of any two pairs of particles. The conditionjust described is characterised by the presence of few parti-cles in the box: ND = nλ3

D is small.The opposite situation is that of a weakly coupled system.

The corresponding configuration is described in Fig. 1.2.

Fig. 1.2. A weakly coupled system.

Now the system is characterised by being composed by anextremely large number of particles. In any given point, thenumber of particles contributing to the electric field is verylarge. Regardless of the particle motion, the field is given bythe superposition of many contributions. As a consequence,by simple averaging of the effects of all the particles con-tributing to the measurement, the measurement is smoothand does not jump in time. Similarly the trajectory of a par-ticle is at any time affected by a large number of other par-

Page 11: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

1.2 Description of interacting systems 5

ticles. The trajectory is smooth and witjout jumps. Thesesystems are called weakly coupled. If in the strongly cou-pled system, the characteristic feature was the presence ofa succession of collisions, in the weakly coupled system, thecharacteristic feature is the mean field produced by the su-perposition of contributions from a large number of particles.

1.2 Description of interacting systemsThe discriminant factor in the previous discussion was thenumber of particles present in the box under consideration.If we choose the conventional box with side equal to the De-bye length, the number of particles present is

ND = nλ3D (1.3)

where n is the plasma density.A system is considered weakly coupled when ND is large

and strongly coupled when ND is small.This concept can be further elaborated by considering the

energies of the particles in the system. The particles in thebox are distributed in a non-uniform, random way, but onaverage, the volume associated with each particle is simplythe volume of the box, λ3

D, divided by the number of particlesin the box, ND. This volume, Vp = n−1, can be used to deter-mine the average interparticle distance, a = V

1/3p ≡ n−1/3.

This relation provides an average statistical distance. Theparticles are distributed randomly and their distances arealso random, but on average the interparticle distance is a.

The electrostatic potential energy between two particleswith separation a is

Epot =q2

4πε0a(1.4)

where we have assumed equal charge q for the two particles.

Page 12: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

6 Physical Derivation of the PIC method

Conversely, from statistical physics, the kinetic energy of theparticles can be computed to be of the order of

Eth = kT (1.5)

where k is the Boltzmann constant.A useful measure of the plasma coupling is given by the

so-called plasma coupling parameter, Λ, defined as:

Λ =Eth

Epot=

4πε0akT

q2(1.6)

Recalling the definition of Debye length (λD = (ε0kT/ne2)1/2)

and the value of a obtained above, it follows that:

Λ =4πε0kT

q2n1/3≡ 4πN

2/3D (1.7)

The plasma parameter gives a new physical meaning tothe number of particles per Debye cube. When many parti-cles are present in the Debye cube the thermal energy farexceed the potential energy, making the trajectory of eachparticle little influenced by the interactions with the otherparticles: this is the condition outlined above for the weaklycoupled systems. Conversely, when the coupling parameteris small, the potential energy dominates and the trajecto-ries are strongly affected by the near neighbour interactions:this is the condition typical of strongly coupled systems.

1.3 Computer simulationA computer simulation of a system of interacting particlescan be conducted in principle by simply following each par-ticle in the system. The so-called particle-particle (PP) ap-proach describes the motion of N particles by evolving theequations of Newton for each of the N particles taking asa force acting on the particle the combined effect of all theother particles in the system.

Page 13: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

1.3 Computer simulation 7

The evolution is discretized in many temporal steps ∆t,each chosen so that the particles move only a small distance,and after each move the force is recomputed and a new moveis made for all the particles. If we identify the particle posi-tion and velocity as, respectively, xp and vp, the equations ofmotion can be written as:

xnewp = xold

p +∆tvoldp

vnewp = vold

p +∆tFp

(1.8)

The main cost of the effort is the computation of the forcewhich requires to sum over all the particles in the system,

Fp =∑p′

Fpp′ (1.9)

where Fpp′ is the interaction force between two particles p

and p′. For example in the case of the electrostatic force,

Fpp′ =qpqp′

4πε0|xp − xp′ |2· xp − xp′

|xp − xp′ |(1.10)

where in practice all forces are computed with the old val-ues of the particle positions available at a given time. Oncethe force is computed the new velocities can be computed.Then the new positions can be computed and the cycle canbe repeated indefinitely.

For each particle, the number of terms to sum to computethe force is N−1, and considering that there are N particles,but that each pair needs to be computed only once, the totalnumber of force computations is N(N − 1)/2.

For strongly coupled systems, where the number of par-ticles per Debye cube is small, the PP approach is feasibleand forms the basis of the very successful molecular dynam-ics method used in condensed matter and in biomolecularstudies. We refer the reader to a specific text on moleculardynamics to investigate the approach more in depth [FS02].

Page 14: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

8 Physical Derivation of the PIC method

The approach is also used in the study of gravitational in-teractions, for example in the cosmological studies of the for-mation and distribution of galaxies. In that case, specificallythe dark matter is studied with a PP approach. The PP ap-proach can be made more efficient by using the Barnes-Hutor tree algorithm [BH86] that can reduce the cost (but notwithout loss of information) to O(N logN).

Even with the reduced cost of the tree algorithm, PP meth-ods cannot be practical for weakly coupled systems wherethe number of particles is very large. As the number of par-ticles increases, the cost scales quadratically (or as N logN )and makes the computational effort unmanageable. In thatcase, one cannot simply describe every particles in the sys-tem and a method must be devised to reduce the descriptionto just a statistical sample of the particles. This is the ap-proach described in the next section.

1.4 Finite size particlesThe key idea behind the simulation of weakly coupled sys-tems is to use as building block of the model not single parti-cles but rather collective clouds of them: each computationalparticle (referred to sometimes as superparticle) representsa group of particles and can be visualised as a small piece ofphase space. The concept is visualized in Fig. 1.3.

The fundamental advantage of the finite-size particle ap-proach is that the computational particles, being of finitesize, interact more weakly than point particles. When twopoint particles interact, for example via coulombian force,the repulsive or attractive force grows as the particles ap-proach, reaching a singularity at zero separation. Finitesize particles instead, behave as point particles until theirrespective surfaces start to overlap. Once overlap occursthe overlap area is neutralized, not contributing to the forcebetween the particles. At zero distances when the parti-

Page 15: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

1.5 Particle in Cell Method 9

Fig. 1.3. Finite size particle.

cles fully overlap (assuming here that all particles have thesame surface) the force become zero. Figure 1.4 shows theforce between two spherical charged particles as a functionof their distance. At large distances the force is identicalto the Coulomb force, but as the distance becomes smallerthan the particle diameter, the overlap occurs and the forcestarts to become weaker than the corresponding Coulombforce, until it becomes zero at zero separation.

The use of finite-size computational particles allows to re-duce the interaction among particles. Recalling the defi-nition of plasma parameter, the use of finite-size particlesresults in reducing the potential energy for the same ki-netic energy. The beneficial consequence is that the correctplasma parameter can be achieved by using fewer particlesthan in the physical system. The conclusion is that the cor-rect coupling parameter is achieved by fewer particles inter-acting more weakly. The realistic condition is recovered.

1.5 Particle in Cell MethodThe idea of the particle in cell (PIC, also referred to as particle-mesh, PM) method is summarised in Fig. 1.5. The system isrepresented by a small number of finite-size particles all in-teracting via the correct potential at distances beyond the

Page 16: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

10 Physical Derivation of the PIC method

Fig. 1.4. Interactions between finite size particles.

overlap distance, but correcting the effect of fewer particlesat small distances by the reduced interaction potential.

The end result is that the electric field fluctuations in thesystem are correctly smooth as they should be in a weaklycoupled system. The reason now is not that at any time avery large number of particles average each other but ratherthat the effect of the few particles close to the measure pointis weak.

Similarly the trajectory of particles are smooth as in thereal system but not because each particle is surrounded by avery large number of near neighbours. Rather the few nearneighbours produce weak interactions.

Page 17: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

1.5 Particle in Cell Method 11

Fig. 1.5. A system of finite size particles.

The collective effect is still correct as the long range inter-action is unmodified and reproduces correctly the physicalsystem.

Page 18: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2Mathematical Derivation of the PIC

method

We consider there the procedure for deriving the PIC method.Two classic textbooks [HE81, BL04a] and a review paper [Daw83]report a heuristic derivation based on the physical proper-ties of a plasma. We consider here a different approachaimed at making a clear mathematical link between the math-ematical model of the plasma and its numerical solution. Tomake the derivation as easy as possible, while retaining allits fundamental steps we consider the following 1D electro-static and classical plasma. The extension to 3D electromag-netic plasmas is no more difficult but clouded by the morecomplicated notation.

The phase space distribution function fs(x, v, t) for a givenspecies s (electrons or ions), defined as the number densityper unit element of the phase space (or the probability offinding a particle in a dx and dv around a certain phase spacepoint (x, v)), is governed by the Vlasov equation:

∂fs∂t

+ v∂fs∂x

+qsE

ms

∂fs∂v

= 0 (2.1)

where qs and ms are the charge and mass of the species, re-spectively.

The electric field in the electrostatic limit is described bythe Poisson’s equation for the scalar potential:

12

Page 19: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.1 Numerical Approach 13

ε0∂2ϕ

∂x2= −ρ (2.2)

where the net charge density is computed from the distribu-tion functions as:

ρ(x, t) =∑s

qs

∫fs(x, v, t)dv (2.3)

2.1 Numerical ApproachThe PIC method can be regarded as a finite element approachbut with finite elements that are themselves moving andoverlapping. The mathematical formulation of the PIC methodis obtained by assuming that the distribution function ofeach species is given by the superposition of several ele-ments (called computational particles or superparticles):

fs(x, v, t) =∑p

fp(x, v, t) (2.4)

Each element represents a large number of physical parti-cles that are near each other in the phase space. For thisreason, the choice of the elements is made in order to beat the same time physically meaningful (i.e. to represent abunch of particles near each other) and mathematically con-venient (i.e. it allows the derivation of a manageable set ofequations).

The PIC method is based upon assigning to each computa-tional particle a specific functional form for its distribution,a functional form with a number of free parameters whosetime evolution will determine the numerical solution of theVlasov equation. The choice is usually made to have two freeparameters in the functional shape for each spatial dimen-sion. The free parameters will acquire the physical meaningof position and velocity of the computational particle. The

Page 20: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

14 Mathematical Derivation of the PIC method

functional dependence is further assumed to be the tensorproduct of the shape in each direction of the phase space:

fp(x, v, t) = NpSx(x− xp(t))Sv(v − vp(t)) (2.5)

where Sx and Sv are the shape functions for the computa-tional particles and Np is the number of physical particlesthat are present in the element of phase space representedby the computational particle.

A number of properties of the shape functions come fromtheir definition:

(i) The support of the shape functions is compact, to de-scribe a small portion of phase space, (i.e. it is zerooutside a small range).

(ii) Their integral is unitary:∫ ∞

−∞Sξ(ξ − ξp)dξ = 1 (2.6)

where ξ stands for any coordinate of phase space.(iii) While not strictly necessary, Occam’s razor suggests

to choose symmetric shapes:

Sξ(ξ − ξp) = Sξ(ξp − ξ) (2.7)

While these definitions still leave very broad freedom inchoosing the shape functions, traditionally the choices actu-ally used in practice are very few.

2.2 Selection of the particle shapeThe standard PIC method is essentially determined by thechoice of Sv, the shape in the velocity direction as a Dirac’sdelta:

Sv(v − vp) = δ(v − vp) (2.8)

Page 21: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.2 Selection of the particle shape 15

This choice has the fundamental advantage that if all parti-cles within the element of phase space described by one com-putational particle have the same speed, they remain closerin phase space during the subsequent evolution.

The original PIC methods developed in the 50’s were basedon using a Dirac’s delta also as the shape function in space.But now for the spatial shape functions, all commonly usedPIC methods are based on the use of the so-called b-splines.The b-spline functions are a series of consecutively higherorder functions obtained from each other by integration. Thefirst b-spline is the flat-top function b0(ξ) defined as:

b0(ξ) =

1 if |ξ| < 1/2

0 otherwise(2.9)

The subsequent b-splines, bl, are obtained by successive in-tegration via the following generating formula:

bl(ξ) =

∫ ∞

−∞dξ′b0(ξ − ξ′)bl−1(ξ

′) (2.10)

Figure 2.1 shows the first three b-splines.Based on the b-splines, the spatial shape function of PIC

methods is chosen as:

Sx(x− xp) =1

∆pbl

(x− xp

∆p

)(2.11)

where ∆p is the scale-length of the support of the computa-tional particles (i.e. its size). A few PIC codes use splinesof order 1 but the vast majority uses b-splines of order 0, achoice referred to as cloud in cell because the particle is auniform square cloud in phase space with infinitesimal spanin the velocity direction and a finite size in space.

Page 22: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

16 Mathematical Derivation of the PIC method

−2 −1.5 −1 −0.5 0 0.5 1 1.5 20

0.5

1b 0(ξ

)

−2 −1.5 −1 −0.5 0 0.5 1 1.5 20

0.5

1

b 1(ξ)

−2 −1.5 −1 −0.5 0 0.5 1 1.5 20

0.5

1

ξ

b 2(ξ)

Fig. 2.1. First three b-spline functions.

2.3 Derivation of the equations of motionTo derive the evolution equations for the free parameters xp

and vp, we require that the first moments of the Vlasov equa-tion to be exactly satisfied by the functional forms chosen forthe elements. This procedure require some explanations:

(i) The Vlasov equation is formally linear in fs and theequation satisfied by each element is still the sameVlasov equation. The linear superposition of the ele-ments gives the total distribution function and if eachelement satisfies the Vlasov equation, the superposi-tion does too. A caveat, the electric field really de-pends on fs making the Vlasov equation non-linear.As a consequence the electric field used in each Vlasovequation for each element must be the total electric

Page 23: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.3 Derivation of the equations of motion 17

field due to all elements, the same entering the com-plete Vlasov equation for fs:

∂fp∂t

+ v∂fp∂x

+qsE

ms

∂fp∂v

= 0 (2.12)

(ii) The arbitrary functional form chosen for the elementsdoes not satisfy exactly the Vlasov equation. The usualprocedure of the finite element method is to requirethat the moments of the equations be satisfied.

We indicate the integration over the spatial and velocitydomain by the symbol < . . . >≡

∫dx∫dv.

2.3.1 Moment 0The zeroth order moment (< V lasov >) gives:

∂ < fp >

∂t+

⟨v∂fp∂x

⟩+

⟨qsE

ms

∂fp∂v

⟩= 0 (2.13)

where we used the interchangeability of the integration indxdv and of the derivation over time. The second and thirdterm are zero, as:∫

∂fp∂x

dx = fp(x = +∞)− fp(x = −∞) = 0

where the last equality follows from the compact support offp, assumed in the definition of the elements. A similar cal-culation holds for the term with the derivative over v. Re-calling that < fp >= Np, it follows:

dNp

dt= 0 (2.14)

The application of the first zeroth order moment leads tothe establishment of the conservation of the number of phys-ical particles per computational particle.

Page 24: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

18 Mathematical Derivation of the PIC method

2.3.2 Moment 1x

The application of the first order moment in x, (< x·V lasov >)gives:

∂ < fpx >

∂t+

⟨vx

∂fp∂x

⟩+

⟨xqsE

ms

∂fp∂v

⟩= 0 (2.15)

The last term is still zero by virtue of integration over v, theother terms, instead, are new. The first term is:

< fpx >= Np

∫Sv(v − vp)dv

∫xS(x− xp)dx

where the first integral is 1 by definition of Sv as a functionof unitary integral and the second expresses the first ordermoment of Sx. Recalling the assumption of symmetry of Sx,that moment equals xp:

< fpx >= Npxp

The third term requires the integration of:∫vdv

∫x∂fp∂x

dx =

∫v [fp(x = +∞)− fp(x = −∞)]xdv −

∫vfdxdv =

− < fpv >

where integration by part has been used. The integral canbe computed as above, reversing the roles of x and v:

< fpv >= Np

∫vSv(v − vp)dv

∫S(x− xp)dx = Npvp

using the parity of Sv. The end result of applying the firstorder moment in x is:

dxp

dt= vp (2.16)

Page 25: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.3 Derivation of the equations of motion 19

2.3.3 Moment 1v

The application of the first order moment in v, (< v·V lasov >)gives:

∂ < fpv >

∂t+

⟨v2

∂fp∂x

⟩+

⟨vqsE

ms

∂fp∂v

⟩= 0 (2.17)

The second term is still zero by virtue of integration over x,as in the case of the zeroth order moment. The first term hasalready been computed above. The remaining term must becomputed:∫

qsE

msdx

∫v∂fp∂v

dv = −∫

qsE

msdx

∫fsdv =

⟨qsE

msfs

⟩using again integration by part and the finite support of theelements.

The remaining integral defines a new important quantity,the average electric field acting on a computational particle,Ep: ⟨

qsE

msfs

⟩= −Np

qsms

Ep

where the electric field on a computational particle is:

Ep =

∫Sv(v − vp)dv

∫Sx(x− xp)E(x)dx (2.18)

Recalling the property of Sv, the formula for Ep simplifies to:

Ep =

∫Sx(x− xp)E(x)dx (2.19)

The first order moment in v gives the final equation:

dvpdt

=qsms

Ep (2.20)

Page 26: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

20 Mathematical Derivation of the PIC method

2.3.4 Equations of motion for the computationalparticles

The equations above give the following complete set of evo-lution equations for the parameters defining the functionaldependence of the distribution within each element:

dNp

dt= 0

dxp

dt= vp

dvpdt

=qsms

Ep

(2.21)

It is a crucial advantage of the PIC method that its evo-lution equations resemble the same Newton equation as fol-lowed by the regular physical particles. The key difference isthat the field is computed as the average over the particlesbased on the definition of Ep.

Naturally, the electric field is itself given by Maxwell’sequations which in turn need the charge density (and forcomplete models also the current density). The particle incell approach described above provides immediately the chargedensity as the integral over the velocity variable of the dis-tribution function:

ρs(x, t) = qs∑p

∫fp(x, v, t)dv (2.22)

Using the functional form for the distribution function ofeach computational element, the charge density becomes:

ρs(x, t) =∑p

qsNpSx(x− xp) (2.23)

The set of equations above provide a closed description forthe Vlasov equation. Once accompanied by an algorithm to

Page 27: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.4 Field Equations 21

solve Maxwell’s equations the full Vlasov-Maxwell systemcan be solved.

2.4 Field Equations

The solution of the field equations can be done with a widevariety of methods. The majority of the existing PIC meth-ods relies on finite difference or finite volume, a choice wefollow here to provide an example of the interfacing with thenumerical solution of the Poisson and Vlasov equations.

Assuming the finite volume approach, a grid of equal cellsof size ∆x is introduced with cell centres xi and cell verticesxi+1/2. The scalar potential is discretized by introducing thecell-averaged values ϕi. The discrete form of the field equa-tion is obtained by replacing the Laplacian operator (i.e. thesimple second derivative in 1D) with a corresponding dis-cretized operator.

In the simplest form, the Poisson’s equation can be dis-cretized in 1D using the classic three point formula:

ε0ϕi+1 − 2ϕi + ϕi−1

∆x2= −ρi (2.24)

where the densities ρi are similarly defined as average overthe cells:

ρi =1

xi+1/2 − xi−1/2

∫ xi+1/2

xi−1/2

ρ(x)dx (2.25)

A most convenient formulation of the density averagedover each cell can be obtained recalling the definition of theb-spline of order 0

∫ xi+1/2

xi−1/2

ρ(x)dx =

∫ ∞

−∞b0

(x− xi

∆x

)ρ(x)dx (2.26)

Page 28: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

22 Mathematical Derivation of the PIC method

and recalling the expression of the density:∫ xi+1/2

xi−1/2

ρ(x)dx =∑p

∫ ∞

−∞b0

(x− xi

∆x

)S(x− xp)dx (2.27)

The standard nomenclature of the PIC method defines theinterpolation function as:

W (xi − xp) =

∫Sx(x− xp)b0

(x− xi

∆x

)(2.28)

It is crucial to remember the distinction between the shapefunction and the interpolation function. The interpolationfunction is the convolution of the shape function with thetop hat function of span equal to the cell. The usefulness ofthe interpolation functions is that they allow a direct com-putation of the cell density without the need for integration.Defining the average cell density as, ρi =

∫ xi+1/2

xi−1/2ρ(x)dx/∆x,

it follows that:

ρi =∑p

qp∆x

W (xi − xp) (2.29)

where qp = qsNp.From the definition of the shape functions based on the

b-spline of order l, it follows that if the shape function Sx =1∆p

bl

(x−xp

∆p

)a very simple expression can be derived when

the particle size equals the cell size, ∆p = ∆x:

W (xi − xp) = bl+1

(xi − xp

∆p

)(2.30)

that follows trivially from the generating definition of the b-splines.

The solution of the Poisson equation can be conducted withthe Thomas algorithm given appropriate boundary condi-tions. Once the solution is obtained, the potential is knownin each cell, but in the form of the discrete values of the cell-

Page 29: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.5 Discretization of the equations of motion 23

averaged potentials ϕi. To compute the fields acting on theparticles, the field is needed in the continuum. A procedureis needed to reconstruct it.

First, the electric field is computed in the cell centres fromthe discrete potentials as:

Ei = −ϕi+1 − ϕi−1

2∆x(2.31)

where centred difference are used. Then the continuum elec-tric field is reconstructed using the assumption that the fieldis constant in each cell and equal to its cell-averaged value

E(x) =∑i

Eib0

(x− xi

∆x

)(2.32)

From the definition of Ep it follows that:

Ep =∑i

Ei

∫b0

(x− xi

∆x

)Sx(x− xp) (2.33)

and recalling the definition of interpolation function,

Ep =∑i

EiW (xi − xp) (2.34)

2.5 Discretization of the equations of motionThe equations of motion derived in paragraph 1.3.4 are sim-ple ordinary differential equations with the same form asthe regular Newton equations. Of course, in the literaturethere are many algorithms to achieve the goal of solving theNewton equations. For the PIC algorithm a efficient choice isto use simple schemes: given the very large number of par-ticles used (billions are now common in published works),the use of complex schemes may result in prohibitively longsimulations. However, if more advanced schemes allow one

Page 30: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

24 Mathematical Derivation of the PIC method

to use large time steps, the additional cost per time step maybe compensated by taking longer time steps.

The simplest algorithm and by far the most used in theso-called leap-frog algorithm based on staggering the timelevels of the velocity and position by half time step: xp(t =

n∆t) ≡ xnp and vp(t = (n + 1/2)∆t) ≡ v

n+1/2p . The advance-

ment of position from time level n to time level n+1 uses thevelocity at mid-point vn+1/2

p , and similarly the advancementof the velocity from time level n − 1/2 to n + 1/2 uses themid point position xn

p . This stepping of velocity over positionand position over velocity recalled some of the early usersof the children’s game bearing also the name leap-frog (seeFig. 2.2).

Fig. 2.2. Visual representation of the leap-frog algorithm.

The scheme is summarised by:

xn+1p = xn

p +∆tvn+1/2p

vn+3/2p = vn+1/2

p +∆tqsms

Ep(xn+1p )

(2.35)

where Ep is computed solving the Poisson equation from theparticle positions given at time level n.

Note that technically the leap-frog algorithm is second or-der accurate, when instead the regular explicit Euler-schemeis only first order. Nevertheless, the two differ in practiceonly for the fact that the velocity is staggered by half timestep. This staggering is achieved by moving the initial veloc-

Page 31: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.6 Recapitulation 25

ity of the first time cycle by half a time step using an explicitmethod:

v1/2p = v0p +∆tqsms

Ep(x0p)

2.6 RecapitulationCollecting the steps gathered so far, the PIC algorithm issummarised by the series of operations depicted in Fig. 2.3.

Particle moverFp -> Xp

Field SolverNg, Jg -> Eg, Bg

Particle -> GridXp -> Ng, Jg

Grid -> ParticleEg,Bg->Fp

Fig. 2.3. Summary of a computational cycle of the PIC method.

Page 32: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

26 Mathematical Derivation of the PIC method

Algorithm of the PIC method, electrostatic case in 1D

(i) The plasma is described by a number of computationalparticles having position xp, velocity vp and each repre-senting a fixed number Np of physical particles.

(ii) The equations of motion for the particles are advancedby one time step using,

xn+1p = xn

p +∆tvn+1/2p

vn+3/2p = vn+1/2

p +∆tqsms

En+1p

using the particle electric field from the previous timestep.

(iii) The charge densities are computed in each cell using:

ρi =∑p

qp∆x

W (xi − xp)

(iv) The Poisson equation is solved:

ε0ϕi+1 − 2ϕi + ϕi−1

∆x2= −ρi

and the electric field Ei in each cell is computed:

Ei = −ϕi+1 − ϕi−1

2∆x

(v) From the field known in the cells, the field acting on theparticles is computed as

En+1p =

∑i

EiW (xi − xn+1p )

which is used in the next cycle(vi) The cycle restarts.

The algorithm above is implemented in the MATLAB codeprovided. The b-spline of order 0 is used for the shape func-

Page 33: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

2.6 Recapitulation 27

tions and consequently of order 1 for the interpolation func-tion.

Page 34: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

3Practical Considerations in using the PIC

method

We consider here some of the most immediate issues relatedto the use of PIC methods.

3.1 StabilityThe first thing to consider in running a PIC code is a properchoice of the time step and of the grid spacing. The prob-lem has been studied theoretically in depth and a preciseunderstanding has been reached. We refer the reader to thetwo main textbooks on the topic for the derivations [BL04a,HE81]. Below we just summarize the results of the analysisthat provide a straightforward prescription that must be fol-lowed in every occasion. The time step needs to resolve bothlight-wave propagation and Langmuir wave propagation:

c∆t < ∆x (3.1)

ωpe∆t < 2 (3.2)

regardless to their relevance to the scale of interest. Thegrid spacing needs to resolve the electron Debye length toavoid the so-called finite grid instability due to the aliasingof different Fourier modes:

∆x < ςλDe (3.3)

28

Page 35: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

3.2 Conservation Laws 29

where ς is a constant of order 1 whose exact value dependson the choice of the interpolation and assignment functions.For the cloud in cell (CIC) choice, the value is ς ≈ π. In sum-mary the standard PIC method need to resolve the finestscales everywhere. For this reason a more advanced ap-proach called implicit moment method has been designed toremove this constraint, allowing the user to resolve just thescales of interest [LBR06a].

3.2 Conservation LawsThe PIC method described in the previous chapter conservesmomentum to machine precision. However, energy is notpreserved exactly. The fundamental reason is that in prac-tice the PIC method uses many particles per cell: there areinfinite particle configurations resulting in the same valueof the quantities projected to the grid. This degree of free-dom is what causes the finite grid instability and the lack ofexact energy conservation.

For explicit PIC codes, based on the algorithm describedabove, the energy needs to be monitored and the time stepand grid spacing need to be chosen sufficiently small as toconserve energy: satisfying the stability constraints is notenough. In practice usually the time step has to be less than1/10 of its stability limit and the grid spacing less than 1/3for energy to be conserved sufficiently. But the actual per-formance is problem dependent.

The implicit moment method solves this problem also, byenforcing a much better (but still not exact) energy conser-vation.

3.3 DiagnosticsThe great advantage of the PIC method is that it providesquantities very similar to those provided in a actual plasma

Page 36: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

30 Practical Considerations in using the PIC method

experiments: the user has both information on the distri-bution of the plasma particles and of the fields. Below wedescribe some of the most used diagnostics.

Typical particle diagnostics are:

• phase space plots (xp vs vp)• more complex phase space density plots where the phase

space is discretized in a grid of cells and the number ofparticles in each cell is counted to give the distributionfunction

• Velocity distribution functions (e.g. histogram of particlecounts in energy bins)

Typical field diagnostics are:

• plots of the fields (e.g. E, ϕ, ρ, . . .) versus space and/ortime

• FFT modes of the field quantities to measure growth ratesof specific modes.

Furthermore, information can be derived from integral quan-tities. Examples are: the total kinetic energy:

Ek =1

2

∑p

mpv2p (3.4)

the total momentum:

P =∑p

mpvp (3.5)

the total energy of the field:

EE = ∆x∑c

ε0E2

2≡ ∆x

∑c

ρϕ

2(3.6)

3.4 Normalisation and non-dimensional unitsIt is traditional in theoretical physics to use non-dimensionalunits to conduct the derivations. This practice is even more

Page 37: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

3.4 Normalisation and non-dimensional units 31

useful in computational physics as it can be used to makesure that the numbers remain close to order one, leading toa maximum accuracy of the finite-digits operations of com-puters.

Many methods to non-dimensionalize can be used. Oneexample is suggested here. Let us consider space and timefirst. To normalise together space and time, one plasma fre-quency (e.g. that of the electrons can be used) and the speedof light are used:

t′ = ωpet

`′ =ωpe`

c

resulting in times counted in periods of electron plasma wavesand lengths in electron inertial lengths de = c/ωpe.

The charge (or mass) can be normalised in units of charge(mass) in the unit cube: Q′ = Q/n0ed

3e (M ′ = M/n0med

3e).

All other quantities can be similarly derived from the unitlength, time, mass and charge of the normalised system.

In practice, the normalisation above corresponds in sim-plifying the expressions of the Vlasov-Maxwell system andof its discretization in the PIC method by choosing a num-ber of quantities as 1. In particular, choosing the charge,mass and reference density of the electrons unitary, e = 1,me = 1, ne = 1, leads to a unitary electron plasma frequency.If further, ε0 = 1 and µ0 = 1 (in SI or c = 1 in cgs), the othernormalisations of velocity, charge and mass follow.

Note that once these fundamental quantities are chose asunitary, all others must follow correctly. For example, ifme = 1, then mi = 1836 for hydrogen and similar for allother derived quantities.

Page 38: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

32 Practical Considerations in using the PIC method

3.5 Initial Loading

The PIC algorithm described in the previous chapter pro-vides a deterministic marching order where the positionsand velocities of the computational particles and the fieldsin the cells are advanced according to precise rules. Theserules require an initialisation based on an initial condition.

Given the initial state of the system a prescribed numberof computational particles need to be generated so that theyrepresent accurately the distribution function of the initialsystem. The operation of creating the initial particles is re-ferred to as particle loading. Two fundamental approachesare common: the random start and the quiet start.

Random starts are obtained using MonteCarlo methodsfor distribution sampling. The simplest case is the use ofthe function RAND of Matlab (or similar in other languages)to generate a uniform distribution. Similarly simple is thegeneration of a Maxwellian distribution using the Matlabfunction RANDN. In some languages a similar function isnot available but algorithms are easily available in the lit-erature or on the web to sample numbers from any distribu-tion function. Usually the initial distribution is the productof separate distributions in each direction of the six dimen-sional phase space.

Quiet starts are an attempt to reduce the noise and inde-termination of random starts. The phase space is coveredby a pattern of computational particles. Their statisticalweights (Np) or their distribution in space (in a non-uniformpattern) is chosen to reproduce the required distribution.For example, a sinusoidal distribution can be reproduced byputting more particles in the peaks and fewer in the valleys.Rigorous mathematical techniques have been developed todo this. However, the use of quiet starts is not common. Forthree reasons. First, the approach is rather more compli-cated formally than the random start. Second, the use of a

Page 39: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

3.6 Boundary Conditions 33

regular array of particles can lead to correlation among theparticles that have no equivalence in reality. Third, the noiseis only reduced briefly, and later in time the discrete natureof the particle representation reasserts itself reintroducinga noise. Nevertheless, in some instances quiet starts can beconsidered.

3.6 Boundary ConditionsTwo sets of boundary conditions are needed: for the fieldsand for the particles.

The field boundary conditions are the same as in any methodsolving the Maxwell equations. The particle boundary condi-tions can be chosen to best represent a physical system. Typ-ical examples are: reflection at a boundary, periodic (wherea particle exists one boundary and re-enters the oppositeboundary with the same speed), removal to represent a wall.

Injection is also a possibility, to impose a prescribed inflowof plasma. Injection is a similar process to particle injectionand it also can rely on deterministic methods (akin to quietstarts) or much more commonly on statistical methods (akinto random starts).

3.7 ExercisesAs a demo session, we suggest the following exercises:

(i) Start from the skeleton MATLAB code provided andadd the following diagnostics:

• History of kinetic and potential energy• History of the total momentum• History of the thermal energy (using the cov func-

tion of MATLAB)• Fourier modes at a given time• History of selected Fourier modes

Page 40: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

34 Practical Considerations in using the PIC method

• Distribution of the particle velocities at a given time• Phase space scatter plot of the particles• Plot of the potential and electric field at a given

time• Space-time plot of the potential and electric field• Phase-space density plot

(ii) Consider a uniform maxwellian plasma and try to ex-ceed, separately, ωpe∆t < 2 and λDe∆x < π. Whathappens to the energy and the particle scatter plot inphase space?

(iii) Consider the same plasma and add a initial sinusoidalperturbation of the particle position. What happensto the energy, and to the Fourier mode with he samewavelength as the initial perturbation? What hap-pens to the phase space? What is the process develop-ing?

(iv) Consider next two beams with a small thermal spreadand two opposite velocities. The systems undergoesthe two-stream instability. Its dispersion relation is:

D(k, ω) = 1−ω2pe

2

[1

(ω − kv0)2+

1

(ω + kv0)2

]• Design a simulation box with length equal to the

wavelength of maximum growth (k = kM ). Run thesimulation and consider the evolution of the Fouriermodes. What happens to the mode supposed to bethe fastest? And what to the Fourier mode with halfthe wavelength (i.e. k = 2kM )?

• Double the simulation box. What happens if youexice the mode k = kM , compared with the modek = kM/2?

• Let a simulation run for a long time, until the en-ergy saturates. What happens to the velocity distri-bution as time progresses?

Page 41: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4Explicit Particle Simulations of Space

Weather

According to the definition used by the U.S. National SpaceWeather Strategic Plan [spa], space weather refers to con-ditions on the sun and in the solar wind, magnetosphere,ionosphere, and thermosphere that can influence the perfor-mance and reliability of space-borne and ground-based tech-nological systems and can endanger human life or health.Adverse conditions in the space environment can cause dis-ruption of satellite operations, communications, navigation,and electric power distribution grids, leading to a variety ofsocioeconomic losses. The topic of space weather is becom-ing ever more important for its societal impact and great na-tional and international efforts are being devoted to it [BD07].

Simulating space weather means literally simulating themagnetized plasma that permeates the whole solar system.A daunting task. Daunting because plasma physics includesa wide variety of space and temporal scales. A plasma ismade of a collection of ionised atoms (nuclei), and electronsinteracting via electric and magnetic fields. Near the Sungravity plays a role too. At the core of the space weathersimulation issue stands the vast gap between the electronand ion scales. An electron is 1836 times lighter than itsnucleus in an hydrogen atom. This simple physical fact cre-ates a great challenge in modeling the small electron scales

35

Page 42: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

36 Explicit Particle Simulations of Space Weather

embedded into solar system sized problems. For example,Fig. 4.1 shows the typical electron and ion scales observed insatellite crossing of the Earth magnetosphere (the magneto-tail to be specific) [Kal98]. The scales are presented in theform of a hourglass with the top part presenting the macro-scopic scales of evolution of the Earth magnetotail that dur-ing quiescent times can be 10,000 km thick but at interestingtimes becomes as thick as the ion inertial length, di or 1000km. The ion scales are smaller and the electron scales muchsmaller, down to 100 m corresponding to typical electron De-bye lengths. Similarly in time, the overall evolution of spaceweather events requires simulating hours, if not days, butthe ion responses are on the scale of seconds to millisecondsand the electrons respond on scales of multiples of microsec-onds.

Simulating days of evolution of the plasma in the solarsystem with a time step of microseconds and with a resolu-tion of 100 m is simply not possible and it will not be possi-ble for a long time to come. The present paper reviews theefforts to overcome this problem and allow a simulation ofspace weather events at the particle level, retaining the fullkinetic and electromagnetic treatment of the plasma.

Traditionally, the impossibility to resolve all scales has ledto the use of fluid (MHD or more advanced models such asHall-MHD and two-fluid) or hybrid methods where the elec-trons are described as a fluid while the ions are kinetic [Lip02].However, such reduced models loose the ability to capturethe dissipation processes at the electron scales. Importantexamples for space weather are the regions of large energyreleases such as shocks and reconnection regions where smallscale processes at the ion and electron particle scale are keyin determining the production of high energy particles (suchas the solar energetic particles in the cosmic rays [BD07])and in allowing macroscopic changes in the magnetic fieldconfiguration (e.g. magnetic reconnection during solar flares

Page 43: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.1 Derivation of the Particle Method 37

and coronal mass ejections [Asc05] or in the Earth environ-ment during magnetic storms and substorms [Kal98]).

We review in the present chapter and the next the fullkinetic models based on the particle in cell (PIC) simulationtechnique. Chapter 4 expands to the general case the deriva-tion of the mathematical foundations of the PIC method pre-sented above, in a manner that helps identify the strengthsand weaknesses for the application to space weather. Thefocus next go on the explicit time discretisation of PIC meth-ods and highlights the severe limitations of this approachwhen applied to space weather. Additional information isprovided about the technical aspects of applying the explicittechnique and developing codes based on it.

Chapter 5 introduces a different approach, that of implicittime differencing in PIC methods, an approach particularlysuitable to space weather applications. The approach is notnew but it is reviewed here especially in light of its more re-cent space weather applications. For this reason, we reviewin Section 6 the general idea of implicit PIC and provide inthe subsequent sections its two possible implementations:fully implicit, requiring a solution of a set of non-linearlycoupled equations and semi-implicit where the coupling islinearised and made more manageable. An introduction isgiven of the recent developments in fully implicit PIC. Thisarea is in its infancy with just a few initial works done but itis perhaps the most promising area of research in this fieldand it has been included despite the lack of a strong previousliterature. Section 8 reviews the much more mature field ofsemi-implicit PIC methods.

4.1 Derivation of the Particle MethodAs a key step in the study of the more advanced applica-tions of PIC methods, we lay first the mathematical ground-work for the formulation of the particle in cell method start-

Page 44: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

38 Explicit Particle Simulations of Space Weather

Fig. 4.1. Visual representation of the typical scales observed in theEarth environment (conditions common in the magnetotail).

ing from the mathematical continuous problem, the Vlasov-Maxwell system. The assumption is made in the derivationsthat classical physics applies, but the extension to specialrelativity is straight-forward. The classic textbooks [HE88,BL04b] report a heuristic derivation based on the physicalproperties of a plasma. Instead, we consider here a differ-ent approach aimed at making a clear mathematical linkbetween the continuous Vlasov-Maxwell description of theplasma and its numerical solution.

The phase space distribution function fs(x,v, t) for a givenspecies s (electrons or ions), defined as the number densityper unit element of the phase space (or the probability offinding a particle in a dx and dv around a certain phase

Page 45: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.1 Derivation of the Particle Method 39

space point (x,v)), is governed by the Vlasov equation:

∂fs∂t

+ v · ∂fs∂x

+qsms

(E+ v ×B) · ∂fs∂v

= 0 (4.1)

where qs and ms are the charge and mass of the species, re-spectively. The derivatives are written in the standard vec-tor notation in the 3-dimensional configuration space x and3-dimensional velocity space v, forming together the classi-cal phase space.

The electric and magnetic fields are given by the two curlMaxwell’s equations,

∇×E = −∂B

∂t

∇×B = µ0ε0∂E

∂t+ µ0j

(4.2)

supplemented by the two divergence equations:

ε0∇ ·E = ρ

∇ ·B = 0

(4.3)

where the net charge density is computed from the distribu-tion functions as:

ρ(x, t) =∑s

qs

∫Vfs(x,v, t)dv (4.4)

and the current density as:

j(x, t) =∑s

qs

∫Vvfs(x,v, t)dv (4.5)

where V is the velocity space.

4.1.1 Discretisation of the Distribution FunctionThe PIC method can be regarded as a finite element approachbut with finite elements that are themselves moving and

Page 46: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

40 Explicit Particle Simulations of Space Weather

overlapping. The mathematical formulation of the PIC methodis obtained by assuming that the distribution function ofeach species is given by the superposition of several ele-ments (called computational particles or superparticles):

fs(x,v, t) =∑p

fp(x,v, t) (4.6)

Each element represents a large number of physical parti-cles that are near each other in phase space. For this reason,the choice of the elements is made in order to be at the sametime physically meaningful (i.e. to represent a bunch of par-ticles near each other) and mathematically convenient (i.e.to allow the derivation of a manageable set of equations).

The PIC method is based upon assigning to each computa-tional particle a specific functional form for its distribution,a functional form with a number of free parameters whosetime evolution will determine the numerical solution of theVlasov equation. The choice is usually made to have two freeparameters in the functional shape for each spatial dimen-sion. The free parameters will acquire the physical meaningof position and velocity of the computational particle. Thefunctional dependence is further assumed to be the tensorproduct of the shape in each direction of the phase space:

fp(x,v, t) = NpSx(x− xp(t))Sv(v − vp(t)) (4.7)

where Sx and Sv are the shape functions for the computa-tional particles and Np is the number of physical particlesthat are present in the element of phase space representedby the computational particle.

A number of properties of the shape functions come fromtheir definition:

(i) The support of the shape functions is compact, to de-scribe a small portion of phase space, (i.e. it is zerooutside a small range).

Page 47: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.1 Derivation of the Particle Method 41

(ii) Their integral over the domain is unitary:∫Vξ

Sξ(ξ − ξp)dξ = 1 (4.8)

where ξ stands for any coordinate or any velocity di-rection.

(iii) While not strictly necessary, Occam’s razor suggeststo choose symmetric shapes:

Sξ(ξ − ξp) = Sξ(ξp − ξ) (4.9)

While these definitions still leave very broad freedom inchoosing the shape functions, traditionally the choices actu-ally used in practice are very few.

4.1.2 Selection of the particle shapesThe standard PIC method is essentially determined by thechoice of Sv, the shape in the velocity direction, as a Dirac’sdelta in each direction:

Sv(v − vp) = δ(vx − vxp)δ(vy − vyp)δ(vz − vzp) (4.10)

This choice has the fundamental advantage that if all par-ticles within the element of phase space described by onecomputational particle have the same speed, they remaincloser in phase space during the subsequent evolution.

The original PIC methods developed in the 50’s were basedon using a Dirac’s delta also as the shape function in space.But now for the spatial shape functions, all commonly usedPIC methods are based on the use of the so-called b-splines.The b-spline functions are a series of consecutively higherorder functions obtained from each other by integration. Thefirst b-spline is the flat-top function b0(ξ) defined as:

b0(ξ) =

1 if |ξ| < 1/2

0 otherwise(4.11)

Page 48: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

42 Explicit Particle Simulations of Space Weather

The subsequent b-splines, bl, are obtained by successive in-tegration via the following generating formula:

bl(ξ) =

∫ ∞

−∞dξ′b0(ξ − ξ′)bl−1(ξ

′) (4.12)

Figure 4.2 shows the first three b-splines.

−2 −1.5 −1 −0.5 0 0.5 1 1.5 20

0.5

1

b 0(ξ)

−2 −1.5 −1 −0.5 0 0.5 1 1.5 20

0.5

1

b 1(ξ)

−2 −1.5 −1 −0.5 0 0.5 1 1.5 20

0.5

1

ξ

b 2(ξ)

Fig. 4.2. First three b-spline functions.

Based on the b-splines, the spatial shape function of PICmethods is chosen as:

Sx(x−xp) =1

∆xp∆yp∆zpbl

(x− xp

∆xp

)bl

(y − yp∆yp

)bl

(z − zp∆zp

)(4.13)

where ∆xp, ∆yp and ∆zp are the lengths of the support ofthe computational particles (i.e. its size) in each spatial di-mension. A few PIC codes use splines of order 1 but the vastmajority uses b-splines of order 0, a choice referred to as

Page 49: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.1 Derivation of the Particle Method 43

cloud in cell because the particle is a uniform square cloudin space with infinitesimal span in the velocity directions.

4.1.3 Derivation of the equations of motionTo derive the evolution equations for the free parameters xp

and vp, we require the first moments of the Vlasov equationto be exactly satisfied by the functional forms chosen for theelements. This procedure requires some explanation. First,the Vlasov equation is formally linear in fs and the equationsatisfied by each element is still the same Vlasov equation.The linear superposition of the elements gives the total dis-tribution function and if each element satisfies the Vlasovequation, the superposition does too. A caveat, the fields re-ally depends on fs making the Vlasov equation non-linear.As a consequence the fields used in each Vlasov equation foreach element must be the total fields due to all elements, thesame entering the complete Vlasov equation for fs:

∂fp∂t

+ v · ∂fp∂x

+qsms

(E+ v ×B) · ∂fp∂v

= 0 (4.14)

Second, the arbitrary functional form chosen for the el-ements does not satisfy exactly the Vlasov equation. Theusual procedure of the finite element method is to requirethat the moments of the equation be satisfied, instead. Themoments of the Vlasov equation are obtained multiplyingby powers of x and v and integrating. We indicate the inte-gration over the spatial and velocity domain by the symbol< . . . >≡

∫dx∫dv.

4.1.3.1 Moment 0

The zeroth order moment (< V lasov >) gives:

∂ < fp >

∂t+

⟨v · ∂fp

∂x

⟩+

⟨qsms

(E+ v ×B) · ∂fp∂v

⟩= 0 (4.15)

Page 50: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

44 Explicit Particle Simulations of Space Weather

where we used the interchangeability of the integration indxdv and of the derivation over time. The second and thirdterm are zero because fp has finite support and vanishes atinfinity in the coordinate space and in velocity. Note that thethird term vanishes only because all terms of v × B do notinclude the same component of v as the partial derivativethey multiply. Recalling that < fp >= Np, it follows:

dNp

dt= 0 (4.16)

The application of the zeroth order moment leads to theestablishment of the conservation of the number of physicalparticles per computational particle.

4.1.3.2 Three first order spatial moments

The application of the first order moment in x, (< x·V lasov >),that implies the use of vector notation to treat simultane-ously three equations for each spatial coordinate, gives:

∂ < fpx >

∂t+

⟨xv · ∂fp

∂x

⟩+

⟨xqsms

(E+ v ×B) · ∂fp∂v

⟩= 0

(4.17)The last term is still zero by virtue of integration over v, theother terms, instead, are new. The first term is:

< fpx >= Np

∫Sv(v − vp)dv

∫xS(x− xp)dx (4.18)

where the first integral is 1 by definition of Sv as a functionof unitary integral and the second expresses the first ordermoment of Sx. Recalling the assumption of symmetry of Sx,that moment equals xp:

< fpx >= Npxp (4.19)

The middle term of eq.(4.17) requires the integration of:∫ ∫x

(vx

∂fp∂x

+ vy∂fp∂y

+ vz∂fp∂z

)dxdv (4.20)

Page 51: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.1 Derivation of the Particle Method 45

When integrated all terms vanish, except that with the deriva-tive in the same direction as the moment. For example in thex direction, only the first term remains,∫ ∫

xvx∂fp∂x

dxdv = −∫ ∫

vxfpdxdv = −Np < vx > (4.21)

where the finite support of fp, integration by part and thesymmetry of Sv have been used. Using vector notation, themiddle term of eq.(4.17) leads to∫ ∫

x

(vx

∂fp∂x

+ vy∂fp∂y

+ vz∂fp∂z

)dxdv = −Npvp (4.22)

The end result of applying the first order moment in x is:

dxp

dt= vp (4.23)

4.1.3.3 Three first order velocity moments

The application of the first order moment in v, (< v·V lasov >)gives:

∂ < fpv >

∂t+

⟨vv

∂fp∂x

⟩+

⟨vqsms

(E+ v ×B) · ∂fp∂v

⟩= 0

(4.24)The first term is computed in analogy to the first term inthe spatial moments. The second term is still zero by virtueof integration over x. The remaining term can be computedas above, recalling that all terms of v×B do not include thesame component of v as the partial derivative they multiply:∫ ∫

vqsms

(E+v×B)·∂fp∂v

dxdv = −∫ ∫

qsms

(E+v×B)fpdxdv

(4.25)using again integration by part and the finite support of theelements.

The resulting integral defines two new important quanti-ties, the average electric field and magnetic field acting on a

Page 52: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

46 Explicit Particle Simulations of Space Weather

computational particle:∫ ∫qsms

(E+ v×B)fpdxdv = −Npqsms

(Ep + vp ×Bp) (4.26)

where the electric field on a computational particle is:

Ep =

∫Sv(v − vp)dv

∫Sx(x− xp)E(x)dx (4.27)

Recalling the property of Sv, the formula for Ep simplifies to:

Ep =

∫Sx(x− xp)E(x)dx (4.28)

For the magnetic field,∫ ∫qsms

v ×Bfpdxdv =

qsms

∫vSv(v − vp)dv ×

∫Sx(x− xp)B(x)dx

(4.29)

resulting in:

Bp =

∫Sx(x− xp)B(x)dx (4.30)

The first order moment in v gives the final equation:

dvp

dt=

qsms

(Ep + vp ×Bp) (4.31)

4.1.4 Equations of motion for the computationalparticles

The equations above give the following complete set of evo-lution equations for the parameters defining the functionaldependence of the distribution within each element:

Page 53: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.1 Derivation of the Particle Method 47

dNp

dt= 0

dxp

dt= vp

dvp

dt=

qsms

(Ep + vp ×Bp)

(4.32)

It is a crucial advantage of the PIC method that its evolu-tion equations resemble the same Newton equations as fol-lowed by the regular physical particles. The key difference isthat the field is computed as average over the shape functionbased on the definition of Ep and Bp.

Naturally, the electric field is itself given by Maxwell’sequations which in turn need the charge density and the cur-rent density. The particle in cell approach provides them im-mediately as integrals of the distribution function over thevelocity variable. Using the functional form for the distribu-tion function of each computational element, the charge andcurrent densities become:

ρs(x, t) =∑p

qsNpSx(x− xp)

js(x, t) =∑p

qsNpvpSx(x− xp)

(4.33)

The set of equations above provide a closed description forthe Vlasov equation. Once accompanied by an algorithm tosolve Maxwell’s equations the full Vlasov-Maxwell systemcan be solved.

In summary, the particle method, as derived above, is afinite-element-like discretisation of phase space. The contin-uum distribution function is replaced by a discrete mathe-matical representation provided by the superposition of mov-ing fixed-shape elements. The pitfalls of this representation

Page 54: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

48 Explicit Particle Simulations of Space Weather

have been studied in depth in the past. A full discussion ofthis aspect is beyond the scope of the present review. Werefer the reader to [BL04b, HE88] for additional comments.In extreme summary, a element of phase space initially de-scribed correctly by the shape functions chosen for the dis-cretisation would be distorted by non-uniform electric andmagnetic fields. Instead, the computational particles havefixed shape and neglect this effect. This approximation in-troduces of course an error that can be interpreted as a modi-fication of the phase space. It would be misleading to confusethis error with numerical diffusion, the distortion of phasespace does not lead to any spatial propagation of informa-tion, as the Liouville theorem insures the conservation ofthe phase-space volume of each element, a process that isstill correctly described by the discretised system. Alterna-tives to PIC have been developed to remove this error byintroducing additional degrees of freedom for each compu-tational element (superparticles) [CLD+96, BH98]. The ad-ditional degrees of freedom can describe the particle shapeand represent its distortion in phase space. However, theadditional complexity of such methods have so far preventedtheir widespread use.

4.2 Explicit Temporal Discretisation of the ParticleMethods

The equations of motion for the computational particles aresimple ordinary differential equations with the same formas the regular Newton equations. Of course, in the literaturethere are many algorithms to achieve the goal of solving theNewton equations. For the PIC algorithm a efficient choiceis to use simple schemes: given the very large number ofparticles used (billions are now common in published works),the use of complex schemes may result in prohibitively longsimulations. However, if more advanced schemes allow one

Page 55: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.2 Explicit Temporal Discretisation of the Particle Methods49

to use large time steps, the additional cost per time step maybe compensated by taking longer time steps [JH06].

The simplest algorithm and by far the most used is theso-called leap-frog algorithm based on staggering the timelevels of the velocity and position by half time step: xp(t =

n∆t) ≡ xnp and vp(t = (n + 1/2)∆t) ≡ v

n+1/2p . The advance-

ment of position from time level n to time level n+1 uses thevelocity at mid-point vn+1/2

p , and similarly the advancementof the velocity from time level n−1/2 to n+1/2 uses the midpoint position xn

p . This stepping of velocity over position andof position over velocity gives the method its name for itsresemblance to the children’s game bearing the same name(see Fig. 4.3).

Fig. 4.3. Visual representation of the leap-frog algorithm. The timediscretisation is staggered, with the electric field, charge densityand particle positions at integer times and the magnetic field, cur-rent and particle velocity at half time steps.

The scheme is summarized by:

xn+1p − xn

p

∆t= vn+1/2

p

vn+1/2p − v

n−1/2p

∆t=

qsms

Ep(xnp ) +

qsms

(vn+1/2p + v

n−1/2p

2

)×Bp(x

np )

(4.34)where the use of Ep and Bp implies knowing the solution ofMaxwell’s equations given the particle positions at time leveln. The first equation is clearly explicit, the second is triv-

Page 56: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

50 Explicit Particle Simulations of Space Weather

ially formulated explicitly as a roto-translation of the vectorvn+1/2p [BL04b].Note that technically the leap-frog algorithm is second or-

der accurate, when instead the regular explicit Euler-schemeis only first order. Nevertheless, the two differ in practiceonly for the fact that the velocity is staggered by half timestep. This staggering is achieved by moving the initial veloc-ity of the first time cycle by half a time step using an explicitmethod:

v1/2p − v0

p

∆t/2=

qsms

Ep(x0p) +

qsms

(v1/2p + v0

p

2

)×Bp(x

0p) (4.35)

4.2.1 Stability of Explicit Time DifferencingThe discretisation of the equations of motion using the leap-frog algorithm (or other similar explicit time differencing)introduces a stability constraint. As usual stability can bestudied with the Von Neumann analysis [MM95, HE88, BL04b]:the equations are linearized and their stability is studied byFourier analysis. Note that the leap-frog algorithm is im-plicit in the Lorentz force term, but explicit on the electricforce. As a consequence only the latter is of primary concernand stability can be studied in the limit of zero magneticfield. Assuming a linear (harmonic) dependence of the elec-tric field,

qsms

Ep(xp) = −Ω2xp (4.36)

the Von Neuman analysis searches for solutions of the formxnp = xpe

iωN t and vnp = vpe

iωN t with the numerical responseof the system given by ωN . Simple algebraic manipulations [HE88,BL04b] lead to: (

Ω∆t

2

)2

= sin2(ωN∆t

2

)(4.37)

Page 57: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.3 Space-Time Discretisation of the Field Equations 51

Notoriously the sin function of real arguments has valuesonly in the [−1, 1] interval. As a consequence, for any valuesof Ω∆t > 2, the Von Neuman analysis leads to a complex nu-merical oscillation frequency, ωN . Indeed being the problemreal to begin with, two complex conjugate solutions arise.The numerical solution becomes unstable, with a numericalgrowth rate that has no physical equivalence. In practice,the particles heat unboundedly and quickly and the simula-tion fails within a few time steps.

The first cardinal rule of explicit plasma simulation is thatthe condition Ω∆t > 2 should never be violated, for any typ-ical Ω in the system. Indeed, practice advises the use of aconsiderably smaller time step of order Ω∆t = .1, to avoidnumerical heating [BL04b].

The temporal stability constraint produces a first greatchallenge to the application of particle methods in space weathersimulation (but also in most other applied plasma physicsproblems). As noted above, the range of time scales typicalof space weather events is tremendous. What the stabilityconstraint imposes is to choose a time step that is able toresolve with a cadence of about 1/10 the fastest frequencyin the system. For space weather applications (see Fig.4.1)this is commonly the electron plasma frequency, at least 5-7orders of magnitude smaller than the typical scales of evolu-tion of space weather phenomena.

4.3 Space-Time Discretisation of the Field EquationsSo far the attention has focused on the particle discretisationof the Vlasov part of the Vlasov-Maxwell system. To com-plete the simulation method, the Maxwell’s equations needto be discretised in space and time.

A wide variety of methods have been developed to do so.Essentially all methods for general electromagnetics can becoupled with particle methods [HE88, BL04b, GVF05]. Nearly

Page 58: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

52 Explicit Particle Simulations of Space Weather

every particle code uses (vastly or slightly) different methodsfrom any other particle code. Below, some general consider-ations are made, applicable to most if not all of the methodsin the literature.

The Maxwell’s equations require two inputs, the sourcesρ and j that come from the information carried by the parti-cles. In turn, the outputs are the electric and magnetic fields(or, equivalently the vector and scalar potential). The mainconcern here is the coupling of Maxwell’s equations with theparticles and its consequences.

We assume that the fields are known at grid points, notnecessarily the same for both fields and are defined as pointvalues or averages over control volumes: Eg, Bg where theindex g labels the discrete points (possibly different for elec-tric and magnetic field). Similarly, we assume that the cho-sen Maxwell scheme needs the sources at (possibly different)discrete grid points defined as averages over control volumesVg defining each discrete point:

ρg =∑s

qsVg

∫V

∫Vg

fdvdx

jg =∑s

qsVg

∫V

∫Vg

vfdvdx

(4.38)

Recalling eq.(4.6-4.7), the computation of the sources forMaxwell’s equations require computing a 3-dimensional in-tegral of the particle shape over the control volume of eachgrid point:

ρg =∑p

1

Vg

∫Vg

Sx(x− xp)dx

jg =∑p

vp1

Vg

∫Vg

Sx(x− xp)dx

(4.39)

where the integrations in velocity space were done easily re-

Page 59: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.3 Space-Time Discretisation of the Field Equations 53

calling the definition of Sv. The integral in space is straight-forward but can involve complicated geometric operationsif one allows general shapes for the control volumes. Forthis reason, the vast majority of PIC methods use an astutechoice of the particle shapes and of the control volumes tosimplify this effort. If the particle shapes are chosen as ineq. (4.13) and the grid is chosen uniform, Cartesian andwith cell sizes in each dimension equal to the particle sizes,a simple and elegant reformulation of the integration stepcan be obtained recalling property (4.12) of b-splines. Eachdimension can be done separately thanks to the choice ofCartesian uniform grid and of the shape of particles as prod-ucts of shapes in each direction. The integral needed in eachdirection can be reformulated as∫

∆xg

Sx(x− xp) =

∫ ∞

−∞Sx(x− xp)b0

(x− xg

∆xg

)(4.40)

where ∆xg is the interval in x relative to control volume Vg.Choosing, ∆xg = ∆xp (called simply ∆x), recalling the defi-nition of Sx, eq. (4.13) and using eq. (4.12):∫ ∞

−∞Sx(x− xp)b0

(x− xg

∆x

)= bl+1

(xg − xp

∆x

)(4.41)

Collecting the integral in each direction, the so-called inter-polation function can be defined:

W (xg − xp) = bl+1

(xg − xp

∆x

)bl+1

(yg − yp∆y

)bl+1

(zg − zp∆z

)(4.42)

The interpolation functions are a direct consequence of thechoice made for the shape functions. Using the b-splinesproves a powerful choice as it allows to write the interpola-tion functions just as b-splines one order higher. The cal-culation of the source for Maxwell’s equations becomes thenjust the sum of a number of function evaluations withoutrequiring geometrically complex integrals:

Page 60: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

54 Explicit Particle Simulations of Space Weather

ρg =1

Vg

∑p

qpW (xg − xp)

jg =1

Vg

∑p

qpvpW (xg − xp)

(4.43)

An analogous set of operations can be carried out for con-necting the output of the Maxwell’s equations to the particleequations of motion. The needed quantities are the electricand magnetic fields derived above in eq. (4.27,4.30). Thedefinitions for the particle fields require continuum fields.These can be obtained once again using interpolation:

E(x) =∑g

EgSE(x− xg)

B(x) =∑g

BgSB(x− xg)

(4.44)

where SE(x−xg) and SB(x−xg) are the fields interpolationfunctions. Upon substitution in the definition of the particlefields,

Ep =∑g

∫Sx(x− xp)EgSE(x− xg)dx

Bp =∑g

∫Sx(x− xp)BgSB(x− xg)dx

(4.45)

The geometrical complexity of the integrals can be avoidedchoosing the interpolation functions for the electric and mag-netic fields as b-splines of order 0:

SE,B(x− xg) = b0

(xg − xp

∆x

)b0

(yg − yp∆y

)b0

(zg − zp∆z

)(4.46)

Page 61: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.3 Space-Time Discretisation of the Field Equations 55

leading to

Ep =∑g

EgW (xg − xp)dx

Bp =∑g

BgW (xg − xg)dx

(4.47)

with the same interpolation function used for the sources.While the vast majority of schemes follows the choice of

b-splines and uniform grids, more advanced schemes havealso been considered. The cell positions can be chosen dif-ferently for different fields and different sources. Staggeredschemes and Yee lattices are commonly used [SB91, TH05].Also different order of interpolations can be used for differ-ent quantities [VB92]. A more radical solution is to considernon-uniform or even unstructured grids (see Sect. 5.3). Inthis case the interpolation cannot use the b-spline propertiesand the convenient definition of interpolation function. Nev-ertheless, the integral definitions above still hold and onecan base the computation of sources and fields using directlythe integral definition.

4.3.1 Space Resolution and Finite Grid InstabilityThe introduction of a grid to compute the field characterizesthe particle methods for plasma physics as particle in cell(PIC) methods. The particles move in a continuum space,but their information is projected to grid points using in-tegration over control volumes. This operation reduces theinformation, collapsing the continuum particle shapes to dis-crete contributions in a set of points (the grid values). Theloss of information allows one numerical instability to creepin: the finite grid instability.

The mathematical study of the finite grid instability iscomplex, requiring a careful and complete analysis of all

Page 62: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

56 Explicit Particle Simulations of Space Weather

computational steps with the Laplace transformation of timeand the Fourier transformation of space. The reader inter-ested in the details is referred to the textbooks on the sub-ject [BL04b, HE88] and to the original work cited therein.The summary of the analysis is that to avoid the finite gridinstability in explicit particles methods, the grid spacing mustbe chosen to satisfy the constraint

∆x/λDe < ς (4.48)

where λDe is the Debye length and the parameter ς is oforder one and depends on the details of the implementation.For the widely used choice of shape functions as b-spline oforder 0 and consequently interpolation functions of order 1,the scheme referred to as cloud in cell (CIC), the literaturereports, ς ≈ π.

The practical consequence of the finite grid instability is atremendous numerical heating of the plasma characterizedby an alternatively positive-negative variation of the electricfield accompanied by a correlated zig-zag perturbation of thephase-space. Within a few cycles, the energy reaches thebounds of overflow in the machine representation of num-bers. The finite grid instability must be avoided at all costs,requiring its stability constraint to be respected everywherein the domain for all directions.

The consequences of this stability constraint for space weathersimulations are devastating. The spatial scale to resolve isthe Debye length in the highest density region of the do-main where the Debye length is smallest. If using uniformgrids, this constraint requires to use cell sizes several ordersof magnitude smaller than the scales of interest. Note thatthis consideration has two sides.

First, often the processes of interest do not reach down tothe Debye scale. For example most reconnection events inspace are dominated by processes that are on the electroninertial length, de = c/ωpe. This scale is still two orders of

Page 63: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.3 Space-Time Discretisation of the Field Equations 57

magnitude larger than the Debye length. Having to resolvethe Debye length purely for numerical stability reasons im-plies a waste of fully 2 orders of magnitude in each direction,or 106, a million times. If the time scale constraint encoun-tered before hits the explicit approach once, the spatial sta-bility constraint hits it three times, once per spatial dimen-sion. The combined effect of these two constraint makes itimperative to look beyond explicit particle methods.

Second, often space plasmas present regions of high den-sity in contact with regions of lower density, resulting in alarge range of Debye lengths. To avoid the finite grid insta-bility, uniform grids need to be chosen to resolve the smallestDebye length in the system. Adaptive schemes can be de-vised to resolve in each region only the local Debye length,resulting in considerable savings [FS08]. However, even inthis case, often the local scales of interest are much largerthan the Debye length and the local grid resolution wouldbe more desirably chosen according to other considerationthan the need to resolve the Debye length.

4.3.2 Time Discretisation of Maxwell’s equationsThe most common discretisation in space locates the elec-tric and magnetic fields and the particle charges and cur-rents at different locations. The Yee lattice in Fig. 4.4 findsby far the widest application but alternative approaches arewidespread. Many approaches are based on finite differ-ences [BL04b, HE88] or finite volume [SB91]. The electricfield and currents are vertex-centered while the magneticfield and the density are cell-centered. Finite element ap-proaches have also been considered [JH06].

Even when the sources are assumed to be known from theexplicit particle approach (i.e. are taken from the previoustime step), still the Maxwell’s equations are a linear coupledsystem for the fields. Whatever the scheme followed, the

Page 64: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

58 Explicit Particle Simulations of Space Weather

Fig. 4.4. Location of the electromagnetic fields in a typical PICmethod based on the Yee lattice discretisation. The current den-sity jg is collocated with the electric field. The explicit PIC does notdirectly use the charge density, except for divergence cleaning (seetext), and for that the charge density ρg and the correction poten-tial δϕg are located on the vertices (i, j, k).

fields on the discrete grid points will be obtained by numeri-cally discretising the Maxwell’s equations that are linear inthe fields:

M(

Eg

Bg

)=

(ρgjg

)(4.49)

where the matrix M summarizes the linear coupling of theelectric and magnetic fields. In the simplest approach theMaxwell’s equations are discretised explicitly. The leap-frogalgorithm is used again (see Fig. 4.3). The current and themagnetic field are computed at the half time steps: Bn+1/2,jn+1/2 and the electric field and the density are computedat the integer time step: En, ρn. A time centered marchingalgorithm follows simply. The magnetic field is computedfrom the ∇×E Maxwell’s equation:

Bn+1/2 = Bn−1/2 −∆t∇×En (4.50)

and the electric field is computed over a time interval half-

Page 65: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.3 Space-Time Discretisation of the Field Equations 59

shifted:

En+1 = En +∆t

µ0ε0

(∇×Bn+1/2 − µ0j

n+1/2)

(4.51)

The same simple marching order used for the particles canbe used also for the fields resulting in a exceeding simpleapproach. However, the use of an explicit scheme within thefield solver introduces an additional stability constraint: theCourant–Friedrichs–Lewy (CFL) [MM95] condition on thepropagation of electromagnetic waves: c∆t < ∆x.

This limitation is intrinsic to the Maxwell’s equations andcan be removed by discretising implicitly just the linear partof the equations. The coupling with the plasma can still betreated explicitly, i.e. the sources are kept frozen to theirvalue at the beginning of the time step, but the coupling be-tween the two curl Maxwell’s equations is kept implicitly.Again many methods can be applied. In practice (for histori-cal more than practical reasons), the method of Ref. [MN71]based on the potential formulation is used in most codeswhere only the field solve is done implicitly but the parti-cle part is still explicit. Instead, the second-order implicitformulation of the Maxwell’s equations based on the electricfield derived in Ref [RLB02b] is used in codes where also theparticles are treated implicitly.

It is worth insisting on the fact that removing the CFLcondition on the light waves has no impact on the other twoconstraints that remain in place as long as the particle partof the algorithm and its coupling with Maxwell’s equationsis done explicitly.

So far the attention has focused on the two curl Maxwell’sequations. In the continuum, the other two divergence con-ditions are automatically satisfied at all times provided thatthey are satisfied at the initial time and requiring that de-

Page 66: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

60 Explicit Particle Simulations of Space Weather

tailed charge conservation is satisfied:

∂ρ

∂t= ∇ · j (4.52)

Once discretised, however, this convenient truth is no longertrue. Most schemes enforce automatically the divergencecondition on B. In fluid modeling, especially applied to spaceweather, great attention needs to go into enforcing the con-dition that ∇ · B = 0. In PIC methods, instead, this con-ditions is usually trivially satisfied by the judicious choiceof a discretisation scheme where ∇ · ∇ × E = 0 is satisfied.This is usually the case, except in some methods applied tonon-uniform grids. In these rare cases, the vast literaturedeveloped for MHD can be of help [T00, DKK+02]. Instead,a much more serious problem for PIC methods comes fromthe other divergence conditions, ε0∇ · E = ρ. This conditionis normally not satisfied easily.

Two types of approaches are commonly followed.First, the so-called charge conserving schemes can be used.

The interpolation of charge and density is chosen in a way toconserve locally charge ensuring that the discretised versionof eq. (4.52) is valid [BL04b]. The approach has two seriousdrawbacks: to enforce this property one is forced to sacrificethe conservation of momentum (see below) and reportedlythe simulations display an increased level of noise requiringmany more particles per cell (see Ref. [BL04b] at page 360and Ref. [MN71]). The advantage is that no elliptic solver isneeded as both divergence equations are automatically en-forced. This feature leads to excellent parallel scaling whenimplemented on massively parallel computers [BAY+09].

Second, divergence cleaning approaches can be used bysimply correcting the electric field for its electrostatic partto enforce Poisson’s equation:

∇2δϕ = ∇ ·E− ρ/ε0 (4.53)

Page 67: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

4.4 Recapitulation of the explicit particle methods 61

where the corrected field is E′ = E − ∇δϕ. Clearly thisachieves the goal by adding a correction. But at the costof solving an elliptic problem, a cpu-intensive operation. Tocircumvent this difficulty inexact versions have been pro-posed [Lan92, MOS+00] where the elliptic equation is notsolved to convergence but is in fact in a sense converged overmultiple time steps, reducing the computational burden atthe cost of allowing a controlled but non-zero error in thedivergence equation.

4.4 Recapitulation of the application of explicitparticle methods to space weather modeling

Collecting the steps gathered so far, the PIC algorithm issummarized by the series of operations depicted in Fig. 4.5.

Fig. 4.5. Summary of a computational cycle of the explicit PICmethod.

The loop is followed step by step without iterations. Start-ing for example from the top, the particle equations of mo-tion discretised with the leap-frog algorithm are advancedone step from xn

p ,vn−1/2p to xn+1

p ,vn+1/2p , the new particle in-

formation is projected to the grid to obtain the density and

Page 68: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

62 Explicit Particle Simulations of Space Weather

current density, sources of Maxwell’s equations. The latterare then solved for the new fields En+1,Bn+1/2, given the oldfields En,Bn−1/2. This operation requires only the sourcesjust computed. Once the new fields are obtained, the par-ticle forces can be computed by interpolation from the gridand the cycle can restart.

The simplicity of the approach explains its wide success.However, as noted above the approach is plagued by two sta-bility constraint coming from the explicit particle discretisa-tion, ωpe∆ < 2 and ∆x/λDe < ς. Additionally, the conditionc∆t < ∆x should also be considered when the field solver isalso explicit.

The key complexity of a plasma comes from the non-linearcoupling of particles and fields. In the real world, the fourblocks displayed in Fig. 4.5 are constantly coupled. Instead,the explicit approach freezes temporarily one to apply theother: the particles move for one time step in frozen fieldsand the Maxwell’s equations advance the fields in one timestep based on frozen sources. Neither are true physically.This is the key limitation of the explicit approach, especiallyin multiple scale system such as is typical for space weatherproblems.

To help the more interested reader familiarize with theexplicit approach, Appendix 1 reports a simple but completeimplementation of the explicit algorithm above in a MAT-LAB code for explicit electrostatic 1D systems.

Page 69: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5Implicit Particle Methods for Space

Weather

To avoid the prohibitively large number of time steps andthe exceedingly high resolution needed to run realistic prob-lems with explicit particle methods, implicit methods havebeen considered for several decades [Mas81, Den81, BF82,LCF83].

The starting point of implicit particle methods replacesthe explicit time differencing of the equations of motion withan implicit scheme. For example, the so-called θ scheme canbe used [VB92, VB95]:

xn+1p = xn

p + vn+1/2p ∆t

vn+1p = vn

p +qs∆t

ms

(En+θ

p (xn+1/2p ) + vn+1/2

p ×Bnp (x

n+1/2p )

)(5.1)

where the flexibility of defining a decentering parameter θ isused to vary the properties of the scheme. The quantities attime level n+ θ are computed as weighted averages betweenthe old and new level, Ψn+θ = Ψn(1 − θ) + Ψn+1θ. Otherimplicit schemes derived from the leap-frog algorithm havebeen proposed also [CLHP89, Fri90].

The equations (5.1) are implicit for two reasons.First, to advance the position the new velocity is needed

and to advance the velocity the new position is needed (be-

63

Page 70: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

64 Implicit Particle Methods for Space Weather

cause the fields need to be evaluated at the mid point be-tween the new and old position). This implicitness is localto each particle and can be handled easily. In fact it can beeliminated with a clever decomposition of the velocity. Thevelocity equation is more conveniently rewritten as:

vn+1/2p = vp + βsE

n+θp (xn+1/2

p ) (5.2)

where βs = qp∆t/2mp (independent of the particle weightand unique to a given species). For convenience, we have in-troduced hatted quantities obtained by explicit transforma-tion of quantities known from the previous computationalcycle:

vp = αns · vn

p

En+θs = αn

s ·En+θs

(5.3)

The transformation tensor operators αns are defined as:

αns =

1

1 + (βsBn)2(I − βsI ×Bn + β2

sBnBn

)(5.4)

and represent a scaling and rotation of the velocity vector.The tensor operator αn

s is the same for all computationalparticles of the same species s.

Second, and more importantly, eqs. (5.1) are implicit be-cause the new fields are needed also. If the electric andmagnetic fields were given, the equations of motion couldbe solved simply. The challenge of the implicit method isthat the electric and magnetic fields are not given. Unlikethe explicit method, the particle equations of motion needthe new fields that are not known yet. The implicit methodreintroduces the coupling of the particle equations with thefield equations. Implicit methods solve the Maxwell’s equa-tions also implicitly in time. The semi–discrete, continuousspace, temporal discretisation to Maxwell’s equations can be

Page 71: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Implicit Particle Methods for Space Weather 65

written as:

∇×En+θ +1

c

Bn+1 −Bn

∆t= 0

∇×Bn+θ − 1

c

En+1 −En

∆t=

cjn+

12

∇ ·En+θ = 4πρn+θ

∇ ·Bn = ∇ ·Bn+1 = 0,

(5.5)

The interpolation formulas derived above provide the ex-pression for the fields in the equations of motion and for thesources in Maxwell’s equations. The coupling of the set ofequations is evident.

The parameter θ ∈ [1/2, 1] is chosen in order to adjust thenumerical dispersion relation for electromagnetic waves (forθ < 1/2, the algorithm is shown to be unstable [BF82]). Wenote that for θ = 1/2 the scheme is second-order accuratein ∆t; for 1/2 < θ ≤ 1 the scheme is first-order accurate.The θ parameter can be adjusted to improve energy conser-vation [Fri90]

The same Von Neumann stability analysis repeated forthe implicit equations above leads to a very different solu-tion, (

Ω∆t

2

)2

= tan2(ωN∆t

2

)(5.6)

The tan function has values in the whole real continuum,allowing the use of any time step ∆t. The stability constraintis eliminated and in principle the time step can be selectedbased only on the physics of interest.

All stability constraints are eliminated and replaced bythe sole constraint of selecting the desired accuracy. Forspace weather simulations this is a great advantage. Thescales of interest are often on the electron inertial length,

Page 72: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

66 Implicit Particle Methods for Space Weather

nearly two orders of magnitude larger than the Debye lengththat needs to be resolved by the explicit method. Similarly,time can be set to resolve the electron trajectories ratherthan the fastest waves. Several orders of magnitude can begained in avoiding unnecessary spatial and temporal resolu-tion. Alone this vastly overwhelms the significant additionalcost per computational cycle of the implicit method over theexplicit method. As shown below for each case considered,the additional cost of one computational cycle can be a fac-tor of 3 to 10 higher for implicit method (depending wetherfully implicit or semi-implicit). But the savings are insteadof several orders of magnitude. In the example presentedin Sect. 5.4.2 the gain of the implicit method is a staggering106, overwhelming any additional cost per cycle.

But what happens then to the scales that are not resolved?The question was immediately felt as the implicit particlemethods were developed and a considerable body of litera-ture is available, reviewed in [BL04b, BC85]. In summary,the scales that are not resolved remain present but in a dis-torted fashion. The frequency of all unresolved waves satu-rates towards the maximum resolved frequency, the Nyquistfrequency of 1/∆t. For a choice of a decentering parame-ter larger than θ > 1/2, the unresolved waves are furtherdamped, at a rate exceeding the natural Landau damping.Physically this allows the energy dissipation towards the un-resolved scales, allowing to capture the gross contribution ofsuch scales to the energy balance. A complete analysis of thefate of all plasma waves when the time step is not resolvingthem is described in Ref. [BF82].

The fundamental problem to address in developing an im-plicit PIC method is the coupling between the equations ofmotion and the field equations for the presence of the timeadvanced electric field (but not magnetic field, that is usedfrom the previous cycle, as no instability is introduced) inthe equations of motion and for the appearance [due to the

Page 73: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.1 Fully Implicit Particle Methods 67

presence of xp and vp in eq. (4.33)] of the particle propertiesin the sources of the Maxwell equations. In both cases thecoupling is implicit, so that the new particle properties needto be known before the fields can be computed and likewisethe new fields need to be available before the new particleproperties can be computed.

In recent years, the direct solution of the coupled systemfor fields and particles became within reach of modern com-putational methods and computer resources [KCL05], buttraditionally, alternative methods were developed to avoiddealing directly with the full system of coupled non-linearequations.

Below, we consider first the more modern fully implicit ap-proach, and consider the more traditional semi-implicit ap-proach next.

5.1 Fully Implicit Particle MethodsThe implicit method requires the coupled solution of the im-plicit equations of motion (5.1), where the new fields at theadvanced time level are required, and of the implicit fieldequations (5.5), where the new particle properties are neededto compute the sources. The coupling is non-linear, just asthe original Vlasov-Maxwell system is also non-linear: theforce on the particles is not given but rather depends non-linearly on the fields that in turn depend on the particles.Modern computational science has developed a powerful toolfor solving such systems of non-linear equations: the precon-ditioned Jacobian-Free-Newton-Krylov (JFNK) approach.

In extreme summary and referring the reader to the rele-vant textbooks on the subject [Kel95], given a non-linear setof equations, f(w) = 0 for the set of unknowns w, the JFNKmethod is based on solving iteratively the residual equationwith the Newton method without having to form the Jaco-bian matrix. The new iteration w(k+1) = w(k) + δw is ob-

Page 74: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

68 Implicit Particle Methods for Space Weather

tained by computing the displacement δw using the Newtonmethod [Kel95], i.e. using a Taylor series expansion trun-cated at first order (to ensure linearity of the resulting equa-tion for δw). To avoid forming and storing the Jacobian ma-trix needed for the Taylor series expansion, the equation forδw is approximated numerically by replacing the derivativeswith differences:

f(w(k)) +f(w(k) + εδw)− f(w(k))

ε= 0 (5.7)

While formally non-linear, eq. (5.7) is linearized by choosingε small enough to ensure the accurate replacement of thefirst order derivative with the difference in the Taylor ex-pansion. In practice, ε is chosen according to the machineprecision [Kel95]. The Jacobian eq. (5.7) is expressed onlyin terms of residual function evaluations and there is noneed to form or store the matrix. To solve eq. (5.7), pre-conditioned Krylov-based schemes are used. Here, we usethe GMRES algorithm since the Jacobian matrix can be nonsymmetric [Saa03].

In the present problem, the unknowns are in principle thewhole set formed by the particle positions and velocities atthe advanced time level: xn+1

p , vn+1p and the fields at the

advanced level: En+1g and Bn+1

g . While viable, this choiceleads in practice to the need to handle the application of theJFNK methods to an extremely large array. The typical par-ticle simulation nowadays employs billions of particle andmillions of grid points. To reduce the load on the computermemory, a new technique, the subsidiarity of the particleequations, has been introduced [KCL05].

The starting point is the realization that the particle equa-tions are not directly coupled with each other. Each set of6 equations for a particle do not require the direct appli-cation of the information for the other particles except viathe fields. So each set of 6 equations can be solved directly

Page 75: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.1 Fully Implicit Particle Methods 69

given the fields. Within the JFNK iteration scheme, the lat-est guess (Newton iteration k) is indeed available. Thereforethe Newton method does not need to consider the particlesas part of the unknown. Given a guess of the fields, the par-ticle properties at the advanced time level are immediatelycomputable. This is the core property of particle subsidiar-ity: the JFNK method considers as unknowns only the fieldsand leaves the particle computation as a user-supplied rulethat is part of the residual evaluation for the fields.

In practice, the approach sets the following unknown vec-tor

w =

En+1g

Bn+1g

(5.8)

and the corresponding residual equation is formed by eq. (5.5).The particle equations become simply a rule on how to com-pute the sources ρn+θ

g and jn+ 1

2g . The computational cycle of

the explicit scheme is replaced by the interaction betweenthe JFNK solver and the residual equation, as outlined inFig. 5.1.

The JFNK method requires the user to provide the rulethat produces the residual given a value of the unknownvector. The implicit particle method needs to procure suchresidual. This is done in steps:

(i) The NK vector w is converted back into separate elec-tric and magnetic fields: En+1

g , Bn+1g .

(ii) These fields are interpolated to the particles: En+1p ,

Bn+1p .

(iii) The mover advances the particles in these fields pro-vided by JFNK.

(iv) Once the particles are moved, the field sources can becomputed: ρn+θ

g and jn+ 1

2g .

(v) With the sources, the field equations provide the resid-

Page 76: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

70 Implicit Particle Methods for Space Weather

Fig. 5.1. Outline of the interaction of particle mover, field residualcomputation and JFNK solver in a fully implicit particle methodusing particle subsidiarity. The equations are indicated in a sum-marized incomplete notation just for reference.

uals, rEn+1g

, rBn+1g

, needed by JFNK in response to itsprovided guess for the fields.

(vi) The NK residual vector is formed: rw =(rEn+1

g, rBn+1

g

)The operations to be conducted are still of the same order ofcomplexity as if the JFNK was directly working also on theparticle equations, however, the memory requirements forstoring the intermediate Krylov vectors for the JFNK solverare greatly reduced.

The use of the JFNK makes the solution of the system ofnon-linear equations extremely simple for the user. Powerfullibraries, ranging from the simple tool provided in the text-books [Kel95] to more sophisticated parallel libraries such

Page 77: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.2 Semi Implicit Methods 71

as PETSc [BBG+09, BBE+08, BGMS97] remove the need forthe user to code the JFNK method. All that is needed is toprovide the simple procedures for computing the residuals.The approach has the advantage of minimizing the personaltime of the programmers who develop the software. How-ever, the computational cost of one compute cycle to bringthe JFNK to completion is several times that of the sim-ple explicit method described above. This additional cost isvastly overwhelmed by the gains in grid spacing and timestep allowed by the removal of the stability constraint.

5.2 Semi Implicit MethodsThe full implicit formulation described above has becometractable numerically only in recent years thanks to the progressin the JFNK approach. Previously, the task was consideredbeyond reach and methods were developed to simplify thenon-linear coupling and reduce it to a more tractable linearproblem. The semi-implicit approach still preserves many ofthe good properties of stability of the fully implicit method.

The research in the field has organized itself into two lines:the implicit moment method [BF82] and the direct implicitmethod [LCF83]. While started from significantly differ-ent points of view, over the years the two approaches haveconverged towards a more common perspective and math-ematical framework. The idea is to linearize the couplingbetween particle and fields and solve it as a coupled linearsystem instead of the true non-linear system it is. This ap-proach is common in scientific computing and is referred toas semi-implicit. For space weather applications, so far, theimplicit moment method has found the majority of applica-tions, while the direct implicit methods is primarily used ininertial fusion research. Below we present in general thesemi-implicit method, focusing on the moment implicit ap-proach as the main example but pointing out the differences

Page 78: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

72 Implicit Particle Methods for Space Weather

Fig. 5.2. Blocks needed in a cycle of the semi-implicit PIC scheme.

between implicit moment and direct implicit when appropri-ate.

The semi-implicit method reduces the number of equa-tions that must be solved self-consistently to a set composedby the field equations and a simplified plasma response modelthat approximates the response of the particles to the fieldchanges over the time step considered. The solution of thisset of equations implicitly, and the subsequent explicit so-lution of the particle equations of motion in the resultingfields, is stable and accurate.

The idea is summarized in Fig. 5.2 where the logic of thesequence of operations involved in the semi-implicit methodis shown. The coupling due to the implicit discretisation ofboth field and particle equations is broken by approximatingthe sources of the field equations using the moment equa-tions instead of the particle equations directly. Once the fieldequations are solved within this approximation, the rest ofthe steps can be completed directly without iterations: with

Page 79: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.2 Semi Implicit Methods 73

the new fields, the particle equations of motion can be solvedand the new current and density can be computed for thenext computational cycle.

The formulation used here is described in Refs. [BF82,VB92, LBR06b, LCF83]. The key step is to derive a suitableset of moment equations that can approximate the responseof the plasma particles to the fields over a computationalcycle. The approach is based on a series expansion of theinterpolation function appearing in the expression for thefield sources, eq. (4.33). The expansion is done with respectto the particle position, choosing the center of the expansionas the particle positions at the start of the computationalcycle:

W (x− xn+1p ) = W (x− xn

p ) + (x− xnp ) · ∇W (x− xn

p )+1

2(x− xn

p )(x− xnp ) : ∇∇W (x− xn

p ) + . . .

(5.9)where a tensor notation is used. The main difference be-tween the implicit moment and direct implicit method is inthe choice of the center of the series expansion. In the im-plicit moment method, the particle mover uses the θ-schemeand it is natural to center the expansion on the old particleposition xn

p . The direct implicit method uses instead one ina number of different movers based on stabilizing the leap-frog algorithm with implicit variants [Fri90]. In this casethe expansion is done around a guess of the new advancedposition [LCF83].

The expansion (5.9) can be used to compute the field sourcesdirectly using particle information only from the previouscomputational cycle and removing the need to iterate theparticle and field equations. The details of the simple but te-dious algebraic manipulations are provided in Ref. [VB92],

Page 80: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

74 Implicit Particle Methods for Space Weather

the final answer being:

ρn+1s = ρns −∆t∇ · Jn+1/2

s

Jn+1/2s = Js − ∆t

2 µs · Eθ − ∆t2 ∇ · Πs

(5.10)

where the following expressions were defined:

Js =∑

p qpvpW (x− xnp )

Πs =∑

p qpvpvpW (x− xnp )

(5.11)

with the obvious meaning, respectively, of current and pres-sure tensor based on the transformed hatted velocities. Aneffective dielectric tensor is defined to express the feedbackof the electric field on the plasma current and density:

µns = −qsρ

ns

msαn

s (5.12)

The expression (5.10) for the sources of the Maxwell’s equa-tions provide a direct and explicit closure of Maxwell’s equa-tions. When eq. (5.10) is inserted in eq. (5.5), the Maxwell’sequations can be solved without further coupling with theparticle equations. The procedure followed distilled fromthe equations of motion of the particles an average responsethat can be used to represent the plasma response withinone time step. This is the key property of the semi-implicitmethod and allows it to retain the once-through approachtypical of explicit methods and eliminates the need for ex-pensive iteration procedures that would require to move theparticles multiple times per each computational cycle.

In the moment implicit method, the plasma response takesthe form presented above and represents a closure of thefluid equations using the particle information to express thepressure tensor. In the direct implicit method, a similar ap-proach is used that relies on the mathematical linearisa-

Page 81: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.2 Semi Implicit Methods 75

tion of the response rather than on the use of the momentmethod [BC85].

5.2.1 Field SolverDifferent versions of the semi-implicit PIC method have re-lied on different solution procedures for the Maxwell equa-tions. In CELESTE1D a potential formulation was applied [VB92],while early versions of CELESTE3D were based on a time-staggered solution of the two divergence Maxwell’s equa-tions and of a second order formulation of the two curl Maxwell’sequations [RLB02b]. More recently [RLB02b] a consistentsecond order formulation has been presented and is summa-rized here.

In the continuum, the two curl Maxwell’s equations givea solution with the property of satisfying also the two di-vergence equations at all times, provided that appropriateinitial and boundary conditions are used. Based on thisproperty [RLB02b], the following second order equation isobtained from the two time-discretised (but continuous inspace) curl equations in eq. (5.5):

(cθ∆t)2 [−∇2En+θ −∇∇ ·

(µn ·En+θ

)]+ εn ·En+θ

= En + (cθ∆t)

(∇×Bn − 4π

cJn

)− (cθ∆t)

2 ∇4πρn(5.13)

where µn =∑

s µns and εn = I + µn, being I the identity

tensor.As shown in Ref. [RLB02b], the second order formulation

for the electric field needs to be coupled with a divergencecleaning step to ensure that

ε0∇ ·En = ρn (5.14)

holds for the initial field of each time step.The boundary conditions for the second order formulation

for E can be derived from the natural boundary conditions

Page 82: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

76 Implicit Particle Methods for Space Weather

expressed in both E and B using theorems of classical elec-trodynamics [RLB02b]. The magnetic field is computed di-rectly once the new electric field is computed, as:

Bn+1 −Bn

∆t+∇×En+θ (5.15)

Using the temporal second-order temporal formulation above,the field equations are further discretised in space (see e.g.Ref. [RLB02b, LBR06b] for details). The discretised equa-tions and their boundary conditions form a non-symmetriclinear system that is solved using GMRES [Saa03]. Forthe divergence cleaning equation, CG (or FFT on a uniformgrids) [Saa03] can be used since the discretised equationleads to a symmetric matrix.

5.2.2 Particle mover

Once the fields are computed from the semi-implicit momentmethod, the particles can be advanced. The set of equationsof motions (5.1) have an inner coupling among themselvesdue to the appearance of the new velocity in the equationfor the position and of the new position in the equation forthe velocity. This coupling is purely local at the level of eachparticle and does not involve coupling with other particles.Instead of simply solving the 6 coupled equations of motionsconsidering position and velocity as unknowns, the formallinearity of the explicit quadrature of the velocity providedin eq.(5.2) can be used. Substituting the first of the Newtoneqs. (5.1) in the second, the nonlinear (vectorial) functionexpressing the discretised Newton equations is:

f(xn+1p ) = xn+1

p − xnp −∆tvp −∆tβsE

n+θp (xn+1/2

p ) (5.16)

The three residual equations above have only three unknowns,the components of xn+1

p , all other quantities being known.

Page 83: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.2 Semi Implicit Methods 77

The equations are non-linear due to the spatial dependenceof the electric and magnetic fields.

Two methods have been used in the literature. First, apredictor-corrector (PC) approach can be used to solve thenon-linear system of equations of motions [VB95]. Alter-natively, less commonly, the Newton method [Kel95] can beused to solve the set of equations of motion to convergence.While the JFNK method can be used for this task also, thesimplicity of the 3 coupled equations allows the use of thefull-fledged Newton method.

The use of the Newton-based mover ensure solution of theequations of motion to convergence of the non-linear itera-tion, when instead the PC mover uses typically a fixed num-ber of iterations allowing for an uncontrolled error. Thisfeature endows the Newton-based mover with an improvedenergy conservation in the overall scheme [LBR06b]. Bothmovers can be extended to the relativistic case [NTZL07].

5.2.3 Stability of the semi-implicit methods

The stability properties of the semi-implicit method describedabove have been studied extensively in the past [BF82]. Thesemi-implicit particle mover removes the need to resolve theelectron plasma frequency, and the implicit formulation ofthe field equations removes the need to resolve the speed oflight.

The time step constraints are replaced by an accuracy limitarising from the derivation of the fluid moment equationsusing the series expansion in eq. (5.9). This limit restrictsthe mean particle motion to one grid cell per time step [BF82],i.e.

vth,e∆t/∆x < 1, (5.17)

The finite grid instability limit for the explicit method, ∆x <

Page 84: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

78 Implicit Particle Methods for Space Weather

ςλDe is replaced by [BF82]

∆x < ε−1vth,e∆t, (5.18)

that allows large cell sizes to be used when large time stepsare taken.

This is a key feature of the semi-implicit method: time andspace scales can be chosen freely according to the desiredaccuracy, but the ratio of spatial and length scales is not free.Rather it must stay within the bounds just outlined:

ε < vth,e∆t/∆x < 1, (5.19)

The upper limit is generally the main concern. The lowerlimit, ε, is in practical cases usually a very small numberthat can often be approximated by zero. The result is thatthe conditions can be satisfied by selecting large grid spac-ings and large time steps. In principle, the lower limit wouldprevent the choice of using large grid spacings with smalltime step, but as noted in practice this limitation is weak tonon-existent and the time step can be chosen as small as de-sired. However, the condition vth,e∆t/∆x < 1 should neverbe violated.

The gain afforded by the relaxation of the stability limitsis two-fold.

First, the time step can far exceed the explicit limit. Intypical space weather problems, the electron plasma frequencyis far smaller than the time scales of interest and its accu-rate resolution is not needed. The processes developing atthe sub-∆t scale are averaged and their energy is dampedby a numerically-enhanced Landau damping. In other ap-proaches, such as the gyrokinetic or hybrid approach [Lip02],such processes are completely removed and the energy chan-nel towards them is interrupted, removing for example thepossibility to exchange energy between sub-∆t fluctuationsand particles. In the semi-implicit approach, instead, thesub-∆t scales remain active and the energy channel remains

Page 85: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.3 Adaptive Gridding 79

open. This is a crucial feature to retain in a full kineticapproach. Furthermore, when additional resolution of thesmallest scales is needed, the semi-implicit method can ac-cess the same accuracy of the explicit method simply usinga smaller time step and grid spacing. This feature is not ac-cessible to reduced model, e.g. gyroaveraged methods, thatremove the small scales entirely.

Second, the cell sizes can far exceed the Debye length. Of-ten the scales of interest are much larger than the Debyelength. The ability to retain a full kinetic treatment with-out the need to resolve the Debye length results in a muchreduced cost for the semi-implicit PIC method.

5.3 Adaptive GriddingAs noted above the particle in cell method is essentially basedon the assumption that the particles have a finite size, andthat finite size is fixed and equal to the cell size. The ap-proach is therefore naturally suited to uniform grids. Theextension to non-uniform, adaptive grids is not straightfor-ward. Nevertheless there are noteworthy attempts to ex-pand the PIC method to non-uniform grids. We review be-low some of the most notable approaches of interest to spaceweather problems. As a matter of order, we organize thetopic here into three groups.

First, we consider methods where the grid is non-uniformbut still retain a regular structure for the connectivity thatallow one to map the grid to a uniform logical grid. This isthe case when all the nodes have equal connectivity, eachnode being in contact with 2 others in 1D, 4 in 2D and 6 in3D. An example of such an arrangement is presented in 2Din Fig. 5.3. This approach can be defined as moving meshadaptation (MMA) as it can be imagined as the end resultof a process that distorts the grid by attracting more pointsin the regions of interest and away from regions where the

Page 86: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

80 Implicit Particle Methods for Space Weather

a) Physical domain b) Logical domain

Fig. 5.3. Conceptual representation of moving grid adaptation. Thegrid in the physical domain x on the left can be mapped to a uni-form grid in the logical coordinates ξ.

system is smooth an uneventful. This approach has been fol-lowed for example within the Celeste implicit moment methodand is reviewed in [Bra93, Bra91, Lap08].

Second, adaptive mesh refinement (AMR) [BO84] can beused for the field part of the PIC method. Main examplesof this approach are [VCF+04, FS08]. The latter approachwas developed especially for space weather application andsuccessful investigations have been reported demonstratingthe ability to resolve with the AMR approach the localizedregions of reconnection embedded in larger systems [FS08].

Lastly, unstructured grids can be used [JH06] starting fromfinite element methods to discretise the fields.

All these approaches need to deal with the fact that as thegrid spacing changes locally, the particles and the cells can-not always have the same size. As noted above the deriva-tion presented is based on such an equality to provide a sim-ple efficient interpolation between particles and cells. Thefirst two approaches have relaxed the requirement that theparticle size remain constant and have based the interpola-tion on the local grid spacing. The particles have the localsize of the cells they are embedded in. For the first approach

Page 87: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.3 Adaptive Gridding 81

this is achieved by assuming that the particle shape functionis constant in the logical space ξ rather than in the physi-cal space x. If the shape functions are chosen in the logicalspace, the interpolation functions can still be computed withthe b-spline chain rule and the same formulas of uniformgrids can still be used. In the second approach, typically apatch-based AMR approach is used and the particles havethe size of the cells in the patch where they reside and in-terpolation can proceed in each patch as if it was a uniformgrid.

This simplification of the interpolation step on adaptivePIC has a serious consequence: the exact derivation breaksdown, the changing particle shape introduces new terms pro-portional to the temporal derivative of the shape function.The derivation of the PIC method outlined in Set. 4.1 as-sumed a fixed particle shape. All the integrations have beendone using such fixed shapes. When this process is followed,a simple analysis proves that momentum is conserved ex-actly when the same interpolation function is used for allquantities [HE88, GVF05] and provided that the solution ofthe Maxwell’s equations also conserve momentum (i.e. thenumerical Green’s function reflects the properties of anti-symmetry of the exact continuum Green’s function).

When the shape functions change in time the mathemat-ical derivation of the PIC method is modified. In particular,the derivation of the equations of motion require additionalterms related to the temporal variation of the shape func-tion. However, in practice these additional terms are ne-glected and the resulting schemes do not conserve momen-tum. A side effect is that particles experience a self-force,due to their traversing regions of different sizes [VCM+02,CN10]. For the moving mesh approach, this error is con-trolled by using smooth grids where the spacing changesprogressively. Being the neglected terms proportional to thechanges in the shape function, when the changes are small

Page 88: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

82 Implicit Particle Methods for Space Weather

the error is small. In the AMR approach, however, the changein particle shape is sudden at the interface between patchesand leads to severe errors that need to be corrected with ap-propriately devised methods [CN10, VCM+02].

5.4 Practical use of particle simulation in spaceweather

The application of particle simulations to space problems isextremely wide. The reader is advised to seek other reviews.As an example the published proceedings of the series of theInternational School/Symposium on Space Simulation (e.g.Ref. [BDS03]) or of the conference series ASTRONUM (seee.g. [PACZ09]) provide recent up to date overviews. We fo-cus here, instead, on the critical aspect of space weather:the coupling of large and small scales. The focus will be onthe use of implicit particle simulation as it has the betterpromise of being able to actually model space weather eventsat the kinetic level. Conversely, the explicit approach is moresuitable to zero in on some detailed physics, a topic of inter-est to space weather but better described as fundamentalspace science and beyond the scope of the present review.

We report first on the latest developments on the imple-mentation of the implicit methods in codes focusing espe-cially on the latest results relative to iPIC3D, a massivelyparallel implicit moment PIC code [MLRu10]. Next, we con-sider the issue of computational costs in the particle simula-tion of space weather problems with multiple-scale coupling.

5.4.1 Scaling of massively parallel implicit PICParticle modeling has led to the development of many codes.For explicit modeling, the simplicity of the algorithm and therelative simplicity of its parallelization has led to the devel-opment of many codes based on significantly different imple-

Page 89: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.4 Practical use of particle simulation in space weather83

mentations with different particle movers and field discreti-sation. Implicit codes are much fewer. Essentially there areonly two families of codes. The direct implicit method ledto the development of the code AVANTI [HL87], later devel-oped into a commercial code, LSP aimed primarily at inertialfusion problems [WROC01]. The implicit moment methodhas been applied primarily in space problems. Even thenames are space-oriented: First came VENUS [BF82], fol-lowed by CELESTE [VB92, LBR06b] whose main improve-ment over VENUS is the use of modern preconditioned Krylovsolvers for the field equations. CELESTE3D is availableopen source [cel]. Parsek2D [MCB+09] and iPIC3D [MLRu10]have brought the implicit moment method to massively par-allel computers.

Figure 5.4 shows a scaling study conducted on NASA’sPleiades using up to 16,384 processors. The study uses onerealistic problem, the study of reconnection in a 2D simula-tion box, using 32x32 cells per processor, each with 4 specieshaving 196 particles per cell. The scaling is done by increas-ing the number of processors at a constant load per proces-sor, thereby increasing the system size, all else (time stepand number of cycles) remaining the same.

As can be noted, the measured scaling is only 20% lowerthan the ideal scaling when going from 32 to 16,384 proces-sors. The details of the parallel implementation allowingsuch performances has been reported in [MLRu10].

5.4.2 Computational Costs of Particle Modeling inSpace Weather

The key difference between explicit and implicit methodsfor their application to space weather is the different se-lection criteria for grid spacing and time step. The explicitmethod must satisfy the stability constraints while the im-

Page 90: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

84 Implicit Particle Methods for Space Weather

Fig. 5.4. Weak scaling study conducted on NASA’s Pleiades super-computer using the implicit moment code iPIC3D. In red, the idealscaling is shown where the total CPU time remains constant as thenumber of processors and the system size are increased keeping theload per processor constant. In blue, the actual observed scaling isshown. Work in collaboration with Stefano Markidis.

plicit method need only to resolve the scales of interest. Anexample is the best illustration of the concept.

Considering again the case of the Earth magnetic tail whosescales are illustrated in Fig. 4.1, Table 5.1 shows the typi-cal choices forced upon the explicit method by the stabilityconstraints. The grid spacing must be chosen equal to thesmallest Debye lenght in the system and the time step mustresolve the electron plasma frequency.

The implicit method, instead, can select the accuracy de-sired and Table 5.1 shows some typical choices. The gridspacing is selected to resolve the scales of reconnection. Thesmallest scale of interest is the electron skin depth that cor-responds to the dissipation layer where field lines decouple

Page 91: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.4 Practical use of particle simulation in space weather85

from the electrons, break and reconnect. The choice is then∆x/de = 1 (justified by the consideration that the reconnec-tion region has a much larger electron skin depth then thereference value, see Ref. [LMD+10] for details), that corre-sponds to ∆x/λDe = 32. This gain increases by another or-der of magnitude in other colder regions, such as in the so-lar wind. The time step is constrained by ∆t < ∆x/vthe orωpe∆t < ∆x/λDe = 100. To resolve time well, a significantlysmaller time step is typically used: ωpi∆t = .1. When thosechoices are made, a gain of order 1.4 · 106 is obtained in CPUtime. For reference, if the same simulation is done on thesame computer with the same number of processors, for animplicit run that took one day, the corresponding explicit runwould require approximately 4,000 years. The gain can bepartially offset by the higher cost per computational time.Typically semi-implicit codes require about three times thecost per cycle. In that case, still a thousend years wouldbe required for the corresponding explicit run. The gainachieved in lower temperature regions, common for exam-ple in the solar wind, are even more staggering, by severalmore orders of magnitude. Given these numbers, it is clearthat the range of application of implicit PIC is vastly largerthan explicit PIC.

The tremendous gain comes at the cost of loosing the in-formation on the scales not resolved. Those scales are noteliminated but rather the waves developing there are dis-torted to the Nyquist frequency and damped. This leaves thechannel open and allows the dissipations to develop. This isexactly what is needed for space weather applications. Notthe detail of the most detailed scale but the ability to resolveonly the sales of the most important processes.

For the demonstration of the application of the model aboveto space weather, we refer the reader to the published workdone with Celeste3D [LB96, LB97, LB00, LB02, LBD03, RLB02a,RBDL04b, RLB04, RBDL04a, Lap03, RLB03, LBR06b, BGH+05,

Page 92: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

86 Implicit Particle Methods for Space Weather

Explicit Implicit Gain

∆x λDe =250m de =8Km 32

∆y λDe =250m de =8Km 32

∆z λDe =250m de =8Km 32

∆t ∆t = 0.1ω−1pe = 2.5 · 10−6s ∆t = 0.1ω−1

pi = 10−4s√1836

Total 1.4 · 106

Table 5.1. Paradigmatic choice of parameters for amagnetospheric simulation with explicit and implicit PIC.

Spatial and temporal scales are shown in each row. The lastcolumn shows the gain in time step and grid spacing for

each dimension of space-time. The last row summarizes thetotal gain.

CL05, NTZL07, IL07, LKK+06, LK07, WL08c, WL08a, WL08b,WLDE08, Lap09] and iPIC3D [MLRu10, LMD+10] at thescales of interest outlined in Table 5.1. In particular, de-tailed comparisons of the application of extremely refinedexplicit simulations and coarser implicit simulations haveproven the ability of the latter to resolve correctly the rele-vant dissipation scales in processes of reconnection [RBDL04b]and in other space physics problems.

AcknowledgmentsThe author is grateful to Stefano Markidis, the main devel-oper of Parsek2D and iPIC3D, to Gianni Coppa for his cleverimplementation of 1D electrostatic PIC in MATLAB (see Ap-pendix 1) as well as for the fruitful discussions on the math-ematical foundations of the PIC method. The author is alsograteful to Jerry Brackbill for the many years of collabora-tion and stimulating exchanges of ideas on the implicit PIC

Page 93: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

5.4 Practical use of particle simulation in space weather87

method. The present work is supported by the Onderzoek-fonds KU Leuven (Research Fund KU Leuven) and by theEuropean Commission’s Seventh Framework Programme un-der the grant agreement no. 218816 (SOTERIA project, www.soteria-space.eu). The simulations were conducted on the resourcesof the NASA Advanced Supercomputing Division (NAS), ofthe NASA Center for Computational Sciences Division (NCCS)and of the Vlaams Supercomputer Centrum (VSC) at theKatholieke Universiteit Leuven.

Page 94: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Appendix 1MATLAB program for 1D electrostatic

PIC

clear allclose all

L=2*pi;DT=.5;NT=200;NTOUT=25;NG=32;

N=1000;WP=1;QM=-1;V0=0.2;VT=0.0;

XP1=1;V1=0.0;mode=1;

Q=WPˆ2/(QM*N/L);rho_back=-Q*N/L;dx=L/NG;

% initial loading for the 2 Stream instability

xp=linspace(0,L-L/N,N)’;vp=VT*randn(N,1);pm=[1:N]’;pm=1-2*mod(pm,2);vp=vp+pm.*V0;

% Perturbation

vp=vp+V1*sin(2*pi*xp/L*mode);xp=xp+XP1*(L/N)*sin(2*pi*xp/L*mode);

p=1:N;p=[p p];un=ones(NG-1,1);Poisson=spdiags([un -2*un un],[-1 0 1],NG-1,NG-1);

% Main computational cycle

for it=1:NT

% update xp

xp=xp+vp*DT;

% apply bc on the particle positions

88

Page 95: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

MATLAB program for 1D electrostatic PIC 89

out=(xp<0); xp(out)=xp(out)+L;out=(xp>=L);xp(out)=xp(out)-L;

% projection p->g

g1=floor(xp/dx-.5)+1;g=[g1;g1+1];fraz1=1-abs(xp/dx-g1+.5);fraz=[fraz1;1-fraz1];

% apply bc on the projection

out=(g<1);g(out)=g(out)+NG;out=(g>NG);g(out)=g(out)-NG;

mat=sparse(p,g,fraz,N,NG);rho=full((Q/dx)*sum(mat))’+rho_back;

% computing fields

Phi=Poisson\(-rho(1:NG-1)*dxˆ2);Phi=[Phi;0];Eg=([Phi(NG); Phi(1:NG-1)]-[Phi(2:NG);Phi(1)])/(2*dx);

% projection q->p and update of vp

vp=vp+mat*QM*Eg*DT;

end

Page 96: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Bibliography

[Asc05] M. J. Aschwanden. Physics of the Solar Corona. An Intro-duction with Problems and Solutions (2nd edition). December2005.

[BAY+09] K. J. Bowers, B. J. Albright, L. Yin, W. Daughton,V. Roytershteyn, B. Bergen, and T. J. T. Kwan. Advances inpetascale kinetic plasma simulation with VPIC and Roadrun-ner. Journal of Physics Conference Series, 180(1):012055–+,July 2009.

[BBE+08] Satish Balay, Kris Buschelman, Victor Eijkhout,William D. Gropp, Dinesh Kaushik, Matthew G. Knepley,Lois Curfman McInnes, Barry F. Smith, and Hong Zhang.PETSc users manual. Technical Report ANL-95/11 - Revision3.0.0, Argonne National Laboratory, 2008.

[BBG+09] Satish Balay, Kris Buschelman, William D. Gropp, Di-nesh Kaushik, Matthew G. Knepley, Lois Curfman McInnes,Barry F. Smith, and Hong Zhang. PETSc Web page, 2009.http://www.mcs.anl.gov/petsc.

[BC85] J. U. Brackbill and B. I. Cohen, editors. Multiple TimeScales, chapter Simulation of Low-Frequency, ElectromagneticPhenomena in Plasmas, (J.U. Brackbill, D.W. Forslund), page271. Academic Press, Orlando, 1985.

[BD07] V. Bothmer and I. A. Daglis. Space Weather – Physics andEffects. Praxis Publishing, 2007.

[BDS03] J. Buchner, C. Dum, and M. Scholer, editors. Space PlasmaSimulation, volume 615 of Lecture Notes in Physics, BerlinSpringer Verlag, 2003.

[BF82] J.U. Brackbill and D.W. Forslund. Simulation of low fre-quency, electromagnetic phenomena in plasmas. J. Computat.Phys., 46:271, 1982.

90

Page 97: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Bibliography 91

[BGH+05] J. Birn, K. Galsgaard, M. Hesse, M. Hoshino, J. Huba,G. Lapenta, P. L. Pritchett, K. Schindler, L. Yin, J. Buchner,T. Neukirch, and E. R. Priest. Forced magnetic reconnection.Geophys. Res. Lett., 32:L06105, 2005.

[BGMS97] Satish Balay, William D. Gropp, Lois Curfman McInnes,and Barry F. Smith. Efficient management of parallelism inobject oriented numerical software libraries. In E. Arge, A. M.Bruaset, and H. P. Langtangen, editors, Modern Software Toolsin Scientific Computing, pages 163–202. Birkhauser Press,1997.

[BH86] J. Barnes and P. Hut. A hierarchical O(N log N) force-calculation algorithm. Nature, 324:4446–449, 1986.

[BH98] William B. Bateson and Dennis W. Hewett. Grid and parti-cle hydrodynamics:: Beyond hydrodynamics via fluid elementparticle-in-cell. Journal of Computational Physics, 144(2):358–378, 1998.

[BL04a] C.K. Birdsall and A.B. Langdon. Plasma Physics Via Com-puter Simulation. CRC Press, Boca Raton, 2004.

[BL04b] C.K. Birdsall and A.B. Langdon. Plasma Physics Via Com-puter Simulation. Taylor & Francis, London, 2004.

[BO84] M. J. Berger and J. Oliger. The AMR technique. J. Compu-tat. Phys., 53:484–512, 1984.

[Bra91] J.U. Brackbill. An adaptive grid with directional control fortoroidal plasma simulation. In Proc. 14th International Confer-ence on the Numerical Simulation of Plasmas, American Phys-ical Society, Annapolis MD, 1991, 1991.

[Bra93] J. U. Brackbill. An adaptive grid with directional control. J.Computat. Phys., 108:38, 1993.

[cel] http://code.google.com/p/celeste/.[CL05] E. Camporeale and G. Lapenta. Model of bifurcated current

sheets in the Earth’s magnetotail: Equilibrium and stability.Journal of Geophysical Research (Space Physics), 110:7206–+,July 2005.

[CLD+96] G. G. M. Coppa, G. Lapenta, G. Dellapiana, F. Donato,and V. Riccardo. Blob method for kinetic plasma simulationwith variable-size particles. Journal of Computational Physics,127(2):268–284, 1996.

[CLHP89] B. I. Cohen, A. B. Langdon, D. W. Hewett, and R. J. Pro-cassini. Performance and Optimization of Direct Implicit Par-ticle Simulation. Journal of Computational Physics, 81:151–+,March 1989.

[CN10] P. Colella and P. C. Norgaard. Controlling self-force errorsat refinement boundaries for AMR-PIC. Journal of Computa-tional Physics, 229:947–957, February 2010.

[Daw83] J. M. Dawson. Particle simulation of plasmas. Rev. Mod.

Page 98: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

92 Bibliography

Phys., 55:403–447, 1983.[Den81] J. Denavit. Time-filtering particle stimulations with

ωpe∆t 1. J. Computat. Phys., 42:337, 1981.[DKK+02] A. Dedner, F. Kemm, D. Kroner, C.-D. Munz,

T. Schnitzer, and M. Wesenberg. Hyperbolic Divergence Clean-ing for the MHD Equations. Journal of Computational Physics,175:645–673, January 2002.

[Fri90] A. Friedman. A Second-Order Implicit Particle Moverwith Adjustable Damping. Journal of Computational Physics,90:292–+, October 1990.

[FS02] D. Frenkel and B. Smit. Understanding Molecular Simula-tion. Academic Press, San Diego, 2002.

[FS08] K. Fujimoto and R. D. Sydora. Electromagnetic particle-in-cell simulations on magnetic reconnection with adaptive meshrefinement. Computer Physics Communications, 178:915–923,June 2008.

[GVF05] Yu. N. Grigoryev, Vitali Andreevich Vshivkov, andMikhail Petrovich Fedoruk. Numerical particle-in-cell meth-ods: theory and applications. VSP BV, AH Zeist, 2005.

[HE81] R. W. Hockney and J. W. Eastwood. Computer SimulationUsing Particles. McGraw-Hill, New York, 1981.

[HE88] R.W. Hockney and J.W. Eastwood. Computer simulation us-ing particles. Taylor & Francis, 1988.

[HL87] D. W. Hewett and A. B. Langdon. Electromagnetic directimplicit plasma simulation. Journal of Computational Physics,72:121–155, September 1987.

[IL07] M. E. Innocenti and G. Lapenta. Momentum creation by driftinstabilities in space and laboratory plasmas. Plasma Physicsand Controlled Fusion, 49:521–+, December 2007.

[JH06] G. B. Jacobs and J. S. Hesthaven. High-order nodal dis-continuous Galerkin particle-in-cell method on unstructuredgrids. Journal of Computational Physics, 214:96–121, May2006.

[Kal98] May-Britt Kallenrode. Space Physics. Springer, 1998.[KCL05] H. Kim, L. Chacon, and G. Lapenta. Fully implicit particle-

in-cell algorithm. Bull. Am. Phys. Soc., 50:2913, 2005.[Kel95] C. T. Kelley. Iterative methods for linear and nonlinear equa-

tions. SIAM, Philadelphia, 1995.[Lan92] A. B. Langdon. On enforcing Gauss’ law in electromag-

netic particle-in-cell codes. Computer Physics Communica-tions, 70:447–450, July 1992.

[Lap03] G. Lapenta. A new paradigm for 3D Collisionless MagneticReconnection. Space Sci. Rev., 107:167–174, April 2003.

[Lap08] G. Lapenta. Adaptive Multi-Dimensional Particle In Cell.ArXiv e-prints, June 2008.

Page 99: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Bibliography 93

[Lap09] G. Lapenta. Large-scale momentum exchange by microin-stabilities: a process happening in laboratory and space plas-mas. Phys. Scripta, 80(3):035507–+, September 2009.

[LB96] G. Lapenta and J.U. Brackbill. Contact discontinuities incollisionless plasmas: A comparison of hybrid and kinetic sim-ulations. Geophys. Res. Lett., 23:1713, 1996.

[LB97] G. Lapenta and J. U. Brackbill. A kinetic theory for the drift-kink instability. jgr, 102:27099–27108, December 1997.

[LB00] G. Lapenta and J.U. Brackbill. 3d reconnection due tooblique modes: a simulation of harris current sheets. Non-linear Processes Geophys., 7:151, 2000.

[LB02] G. Lapenta and J.U. Brackbill. Nonlinear evolution of thelower hybrid drift instability: Current sheet thinning andkinking. Phys. Plasmas, 9(5):1544–1554, May 2002.

[LBD03] G. Lapenta, J.U. Brackbill, and W.S. Daughton. The unex-pected role of the lower hybrid instability in magnetic recon-nection in three dimensions. Phys. Plasmas, 10(5):1577–1587,May 2003.

[LBR06a] G. Lapenta, J. U. Brackbill, and P. Ricci. Kinetic approachto microscopic-macroscopic coupling in space and laboratoryplasmas. Physics of Plasmas, 13:5904, May 2006.

[LBR06b] G. Lapenta, J .U. Brackbill, and P. Ricci. Kinetic approachto microscopic-macroscopic coupling in space and laboratoryplasmas. Phys. Plasmas, 13:055904, 2006.

[LCF83] A.B. Langdon, BI Cohen, and A Friedman. Direct implicitlarge time-step particle simulation of plasmas. J. Computat.Phys., 51:107–138, 1983.

[Lip02] Alexander S. S. Lipatov. The Hybrid Multiscale SimulationTechnology. Springer, Berlin, 2002.

[LK07] G. Lapenta and J. King. Study of current intensification bycompression in the Earth magnetotail. Journal of GeophysicalResearch (Space Physics), 112:12204–+, December 2007.

[LKK+06] G. Lapenta, D. Krauss-Varban, H. Karimabadi, J. D.Huba, L. I. Rudakov, and P. Ricci. Kinetic simulations of x-line expansion in 3D reconnection. grl, 33:10102–+, May 2006.

[LMD+10] G. Lapenta, S. Markidis, A. Divin, M. Goldman, andD. Newman. Scales of guide field reconnection at the hydro-gen mass ratio. Physics of Plasmas, 17(8):082106, 2010.

[Mas81] R.J. Mason. Implicit moment particle simulation of plas-mas. J. Computat. Phys., 41:233, 1981.

[MCB+09] S. Markidis, E. Camporeale, D. Burgess, Rizwan-Uddin,and G. Lapenta. Parsek2D: An Implicit Parallel Particle-in-Cell Code. In N. V. Pogorelov, E. Audit, P. Colella, & G. P. Zank,editor, Astronomical Society of the Pacific Conference Series,volume 406 of Astronomical Society of the Pacific Conference

Page 100: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

94 Bibliography

Series, pages 237–+, April 2009.[MLRu10] Stefano Markidis, Giovanni Lapenta, and Rizwan-uddin.

Multi-scale simulations of plasma with ipic3d. Mathematicsand Computers in Simulation, 80(7):1509–1519, 2010.

[MM95] K.W Morton and D.F. Mayers. Iterative methods for linearand nonlinear equations. SIAM, Philadelphia, 1995.

[MN71] R. L. Morse and C. W. Nielson. Numerical Simulation ofthe Weibel Instability in One and Two Dimensions. Physics ofFluids, 14:830–840, April 1971.

[MOS+00] C.-D. Munz, P. Omnes, R. Schneider, E. Sonnendrucker,and U. Voß. Divergence Correction Techniques for MaxwellSolvers Based on a Hyperbolic Model. Journal of Computa-tional Physics, 161:484–511, July 2000.

[NTZL07] K. Noguchi, C. Tronci, G. Zuccaro, and G. Lapenta. For-mulation of the relativistic moment implicit particle-in-cellmethod. Physics of Plasmas, 14(4):042308–+, April 2007.

[PACZ09] N. V. Pogorelov, E. Audit, P. Colella, and G. P. Zank,editors. Numerical Modeling of Space Plasma Flows:ASTRONUM-2008, volume 406 of Astronomical Society of thePacific Conference Series, April 2009.

[RBDL04a] P. Ricci, J. U. Brackbill, W. Daughton, and G. Lapenta.Influence of the lower hybrid drift instability on the onset ofmagnetic reconnection. Physics of Plasmas, 11:4489–4500,September 2004.

[RBDL04b] P. Ricci, J.U. Brackbill, W. Daughton, and G. Lapenta.Collisionless magnetic reconnection in the presence of a guidefield. Phys. Plasmas, 11(8):4102–4114, 2004.

[RLB02a] P. Ricci, G. Lapenta, and J.U. Brackbill. Gem challenge:Implicit kinetic simulations with the physical mass ratio. Geo-phys. Res. Lett., 29:10.1029/2002GL015314, 2002.

[RLB02b] P. Ricci, G. Lapenta, and J.U. Brackbill. A simplified im-plicit maxwell solver. J. Computat. Phys., 183:117–141, 2002.

[RLB03] P. Ricci, G. Lapenta, and J.U. Brackbill. Electron accelera-tion and heating in collisioneless magnetic reconnection. Phys.Plasmas, 10(9):3554–3560, 2003.

[RLB04] P. Ricci, G. Lapenta, and J.U. Brackbill. Structure ofthe magnetotail current: Kinetic simulation and comparisonwith satellite observations. Geophys. Res. Lett., 31:L06801,doi:10.1029/2003GL019207, 2004.

[Saa03] Y. Saad. Iteractive Methods for Sparse Linear Systems.SIAM, Philadelphia, 2003.

[SB91] D. Sulsky and J. U. Brackbill. A numerical method for sus-pension flow. J. Computat. Phys., 96:339, 1991.

[spa] http://www.ofcm.gov/nswp-sp/text/a-cover.htm.[T00] Gabor Toth. The ∇ · B = 0 constraint in shock-capturing

Page 101: Particle In Cell Methods - University of New Hampshirefishercat.sr.unh.edu/psc/_downloads/lapenta.pdf · Particle In Cell Methods With Application to Simulations in Space Weather

Bibliography 95

magnetohydrodynamics codes. J. Comput. Phys., 161(2):605–652, 2000.

[TH05] A. Taflove and Susan C. Hagness. Computational Electro-dynamics: The Finite-Difference Time-Domain Method. ArtechHouse Publishers, Norwood, 2005.

[VB92] H. X. Vu and J. U. Brackbill. Celest1d: An implicit, fully-kinetic model for low-frequency, electromagnetic plasma simu-lation. Comput. Phys. Comm., 69:253, 1992.

[VB95] H.X. Vu and J.U. Brackbill. Accurate numerical solution ofcharged particle motion in a magnetic field. J. Computat. Phys.,116:384, 1995.

[VCF+04] J.-L. Vay, P. Colella, A. Friedman, D. P. Grote, P. Mc-Corquodale, and D. B. Serafini. Implementations of meshrefinement schemes for Particle-In-Cell plasma simulations.Computer Physics Communications, 164:297–305, December2004.

[VCM+02] J.-L. Vay, P. Colella, P. McCorquodale, B. van Straalen,A. Friedman, and D. P. Grote. Mesh refinement for particle-in-cell plasma simulations: Applications to and benefits for heavyion fusion. Laser and Particle Beams, 20:569–575, October2002.

[WL08a] W. Wan and G. Lapenta. Electron Self-Reinforcing Pro-cess of Magnetic Reconnection. Physical Review Letters,101(1):015001–+, July 2008.

[WL08b] W. Wan and G. Lapenta. Evolutions of non-steady-statemagnetic reconnection. Physics of Plasmas, 15(10):102302–+,October 2008.

[WL08c] W. Wan and G. Lapenta. Micro-Macro Coupling in PlasmaSelf-Organization Processes during Island Coalescence. Phys-ical Review Letters, 100(3):035004–+, January 2008.

[WLDE08] W. Wan, G. Lapenta, G. L. Delzanno, and J. Egedal.Electron acceleration during guide field magnetic reconnec-tion. Physics of Plasmas, 15(3):032903–+, March 2008.

[WROC01] D. R. Welch, D. V. Rose, B. V. Oliver, and R. E. Clark.Simulation techniques for heavy ion fusion chamber transport.Nuclear Instruments and Methods in Physics Research SectionA: Accelerators, Spectrometers, Detectors and Associated Equip-ment, 464(1-3):134–139, 2001.