Computational physics

Youjun Hu
Institute of Plasma Physics, Chinese Academy of Sciences
Email: yjhu@ipp.cas.cn

July 23, 2018

1 Introduction

Physics becomes concrete, impressive, and fun when we compute it numerically and visualize the process by graphics. Computational physics are primarily about numerically solving three types of partial differential equations (PDEs), namely hyperbolic, parabolic, and elliptic PDEs, which respectively correspond to advection (wave) equations, diffusion equations, and Poisson’s equations.

2 Advection equation

In one-dimensional case, an advection equation takes the following form:

∂y-= − c∂y,
 ∂t     ∂x
(1)

where c is a constant. A natural choice of differencing scheme for the above equation is

y(n+1)− y(n)  y((ni+)1) − y((ni−)1)
-i-------i- = ------------,
     Δt           2Δx
(2)

which however is unconditionally unstable (tested by me numerically. the stability analysis can prove that the above scheme is unconditional unstable[2]). The Lax-Friedrichs scheme modifies the above scheme to the following form:

        y(n) +y(n)        (n)     (n)
y(in+1)−--(i−1)2-(i+1)-     y(i+1) −-y(i−1)
        Δt        = − c    2Δx     ,
(3)

which is stable if the CFL condition is satisfied. However this scheme introduces heavy damping in the solution, as is shown in Fig 1. The Lax-Friedrichs scheme is an explicit scheme. Let us try implicit schemes. One natural choice of implicit scheme is of the following form:

                  ⌊ (n+1)   (n+1)    (n)     (n)  ⌋
y(in+1)−-y(ni)     1 ⌈y(i+1)-−-y(i−1)   y(i+1) −-y(i−1)⌉
     Δt     = − 2c      2Δx      +     2Δx      ,
(4)

which is called the Crank–Nicolson implicit scheme. An implicit scheme usually requires that an linear equations system be solved because the unknown future values are usually coupled together. The scheme (4) can be organized in the following form

            ⌊y(n+1)− y(n+1)⌋            ⌊ y(n)  − y(n)  ⌋
y(in+1)+ Δtc ⌈-(i+1)---(i−1)⌉ = y(ni)−  Δtc⌈ -(i+1)---(i−1)⌉,
         2        2Δx               2        2Δx
(5)

which is a traditional equation system. Figure 1 compares the results calculated by the Lax-Friedrichs scheme and the Crank–Nicolson scheme, which shows that no damping is introduced by the Crank-Nicolson scheme.


PICPIC

Figure 1: Evolution of the waveform computed by the Lax-Friedrichs scheme (left) and the Crank–Nicolson implicit scheme (right). Simulations are performed with the Initial condition given by y(x,t = 0) = exp(100(x0.5)2), time-step size dt = 0.05dx∕c, grid spacing dx = 1(Nx 1), Nx = 200. Both schemes give correct the propagation speed, but the Lax-Friedrichs scheme introduces heavy damping in the solution.


 

 

3 Wave equation

A wave equation in one-dimension takes the following form:

 2      2
∂-y = c∂-y,
∂t2    ∂x2
(6)

which is a second order differential equation and can be written as two coupled advection equations. Define a new function ξ by

∂ξ-= ∂y-
∂t   ∂x
(7)

Then Eq. (6) can be written as

 2
∂-y2 = c-∂ξ-,
∂t     ∂t∂x
(8)

which can be simplified as

∂y    ∂ξ
---= c---.
∂t    ∂x
(9)

Equation (7) and (9) are two couple advection equations.

3.1 Maxwell’s equation in 1D case

For Maxwell’s equation in one-dimension case, there are two independent TEM modes, one of which is described by

∂By- = ∂Ez,
 ∂t    ∂x
(10)

∂Ez- = c2 ∂By,
 ∂t      ∂x
(11)

where c = 1√ μ0ε0- is the speed of light in vacuum. In an electromagnetic wave, Ez is c times of Bz in SI units. To make the two variables in the above equation takes similar magnitude, define Ez = Ez∕c. Then using (Ez,By) as variables, the above equations are written

        --
∂By-   ∂Ez-
 ∂t = c ∂x ,
(12)

 --
∂Ez-   ∂By-
 ∂t = c ∂x ,
(13)

3.2 The Lax scheme

Similar to the case of advection equation, the following simple differencing scheme for the vacuum TEM equations (12) and (13):

  (n+1)    (n)    -(n)    --(n)
B-yi--−-B-yi = cEz(i+1) −-E-z(i−1).
     Δt              2Δx
(14)

E-(zn+i1)− E-(zn)i    By(n()i+1) − B (ny)(i−1)
-----Δt----- = c-----2Δx-------.
(15)

is unstable (tested numerically by me). The Lax scheme modifies the above scheme to the following form:

        B (n)  +B(n)      --      --
B-(ny+i1)−---y(i−1)2-y(i+1)    E-(nz()i+1)-−E-(zn)(i−1)
         Δt          = c     2Δx       .
(16)

--(n+1)   E(nz()i−1)+E(zn)(i+1)-     (n)      (n)
E-zi--−-------2----- = cB-y(i+1)-− B-y(i−1).
         Δt                  2Δx
(17)

I tested this and found it induces heavy damping as it does in the case of advection equation.

3.3 The Crank–Nicolson scheme

Let us try the Crank-Nicolson implicit scheme:

                 ( --      --       --       --    )
B(yn(+i)1)− B(yn()i)   1   E (nz(+i+11)) −E (zn+(i1−)1)  E (nz)(i+1) − E(zn()i−1)
-----Δt------= 2c( -----2Δx-------+ ------2Δx------) ,
(18)

-(n+1)  -(n)     (   (n+1)    (n+1)    (n)     (n)  )
Ez(i)--−-Ez(i)-  1 ( B-y(i+1) −-By(i−1) B-y(i+1) −-By(i−1))
     Δt      = 2c        2Δx      +       2Δx        .
(19)

The above differencing scheme can be organized in the following form:

            (--(n+1)   -(n+1))       ( --(n)    --(n)   )
B(n+1)− Δtc (E-z(i+1) −-Ez(i−1)) = Δtc( E-z(i+1)-−E-z(i−1)) + B(n),
 y(i)     2         2Δx           2         2Δx            y(i)
(20)

            (  (n+1)   (n+1))       (   (n)      (n)  )
E(n+1)− Δt-c( By(i+1) −-By(i−-1)) = Δtc( B-y(i+1) −-By(i−1)) + E(n).
 z(i)     2         2Δx           2          2Δx           z(i)
(21)

which is a linear equation system for (Byi(n+1),Ezi(n+1)) with i = 1,2,Nx, where Nx is the number of grids in the x direction. This linear system is solved by using LU decomposition of the coefficient matrix (the LU decomposition can be viewed as the matrix form of Gaussian elimination.). The evolution of the wave form calculated by this scheme is plotted in Fig. 2.


PICPIC

Figure 2: Evolution of the TEM waveform (By,Ez) computed by the Crank–Nicolson implicit scheme. Simulations are performed with the initial condition Ez(x,t = 0) = 0, By(x,t = 0) = exp((xx0)2(0.1L)2), x0 = 0.5m, L = 1m, time-step size dt = 0.01dx∕c, grid spacing dx = 1(Nx1), Nx = 100. Fixed zero boundary condition is used: Ez(x = 0) = Ez(x = L) = 0, By(x = 0) = By(x = L) = 0. Since the waveform has not reach the boundary, the boundary has no effect on the evolution. The results show that two traveling waves emerge from the Gaussian waveform of By, propagating in the opposite directions. The propagation speed is correct.


 

4 Diffusion equation

The stencil used in the explicit, implicit, and Crank–Nicolson implicit method is given in Figure (3).

 


PICPICPIC

Figure 3: Stencil of an explicit scheme (left) implicit scheme (middle) and the Crank-Nicolson implicit scheme (right) for the diffusion equation ut = uxx.


This part is to be continued.

 

5 Poisson’s equation

Poisson’s equation is written

∇2φ = S,
(22)

where S is a known source term. In Cartesian coordinates and in the 2D case, the above equation is written

∂2φ   ∂2φ
--2-+ --2-= S(x,y).
∂x    ∂x
(23)

Consider solving the above equation in a rectangular domain with xa x xb and ya y yb and with φ = 0 on the boundary.

5.1 Discretized form using finite differencing

Discretize x as xi = xa + (i + 1)Δx, where Δx = (xb xa)(M + 1) and i = 0,1,2,,M 1. Similarly, discretize y as yj = ya + (j + 1)Δy, where Δy = (yb ya)(N + 1) and j = 0,1,2,,N 1. Then the above equation can be discretized by using the following finite difference:

φi+1,j −-2φi,j +-φi−1,j + φi,j+1 −-2φi,j-+φi,j−-1= S ,
        Δ2x                   Δ2y            i,j
(24)

where φi,j = φ(xi,yj) and Si,j = S(xi,yj). Equation (24) can be arranged as

aφi+1,j + aφi−1,j + cφi,j + bφi,j+1 + bφi,j−1 = Si,j,
(25)

where a = 1Δx2, b = 1Δy2, and c = (        )
  2Δ2x + 2Δ2y-. This is a 5-points stencil, as is illustrated in Fig. 4.


PIC

Figure 4: Five-points stencil of the finite differencing scheme in Eq. (25).


 

In this discritization, the boundary conditions are written as φ1,j = φM,j = 0 and φi,1 = φi,N = 0.

5.2 Matrix form of the difference scheme

In order to solve the linear equation system (25), we prefer to formulate it in a matrix form. In order to do this, we need to order the 2D discrete unknowns φi,j in a 1D sequence. Two natural ordering schemes are the row-ordering and the column ordering. I choose the row ordering, as is illustrated in Fig. 5.


PIC

Figure 5: Row-ordering of the 2D discrete unknowns φi,j on a 3 × 3 mesh.


Using the above ordering, the linear equation system (25) for the special case of a 3 × 3 mesh is written as the following matrix form:

(                           ) (    )   (     )
  c  a     b                    φ0        S0
|| a  c  a     b             || || φ1 ||   ||  S1 ||
||    a  c        b          || || φ2 ||   ||  S2 ||
|| b        c  a     b       || || φ3 ||   ||  S3 ||
||    b     a  c  a     b    || || φ4 || = ||  S4 || ,
||       b     a  c        b || || φ5 ||   ||  S5 ||
||          b        c  a    || || φ6 ||   ||  S6 ||
(             b     a  c  a ) ( φ7 )   (  S7 )
                 b     a  c     φ8        S8
(26)

where all the blank elements are zeros. This 9 × 9 matrix is sparse but is not tridiagonal. Each row of the matrix corresponds to one difference equation at a grid point. It is not difficult to generalize the above 9 × 9 matrix to a general MN ×MN matrix. The general pattern is that those rows that corresponds to inner grid points have the following pattern (,b,,a,c,a,,b,), where c is on the diagonal location and the distance between b and c is M. For those rows that correspond to boundary grid points, some b and/or a can be absent. Specifically, (1) the left a is absent for all the rows corresponding to the left boundary grids; (2) the right a is absent for all the rows corresponding to the right boundary grids; (3) the left b is absent for all the rows corresponding to bottom boundary grids; (4) the right b is absent for all the rows corresponding to the top boundary grids. The following Fotran code illustrates how to set up the matrix elements for this kind of sparse matrix:

dx=1.0/(m+1)
dy=1.0/(n+1)
a_coef= 1./dx**2
b_coef=1./dy**2
c_coef = -2*(a_coef+b_coef)
A=0 !initialize coefficent matrix
do  II=0,m*n-1
     A(II,II)=c_coeff !diagonal elements
     j = II/m !recover the original index in the y direction of the 2D mesh
     if (j.gt.0) A(II,II-m)=b_coef
     if (j.lt.n-1) A(II,II+m)=b_coeff
     i = II - j*m !recover the original index in the x direction of the 2D mesh
     if (i.gt.0) A(II,II-1)=a_coeff
     if (i.lt.m-1) A(II,II+1)=a_coeff
enddo
I use PETSc parallel library[1] to solve the above linear system. In this case, the corresponding code for setting up the matrix in parallel is as follows:

dx=1.0/(m+1)
dy=1.0/(n+1)
a_coef= 1./dx**2
b_coef=1./dy**2
c_coef = -2*(a_coef+b_coef)
call MatGetOwnershipRange(A,Istart,Iend,ierr)
do  II=Istart,Iend-1
     call  MatSetValues(A,ione,II,ione,II,c_coef,INSERT_VALUES,ierr) !diagonal elements

     j = II/m !recover the original index in the y direction of the 2D mesh
     if (j.gt.0) then
        JJ = II - m
        call MatSetValues(A,ione,II,ione,JJ,b_coef,INSERT_VALUES,ierr)
     endif
     if (j.lt.n-1) then
        JJ = II + m
        call MatSetValues(A,ione,II,ione,JJ,b_coef,INSERT_VALUES,ierr)
     endif

    i = II - j*m !recover the original index in the x direction of the 2D mesh
     if (i.gt.0) then
        JJ = II - 1
        call MatSetValues(A,ione,II,ione,JJ,a_coef,INSERT_VALUES,ierr)
     endif
     if (i.lt.m-1) then
        JJ = II + 1
        call MatSetValues(A,ione,II,ione,JJ,a_coef,INSERT_VALUES,ierr)
     endif
enddo
call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
call MatAssemblyEnd  (A,MAT_FINAL_ASSEMBLY,ierr)
All the elements that are not updated by MatSetValues in the above code are by default zero.

5.3 Verification of the numerical solution

For the particular source term given by

S(x,y) = sin(πx) sin(πy),
(27)

then

φ (x,y) = −-12 sin(πx)sin(πy),
          2π
(28)

satisfies the equation and the boundary condition ψ = 0 at xa = 0, xb = 1, ya = 0, and yb = 1. Therefore the above expression is an analytic solution to the problem. Figure 6 compares the numerical solution with the analytic one, which indicates the two results agree with each other, and thus verifying the correctness of the numerical solution.


PIC

Figure 6: Comparison between the numerical solution and analytic solution of Poisson’ equation. Numerical parameters: grid number M = 50, N = 50. The resulting linear system has 2500 unknowns. PETSc provides a flexible way of choosing different algorithms for solving the linear system via command line options. The command line options used for this case is: mpiexec -n 3 ./poisson -pc_type bjacobi -sub_pc_type ilu -ksp_type bcgs -ksp_monitor, which chooses the preconditioner type and Krylov subspace method type. The KSP residual norm is 1.456 × 107 after 25 iterations.


 

6 A simple example of numerical instability

For the following ordinary differential equation:

dy = − ay,
dt
(29)

where a is a positive constant, with the initial condition y(0) = y0, the analytic solution is given by

y = y0exp(− at),
(30)

which is a monotonically decreasing function of t. Let us try to solve this initial value problem numerically. Discritizing time as  tn = nΔt with Δt > 0, we use the following explicit differencing scheme:

 (n+1)   (n)
y----−-y---= − ay(n),
    Δt
(31)

i.e.,

y(n+1) = (1 − Δta )y(n),
(32)

where y(n) = y(tn) and y(n+1) = y(tn+1). If we choose a large time-step Δt with Δt > 2∕a, then |1 Δta| > 1 and the above scheme gives a numerical solution with amplitude increasing with time, instead of decaying. This is totally different from the analytic solution, which indicates the numerical solution is wrong in this case. This kind of wrong numerical solution is called a numerical instability. An example is shown in Fig. 7.


PIC

Figure 7: Comparison between the analytic solution (30) (black) and the numerical solution (blue) calculated by the scheme (32) with Δt = 2.1. Other parameters: y0 = 1, a = 1.


 

Let us consider the following implicit scheme

y(n+1) −-y(n)     (n+1)
    Δt     = − ay    ,
(33)

(where the right-hand side is evaluated at the future time time), i.e.,

 (n+1)     y(n)
y     = 1+-aΔt-.
(34)

Note that no matter how large the time step-length Δt is, the above scheme always give a solution which is decreasing with time, i.e., no numerical instability appears. An example is shown in Fig. 8.


PIC

Figure 8: Comparison between the analytic solution (30) (black) and the numerical solution (blue) calculated by the scheme (34) with Δt = 2.1. Other parameters: y0 = 1, a = 1.


If a one-step explicit scheme is unstable, then the corresponding implicit scheme is stable. This is because that an implicit scheme corresponds to a time-reversed version of the corresponding explicit scheme.

 

7 Finite difference

Taylor expansion of f(x) at x = xi is written as

                            2
f(xi + h) = f(xi)+ hf(1)(xi)+ h-f (2)(xi)+ O (h3)
                            2
(35)

8 The predictor-corrector method

This method is very similar to and often confused with the Runge-Kutta method. Consider the following differential equation

dy
--= f(y)
dt
(36)

A natural discretized form that is time-centered would be

y    = y + Δt-[f (y   )+ f(y )].
 n+1    n   2    n+1      n
(37)

Unfortunately the presence of yn+1 on the right-hand side makes this scheme implicit, and thus a direct solution is possible only for some special cases (e.g. f(y) is a linear function of y). Generally, we need to use iterations to solve the above equation. A convenient initial guess is yn+1 yn. If we iterate for only twice, i.e.,

y(1n)+1 = yn + Δtf(yn)
(38)

y(2) = y + Δt-[f (y(1))+ f(y )].
 n+1    n   2    n+1      n
(39)

Then this is the predictor-corrector method (also called Heun’s method). This method consists of a guess for yn+1 based on the Euler method (the Prediction) followed by a correction using trapezoidal rule.

If we iterate until convergence, then this is a general implicit scheme.

 

 

9 Spectral method—–to be revised

Spectral methods refers to methods of using linear combination of global basis functions to approximate a unknown function. Here “global” means that the basis functions extending over the whole spatial domain of interest, i.e., has a support as large as the whole domain of interest (contrast to the finite element method, which use local basis functions). Here we consider Fourier spectral method, which uses trigonometric functions as basis functions. Consider the following two-point boundary value problem:

        [   2       ]
L ψ(x) ≡ − ∂--+ V (x) ψ(x) = S (x),
           ∂x2
(40)

with the boundary condition ψ(x = L) = ψ(x = 0), where V (x) and S(x) are known functions. Expand ψ(x) in terms of the Fourier basis functions:

      N −1      (      )
ψ(x) ≈ ∑  ˆψn exp  n 2πix- ,
       n=0          L
(41)

where ˆψ n are unknown coefficients. Substitute this expression into the left-hand side of Eq. (40), we obtain

    (    )       (      )                 (     )
N∑−1  2πn-2 ˆ       2πix    N∑− 1    ˆ       2πix
       L    ψnexp  n  L   +     V(x)ψnexp  n  L   .  (42)
 n=0                        n=0
Define the residual R as the difference between the above expression and the source term S(x), i.e.,
    N∑−1( 2πn)2       ( 2πix )  N∑−1          (  2πix )
R =      ----  ˆψnexp  n----  +     V(x)ˆψn exp  n ---- − S (x).
    n=0   L              L     n=0               L
(43)

We want the residual to be as small as possible in the whole domain of interested. We need to define how to measure the smallness of the residual. A general method is to choose some “test functions” and take the inner product of the test functions with the residual over the whole domain. Then the inner product is used to measure the smallness of the residual. Different spectral methods are classified by the different “test functions” chosen for the inner product.

9.1 Pseudo-spectral method

In the Pseudo-spectral method, the test functions are chosen to be δ(xxm), where δ is the Dirac-delta function and xm with m = 0,1,2,,N 1 are special spatial points chosen for a set of basis functions. These points are called collocation points and differs for different basis functions used. For Fourier basis functions the collocation points are points with uniform interval given by xm = mL∕N with m = 0,1,2,,N 1. Performing the inner product 0L()δ(x xm)dx on the residual and demand the result to be zero, we obtain

N∑− 1(2πn )2      (  2πix  )  N∑− 1           (  2πix )
     ----  ψˆn exp  n----m- +     ˆψnV(xm )exp n ----m- − S(xm) = 0,
n=0   L               L      n=0                 L
(44)

which can be organized as

                    [               ]
N∑− 1      ( 2πixm )  (2πn )2
    ˆψnexp  n--L---    -L--   +V (xm)  = S(xm).
n=0
(45)

where m = 0,1,N 1. Equation (45) is a linear equation system for the expansion coefficients ˆψ n. Since taking the inner product with a Dirac-delta function δ(x xm) correspond to choosing a particular spatial point xm, the above equation is actually demanding that the approximate function satisfies the original differential equation exactly on the set of collocation points.

9.2 Galerkin method

Choose the set of test functions as exp(2πimx∕L) with m = 0,1,,N 1. Perform the inner product of the residual with the test functions exp(2πimx∕L), i.e., L1 0LR exp(2πimx∕L)dx, and demand the result to be zero, yielding

(     )                    ∫          (        )
  2πm- 2 ˆ    N∑−1    ˆ    1- L           2πimx-
   L     ψm +    Vmn ψn − L 0  S(x)exp  −  L     dx = 0,
              n=0
(46)

where use has been made of

1 ∫ L    (2πix       )
L-    exp  --L-(n − m)  dx = δnm,
   0

with δnm is the Kronicle-delta function, and

        ∫ L        (           )
Vmn = 1-   V (x )exp  2πix (n − m)  dx.
      L  0            L
(47)

Direct evaluating the integration of the source term as appearing in Eq. (46) involves N operation for each value of m and thus total N2 operations are needed. The computational efficiency can be improved by first expanding S(x) in terms of the basis function (as what is done for ψ):

       N−1      (      )
S(x) ≈ ∑  Sˆ exp n 2πix-  .
       n=0 n        L

Then the integration of the source term reduces to Ŝm. Then equation (46) is written

(2πm-)2      N∑−1
   L    ˆψm +    Vmn ˆψn = ˆSm.
             n=0
(48)

Since computing Ŝm with m = 0,1,,N 1 using FFT involves only N log N operations, this method is more efficient than directly evaluating the integration. Similar situation apply to the computation of V mn. The matrix V mn depends on m and n through the combination (n m). Since both m and n are in the range [0 : N 1], the range of (n m) is also in [0 : N 1]. Therefore the matrix V mn has N independent matrix elements. Computing each one of these N elements by directly evaluating the integration (47) involves N operations. Therefore, to obtain all the N independent elements, the number of operations is N2. The same method used to compute the source term can be applied to compute V mn, which reduces the operation number to N log N. Expand V (x) as

      N∑−1     (  2πix)
V(x) ≈    ˆVkexp  k-L--
       k=0

then V mn is written as

       1 ∫ LN∑− 1     (  2πix)    ( 2πix       )
Vmn  = --       ˆVkexp  k----  exp  ----(n − m)  dx = ˆVm−n.
       L  0 k=0          L          L
(49)

Therefore Eq. (48) is finally written

(     )2     N− 1
  2πm--  ˆψ  + ∑   ˆV   ψˆ = Sˆ ,
   L     m   n=0  m−n  n   m
(50)

which is a linear equation system for ˆψ m with m = 0,1,,N 1.

9.2.1 Computation of n=0N1ˆVmnψˆ n in initial value problems

Equation (50) can be considered as a stead-state equation of the following time-dependent equation

∂ˆψm   ( 2πm )2     N∑−1
-∂t-=   -L--  ψˆm  +    ˆVm −nˆψn − Sˆm,
                    n=0
(51)

Note that the term n=0N1 ˆ
Vmnˆ
ψ n on the right-hand side of the above equation involves matrix multification, which involves N2 operations. When solving Eq. (51) as an initial value problem, where  ˆ
ψ m is known at the current time step, there is an efficient way of evaluating n=0N1Vˆmnψˆ n which avoids the computationally expensive matrix multification. Note that the term n=0N1ˆVmnˆψ n is actually the Fourier transform of V (x)ψ(x). Thus an efficient method of computing this term is to first transform ψˆ n back to real space and doing the multification between V (x) and ψ(x) in real space. Then transform the result back to Fourier space. Since the transform can be performed by FFT, which involves only N log N operations, this method is more efficient than directly computing the matrix multification nˆVmnˆψn.

10 Interpolating

ddd

11 von Neuman stability analysis

 

Ampere’s equation is written

∇ × δB = μ0δJi + μ0δJe
(52)

Neglecting the ion current, then the above equation is written

∇ × δB = μ δJ
          0  e
(53)

Using δJe = en0δue, the above equation is written

∇ × δB = − μ0ene0δue
(54)

⇒ (∇ × δB)× B0 = − μ0ene0δue × B0
(55)

Using δue × B0 = δE, the above equation is written

⇒  (∇ × δB )× B  = μ en δE
              0    0  e0
(56)

Define βe = μ0ene0, then the above equation is written as

δE = 1-(∇ × δB)× B0
     βe
(57)

            1
⇒ δE(n+1) =--(∇ × δB (n+1))× B0
           βe
(58)

Faraday’s law is written as

δB (n+1) − δB(n)
--------------= − [α ∇ × δE(n+1) +(1 − α )∇ × δE (n)]
      Δt
(59)

Assume B0 is uniform and performing Fourier transformation over the space, equations () and () are written

          1
δEˆ(n+1) = β-(ik × δˆB(n+1)) ×B0
           e
(60)

 ˆ (n+1)   ˆ (n)
δB-----−-δB--- = − [θik × δˆE(n+1) +(1 − θ)ik× δˆE (n)]
      Δt
(61)

Consider the case that B0 is along the z direction and k = kˆz, equation () is written as

δEˆ(n+1) = 1-(ikB0δBˆ(n+1) +ikδBˆ(nz+1)B0)
          βe
(62)

Using this in Eq. (), yielding

δˆB(n+1) − δˆB(n)   [   kB                            ]
--------------= −  − θ--0k × δˆB(n+1) + (1− θ)ik × δˆE(n)
      Δt               βe
(63)

δˆB(n+1) − δˆB(n)   [   kB              kB                                         ]
--------------= −  − θ--0k δB ˆ(xn+1)ˆy + θ-0kδBˆ(yn+1)ˆx + (1 − θ)ikδ ˆE(xn)ˆy− (1− θ)ikδE ˆ(yn)ˆx
      Δt               βe              βe
(64)

 

Assume δˆE(n) and δˆB(n) take the following form

  (n)     (0)i(−nωΔt)
δˆE   = δˆE   e
(65)

δˆB(n) = δˆB (0)ei(−nωΔt)
(66)

 

 

References

[1]   Satish Balay, Shrirang Abhyankar, Mark F. Adams, Jed Brown, Peter Brune, Kris Buschelman, Lisandro Dalcin, Victor Eijkhout, William D. Gropp, Dinesh Kaushik, Matthew G. Knepley, Dave A. May, Lois Curfman McInnes, Richard Tran Mills, Todd Munson, Karl Rupp, Patrick Sanan, Barry F. Smith, Stefano Zampini, Hong Zhang , and Hong Zhang. PETSc Web page. 2018. http://www.mcs.anl.gov/petsc.

[2]   Richard Fitzpatrick. Computational Physics:An introductory course. Richard Fitzpatrick, 2004.