fundamentals of plasma simulation (i)

53
Fundamentals of Plasma Simulation (I) 核核核核核核 核核核核 核核核核核核 / 核核核核 核核核核核核/ 核核核核 核核核 () / 核核核核D1 2007.4.9 — 2007.7.13 Part two: Fundamentals of simulation me thods Introduction Importance of simulation & limitations of simulation Developments of computer system & parallel computation Time advance Initial value problem Numerical stability & CFL condition Explicit methods Semi-implicit & fully implicit methods Predictor/Corrector methods References: T. Tajima, computational plasma physics

Upload: demi

Post on 18-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Fundamentals of Plasma Simulation (I). 核融合基礎学(プラズマ・核融合基礎学) / 京都大学 李継全( 准 教授) / 岸本泰明(教授) / 今寺賢志( D1 ) 2007.4.9 — 2007.7.13. Part two: Fundamentals of simulation methods ➣ Introduction Importance of simulation & limitations of simulation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Fundamentals of Plasma Simulation (I)

Fundamentals of Plasma Simulation (I)核融合基礎学(プラズマ・核融合基礎学) / 京都大学

李継全(准教授) / 岸本泰明(教授) / 今寺賢志( D1 )2007.4.9 — 2007.7.13

Part two: Fundamentals of simulation methods ➣ Introduction

Importance of simulation & limitations of simulation Developments of computer system & parallel computation

➣ Time advance Initial value problem Numerical stability & CFL condition Explicit methods Semi-implicit & fully implicit methods Predictor/Corrector methods

References: T. Tajima, computational plasma physics

Page 2: Fundamentals of Plasma Simulation (I)

Importance of numerical simulation

Analytical solutions exist only in limit cases. We have established several theoretical approaches to describe plasmas—plasma equations. Generally speaking, we can investigate physical phenomenon by applying these theories if we might have the solutions of these equations. However, plasma physics, like all sciences, is full of high nonlinearity and complexity, analytical solutions exist only in extremely rare cases.

Experimental tools are also limited.On the other hand, traditional experiments is limited to measure only a small fraction of the interested quantities with a limited degree of accuracy. Hence, one is usually faced to interpret limited observations with incomplete analytical solutions. Numerical modeling and simulation can bridge the gap between experiments and the ability of theorists. Numerical experiment is to simulate the physical behavior of complicated plasma by solving an appropriate set of equations based on an accepted model.

Page 3: Fundamentals of Plasma Simulation (I)

Importance of numerical simulation (cont.)

Numerical simulation is popular and powerful in almost all scientific research fields. On the one hand, it includes many advantages of numerical modeling to helpfully solve some traditional problems or reproduce complex physical phenomenon. On the other hand, simulation is essential in studying plasma turbulence and related transport, nonlinear dynamics like chaos and structure formation. Simulation can try innovative ideaMost importantly, simulation can solve some problems which is out of analytical solutions or not realistic due to scale in experiments. For example, it is difficult to reproduce space plasma process in laboratory but it is possible to have a numerical observatory. It can perform some innovative ideas to predict new physics.

Page 4: Fundamentals of Plasma Simulation (I)

Descriptions and simulations of plasmas

Real physical Processes

Experiments; et al.

Numerical simulationDiscrete algebraic appro.;

Numerical algorithms;Codes; et al.

Mathematic modeling Description

Plasma theories; et al

Computer simulation may be regarded as the theoretical exercise of numerically solving an initial-value-boundary-value problem.

Simulation consists of following the temporal evolution of the configuration.

Central task in simulation is the calculation of partial derivatives: ∂nu(t,x,v)/ ∂xn; ∂nu(t,x;v)/ ∂tn ; ∂nu(t,x;v)/ ∂vn with high accuracy. In the following lectures, we will introduce some fundamental methods (schemes) to do space discretization and time advance in numerically solving equation systems.

Page 5: Fundamentals of Plasma Simulation (I)

Targets of plasma simulations

Target equations in simulationVlasov & F-P simulation: (Vlasov code) ● kinetic equations (Vlasov; drift-kinetic; gyrokinetic; F-P) in (x, v) phase space ● gyrokinetic Poisson-Ampere eqs. Particle simulation: (particle code) ● kinetic-Maxwell system (gyrokinetic;drift-kinetic eq.) ● particle motion equation ● poisson-Ampere eqs.

Fluid simulation: (fluid code) ● fluid moment equations (MHD; fluid; gyro-fluid)

Plasma physics theory

Kinetic description(Kinetic/gyro-kinetic

theory)

fluid description(MHD; two-fluid; …)

Gyro-fluid description(with Landau and

FLR damping)

Particle codesVlasov &

Fokker-Planck codes Kinetic/fluid Hybrid code

Fluid/MHD code/Gyrofluid code

Kinetic electrons Fluid ions

Page 6: Fundamentals of Plasma Simulation (I)

Limitations of numerical simulation

Numerical modeling: Numerical simulation results depend on the numerical modeling which should include most essential factors due to the complexity of plasma physics. That is, the physical description of the system by the chosen equations must be accurate for the considered problem (e.g., length and time scales)

Computer resource (speed; memory……) is always limited so that the physical size of the problem in time and in space has to be shortened.

Simulation uses different statistical average from the strict ensemble averaging. Computer produces only one ensemble per run in general, however, for most statistical arguments, the quantities are statistically averaged ones. It is not practical to perform many runs to make ensemble averaging. If the system is in a quasi-steady state, the average and spatial average are used to replace the ensemble averaging.

Numerical accuracy due to the time-spatial discretization. How close can we approach the true description of plasma processes (continuous functions in equation system) by discretizing all the physical processes (discrete grid or particle quantities) for the computer. This is related the numerical discretization methods and also capacity of computer if the accuracy increases linearly with the number of grids or particles.

Page 7: Fundamentals of Plasma Simulation (I)

Developments of computer system & parallel computation

The speed of computer increases exponentially through the years (from Top500 data).

102

103

104

105

106

1992 1994 1996 1998 2000 2002 2004 2006 2008

Pea

k s

pee

d (

GF

lop

s)

Time (Year)

Fujitsu

Hitachi

Intel

IBM

NEC

IBM

IBM(Flop=floting point operations per second)

processor number

Single scalar processor

(CPU)

Vector process

or

parallel supercomput

erS – speed of each processorF – efficiency of the parallelized code Np – number of processorsP – proportion (can be parallelized)τ C – time for inter-processor communication τ S – S /Np

Cp

P PFSN

NP

S

N )1(

1

1

N

S

FN

PP C

pP

S

Parallel execution time for problem N

Speed-up is:

Page 8: Fundamentals of Plasma Simulation (I)

Summary of plasma equations

)1

( Bc

Em

q

m

F

dt

di

i

i

i

ii

ii

dt

xd

0 ;14

1 ;4

Bt

E

cJ

cB

t

B

cEE

m

m

s

iss

mss

m xxqdtxNqtx )(),,(),( 3

The microscopic sources are determined by

s

iiss

mss

m xxqdtxNqtxJ )(),,(),( 3

N

iii

m ttxxxtN1

)]([)]([),,( with

Particle simulations

Or Boltzmann (FP, Vlasov) equation plus equation of motion and Maxwell equations

c

ssss

t

ffB

cE

m

q

x

f

t

f

)

1(

Fluid simulations

csssssssxsss QuEnqqPuuumnpumnpt

22

2

3

2

3Energy equation

cssssssssss RBuc

EqnPuut

nmudt

dnm

)1

(�Equation of motion

nss Qnut

n

Continuity equation

zzzz

m jct

2],[1

],[

42],[ t

MHD simulations

Page 9: Fundamentals of Plasma Simulation (I)

Initial value problemThe equations above can be written as the following general form

n

n

m

m F

x

FFxtGxtF

t

,,;,,),,(with ),( 0000

xFF tt

and boundary conditions

Typically, this is an initial value problem. In kinetic modeling (Particle or Vlasov simulations, it includes the dependence of velocity and its derivatives. In plasma fluid (MHD) simulations, it is simplified as

Initial value problem is common in computational physics, also in plasma simulations, for example, particle motion in electric and magnetic field; plasma turbulence and transport simulation; wave-particle interaction; wave propagation; …... We will separate the problem into two issues: time integration and spatial discretization. Before that, we first introduce preliminary computational techniques in plasma simulations.

m

m

x

FFxtGxtF

t

,;,),( )( 000xFF tt

with

Page 10: Fundamentals of Plasma Simulation (I)

General procedures in simulations

To perform a simulation for a given physical problem, we should consider these steps

1. Mathematical formula (equations with initial value and boundary conditions)

2. Numerical discretization (discrete continuous physical quantities in time and space, calculate derivatives). In this step, we obtain a system of algebraic equations. For the spatial discretization, some well-established methods can be applied such as finite-differences; finite element; finite volume; and spectral methods. (Numerical error is produced in this step during discretization!)

3. Time advance. For the time integration, various explicit or implicit schemes have been constructed. If implicit scheme is employed, we need to have a solver.

4. Numerical diagnoses and result analyses to approximate solution.

Page 11: Fundamentals of Plasma Simulation (I)

Initial value problem—1D case

m

m

x

ffxtGxtf

t,;,),( )( 000

xFF tt

with

Considering an initial value problem represented by partial differential equation

In order to solve (numerically integrate ) this equation by computer, we should discretize it in time and in space, i.e., we must approximate the differentiation by finite difference. For example, simply we can have

2

11

2

21 2),( ;),(

t

fffxtf

tt

ffxtf

t

ij

ij

ij

ij

ij

t→i

x→ j

(i,j)(i,j-1) (i,j+1)

(i+1,j)

(i-1,j)

2

11

2

21 2

),( ;),(x

fffxtf

xx

ffxtf

x

ij

ij

ij

ij

ij

These expressions reduce to the original differentiation when ∆t tends to zero.

...2

2

...2

1

)(2

2

22

2

22

2

42

2

2

11

t

ft

t

ftff

t

ft

t

ftf

t

tt

f

t

fff

ij

iji

jij

ij

iji

j

ij

ij

ij

ij

Many schemes representing the differential operators can be chosen, which depends on the accuracy and economy in simulation.

Page 12: Fundamentals of Plasma Simulation (I)

Numerical stability—Courant-Friederich-Levy(CFL) conditionWhen we choose the finite difference scheme, more important consideration should be its numerical stability in time. We will take the harmonic oscillator as an example to analyze it. This harmonic oscillator may originate from plasma oscillation.

xen

d

UE e

0

Consider an infinite slab of electrons and ion with a width of d (in x ) and particle density of n0. Assumethat the electrons are displaced by a small distance x in the x direction. This creates two regions of nonzero charge density. The electric field is produced as

+++++++++

---------

ions

d

electrons

n0

The electrons move under the electric field acceleration with an initial position x0(t=0). This initial value problem is described as

xxEm

e

dt

dp

e

2)(

dt

dx

Now we can choose different finite difference scheme to discretize these equations. It will show different numerical stability!

)cos(0 txx peIt has an analytical solution

Page 13: Fundamentals of Plasma Simulation (I)

Numerical stability—CFL condition (cont.)

Firstly, a so-called forward differencing is applied

xtdt

dp

ii2

1

iii

t

xx

dt

dx

1

We look for linear stability with an amplification factor g over he adjacent time step to analyze the numerical properties of this equation systemAssuming

)1ˆ (with )( ;)()( ; 201 igegxgxx iiitiiiii

The finite difference equations become

)()()(

)()()(0001

02001

iii

ip

ii

gtxgxg

xgtgg

The amplification factor g can be solved by setting the determinant of the amplification matrix as zero

01)-(g1

1 2222

tgt

tgp

p

1 Δtiωg p

It can be seen that if |g|2=1+ω 2 t∆ 2>1, the solution blows up in time. The amplitude of oscillator is amplified numerically. So, this forward differencing scheme is always numerically unstable for any small t! (This means we can not use it.) ∆

Page 14: Fundamentals of Plasma Simulation (I)

Numerical stability—CFL condition (cont.)Now we choose another finite difference scheme, the so-called leapfrog scheme

υ

x

t

ti i+1 i+2

i+1/2 i+3/2

2121

ip

ii

xtdt

d

12123

iii

t

xx

dt

dx

Using the same amplification factor g defined in

)1ˆ (with )( ;)()( ; 201 igegxgxx iiitiiiii

We have the amplification matrix 1

2123

212

ggtg

tgg p

The determinant of amplification matrix equals to zero, we have

01)2( 222 gtg p

1421 2222 tttg ppp

Page 15: Fundamentals of Plasma Simulation (I)

Numerical stability—CFL condition (cont.)

01422 tpIf

41ˆ21 2222 ttitg ppp

Then

In this case 1*2 ggg This scheme is stable. If , it is unstable.01422 tp

The stability condition is pt 2

Time step should be enough small to achieve desirable accuracy. This is the Courant –Friederich—Levy (CFL) condition.

Leapfrog scheme is common in particle simulation since two first-order differential equations can be separately integrated for each particle. In simulations, especially in particle simulation with enough more particles, we should consider two aspects when we choose the scheme: — The scheme is as fast a method as possible and still retain acceptable accuracy; — Minimum information needs to be stored when the equation is integrated. On the one hand, it will take more calculation, on the other hand, it will cost much time for data communication among processors in modern parallel simulations.

Leapfrog scheme is of advantages in these two aspects compared to high-order scheme like Runge-Kutta method.

Page 16: Fundamentals of Plasma Simulation (I)

Biasing schemeFor the same differential equation system of plasma oscillator

xxEm

e

dt

dp

e

2)(

dt

dx

We generalize the leapfrog scheme to introduce a non-integer time step, (i+τ )th time step to push the above equation, similarly discretize the equations to get

ip

ii

xtdt

d 21

211

iii

t

xx

dt

dx

When τ =0, it reduces to the forward differencing scheme which is numerical stable; when τ =1/2, it is the leapfrog scheme, which is numerical stable for . pt 2

Similar numerical stability analysis for this scheme. The amplification matrix is

1

1 2

gtg

tgg p

0)1(

1

1 22222

gtggtg

tggp

p

When τ =1, the scheme becomes implicit, we have

0)1( 2222 gtg p 11

1|| 222

tg

pHence, this scheme is always stable.

Page 17: Fundamentals of Plasma Simulation (I)

Discretization of derivatives in numerical calculation

t→i

x→ j

(i,j)(i,j-1) (i,j+1)

(i+1,j)

(i-1,j)

t

ff

dt

df

t

ff

dt

df

t

ff

dt

df ii

backward

ii

centered

ii

forward

1111

| ;2

| ;|

x

ff

dx

df

x

ff

dx

df

x

ff

dx

df jjbackward

jjcentered

jjforward

1111 | ;2

| ;|

In numerical calculations, there are many different ways to discrete the derivatives. For example for the first order derivative in time and space, we can have

And also in the initial value problem with spatial derivatives, we can calculate the spatial derivatives in different time. For example in a diffusion problem

2

2

x

Tu

t

T

We can have two different ways of descretization

2

111 2

x

TTTu

t

TT ij

ij

ij

ij

ij

2

11

111

1 2

x

TTTu

t

TT ij

ij

ij

ij

ij

)2( 1121 i

jij

ij

ij

ij TTT

x

tuTT

)(

21 1

1112

1

21 i

jij

ij

ij TT

x

tuT

x

tuT

Page 18: Fundamentals of Plasma Simulation (I)

Explicit and implicit schemesBased on the discretization above, we can see two different schemes:

In the first case, the new future value [t=(i+1)∆t] can be given entirely by the old values at t=i ∆t. This is called as explicit scheme. In this case, the calculation is straightforward and easy. In the second case, the new future value [t=(i+1)∆t] should be calculated by the old values and some undetermined new values. This is called as implicit scheme. Since we do not know the undetermined new values, we cannot advance the differential in an explicit way. In this case, we should have a solver to calculate the matrix.

So let’s come back to the Bias scheme

when τ =0, the forward differencing scheme is explicit method (unstable); when τ =1/2, the leapfrog scheme is also explicit method (but conditionally stable)

t→i

x→ j

(i,j)(i,j-1) (i,j+1)

(i+1,j)

(i-1,j)Old values

υ

x

t

ti i+1 i+2

i+1/2 i+3/2

Old values

Page 19: Fundamentals of Plasma Simulation (I)

Explicit and implicit schemes (cont.)when τ ≤1/2, we call this is the backward bias scheme. It is an explicit method;

υ

x

t

ti i+1 i+2

i+1/2 i+3/2

Old values

υ

x

t

ti i+1 i+2

i+1/2 i+3/2

Old values

Here the reason we call the forward bias scheme with τ ≥1/2 as implicit method is because we have to express partially the terms at t=(i+ τ ) t by using old values at t=i t an∆ ∆d new values t=(i+ 1) t. ∆

when τ ≥1/2, it is called forward bias scheme, it becomes implicit method.

Page 20: Fundamentals of Plasma Simulation (I)

Low order or high order schemes

The characteristics of leapfrog scheme are: two-order accuracy; explicit and simple; numerically stable. Taking the plasma oscillator as an example, equations become

The accuracy of a finite difference approximation depends on a number of aspects. Higher accuracy can be achieved by the inclusion of more terms in the Taylor expansion and by using preferably centered difference schemes rather then one sided differencing such as backward or forward differencing like follows.

)(8

1

2|

);(2

1|

323

311

22

21

tΟtt

f

t

ff

dt

df

tΟtt

f

t

ff

dt

df

iii

centered

iii

forward

Usually, higher order schemes can get a better approximation to the actual result, however, how high order an approximation is necessary depends on numerical purposes.

xdt

xdp2

2

2

4

42

2

2expansionTayler

2

11

2

2

122

t

xt

t

x

t

xxx

dt

xd iii

Page 21: Fundamentals of Plasma Simulation (I)

Low order or high order schemes (cont.)

4th Runge-Kutta scheme is a typical high-order method, which is characterized by: 4th order accuracy; explicit (or implicit); numerically stable. It needs 3~4 times storage of leapfrog scheme. Usual 4th order RK scheme for equation dx/dt=f (t,x) is

)(6/)( 44321

1 txxxxxx ii

];2/,)2/1[(

);,(

12

1

xxtitfx

xtitfxi

i

]2,)1[(

];4/)(,)2/1[(

324

213

xxxtitfx

xxxtitfxi

i

Comparison between low-order leapfrog scheme and high-order RK scheme: the former gives numerical stability and energy conservation, but can not follow sudden changes in the exact solution (discontinuity). However, RK scheme may cause an increase of energy at a rate determined by the allowed error along trajectories in a non-dissipative system. High-order RK scheme can calculate sharp change of the exact solution much more closely than the leapfrog method.

Page 22: Fundamentals of Plasma Simulation (I)

Low order or high order schemes (cont.)

Example: Phase space orbits of pendulum

Leapfrog Runge-KuttaExample: Phase space trajectories of Rayleigh oscillator

sin2

22 mg

tm

Periodic orbit Non-periodic orbit

42

2

2

t

xC

t

xBA

t

xkx

t

xm

Leapfrog scheme correctly gives a closed orbit; RK scheme shows the orbit open up due to error.

RK scheme shows true trajectory with change corners; Leapfrog one overshoots sharp change and damps the error.

Leapfrog Runge-Kutta

Page 23: Fundamentals of Plasma Simulation (I)

Low order scheme? high order ?

1. Higher order scheme is of high accuracy but also require more computational effort. The choice of the approximation order is one of computational efficiency.  

2. A second consideration is how well a chosen grid resolves the actual solution. It requires a good resolution to realize the advantage of a high order scheme. However, a lower order scheme may already provide reasonable results for a good grid resolution.

3. The first order schemes should always be avoided. In many cases it is sufficient to use a scheme of second order accuracy. In terms of numerical efficiency one often has the choice between a simple second order scheme and larger number of grid points or a more complex higher order approximation with less grid points (and thus larger grid spacing). Advantages and disadvantages should be carefully considered, i.e., numerical efficiency to achieve a particular accuracy. The complexity of higher order schemes usually requires more effort in terms of programming and programs are of higher complexity.

4. High order schemes have only limited advantage for discontinuities.

Some important aspects should be considered when we choose suitable scheme:

Page 24: Fundamentals of Plasma Simulation (I)

Explicit scheme

Explicit scheme is traditionally of simplicity in programming code and high speed to push the time integration. In addition, it possesses high parallelization efficiency in modern parallel computation.

We will introduce some typical explicit scheme in the application of plasma simulations.

Page 25: Fundamentals of Plasma Simulation (I)

Explicit scheme— Particle motion— Time centered scheme

The equation of motion is discretized in the time-centered scheme as

2/12/10

1

)(

i

ycix

e

ix

ix B

m

e

t

2/12/10

1

)(

i

xciy

e

iy

iy B

m

e

t

Now we must approximate by the average of vicinal grids 2/1;iyx

iyx

iyx

iyx ;

1;

2/1; 2

1

Then we have finite difference equations

iyiy

cix

ix

t

11

2 ixi

xci

yiy

t

11

2

0Bm

e

dt

d

e

meBie cti c

0yx

ˆ

0 ;ˆ with

In the code, we should reproduce the gyromotion with constant velocity.

Let us consider the particle motion in a static magnetic filed due to Lorentz force

Page 26: Fundamentals of Plasma Simulation (I)

Explicit scheme— Time centered scheme (cont.)

If let g=υ i+1/υ i be the amplification factor, stability analysis shows the amplification matrix

12/)1(

2/)1(1

ggt

gtg

c

c

Stability equation is 0)1()2/()1( 222 gtg c

It gives the stability condition |g|2=1 when

ct /2

This is similar to the leapfrog stability for the plasma oscillation.

Page 27: Fundamentals of Plasma Simulation (I)

Explicit scheme—transport problem (—FTCS scheme)

Corresponding difference equation for 1D case by using FTCS scheme is

)2( 1121 i

jij

ij

ij

ij TTT

x

tuTT

FTCS— forward in time (FT) and centered in space (CS)

t→i

x→ j

(i,j)(i,j-1) (i,j+1)

(i+1,j)

With truncation error

)(6

1

24

4

4

2

2

xΟx

T

x

tuxuT

iji

j

The general approach in considering the numerical stability of a scheme is to derive an amplification factor for a Fourier mode and the amplification factor is defined as . It can be derived as

tiixkjiij eT ˆˆ

tieg ˆ

2

sin4

1 22

xk

x

tug

CFL condition is |g|2≤1 for all wave-numbers. That isu

xt

2

2

2

2

2

2

y

T

x

Tu

t

T

Transport phenomenon such as heat conductivity or magnetic field diffusion are very popular in plasma physics. It is described by a parabolic differential equation

Page 28: Fundamentals of Plasma Simulation (I)

In 2D case, the difference equation becomes

)2()2( 1,,1,2,1,,12,1

,ikj

ikj

ikj

ikj

ikj

ikj

ikj

ikj TTT

y

tuTTT

x

tuTT

CFL condition is 1

22

11

2

1

yxu

t

An improved scheme can be derived if ∆x=∆y,

)2( 1,,1,2* i

kjikj

ikj

ijj TTT

x

tuTT

)2( *,1

*,

*,12

*1kjkjkjj

ij TTT

x

tuTT

Explicit scheme—transport problem (—2D FTCS scheme)

Page 29: Fundamentals of Plasma Simulation (I)

—Richardson schemeDifference equation of diffusion problem by using a leapfrog scheme is

)2(2

11211 i

jij

ij

ij

ij TTT

x

tuTT

This is a scheme with centered difference in time and in space. It is called as Richardson scheme. Stability analysis yields the equation of the amplification factor

012

sin8 2

22

gxk

x

tug

t→i

x→ j

(i,j)(i,j-1) (i,j+1)

(i+1,j)

(i-1,j)

It can be seen that |g|2>1. This scheme is unconditionally unstable

2

22

22 2

sin4

12

sin4

xk

x

tuxk

x

tug

The amplification factor is

Explicit scheme—transport problem (—Leapfrog scheme)

Page 30: Fundamentals of Plasma Simulation (I)

Explicit scheme—transport problem (—DuFort-Frankel scheme)The unconditionally unstable Richardson scheme can be modified by splitting 112 i

jij

ij TTT

into two time levels. It leads to the so-called Dufort-Frankel scheme

])([2

111

1211 i

jij

ij

ij

ij

ij TTTT

x

tuTT

t→i

x→ j

(i,j-1) (i,j+1)

(i+1,j)

(i-1,j)

We can explicitly solve this difference equation as

21

111 2

with 1

1)(

1 x

tuTTTT i

jij

ij

ij

The equation of amplification factor can be derived as

01

1)cos(

12

gxkg

The amplification factor is

)(sin1)cos(1

1 22 xkxkg

It shows this scheme is stable for all wave-numbers. However, it may give oscillatory solution so that this method in this range is not accurate.

Page 31: Fundamentals of Plasma Simulation (I)

Explicit scheme—fluid (MHD) model— convective problem

Fluid (MHD) equations are hyperbolic and they are of convection type.

This equation system is not straightforward to be integrated in time since they include the convective derivative terms (also called advective term) ),( xtfu

t

vtdt

d

Dt

D

zt

z

yt

y

xt

xv

means the rate of change at fixed point (Eulerian)

means the rate of change at moving point (Lagrangian)

the change due to motion

In Eulerian frame, there is difficulty to integrate in spatially-fixed time due to this nonlinear term. (still current research topics!) On the other hand, one attempts to come to Lagrangian frame to solve some difficulty appeared in Eulerian approach, it also bring in some own new problems (such as grid entanglements as the fluid churns; complex Lagrangian algorithm).

0)(

ut mm

pBjc

uutm

1

2)(1

1jupup

t

px

Page 32: Fundamentals of Plasma Simulation (I)

The convective difficulty associated with the Eulerian algorithm may be looked at in a simple 1D example.

),( with 0 xtx

f

t

f

All fluid (MHD) equations include such a structure. For example, in density equation, υ is ρ; in momentum and pressure equations, υ is u. At first, we consider the simplest case with constant υ. The analytical solution at time t for an initial value condition f(t=0, x)=F(x) is given by the transport of initial profile,

)(),( txFxtf Now we will take numerical approximation. The simplest way is direct discretization by using FTCS scheme

x

ffu

t

ff ij

ij

ij

ij

211

1

ij

ij

ij

ij ff

x

tuff 11

1

2

Stability analysis shows that the amplification factor is

xkx

tuig

sinˆ1

So this is always numerically unstable scheme. This indicates that the algorithm using FTCS scheme cannot be utilized.

Explicit scheme—fluid (MHD) model— Linear convection

Letting and then, tiixkjiij ef ˆˆ tieg ˆ

xkixkiti eex

te

ˆˆˆ

21

Page 33: Fundamentals of Plasma Simulation (I)

If we replace the spatial differencing by using upwind scheme is last FTCS method, we get

x

ffu

t

ff ij

ij

ij

ij

1

1

ij

ij

ij

ij ff

x

tuff 1

1

Stability analysis shows that the amplification factor is

xkixkx

tug

sinˆ1cos1

The stability require (CFL condition)

2

sin141*|| 22 xk

x

tu

x

tuggg

uxtx

tu

or 1

t→i

x→ j

(i,j)(i,j-1)

(i+1,j)

Expanding the upwind scheme in Taylor series

0),(12

1 222

2

xtΟx

f

x

tux

x

f

t

f

This scheme is the first order accurate with leading error term represented by second derivative of x, therefore it represents a numerical diffusion.

Explicit scheme—fluid (MHD) model— Upwind scheme

Page 34: Fundamentals of Plasma Simulation (I)

Explicit scheme—fluid (MHD) model— leapfrog schemeA rather simple and second order accurate scheme is the so-called Leapfrog scheme

t→i

x→ j

(i,j)(i,j-1) (i,j+1)

(i+1,j)

(i-1,j)

x

ffu

t

ff ij

ij

ij

ij

2211

11 ij

ij

ij

ij ff

x

tuff 11

11

Stability analysis shows that the amplification factor is

01sin2ˆ2

gxkx

tuig

If , |g|=1. In this case this scheme is numerically stable. On the other hand, , |g|>1, the algorithm is unstable. Thus the linear stability condition (CFL condition) for all wave-numbers is

We obtain

xkx

tuxk

x

tuig 2

2

sin1sinˆ

1121

21

ij

ij

ij

ij ff

x

tuff

1|| xtu1|| xtu

||xt

Leapfrog scheme only requires either the oven or the odd gridpoints/timelevels. The differencing decouples odd and even grid points at any given time step such that a solution can develop independently on the interlaced odd/even grid. Thus it may lead to strong oscillations on the grid scale if the two grids are combined. This problem in connection to the issues of diffusion and dispersion.

Page 35: Fundamentals of Plasma Simulation (I)

Explicit scheme—fluid (MHD) model— Lax schemeIf we replace by a spatially averaged term in the FTCS scheme, we can have the so-called Lax scheme

ijf 2)( 11

ij

ij

ij fff

ij

ij

ij

ij

ij

ij

ij

ij ff

x

tuffff

x

tuff 111111

1

22

1

2

Similarly, we can do stability analysis to get the amplification factor

xkx

tuixkg

sinˆcos

2

22 1sin1||x

tuxkg

Therefore the stability (CFL) condition is

|| 1|| 2 xtg

Although this scheme is stable, the accuracy is the first order in space. When the CFL condition is not satisfied, an oscillating solution grows exponentially in time.

Page 36: Fundamentals of Plasma Simulation (I)

Explicit scheme—fluid (MHD) model— Lax scheme (cont.)If we rewrite the difference equation

ij

ij

ij

ij

ij

ij

ij

ij

ij

ij ff

x

tuffffffff 1111

1111

22

2

12

2

1

2

1

The corresponding differential form is

022 2

22

2

2

x

f

x

f

t

x

t

ft

t

f

An effective diffusion is incurred in this equation. With , the spatial numerical diffusion incurred by this algorithm

222 ~ xt

fttxfD 2222 ]22[""

||xt When , the numerical diffusion coefficient “D” is positive, the scheme is stable. On the contrary, it is unstable. It is very difficult to satisfy the exact condition since the velocity υ is a variable.

In addition, the algorithm also causes distortion in the dispersion relation of the eigenmodes.

||xt

Page 37: Fundamentals of Plasma Simulation (I)

Explicit scheme—fluid (MHD) model— Lax-Wendroff scheme

A scheme closely related to the Leapfrog is the Lax-Wendroff method, which can avoid excessive numerical diffusion and distortion of the dispersion relation in the LAX scheme.

In this scheme, we have twice discretization by using Lax scheme. The first step is over a half time step

ij

ij

ij

ij

ij ff

x

tufff 1111

21

2

2/

2

1

The second step is a full time step

211

211

1

2

ij

ij

ij

ij ff

x

tuff

Combining two steps, we have

i

jij

ij

ij

ij

ij

ij fff

x

tuff

x

tuff 2222

1 22

2/

2

1

2

t→i

x→ j(i,j)

(i+1/2,j-1) (i+1/2,j+1)

(i+1,j)

(i,j-2) (i,j+2)

(Actually, this is a predictor-corrector scheme, we will explain the details later.)

Page 38: Fundamentals of Plasma Simulation (I)

Explicit scheme—fluid (MHD)— Lax-Wendroff scheme (cont.)

Stability analysis shows

12cos2

2sin2

ˆ12

xkx

tuxk

x

tuig

Stability condition |g|2≤1 gives

12cos12

12

1|| 222

2

xkx

tu

x

tug

Hence the stability condition gives CFL condition12

2

x

tu

||xt

Lax-Wendroff scheme is a second order method in time and in space. The second term in the brace of right side is a diffusion term called the Lax-Wendroff diffusion.

Page 39: Fundamentals of Plasma Simulation (I)

)(|2

| 32

221 t

t

ftu

t

ftuff jj

ij

ij

Lax-Wendroff scheme can be derived by using the forward time discretization with a correction that eliminates the lowest order error of the forward time differencingas follows. Expanding the convective equation in time using a Taylor series

Substituting the time derivatives from the differential equation

)(|2

)(| 3

2

221 t

x

ftu

x

ftuff jj

ij

ij

Using centered differences for the spatial derivatives

i

jij

ij

ij

ij

ij

ij fff

x

tuff

x

tuff 1111

1 22

Hence this scheme can be regarded as a correction of the FTCS scheme to eliminate the lowest order error of the forward time differencing due to numerical diffusion.From the stability analysis, in the small k∆x limit,

6422

2 )2(4

)2(

21

21|| xkΟ

xk

x

tu

x

tug

Hence the numerical diffusion is fourth order in k∆x , it is small for long wavelength.

Explicit scheme—fluid (MHD)— Lax-Wendroff scheme (cont.)

Page 40: Fundamentals of Plasma Simulation (I)

Implicit scheme

The stability of explicit schemes is governed by the CFL condition about the allowable time step. These methods could become inefficient when the equation system becomes high stiff or when the spatial mesh is largely non-uniform. In such cases it is desirable to use implicit scheme. The advantage of this method lies in the numerical stability and large time step.

Page 41: Fundamentals of Plasma Simulation (I)

Implicit scheme – transport problem – FTCS scheme

Corresponding difference equation for 1D case by using implicit FTCS scheme is

)2( 11

1112

1

ij

ij

ij

ij

ij TTT

x

tuTT

FTCS— forward in time (FT) and centered in space (CS)

t→i

x→ j

(i+1,j)(i+1,j-1) (i+1,j+1)

(i,j)

With truncation error

)(6

12

44

42

xΟx

T

tu

xtuT

iji

j

For the amplification factor . Stability analysis showstieg ˆ

1

22 2

sin4

1

xk

x

tug

This indicates this scheme is unconditionally stable for all wave-numbers

2

2

2

2

y

T

x

Tu

t

T

Transport phenomenon is described by a parabolic differential equation

From here, we can see that we must calculate the inversion of a matrix at each time step. This is the general nature of implicit scheme. This method is expensive to use in the code.

Page 42: Fundamentals of Plasma Simulation (I)

Implicit scheme – transport problem – Crank-Nicholson scheme

)2(2

)2(2 112

11

1112

1 ij

ij

ij

ij

ij

ij

ij

ij TTT

x

tuTTT

x

tuTT

This scheme produces a second order error in time and in space. The scaling of second order error in time is due to the centered time derivative. The equation of the amplification factor is

This indicates this scheme is unconditionally stable for all wave-numbers.

In explicit FTCS scheme, if we average the spatial diffusion term in time, the difference equation becomes implicit

2sin

21

2sin

21

22

22

xkxtu

xkxtu

g

02

sin2

2sin

21 2

22

2

xk

x

tug

xk

x

tug

The amplification factor is

t→i

x→ j

(i+1,j)(i+1,j-1) (i+1,j+1)

(i,j)(i,j-1) (i,j+1)

Page 43: Fundamentals of Plasma Simulation (I)

Implicit particle code – first order accurate method

In introducing the bias scheme for plasma oscillation, we have known the feature of implicit scheme in solving the equation of motion. Here we consider a 1D unmagnetized homogeneous plasma of finite size particle with only electrostatic interaction. The equation can be discretized by using a fully implicit leapfrog scheme

dt

dx

),( xtEm

q

dt

d

k

k

)(4),(

jj

j xxSqx

xtE

2/11 ij

ij

ij txx

)()( 112/12/1 xExxSxdm

qt ii

jj

jij

ij

])()([4)( 1122/1

1

xExxSxdm

qttxxSq

x

xE iij

j

jij

ij

jj

i

This scheme is restricted by the following time step

max

112 )()(

xExxSxdm

q

t

x iij

j

j

Page 44: Fundamentals of Plasma Simulation (I)

Implicit particle code – Implicit time filteringThe primary goal of the implicit method is to model low frequency phenomena accurately. We will improve the first-order-scheme above so that damping of unwanted high frequency modes increases and the damping of low frequency mode decreases. One way to do so is to replace the fully implicit acceleration in the equation of motion with a time averaged acceleration. This means it will approximately filter out the high frequency responses. One of scheme is

2/11 ij

ij

ij txx

)()( 2/12/12/1 xExxSxdm

qt ii

jj

jij

ij

2/)( 11 iii EEE

It can be seen that these two difference equation are virtually time centered, then preserving the second order accuracy in the leapfrog scheme. The same techniques are used again to solve recursively for the time advanced electric field. This scheme requires more memory and more computation, but has improved frequency filtering over the first order accurate methods.

We can do stability analysis to confirm the improvement.

Page 45: Fundamentals of Plasma Simulation (I)

Semi-implicit schemeAdvantages of implicit schemes: In order to describe the long-time scales of MHD behavior such as the resistive processes, implicit scheme is very useful to remove the time step constraint, by selectively damping out the high frequency components of the field response in the system. However, larger time step causes the narrower spectral width of damping modes. Disadvantages of implicit schemes: On the other hand, implicit scheme requires a large block matrix inversion. Semi-implicit scheme: This method allows a large time step and avoids a large matrix inversion in solving the full implicit equation. The main idea of semi-implicit methods is to add new terms in the time-difference scheme of the MHD equations. These new terms do not affect the solution as the time step tends to zero, and yet the method is absolutely stable relative to fast modes. The step restriction characteristic of ideal MHD is also eliminated.

In the semi-implicit method, the terms approximating linear behavior of fast modes are taken implicitly to achieve numerical stability. The method is similar to implicit methods in 1D case. In the multidimensional anisotropic case, the simplicity of the additional terms makes it possible to obtain matrices that consist of three diagonal blocks and can be easily inverted. Because of efficient matrix inversion, the time complexity of the implicit step is the same as for the explicit step. The form of the semi-implicit terms added in various schemes depends on the nature of the fast modes that must be suppressed.

Page 46: Fundamentals of Plasma Simulation (I)

Semi-implicit scheme – Alfven wave equation

For example, for the fast compressible Alfven wave equation

xa

t

b

x

ba

t

2

2

2

2

xa

t

b

Here b may be magnetic f

ield; υ is fluid velocity, a is the Alfven velocity.

2

2202

22

2

2202

2

xa

xa

xa

t

b

Considering discretizing in time, wave equation becomes

This is an explicit scheme with time step CFL restriction for fast mode. To make the scheme become unconditional stable, we can move the second spatial derivative term to the time step (i+1), but it becomes an implicit scheme. So we add a new term in both sides to make them implicit on the LHS implicit and explicit on the RHS to avoid the calculation of the inversion of matrix.

2

222

02

222

2

1222

01

x

bta

x

bta

t

btb

x

btab

iii

ii

t

b

tt

bb

t

bb

t

bb

t

bbb

t

b iiiiiiiii 122

1

2

1

2

1

2

11

2

2

2

2221

x

bta

t

btbb

iiii

D S Harned & W Kerner, J Comput. Phys. 60, 62(1985)

Page 47: Fundamentals of Plasma Simulation (I)

Semi-implicit scheme – Alfven wave equation (cont.)

This is equivalent to adding a linear term with a coefficient proportional to ∆t in original wave equation

t

btG

xa

t

b

Stability analysis shows it unconditional stable provided that

kattG encyeigenfrequ system with 1422

Where a0 is a constant, which is determined the stability condition. The subtraction of these new terms can have the same effect as making the fast modes implicit, even if it may be very different from the Alfven velocity a. This method is unconditionally stable when a0≥a.

Page 48: Fundamentals of Plasma Simulation (I)

Predictor-corrector scheme

The previous schemes like leapfrog and Runge-Kutta scheme are called single-step methods because they use only the information from one previous point to compute the successive point. that is, only the initial point (i=0, j) is used to compute (i+1, j), and in general, (I, j) is needed to compute (i+1, j). After several points have been found, it is feasible to use several prior points in the calculation. We can develop multiple step method.

A desirable feature of a multi-step method is that the local truncation error can be determined and a correction term can be included, which improves the accuracy of the answer at each step. Also, it is possible to determine if the step size is small enough to obtain an accurate value for (i+1, j), yet large enough so that unnecessary and time-consuming calculations are eliminated.

Actually, we have met this treatment (predictor-corrector) in Lax-Wendroff scheme by a two-step procedure.The first is over a half time step (predictor): i

jij

ij

ij

ij ff

x

tufff 1111

21

2

2/

2

1

The second is a full time step (corrector): 211

211

1

2

ij

ij

ij

ij ff

x

tuff

Page 49: Fundamentals of Plasma Simulation (I)

Predictor-corrector scheme – Alfven wave equations In applying the semi-implicit scheme for the Alfven wave problem, a practical way to advance the differential equation in a code is a two-step predictor-corrector scheme.

xa

t

b

x

ba

t

From the wave equations, by writing the time partial derivative as , the predicted values are

kbixb ˆ~

ii kaitbb )ˆ(*

ii bkait )ˆ(*

The corrected values are ];)ˆ()[ˆ(*)ˆ(1 iiiii btaitakibtaibb ])ˆ()[ˆ(*)ˆ(1 iiiii taibtakibtai

Or they can be written as ii

b

attai

taiatb

22

221

ˆ1

Usual stability analysis gives the equation of amplification factor

0])1[( 22222 atgat 442222 )12(1|| atatg The explicit system of this predictor-corrector equations is stable if

)/()12( 2 at For θ=1/2, the scheme is unstable for all t, for ∆ θ=1, is stable when t <1/a. ∆

Page 50: Fundamentals of Plasma Simulation (I)

Predictor-corrector scheme – Alfven wave equations (cont.)

If we try to modify this predictor-corrector scheme according to the semi-implicit technique,

2

222

022

2

1222

01 *

x

btabat

xtab

x

btab

iii

ii

a0 is some constant. For the velocity equation, we have

x

b

x

bta iiii

11

2

xa

t

b

x

ba

t

xtabb

ii

*

x

bta

ii

*

The corrected values are

The predicted values are

With 0.5≤ θ≤1. This method is unconditionally stable if

22

20 )21(

16

aa

D S Harned & W Kerner, J Comput. Phys. 65, 57(1986)

Page 51: Fundamentals of Plasma Simulation (I)

Predictor-corrector scheme – Guiding center plasmas In drift kinetic particle simulation, it needs to solve the equation of guiding center motion. The guiding center method exhibits a partially fluid-like behavior in the direction perpendicular to magnetic field and a particle-like behavior along the field. The equations are described as

dt

xd2B

BEc

//

// Em

q

dt

d

//

// dt

dx

A simplest predictor-corrector scheme for these guiding center motion includes three steps:

Predictor step:

020

11*

)(2

BxEB

c

t

xx iiii

Predicted electric field:

k

ik

ii xxqEx )(4 1*1*1*

Corrector step: 01*1*

20

1

)()(2

BxExEB

c

t

xx iiiiii

If finite size particles are involved, δ is replaced by form factor S.

Electric field is solved by Poisson’s equation at xi

This scheme is stable, but slightly dissipative and dispersive.

Page 52: Fundamentals of Plasma Simulation (I)

Final remarksThe numerical simulation should satisfy following aspects:

Consistency: The differential equation describing a physical problem can be recovered from difference equations under employing some schemes. this is a minimum requirement for any discretization. This can be done in terms of a Taylor expansion of the discretized equations.

Stability: Numerical stability is absolutely necessary for the numerical method. Usually, Von Neuman stability method can be applied.

Assume that the error can be expanded in a Fourier series

N

kkj xjkia

1

0 )ˆexp(

)ˆexp( xjkig iij

Considering a particular mode with amplification factor g, stability require |g|≤1.)](ˆexp[0 tqixjkii

j So we can have the amplification factor ]ˆexp[1 tqig i

jij

Convergence: The approximate solution is required to actually converge to the exact solution in the limit of zero grid size and time step. However, this convergence is not obvious. For some cases consistency and stability are necessary for the convergence of the approximate solution to the actual solution. (Lax equivalence theorem: “Given a properly posed linear initial value problem and a finite difference approximation to it that satisfies the consistency condition, stability is the necessary and sufficient condition for convergence”.)

Page 53: Fundamentals of Plasma Simulation (I)

Accuracy: In cases where both consistency and stability are satisfied it can usually be expected that the solution error will be approximately the truncation error. Even though the numerical solution may converge to the accurate solution it is usually not necessary to approximate the exact solution with arbitrary accurateness. In many cases it expected to derive qualitative or quantitative results with sufficient accurateness for the particular purpose of the model. To obtain confidence in more complex nonlinear models where analytic solution are in general not available a variety of confidence building measure can be applied. For many applications it is not only helpful but necessary to test simplified related problems first.

Efficiency: Computational efficiency is not entirely well defined yet. A better approach is to fix a required quality of the result and then to compare the execution time for different methods and realizations including aspects such as vectorization, parallelization, and the actual style of programming in addition to the particular method for the numerical approximation.

Finally, the estimate of total execution time for a simulation/modeling program is of importance. Practically, this is helpful not only to diagnose the program but also to plan larger size programs and to gain an understanding of the potential for a program, i.e., whether it can be scaled up to treat a compelling application.

Final remarks (cont.)