Stephen C. Jardin Princeton Plasma Physics...

53
MHD Simulations for Fusion Applications Lecture 3 The Galerkin Finite Element Method Stephen C. Jardin Princeton Plasma Physics Laboratory CEMRACS ‘10 Marseille, France July 21, 2010 1

Transcript of Stephen C. Jardin Princeton Plasma Physics...

MHD Simulations for Fusion Applications

Lecture 3

The Galerkin Finite Element MethodStephen C. Jardin

Princeton Plasma Physics Laboratory

CEMRACS ‘10

Marseille, France

July 21, 2010

1

Outline of Remainder of Lectures

• Galerkin method• C1 finite elements• Examples• Split implicit time

differencing

Today Tomorrow• Split implicit time

differencing for MHD• Accuracy, spectral

pollution, and representation of the vector fields

• Projections of the split implicit equations

• Energy conserving subsets• 3D solver strategy• Examples

Weak Form of a Differential EquationConsider the ordinary differential equation on the domain [a,b]:

( ) ( ) ( ) ( ) (1)d dp x q x U x f xdx dx

⎡ ⎤⎛ ⎞− + =⎜ ⎟⎢ ⎥⎝ ⎠⎣ ⎦

We choose a function space H1, and multiply (1) by an arbitrary member of that function space, and integrate over the domain:

( ) ( ) ( ) ( ) ( ) ( ) (2 )b b

a a

d dV x p x q x U x dx V x f x adx dx

⎡ ⎤⎛ ⎞− + =⎜ ⎟⎢ ⎥⎝ ⎠⎣ ⎦∫ ∫

( ) ( ) ( ) ( ) (2 )b b

a a

dV dUp x q x VU dx V x f x bdx dx

⎡ ⎤⎛ ⎞ + =⎜ ⎟⎢ ⎥⎝ ⎠⎣ ⎦∫ ∫

Or, after integrating by parts (assuming the boundary term vanishes):

If we require that Eq. (2) hold for every function V(x) in the function space H1, it is called the weak form of Eq. (1). Note that only first derivatives occur in (2b), whereas 2nd derivatives occur in (1)

Galerkin Finite Element MethodThe Galerkin finite element method is a discretization of the weak form of the equation. To apply, we chose a finite dimensional subspace S of the infinite dimensional Hilbert space H1, and require that Eq. (2) hold for every function in S.

1( ) ( ) ( ) ( ) 1,

b bNji

j i j ij a a

dda p x q x dx x f x i Ndx dx

ϕϕ ϕ ϕ ϕ=

⎡ ⎤⎛ ⎞+ = =⎢ ⎥⎜ ⎟

⎝ ⎠⎣ ⎦∑ ∫ ∫

1( ) ( )

N

j jj

U x a xϕ=

= ∑

( ) ( )

( ) ( )

bji

ij i ja

b

i ia

ij j iM a

ddM p x q x dxdx dx

b x f x

b

dx

ϕϕ ϕ ϕ

ϕ

⎡ ⎤⎛ ⎞= +⎢ ⎥⎜ ⎟

⎝ ⎠⎣ ⎦

=

=

known basis functions that span Saj are amplitudes to be solved for

Letting Equation (2b) becomes

Or,

In the finite element method, the basis functions are low order polynomials

( ) ( )iV x xϕ=

Simple Example: Linear Elements in 1D

1

( ) ( )N

j jj

U x a xϕ=

= ∑

( )i xϕ 1( )i xϕ +1( )i xϕ −

xixi-1 xi+10 L

1

0 0, (constants) ( )p p q q f f x= = =

, ati i j jx xϕ δ= =

linear: xi = ih

h=L/N

0 , 0

2 1 0 01 2 1 01

0 1 2 10 0 1 2

i j i jp dx K ph

ϕ ϕ

−⎡ ⎤⎢ ⎥− −⎢ ⎥∇ ∇ = =⎢ ⎥− −⎢ ⎥−⎣ ⎦

∫∫ i 0 , 0

4 1 0 01 4 1 00 1 4 160 0 1 4

i j i jhq v v dx A q

⎡ ⎤⎢ ⎥⎢ ⎥= =⎢ ⎥⎢ ⎥⎣ ⎦

∫∫“mass matrix”“stiffness matrix”

Leads to sparse, diagonally dominant matrices: Mi,j = Ki,j + Ai,j

i ib fdxϕ= ∫∫

ij j iM a b=

1( ) ( ) ( ) ( ) 1,

b bNji

j i j ij a a

dda p x q x dx x f x i Ndx dx

ϕϕ ϕ ϕ ϕ=

⎡ ⎤⎛ ⎞+ = =⎢ ⎥⎜ ⎟

⎝ ⎠⎣ ⎦∑ ∫ ∫

Linear elements only overlap with their nearest neighbors

Note: We were able to solve a 2nd order ODE with linear elements!

1( ) ( )

N

j jj

U x a xϕ=

= ∑

( )i xϕ 1( )i xϕ +1( )i xϕ −

xixi-1 xi+10 L

1

1( ) ( ) ( ) ( ) 1,

b bNji

j i j ij a a

dda p x q x dx x f x i Ndx dx

ϕϕ ϕ ϕ ϕ=

⎡ ⎤⎛ ⎞+ = =⎢ ⎥⎜ ⎟

⎝ ⎠⎣ ⎦∑ ∫ ∫

( ) ( ) ( ) ( )d dp x q x U x f xdx dx

⎡ ⎤⎛ ⎞− + =⎜ ⎟⎢ ⎥⎝ ⎠⎣ ⎦( )

b

ia

dx xϕ∫

ij j iM a b=

Extension to Higher Order EquationsSuppose we have a 4th order equation:

4

4 ( ) ( )d U x f xdx

=

Form the weak form: 4

4

3

3

2 2

2 2

( ) ( ) ( ) ( )

( ) ( )

( ) ( )

b b

i ia a

b bi

ia a

b bi

ia a

dx U x dx x f x dxdx

d d U dx x f x dxdx dx

d d U dx x f x dxdx dx

ϕ ϕ

ϕ ϕ

ϕ ϕ

=

− =

=

∫ ∫

∫ ∫

∫ ∫

(assumes the boundary terms vanish)

Application of the Galerkin method to a 4th order equation requires that the second derivative of the basis functions be defined everywhere.

For a 2nd order equation, only the first derivative need be defined.

1

( ) ( )N

j jj

U x a xϕ=

= ∑

Integrate by parts twice:

Elements with higher continuityLinear elements are continuous, but only the function and first derivative are well defined. To represent a second derivative, both the function and first derivative must be continuous. They must be a subset of H2

j-1 j j+1j-1 j j+1

1 ( )j xϕ 2 ( )j xϕThe Hermite Cubic elements associate two basis functions with each node j, defined on the interval xj-1 < x < xj+1 as:

( ) ( )( )

21

22

1, 1

2, 2

( ) 1 2 1

( ) 1

( )

( )

jj

jj

y y y

y y y

x xx

hx x

x hh

ϕ

ϕ

ϕ ϕ

ϕ ϕ

= − +

= −

−⎛ ⎞= ⎜ ⎟

⎝ ⎠−⎛ ⎞

= ⎜ ⎟⎝ ⎠

These have the property that:1. In the interval xj < x < xj+1 , a complete

cubic can be represented by:

2. The first derivatives vanish at the element boundaries

3. The second derivatives are defined everywhere

1, 2, 1, 1 2, 1( ), ( ), ( ), ( ),j j j jx x x xϕ ϕ ϕ ϕ+ +

j-1 j j+1j-1 j j+1

1 ( )j xϕ 2 ( )j xϕ

Hermite Cubic Finite Elements

1, 2,1

( ) ( ) ( )N

j j j jj

U x a x b xϕ ϕ=

⎡ ⎤= +⎣ ⎦∑

In the interval [ j , j+1 ] , the function is written as:

( )( )

( )( )

1, 2, 1 1, 1 1 2, 1

21 1

31 1

2 30 1 2 3

( ) ( ) ( ) ( ) ( )

3 2 3

2 2

j j j j j j j j

j j j j j j

j j j j

U x a x b x a x b x

a b x a hb a hb x h

a hb a hb x h

c c x c x c x

ϕ ϕ ϕ ϕ+ + + +

+ +

+ +

= + + +

= + + − − + −

+ + − +

= + + +

Simple physical interpretation:

aj is value of function at node jbj is value of derivative at node j

0

12 2

123 2 3 2

13

1 0 0 00 1 0 0

3 / 2 / 3 / 1/2 / 1/ 2 / 1/

j

j

j

j

acbc

ac h h h hbc h h h h

+

+

⎡ ⎤⎡ ⎤ ⎡ ⎤⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥=⎢ ⎥⎢ ⎥ − − −⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥−⎣ ⎦⎣ ⎦ ⎣ ⎦

i

Complete cubic polynomial determined by values of function and derivative at endpoints

j j+1

1 ( )j xϕ

2 ( )j xϕ

Hermite Cubic Finite Elements-2

1, 2,1

( ) ( ) ( )N

j j j jj

U x a x b xϕ ϕ=

⎡ ⎤= +⎣ ⎦∑

In the interval [ j , j+1 ] , the function is written as:

( )( )

( )( )

1, 2, 1 1, 1 1 2, 1

21 1

31 1

2 30 1 2 3

( ) ( ) ( ) ( ) ( )

3 2 3

2 2

j j j j j j j j

j j j j j j

j j j j

U x a x b x a x b x

a b x a hb a hb x h

a hb a hb x h

c c x c x c x

ϕ ϕ ϕ ϕ+ + + +

+ +

+ +

= + + +

= + + − − + −

+ + − +

= + + +

1 1( )j xϕ +

2 1( )j xϕ +Complete cubic in each interval!

Linear elements

1st Hermite cubic

2nd Hermite cubic

( )xϕ

( )xϕ′

( )xϕ′′

j-1 j j+1j-1 j j+1

j-1 j j+1

not defined

Comparison of elements and derivatives

Types of Finite Elements in 2D

Shape Order Continuity

, 0

( , ) i kik

i k Mi k

x y C x yφ+ <

= ∑rectangle

triangle

Order M if complete polynomial to that order

C0: continuous across element boundaries

C1: continuous first derivatives across element boundaries

DG: discontinuous Galerkin

Element Shape

Rectangle:

• natural for structured mesh

• allows tensor product forms

bi-linear: t=1, bi-quadratic: t=2, etc

•cannot refine locally without hanging nodes

Triangle:

• natural for unstructured mesh

• easier to fit complex shapes

• can easily refine locally0 ,

( , ) i kik

i k t

x y a x yφ≤ ≤

= ∑

Element OrderIf an element with typical size h contains a complete polynomial of order M, then the error will be at most of order hM+1

This follows directly from a local Taylor series expansion:

Thus, linear elements will be O(h2)quadratic elements will be O(h3)cubic elements will be O(h4)quartic elements will be O(h5)complete quintic elements will be O(h6)

0 0

10 0

0 0 ,

1( , ) ( ) ( ) ( )!( )!

kM kl k l M

l k lk l x y

x y x x y y O hl k l x y

φφ − +−

= =

⎡ ⎤∂= − − +⎢ ⎥− ∂ ∂⎣ ⎦

∑∑

Element ContinuityTheorem: A finite element with continuity Ck-1 belongs to Hilbert space Hk, and hence can be used for differential operators with order up to 2k

Continuity Hilbert Space ApplicabilityC0 H1 second order equationsC1 H2 fourth order equations

This applicability is made possible by performing integration by parts in the Galerkin method, shifting derivatives from the unknown to the trial function

[ ]

( )2 2 2 2

recall:

( , ) ( , )

( , ) ( , )

i idomain domain

i idomain domain

v f x y dxdy f x y v dxdy

v f x y dxdy f x y v dxdy

φ φ

φ φ

∇ ∇ = − ∇ ∇

⎡ ⎤∇ ∇ = ∇ ∇⎣ ⎦

∫∫ ∫∫

∫∫ ∫∫

i i

Hk means that derivatives exist up to order k

The vast majority of the literature concerns C0

elements,.

Here we concentrate on C1 elements because we are interested in higher order equations

NOTE: requires the trial function have appropriate boundary conditions

Reduced Quintic 2D Triangular Finite Element: Q18

θP1(x1,y1)

P3(x3,y3)

P2(x2,y2)

origin

ξ

η

20

1

( , ) k km nk

k

aφ ξ η ξ η=

= ∑ k mk nk1 0 02 1 03 0 14 2 05 1 16 0 27 3 08 2 19 1 210 0 311 4 012 3 113 2 214 1 315 0 416 5 017 3 218 2 319 1 420 0 5For C1, require that the normal slope along the edges φn have only cubic variation:

5b4ca16 + (3b2c3 – 2b4c)a17 + (2bc4 – 3b3c2) a18 + (c5 – 4b2c3)a19 – 5bc4a20 = 0

5a4ca16 + (3a2c3 – 2a4c)a17 + (-2ac4 – 3a3c2) a18 + (c5 – 4a2c3)a19 – 5ac4a20 = 0

20 – 2 = 18 unknowns:

These are determined in terms of [ φ, φx, φy , φxx, φxy, φyy ] at P1,P2,P3

Implies C1 continuity at edges and C2 at nodes !

x

y

Specify the function and it’s first and second derivatives at the 3 nodes (φ, φx, φy, φxx, φxy, φyy)

Guarantees C0 continuity

Note: general quintic has 21 terms. 1 has been set to zero, and 2 others will be determined by constraints.

ξ,η are local orthogonal coordinates

No mk=4, nk=1 term

6 Unknowns at each node!

2 3 4 51

2 3 41

2 31

1

1

1

2

2

2

2

2

2

3

3

3

3

3

3

1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 1 0 2 0 0 3 0 0 0 4 0 0 0 0 5 0 0 0 00 0 1 0 0 0 0 0 0 0 0 0 0 0

00

b b b b bb b b b

b b bξ

η

ξξ

ξη

ηη

ξ

η

ξξ

ξη

ηη

ξ

η

ξξ

ξη

ηη

φφφφφφφφφφφφφφφφφφ

− − −⎡ ⎤⎢ ⎥ − −⎢ ⎥ − −⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥ =⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

2 3

2

2 3

2 3 4 5

2 3 4

2 3

2 3

2

0 0 00 0 0 2 0 0 6 0 0 0 12 0 0 0 0 20 0 0 0 00 0 0 0 1 0 0 2 0 0 0 3 0 0 0 0 0 0 0 00 0 0 0 0 2 0 0 2 0 0 0 2 0 0 0 2 0 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 00 1 0 2 0 0 3 0 0 0 4 0 0 0 0 5 0 0 0 00 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 2 0 0 6 0 0 0 12 0 0 0 0 20 0 0 0 00 0 0 0 1 0 0 2 0 0 0 3 0 0

b b bb b

b b ba a a a a

a a a aa a a

a a aa a

− −−

− −

2 3

2 3 4 5

2 3 4

2 3 4

2 3

2 3

2 3

4

0 0 0 0 0 00 0 0 0 0 2 0 0 2 0 0 0 2 0 0 0 2 0 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 00 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 1 0 0 2 0 0 0 3 0 0 0 0 4 0 0 0 0 50 0 0 2 0 0 0 2 0 0 0 0 2 0 0 0 0 2 0 00 0 0 0 1 0 0 0 2 0 0 0 0 3 0 0 0 0 4 00 0 0 0 0 2 0 0 0 6 0 0 0 0 12 0 0 0 0 20

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5

a a ac c c c c

c c c cc c c c

c c cc c c

c c c

a

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

172 3 4 5

4 184 3 2 2 3

192 3 4 54 4

204 3 2 2 3

3 2 52 3 43 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 52 3 4

aaaaaaaaaaaaaaaaa

a c ac c ac aca c a c a c ab c bc c ab c bcb c b c b c

⎡ ⎤⎡⎢ ⎥⎢⎢ ⎥

⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥

− − + −⎢ ⎥⎢ ⎥⎢ ⎥− − − − ⎣⎢ ⎥⎣ ⎦

⎤⎥

⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎦

[ ] [ ][ ]T A′Φ =or,

20

1( , ) k km n

kk

aφ ξ η ξ η=

= ∑using the expansionCalculate the value of φ and it’s derivatives wrt local coords. ξ and η at the 3 vertex points

Combine with the 2 constraint equations:

[ ] [ ]1A T − ′⎡ ⎤= Φ⎣ ⎦

How to calculate the coefficients in terms of the unknowns:

How to calculate the coefficients in terms of the unknowns-2:The previous viewgraph calculated the coefficient matrix in terms of derivatives in the rotated coordinate system, which is different for each element. To get the coefficient matrix in terms of the vector containing the actual derivatives with respect the Cartesian coordinates (x,y), we have to apply a rotation matrix that depends on the triangle’s orientation.

⎡ ⎤⎢ ⎥= ⎢ ⎥⎢ ⎥⎣ ⎦

1

1

1

RR R

R

2 2

2 2

2 2

1 0 0 0 0 00 cos sin 0 0 00 sin cos 0 0 00 0 0 cos 2sin cos sin0 0 0 sin cos cos sin sin cos0 0 0 sin 2sin cos cos

θ θθ θ

θ θ θ θθ θ θ θ θ θ

θ θ θ θ

⎡ ⎤⎢ ⎥⎢ ⎥

−⎢ ⎥= ⎢ ⎥

⎢ ⎥⎢ ⎥− −⎢ ⎥−⎣ ⎦

1R

2G = T RiRelates the coefficient matrix directly to the function and derivatives wrt (x,y) at the nodes

20x18 matrix consisting of the first 18 columns of T-1

Each triangle hasit's own 18 18

gij

× G

20

1

i im nj ij

i

v gξ η=

= ∑

The Trial Functions:20 20 18 18

1 1 1 1

i i i im n m ni ij j j j

i i j j

a g vφ ξ η ξ η= = = =

= = Φ = Φ∑ ∑∑ ∑

These are the trial functions. There are 18 for each triangle.

The 6 shown here correspond to one node, and vanish at the other nodes, along with their derivatives

Each of the six has value 1 for the function or one of it’s derivatives at the node, zero for the others.

Note that the function and it’s derivatives (through 2nd) play the role of the amplitudes: 6 at each node!

ai = gij Φj Function and derivatives wrt (x,y)

201 1

1

20 202 ( 2) ( ) ( ) ( 2)

1 1

( , ) k k k k

k l k l k l k l

m n m nk k k

k

m m n n m m n nk l kl kl k l k l

k l

a m n

a a K K m m n n

φ ξ η ξ η ξ ξ η η

φ ξ η ξ η

− −

=

+ − + + + −

= =

⎡ ⎤∇ = ∇ + ∇⎣ ⎦

∇ = = +

∑∑

1 11

( ) ! !( , ) ( 2)!

( 2, ) ( , 2)

m mm n n

element

kl kl k l k l k l k l k l k lelement

a b m nd d cF m n m n

K K d d m m F m m n n n n F m m n n

ξ η ξ η

ξ η

+ ++

⎡ ⎤− −⎣ ⎦=≡ + +

≡ = + − + + + + −

∫∫

∫∫

Integrals involving powers of the local coordinates can be done analytically:

Thus, for example:

ai = gijΦj

All matrix elements easily calculated in terms of the ai (or gij)

20

1

i im nj ij

i

v gξ η=

= ∑

20 20 18 18

1 1 1 1

i i i im n m ni ij j j j

i i j ja g vφ ξ η ξ η

= = = =

= = Φ = Φ∑ ∑∑ ∑

Very compact representation compared to a popular C0 Element because all unknowns on nodes

6

66

Lagrange Cubic: C0, h4

Reduced Quintic: C1, h5

6

66

6

6 new unknowns: 2 new triangles

6/2 = 3 unknowns/ triangle

9 new unknowns: 2 new triangles

9/2 = 41/2 unknowns/ triangle

split

split

Comparison of reduced quintic to other popular triangular elements

Vertexnodes

Line nodes

Interior nodes

accuracyorder hp

UK/T continuity

linear element 3 0 0 2 ½ C0

Lagrange quadratic 3 3 0 3 2 C0

Lagrange cubic 3 6 1 4 4½ C0

Lagrange quartic 3 9 3 5 8 C0

reduced quintic 18 0 0 5 3 C1 *

N M

Linear Elements Reduced Quintic Elements21

LE aN

= 51

QE bM

=

15

2 / 5 2 / 5same ~error L QbE E M N Na

⎛ ⎞=> = => = ⎜ ⎟⎝ ⎠

. .. . .. . . .

. . . .. . .

. . . .. . . .

. . .. .

x xx x

x xx x x

x x xx x x

x xx x

x x

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

.. .

. .

. ..

x xx x

x x xx x

x xx x

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

N2

36N4/5

2N12N2/5

Win for N > 20 !

2 S∇ Φ =Second order equation:

N M

Linear Elements Reduced Quintic Elements21

LE aN

= 51

QE bM

=

15

2 / 5 2 / 5same ~error L QbE E M N Na

⎛ ⎞=> = => = ⎜ ⎟⎝ ⎠

. .. . .. . . .

. . . .. . .

. . . .. . . .

. . .. .

x xx x

x xx x x

x x xx x x

x xx x

x x

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

.. .

. .

. ..

x xx x

x x xx x

x xx x

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

4N2

36N4/5

4N12N2/5

Win for N > 6 !

4 S∇ Φ =

2∇ Φ = Ψ2 S∇ Ψ =

Fourth order equation:

Anisotropic Diffusion

2BB S

t Bφ κ φ κ φ∂ ⎡ ⎤= ∇ ∇ + ∇ ∇ +⎢ ⎥∂ ⎣ ⎦

i i i

18

1j j

j

vφ=

= Φ∑20

( ) ( )

1

i im nl lj ij

i

v gξ η=

= ∑

Apply Galerkin method:

Typically κ|| >> κ⊥

( ) ( ) ( ) ( )2

( ) ( ) ( )2

l l l lj j j j

l l lj j j

BBv dxdz v v v S d dt B

v BB v v S d dB

φ κ φ κ φ ξ η

κφ κ φ ξ η

⎡ ⎤⎡ ⎤∂= ∇ ∇ + ∇ ∇ +⎢ ⎥⎢ ⎥∂ ⎢ ⎥⎣ ⎦⎣ ⎦

⎧ ⎫= − ∇ ∇ − ∇ ∇ +⎨ ⎬

⎩ ⎭

∫∫ ∫∫

∫∫

i i i

i i i

Now, ( ) ( ) ( ),ˆl l lj j jv B v z vψ ψ⎡ ⎤∇ = ∇ ×∇ = ⎣ ⎦i i

[ ]18

,1

( , ) , ,j j

j k kk

v d d v d d

R

ξ η φ ξ η ψ φ ψ ξ η

=

⎡ ⎤∇ ∇ = ⎣ ⎦

= Φ

∫∫ ∫∫

BBi i

( )( )18 18 20 20 20 20

, , , , ,1 1 1 1 1 1

18 18

, , ,1 1

( 2, 2)

j k p j q i r k s l p q q p r s s ri l p q r s

p q r s p q r s i l

j k i l i li l

R g g g g m n m n m n m n

F m m m m n n n n

P

= = = = = =

= =

≡ − − ×

+ + + − + + + − Ψ Ψ

= Ψ Ψ

∑∑∑∑∑∑

∑∑

Evaluation of the Matrix Elements

( )( )20 20 20 20

, , , , , , ,1 1 1 1

( 2, 2)

j k i l p j q i r k s l p q q p r s s rp q r s

p q r s p q r s

P g g g g m n m n m n m n

F m m m m n n n n= = = =

≡ − −

× + + + − + + + −

∑∑∑∑

[ ]

ˆ

, x y y x

z

a b a b a b

a b a bξ η η ξ

ψ= × ∇

= −

= −

B

Anisotropic Diffusion

N..number of points per side

10 20 30 40 60

RM

S e

rror i

n st

eady

-sta

te

1e-6

1e-5

1e-4

1e-3

1e-2

1e-1κ|| = 10**4 κ|| = 10**5

κ|| = 10**6 κ|| = 10**7 κ|| = 10**8 power law

N-4

N-5

2BB S

t Bφ κ φ κ φ∂ ⎡ ⎤= ∇ ∇ + ∇ ∇ +⎢ ⎥∂ ⎣ ⎦

i i i

Solve to steady state

cos cosx ySL L

π πψ= =

Shows greater than N-5 convergence

2D Incompressible MHD

[ ]

2 2 2 4

2

, ,

,

t

t

φ φ φ ψ ψ μ φ

ψ ψ φ η ψ

∂ ⎡ ⎤ ⎡ ⎤∇ + ∇ − ∇ = ∇⎣ ⎦ ⎣ ⎦∂∂

+ = ∇∂

2 2 2 2 2

4 4

2 2

1 1

, ,

,

,

n n n

n n

n n n n

t t t t

t

t t t

t t

φ φ θδ φ φ θδ φ ψ θδ ψ ψ θδ ψ

μ φ θδ φ

ψ ψ θδ ψ φ θδ φ η ψ θδ ψ

φ φ ψ ψφ ψδ δ

+ +

⎡ ⎤ ⎡ ⎤∇ + ∇ + ∇ + − ∇ + ∇ +⎣ ⎦⎣ ⎦⎡ ⎤= ∇ + ∇⎣ ⎦

⎡ ⎤ ⎡ ⎤+ + + = ∇ + ∇⎣ ⎦⎣ ⎦

− −= =

18

1

n nj j

jvφ

=

= Φ∑18

1

n nj j

j

vψ=

= Ψ∑

20

1

i im nj ij

i

v gξ η=

= ∑Multiply equations by each trial function and integrate over space

“reduced MHD”

φ is stream function

ψ is poloidal flux

θ-centering….time centered about n+1/2 for θ=0.5

note:

Leads to the Matrix Implicit System

11 12 * *, , , , , ,

21 22 * *, , , , , ,

*, , , , ,

, , ,11 12,

21 22

[ ][ ]

[(

(1 ) ]

j j i j i j k k i j i j k k

j j i j k k i j i k j k i j

ni j i j k k i j k k n

i j k k ii jj j

j j

S S A t G B tGS S tK M t K A

A t G Gt G G

BD DD D

θδ μ θδθδ θδ η

δ θδ θ

θ μ

⎡ ⎤ ⎡ ⎤+ Φ + − Ψ=⎢ ⎥ ⎢ ⎥Ψ + Φ −⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

⎧ ⎫− Φ − Φ⎪ ⎪ Ψ −⎨ ⎬+ −⎡ ⎤ ⎪ ⎪⎩ ⎭=⎢ ⎥

⎢ ⎥⎣ ⎦

*,

*1, , , 2*1

, , 2,

)

[ ( )( )

(1 ) ]

j k k

ni j i k j k kn

i j k k ki j

M t KtK

A

δ θδ θ

θ η

⎡ ⎤Ψ⎢ ⎥

⎢ ⎥⎢ ⎥

⎧ ⎫− Φ − Φ⎢ ⎥⎪ ⎪− Ψ + Ψ ⎨ ⎬⎢ ⎥− −⎪ ⎪⎢ ⎥⎩ ⎭⎣ ⎦

11 12 1 11 12

21 22 1 21 22

n nj j j j j j

n nj j j j j j

S S D DS S D D

+

+

⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤Φ Φ=⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥Ψ Ψ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦

Solve each time step using SuperLU

For linear problem,only need to form LU decomposition once and do a back-substitution each time step.

Note that stream function and vorticity are solved together

Tilting of a Plasma Column

0 1

1

[2 / ( )] ( ) cos , 1( 1/ ) cos , 1

( ) 0

kJ k J kr rr r r

J k

θψ

θ<⎧

= ⎨ − >⎩=

Initial Condition:

Give small perturbation and evolve in time

Stream function and vorticity at final time

Flux (top) and current (bottom) at initial and final times

Tilting of a Plasma Column-cont

Converged (in time) growth rate the same for N=30,40 out to 6 decimal places

Boundary Conditions

x

y

x

y

xx

xy

yy

φφφφφφ

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥

Φ = ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

If boundary aligned with x axis:

Homogeneous Dirichlet

Homogeneous Neumann

000

x

xx

φφφ

==

=

0

0y

xy

φ

φ

=

=

Non-Rectangular Boundary Conditions

At each boundary point, define a local normal and curvature:

ˆˆ ˆ /n n dt dlκ ≡ ⋅

We then define a new set of basis functions for that boundary node that are locally aligned with the boundary and curvature

Old basis functions

Ignoring curvature

with curvature

002 2

2 2

2 2

2 2

2 2

1 0 0 0 0 000 2 ( ) 20 0 00 0 0 2 20 0 0

x y y x y x xn

y x x y x y x y yt

x x y y xxnn

x y x y x y xynt

y x y x yytt

n n n n n nn n n n n n n n

n n n nn n n n n nn n n n

νμκ κ κ νμκ κ κ νμ

νμνμνμ

⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥ −⎢ ⎥ ⎢ ⎥⎢ ⎥

− − − −⎢ ⎥ ⎢ ⎥⎢ ⎥= ⎢ ⎥ ⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ − −⎢ ⎥ ⎢ ⎥⎢ ⎥ −⎣ ⎦ ⎣ ⎦ ⎣ ⎦

i

34

3D C1 elements by combining Q18 triangles in (R,Z) Hermite Cubic representation in the toroidal angle φ

( ) ( ) ( )2 21 2( ) | | 1 2 | | 1 ; ( ) | | 1x x x x x xΦ = − + Φ = −

]

181 2

, 1 , 21

1 2, 1 1 , 1 2

( , , ) ( , ) ( / ) ( / )

( / 1) ( / 1)

j j k j kj

j k j k

U R Z R Z U h U h

U h U h

ϕ ν ϕ ϕ

ϕ ϕ=

+ +

⎡= Φ + Φ⎣

+ Φ − + Φ −

Each toroidal plane has two Hermite cubic functions associated with it

Solution for each scalar function is represented in each triangular wedge as the product of Q18 and Hermite functions

All DOF are still located at nodes: => very efficient representation

35

2-Fluid MHD Equations:

( ) 2 2

2

2

2

( ) 0

( )

3 32 23 3

52

2 2

1

32

i

ee e e

GV

e H

ee

ii i i

n nt

t

nM pt

p p p J Qt

p

p hne

pp nne

p p V Qt

n

λ

μ

η

η

μ

Δ

Δ

∂+ ∇ • =

∂∂

= −∇ × = ∇ × = ∇×∂

∂+ • ∇ + ∇ = × − + ∇

+ × = +

∂ ⎛ ⎞+

× − ∇ − ∇

⎡ ⎤∇ − ∇⎢ ⎥⎣ ⎦∇ = − ∇ + + − ∇ +⎜ ⎟∂ ⎝ ⎠

∂ ⎛ ⎞+ ∇ = − ∇ + ∇ − ∇ −⎜ ⎟∂ ⎝ ⎠

V

B E B A J B

V V V J B V

E V

Π

J B JB J

V V q

V q

J

V

i i i

i i

i

i

i

2R

-esfl

istiuid

ve MHDterms

2 2 2R RU R χϕ ϕω −⊥= ∇ × ∇ + ∇ + ∇V

20 ˆlnR R Rf zψϕ ϕ= ∇ ×∇ + ∇ −A

8 scalar 3D variables:, , , , , , ,e if U n p pψ χ ω

No further approximations! Solve these as faithfully as possible in realistic geometry

ϕ

Z

R

36

t = 1

t = 16

t = 24

t = 32

t = 40

t = 8

“GEM” reconnection test problem1 for 2-fluid MHD

• Starts like resistive MHD

• Dramatic change in configuration for t > 20

In-plane current density contours at different times

1J. Birn, et al, J. Geophys. Res. 106 (2001) 3715

37

2-fluid reconnection requires high resolution for convergent results

• Note sudden transition where velocity abruptly increases

•These calculations used a hyperviscosity term in Ohm’s law proportional to h2 . . . required for a stable calculation

• Reconnected Flux at t=40 converges as 1/h5

38

vorticity field velocity divergence

out-of-plane current out-of-plane magnetic field

2F GEM Reconnection snapshot at time of maximum velocity t ~ 32 (2002 nodes)

Energy conservation to 1 in 103, flux conservation exact, symmetry preserved even though triangles were not arranged symmetrically.

mid

plan

e

39

Midplane Current density collapses to the width of 1-3 triangular elements

t=32 time of previous contour plot( note sudden collapse at t=23+)

40

Midplane electric field before and after transitiont=20

X-Midplane

10 15 20 25 30 35-0.01

0.00

0.01

0.02

0.03

0.04

t=30

X-Midplane

10 15 20 25 30 35-0.2

0.0

0.2

0.4

Total Electric FieldResistivity J x BV x BHyper-resistivity

( ) 2 21ˆ e HJ B p hJVEne

B Jz η λ×−⎡ ⎤= − ∇+ +⎢ ⎥⎣ ⎦× − ∇iReconnection rate:

41

Blowup showing electric field after transition

X-Midplane

20 21 22 23 24 25-0.2

0.0

0.2

0.4

Total Electric FieldResistivity J x BV x BHyper-resistivity

( ) 2 21ˆ e HJ B p hJVEne

B Jz η λ×−⎡ ⎤= − ∇+ +⎢ ⎥⎣ ⎦× − ∇i

one triangle

Hyper-resistivity coefficient must be large enough that current density collapse is limited to 1-2 triangles: reason for factor h2

t=30

X-Midplane

10 15 20 25 30 350.2

0.0

0.2

0.4

42

The split-implicit time advance

43

2 22

2 2 0

u vcu ut x c

v u t xct x

∂ ∂ ⎫= ⎪ ∂ ∂⎪∂ ∂ − =⎬∂ ∂ ∂ ∂⎪=⎪∂ ∂ ⎭

Consider a simple 1-D Hyperbolic System of Equations (Wave Equation)

44

2 22

2 2 0

u vcu ut x c

v u t xct x

∂ ∂ ⎫= ⎪ ∂ ∂⎪∂ ∂ − =⎬∂ ∂ ∂ ∂⎪=⎪∂ ∂ ⎭

1 1 11/2 1/2 1/2 1/2

1 1 11/2 1/2 1 1

(1 )

(1 )

n n n n n nj j j j j j

n n n n n nj j j j j j

u u v v v vc

t x x

v v u u u uc

t x x

θ θδ δ δ

θ θδ δ δ

+ + ++ − + −

+ + ++ + + +

⎡ ⎤⎛ ⎞ ⎛ ⎞− − −= + −⎢ ⎥⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎢ ⎥⎝ ⎠ ⎝ ⎠⎣ ⎦

⎡ ⎤⎛ ⎞ ⎛ ⎞− − −= + −⎢ ⎥⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎢ ⎥⎝ ⎠ ⎝ ⎠⎣ ⎦

Consider a simple 1-D Hyperbolic System of Equations (Wave Equation)

Implicit Centered Difference:

Stable for θ ≥ ½ 2nd order for θ = ½

45

1 1 11/2 1/2 1/2 1/2

1 1 11/2 1/2 1 1

(1 )

(1 )

n n n n n nj j j j j j

n n n n n nj j j j j j

u u v v v vc

t x x

v v u u u uc

t x x

θ θδ δ δ

θ θδ δ δ

+ + ++ − + −

+ + ++ + + +

⎡ ⎤⎛ ⎞ ⎛ ⎞− − −= + −⎢ ⎥⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎢ ⎥⎝ ⎠ ⎝ ⎠⎣ ⎦

⎡ ⎤⎛ ⎞ ⎛ ⎞− − −= + −⎢ ⎥⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎢ ⎥⎝ ⎠ ⎝ ⎠⎣ ⎦

( ) ( )

1 1 11 1 1 1 1/2 1/21 2 2

2 2

1 1 11/2 1/2 1 1

2 2( ) (1 )

(1 )

n n n n n n n nj j j j j j j jn n

j j

n n n n n nj j j j j j

u u u u u u v vu u tc tc

x x x

tcv v u u u ux

δ θ θ θ δδ δ δ

δ θ θδ

+ + ++ − + − + −+

+ + ++ + + +

⎡ ⎤⎛ ⎞ ⎛ ⎞ ⎛ ⎞− + − + −= + + − +⎢ ⎥⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎢ ⎥⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎣ ⎦

⎡ ⎤= + − + − −⎣ ⎦

Consider a simple 1-D Hyperbolic System of Equations (Wave Equation)

Substitute from second equation into first:

These two equations are completely equivalent to those on the previous page, but can be solved sequentially!

Only first involves Matrix Inversion … Diagonally Dominant

46

2 2

2 2 2

2 2 2

2 2 2

2 2 2

2 2

1 211 21

1 211 21

1 211 21

1 11 1

1 11 1

1 11 1

S SSS S SS S

S S SS SS S SS S

S S SS SS SS S

S SS S

S SS S

S SS

⎡ ⎤+ −−⎡ ⎤⎢ ⎥⎢ ⎥ − + −− ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥ − + −−⎢ ⎥⎢ ⎥ − + −− ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥ − + −−⎢ ⎥⎢ ⎥

− +− ⎢ ⎥⎣ ⎦⎢ ⎥ →⎢ ⎥− ⎡ ⎤⎢ ⎥ ⎢ ⎥−⎢ ⎥ ⎢ ⎥⎢ ⎥− ⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥− ⎢ ⎥⎢ ⎥ ⎢ ⎥−⎢ ⎥ ⎢ ⎥⎢ ⎥⎣ ⎦ ⎣ ⎦

2N

N

N

Substitution takes us from having to invert a 2N x 2N system that has large off-diagonal elements to sequentially inverting a N x N system that is diagonally dominant + the identity matrix.

Mathematically equivalent same answers!

Matrices to be inverted

1c tSx

θ δδ

=

Coupled system Un-coupled system

47

2 2 2 1 2 2

1 11/2 1/2 1/2 1/2

1 1 (1 )

(1 )

n n nx j x j x j

n n n nj j x j x j

S u S u S v

v v S u u

θ δ θ θ δ δ

θδ θ δ

+

+ ++ + + +

⎡ ⎤ ⎡ ⎤− = + − +⎣ ⎦ ⎣ ⎦⎡ ⎤= + + −⎣ ⎦

2 1 1 1 11 1

1/2 1/2

2n n n nx j j j j

n n nx j j j

u u u u

v v v

tcSx

δ

δ

δδ

+ + + ++ −

+ −

≡ − +

≡ −

( ) ( )

1 1 11 1 1 1 1/2 1/21 2 2

2 2

1 1 11/2 1/2 1 1

2 2( ) (1 )

(1 )

n n n n n n n nj j j j j j j jn n

j j

n n n n n nj j j j j j

u u u u u u v vu u tc tc

x x x

tcv v u u u ux

δ θ θ θ δδ δ δ

δ θ θδ

+ + ++ − + − + −+

+ + ++ + + +

⎡ ⎤⎛ ⎞ ⎛ ⎞ ⎛ ⎞− + − + −= + + − +⎢ ⎥⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎢ ⎥⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎣ ⎦

⎡ ⎤= + − + − −⎣ ⎦

Rewrite using standard finite-difference notation:

Operator to invert

48

u vct xv uct x

∂ ∂=

∂ ∂∂ ∂

=∂ ∂

n

n

u vc v tt x tv uc u tt x t

θδ

θδ

∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

An alternate derivation:

Expand RHS in Taylor series in time to time-center

49

u vct xv uct x

∂ ∂=

∂ ∂∂ ∂

=∂ ∂

n

n

u vc v tt x tv uc u tt x t

θδ

θδ

∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

n n

n

u uc v t c u tt x x t

v uc u tt x t

θδ θδ

θδ

⎡ ⎤∂ ∂ ⎛ ∂ ∂ ⎞⎡ ⎤= + +⎢ ⎥⎜ ⎟⎢ ⎥∂ ∂ ∂ ∂⎣ ⎦⎝ ⎠⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

An alternate derivation:

Expand RHS in Taylor series in time to time-center

Substitute from second equation into first

50

2 22 2 2 1 2 2

2 2

1 1

1 ( ) 1 (1 )( )

(1 )

n n n

n n n n

t c u t c u tc vx x x

v v tc u ux x

θ δ θ θ δ δ

δ θ θ

+

+ +

⎡ ⎤ ⎡ ⎤∂ ∂ ∂− = + − +⎢ ⎥ ⎢ ⎥∂ ∂ ∂⎣ ⎦ ⎣ ⎦

∂ ∂⎡ ⎤= + + −⎢ ⎥∂ ∂⎣ ⎦

u vct xv uct x

∂ ∂=

∂ ∂∂ ∂

=∂ ∂

n

n

u vc v tt x tv uc u tt x t

θδ

θδ

∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

n n

n

u uc v t c u tt x x t

v uc u tt x t

θδ θδ

θδ

⎡ ⎤∂ ∂ ⎛ ∂ ∂ ⎞⎡ ⎤= + +⎢ ⎥⎜ ⎟⎢ ⎥∂ ∂ ∂ ∂⎣ ⎦⎝ ⎠⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

An alternate derivation:

Expand RHS in Taylor series in time to time-center

Substitute from second equation into first

Use standard centered difference in time:

51

u vct xv uct x

∂ ∂=

∂ ∂∂ ∂

=∂ ∂

n

n

u vc v tt x tv uc u tt x t

θδ

θδ

∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

n n

n

u uc v t c u tt x x t

v uc u tt x t

θδ θδ

θδ

⎡ ⎤∂ ∂ ⎛ ∂ ∂ ⎞⎡ ⎤= + +⎢ ⎥⎜ ⎟⎢ ⎥∂ ∂ ∂ ∂⎣ ⎦⎝ ⎠⎣ ⎦∂ ∂ ∂⎡ ⎤= +⎢ ⎥∂ ∂ ∂⎣ ⎦

2 22 2 2 1 2 2

2 2

1 1

1 ( ) 1 (1 )( )

(1 )

n n n

n n n n

t c u t c u tc vx x x

v v tc u ux x

θ δ θ θ δ δ

δ θ θ

+

+ +

⎡ ⎤ ⎡ ⎤∂ ∂ ∂− = + − +⎢ ⎥ ⎢ ⎥∂ ∂ ∂⎣ ⎦ ⎣ ⎦

∂ ∂⎡ ⎤= + + −⎢ ⎥∂ ∂⎣ ⎦

An alternate derivation:

Expand RHS in Taylor series in time to time-center

Substitute from second equation into first

Use standard centered difference in time:

This is the same operator as before when centered spatial differences used

Summary• Finite elements with C1 continuity can be used with differential equations up

to 4th order.

• Hermite cubic element is an attractive C1 element in 1D– 2 DOF at each node

• Q18 is an attractive C1 element in 2D– All DOF defined at nodes very compact compared to other elements

– Shown to be very accurate

– Curved domains can be accommodated with normal vector and curvature

– High accuracy has been verified in demanding tests

• 3D Element can be made as the tensor product of Q18 and Hermite cubic

• Fits naturally into implicit method for MHD in tokamak (next lecture)

53