computational magneto-fluid dynamicsu0016541/mhd_sheets_pdf/cmfdles1.uu09.pdf · computational...
TRANSCRIPT
Computational Magneto-Fluid Dynamics CMFD-1
Computational Magneto-Fluid Dynamics
Rony KeppensCentre for Plasma-Astrophysics, K.U.Leuven (Belgium)
& FOM-Institute for Plasma Physics ‘Rijnhuizen’
& Astronomical Institute, Utrecht University
Guest lectures at Utrecht University, May-June 2009
With material based on PRINCIPLES OF MAGNETOHYDRODYNAMICS
by J.P. Goedbloed & S. Poedts (Cambridge University Press, 2004)
and on ADVANCED MAGNETOHYDRODYNAMICS
by J.P. Goedbloed R.Keppens & S. Poedts (CUP, to appear 2009-2010)
Computational Magneto-Fluid Dynamics CMFD-2
Computational Magneto-Fluid dynamics
�
�
�
Overview: may 11
• Numerical MHD in brief: governing MHD equations; example numerical applica-tions; focus of this course.
• Linear advection equation: discretizations, stability, diffusion, dispersion, order ofaccuracy.
• Linear hyperbolic systems and nonlinear scalar equations: Riemann problem,Burgers equation, shocks and rarefactions.
Computational Magneto-Fluid Dynamics CMFD-3
�
�
�
Overview: may 18
• Finite Volume discretization: integral versus differential form, explicit time integra-tion, CFL condition, TVD concept and TVDLF method.
• Euler equations: gas dynamics in 1D, solution of the Riemann problem. TVDLFsimulations.
• Multi-D hydro applications: Rayleigh-Taylor and Kelvin-Helmholtz instability devel-opment, demonstrative shock-dominated astrophysical problems.
Computational Magneto-Fluid Dynamics CMFD-4
�
�
�
Overview: may 25
• Preliminary aspects for MHD simulations: conservative and primitive formulations,generalized Riemann invariants. Compound waves.
• 1.5D isothermal MHD: with TVDLF simulations.
• Multi-D MHD: MHD wave anisotropies; ∇ · B = 0 for shock-capturing schemes
Computational Magneto-Fluid Dynamics CMFD-5
�
�
�
Overview: june 8
• Demonstrative multi-D MHD applications: nonlinear evolution of linearly unstable,idealized configurations (from planar shear layers to 3D jet simulations, revisitingKelvin-Helmholtz instabilities, modeling kink instabilities).
• Transonic MHD in astrophysical simulations: transmagnetosonic winds, astro-physical jet launching, accretion funnels onto magnetized stars
Computational Magneto-Fluid Dynamics CMFD-6
�
�
�
Magnetohydrodynamic model:
• macroscopic dynamics of perfectly conducting plasma
⇒ ideal MagnetoHydroDynamic – MHD – description
⇒ continuum, single fluid description of plasma in terms of ρ, v, p, B
⇒ conservation of mass, momentum, energy, and magnetic flux
• magnetic field B introduces Lorentz force J × B
⇒ perpendicular to field lines and current J
⇒ attractive/repulsive forces between parallel current-carrying wires
• no magnetic sources or ‘monopoles’ hence ∇ · B = 0
⇒ contrast to electric charges (sources of electric field)
⇒ magnetic field lines (tangent to B) have no beginning or end
⇒ always form closed loops
Computational Magneto-Fluid Dynamics CMFD-7
�
�
�
Governing equations:
• 8 non-linear PDE for density ρ, velocity v, temperature T , B
∂ρ
∂t+ ∇ · (vρ) = 0
ρ
(∂v
∂t+ v · ∇v
)
+ ∇p− (∇× B) × B = ρg
ρ
(∂T
∂t+ v · ∇T
)
+ (γ − 1)p∇ · v = Sq
∂B
∂t−∇× (v × B) = SB
• pressure p = ρT (ideal gas only), external gravity g
⇒ Euler for gas dynamics + pre-Maxwell equations
⇒ use EM units where µ0 = 1
• Add ∇ · B = 0 ⇒ no magnetic monopoles
• Ideal MHD : no heat source/sink Sq, no source term SB
Computational Magneto-Fluid Dynamics CMFD-8
• conservation of mass: local density value can alter in 2 ways
∂ρ
∂t= − ρ∇ · v
︸ ︷︷ ︸local compressions
− v · ∇ρ︸ ︷︷ ︸
advected density gradients
⇒ total mass is conserved (no sinks/sources)
• momentum equation (Newton’s law)
ρ
(∂v
∂t+ v · ∇v
)
+ ∇p− (∇× B)︸ ︷︷ ︸
J
×B = ρg
⇒ inertial effects, pressure gradients, Lorentz force, exte rnal gravity
⇒ current found from B directly: Ampere’s law
J = ∇× B
⇒ neglects displacement current term in Maxwell equation
1
c2∂E
∂t+ µ0J = ∇× B
⇒ non-relativistic plasma flows v ≪ light speed c
Computational Magneto-Fluid Dynamics CMFD-9
�
�
�
The induction equation:
• evolutionary equation for B in ideal MHD: Faraday’s law
∂B
∂t= ∇× (v × B)
︸ ︷︷ ︸−E
⇒ field lines are frozen in plasma
⇒ unimpeded flow along B, flow ⊥ B displaces field line
⇒ analytically: if ∇ · B = 0 initially, then always
• electric field in co-moving frame for perfectly conducting fluid
E′ = E + v × B = 0
Computational Magneto-Fluid Dynamics CMFD-10
�
�
�
Ideal versus resistive MHD: kinetic modeling
• kinetic ‘MHD’: induction equation in multi-D MHD + ∇ · B = 0
⇒ prescribed velocity field, no back-reaction of B on flow (ignore Lorentz force)
⇒ assume B2/2 ≪ ρv2/2: insignificant magnetic energy
• Weiss (1966!) numerical simulations with resistivity
⇒ expulsion of magnetic flux by eddies
• consider medium with constant resistivity η, Ohm’s law
E′ = E + v × B = η j .
⇒ induction equation then given by
∂B
∂t= ∇× (v × B) + η∇2B
Computational Magneto-Fluid Dynamics CMFD-11
�
�
Weiss kinetic simulations
• kinematic modeling: velocity field v time-invariant
⇒ set v = [sin(2πx) sin(2πy − π/2), sin(2πx + π/2) sin(2πy)]
⇒ 2D incompressible flow ∇ · v = 0
⇒ models 4 convection cells on unit square [0, 1]2
• magnetic field evolution from induction equation with resistivity
• ensure ∇ · B = 0: use vector potential
B = ∇× A ⇒ ∇ · (∇× A) = 0
⇒ 2D case: just involves z-component of vector potential Az ≡ A
B =
(∂A
∂y,−∂A
∂x, 0
)
Computational Magneto-Fluid Dynamics CMFD-12
• solve numerically induction equation in 2D
⇒ consider cases η = 0.1, η = 0.01, η = 0.001
⇒ from resistive towards ideal MHD case
⇒ η = 0: frozen in limit (only numerical diffusion)
• perform 302 simulations, initial B = (0, 1)
⇒ evolution of magnetic energy: 3 phases
⇒ field amplification, resistive diffusion, steady state
⇒ turnover: convective term comparable to resistivity
Computational Magneto-Fluid Dynamics CMFD-13
• steady-state configuration:
⇒ magnetic field/flux expelled from centre of eddies as η → 0
⇒ flux concentrates at edges of convective cells
⇒ returns in modern full 2D/3D MHD magnetoconvection models
Computational Magneto-Fluid Dynamics CMFD-14
�
�
Ideal MHD and flux conservation:
• magnetic flux through surface intersecting B lines Ψ ≡∫ ∫
S
B · ndS
S1
S2
⇒ identical for any surface S along ‘flux tube’
⇒ easily found from Gauss theorem:∫ ∫ ∫
V
∇ · B dV =
∫ ∫
σ
B · ndσ = −∫ ∫
S1
B1 · n1dS1 +
∫ ∫
S2
B2 · n2dS2 = 0
• conservation of magnetic flux: basic law of ideal MHD
⇒ flux through surface element moving with fluid will remain con stant:
Ψ =
∫ ∫
C
B · ndσ = constant
⇒ for closed contour C moving with plasma
Computational Magneto-Fluid Dynamics CMFD-15
�
�
Ideal MHD and conservation laws:
• equivalently: conservation laws for density ρ, momentum density m = ρv, H and B
∂ρ
∂t+ ∇ · (vρ) = Sρ
∂m
∂t+ ∇ · (vρv − BB) + ∇ptot = Sρv
∂H∂t
+ ∇ · (vH + vptot − BB · v) = Se
∂B
∂t+ ∇ · (vB − Bv) = SB
• ptot ≡ thermal pressure + magnetic pressure
• total energy density H has 3 contributions
H =p
γ − 1︸ ︷︷ ︸internal
+ρv2
2︸︷︷︸kinetic
+1
2B2
︸︷︷︸magnetic
• Sources (Sinks) of conserved quantities in right hand side
Computational Magneto-Fluid Dynamics CMFD-16
�
�
Scale invariance:
• units of length, mass, time (plus µ0 = 1)
⇒ trivially scale out of equations
⇒ take lengthscale l0, field strength B0, density ρ0
⇒ speed v0 = B0/√ρ0 timescale from t0 = l0/v0
• pure MHD signal at Alfv en speed B0/√ρ0
⇒ field line wiggles: magnetic tension as restoring force
x
z
k
y
B0
v1+B0 B1
• MHD can be applied to laboratory, solar, galactic dimensions alike!
⇒ macroscopic dynamics of plasmas in dimensionless form
Computational Magneto-Fluid Dynamics CMFD-17
�
�
�
Example applications:
• consider STATIC MHD equilibria v = 0, leaves only{−∇p + (∇× B) × B + ρg = 0
and ∇ · B = 0
⇒ governing equations for stratified, magnetostatic equilibria
• Prominences in solarcorona
• translational symme-try
⇒ 2D in cross-section
• Tesla strong B intokamaks
• neglect g, axisym-metry
⇒ 2D in cross-section
Computational Magneto-Fluid Dynamics CMFD-18
�
�
�
Computing prominence equilibria:
• 2D Problem in cross-section governed by second order elliptic PDE
⇒ in terms of flux function ψ(y, z), field lines on isosurfaces
⇒ along poloidal flux contour: pressure gradient balances gravity
• use 2D Finite Element discretization, Picard iterate to solution
⇒ use local expansion functions , of given polynomial form (here bicubic)
⇒ isothermal, double prominence (left); non-isothermal three-part structure (right)
(from Petrie et al, ApJ, 2007)
Computational Magneto-Fluid Dynamics CMFD-19
�
�
�
Tokamak equilibria:
• Controlled thermonuclear fusion: magnetically caged (Tesla fields), hot plasmas
⇒ balance of ∇p = J × B: three orthogonal vectors
• 3D visualization: ρ-isosurfaces, p in cross-section, grid impression
⇒ B vectors and selected fieldlines: variation of winding with radius
Computational Magneto-Fluid Dynamics CMFD-20
�
�
�
Geodynamo simulations:
• Earth’s magnetic field is currently mostly dipolar:
– evidence from magnetized rocks that orientation reverses every few 100000years, taking a few 1000 years for full reversal.
• Earth consist of inner core, outer core, mantle, crust:
– liquid iron outer core (1300 < R < 3400 km) must maintain field
– rotation and convection in moving conducting fluid described by Ohm’s law
E + v × B = η j .
– Inhomogeneity of magnetic field decays in time τD determined by resistivity ηand length scale l0 ∼ ∇−1 of inhomogeneity:
τD = µ0l20/η = l20/η .
– resistive diffusion time scale τD ∼ 5 × 1011 s = 16 000 years
– need sustained B generation by molten iron motion
– convection driven by heat from radioactive decay in inner solid core
Computational Magneto-Fluid Dynamics CMFD-21
• Full 3D MHD simulations by Glatzmaier & Roberts (1995):
– simulated several 100000 years of geodynamo activity
– inner core mediates reversals: its B changes on diffusion time
– captured reversal event, changed dipole orientation in 1000 years:
http://www.es.ucsc.edu/ glatz/(website Gary Glatzmaier)
• spectral method : all variables written in expansion exploiting global functions ,in particular here: Chebyshev polynomials (radial variation) and spherical harmonics(both angular variations)
Computational Magneto-Fluid Dynamics CMFD-22
�
�
�
Eruptive event studies:
• simulating 3D kink-unstable loop evolution
⇒ Torok & Kliem, ApJ 2005, 630, L97
• Further ejection and CME initiation
• Finite difference/volume – Lax-Wendroff method : update local function valuesthrough fluxes computed from neighboring grid points. Here for zero-beta p = 0conditions, neglect g, stabilized by added viscosity terms and ‘artificial smoothing’
Computational Magneto-Fluid Dynamics CMFD-23
�
�
Numerical discretizations and MHD:
• 3 examples given meant to demonstrate
⇒ diversity of MHD problems : static, dynamic, long term slow evolution versussudden events, different geometries, . . .
⇒ diversity of employed discretizations (FEM, spectral, finite difference, finitevolume) and numerical algorithms
• This course can NOT treat all of these in detail
⇒ I will focus on modern, shock-capturing schemes
⇒ pay attention to nonlinear ideal MHD in particular
⇒ give state-of-the-art examples, for Finite Volume approaches
Computational Magneto-Fluid Dynamics CMFD-24
�
�
Reference material:
• Throughout this course, I use material based on
⇒ Principles of Magnetohydrodynamics , Goedbloed & Poedts , CUP 2004
⇒ Advanced Magnetohydrodynamics , Goedbloed, Keppens & Poedts , CUPto appear 2009-2010
• I also recommend (mostly HD):
⇒ P. Wesseling, Principles of Computational Fluid dynamics
⇒ E. F. Toro, Riemann Solvers and Numerical Methods for Fluid dynamics. Apractical Introduction (2nd Edition)
⇒ R. J. LeVeque, Numerical Methods for Conservation Laws
⇒ R. J. LeVeque, Finite Volume Methods for Hyperbolic Problems
⇒ R. J. LeVeque, D. Mihalas, E. A. Dorfi and E. Muller, Computational Methodsfor Astrophysical Fluid Flow
Computational Magneto-Fluid Dynamics CMFD-25
�
�
�
The advection equation
Trivial problem: linear advection equation
⇒ ∂tρ + v∂xρ = 0
⇒ constant given velocity v
⇒ initial density pulse ρ(x, t = 0) = ρ0(x)
Trivial solution: ρ(x, t) = ρ0(x− vt)
⇒ analytically: done!
⇒ numerically?
Computational Magneto-Fluid Dynamics CMFD-26
�
�
Focus on Riemann Problem
• initial data ρ(x, 0) =
{ρl x < 0ρr x > 0
⇒ two constant states separated by discontinuity
⇒ solution still trivial, graphically:
1 x-t plane
t
x
Linear advection (v>0)
vt
t=0
t=t1ρ
ρ
l
r
x= 0
x= 0
rρl ρ
x= 0
ρl
ρr
Computational Magneto-Fluid Dynamics CMFD-27
�
�
Numerical discretizations
• First Attempt:
⇒ temporal discretization: forward Euler
⇒ spatial discretization: Centered differencing
⇒ ρn+1
i−ρn
i
∆t + vρn
i+1−ρn
i−1
2∆x = 0
• numerically solve Riemann Problem
⇒ manifestation of a numerical instability
⇒ Von Neumann stability analysis: insert ρ(x, tn) = Gnρoeikx
⇒ amplification ρn+1 = Gn+1
Gn ρn ≡ Gρn
⇒ | G |=√
1 +(v∆t
∆xsink∆x
)2> 1 for all k
⇒ unconditionally unstable!
Computational Magneto-Fluid Dynamics CMFD-28
�
�
�
Upwind method
• Second Attempt:
⇒ temporal discretization: forward Euler
⇒ spatial discretization: upwind, for v > 0:
⇒ ρn+1
i−ρn
i
∆t+ v
ρn
i−ρn
i−1
∆x= 0
• numerically solve Riemann Problem
⇒ first order upwind method (here indentical to TVDLF1)
⇒ note: diffusion off the ‘contact discontinuity’
⇒ Von Neumann stability analysis: amplification
| G |=√
1 + 2v∆t
∆x
(∆t
∆xv − 1
)
(1 − cos k∆x)
⇒ stable for ∆t < ∆x/v
Computational Magneto-Fluid Dynamics CMFD-29
�
�
MacCormack method
• mixture of (spatially) forward and backward difference
⇒ ρ∗i = ρni − ∆t∆xv
(ρni+1 − ρni
)
⇒ ρ∗∗i = ρni − ∆t∆xv
(ρ∗i − ρ∗i−1
)
⇒ ρn+1i = ρ∗
i+ρ∗∗
i
2
• rewritten:
ρn+1i = ρni − ∆t
∆xv(ρn
i+1−ρn
i−1
2
)
+ (∆t)2
(∆x)2v2(ρn
i+1−2ρn
i+ρn
i−1
2
)
⇒ second order accurate
⇒ Von Neumann stability:
| G |=√
1 +(∆t)2
(∆x)2v2 (cos2 k∆x− 2 cos k∆x + 1)
[(∆t)2
(∆x)2v2 − 1
]
⇒ stable | G |≤ 1 for ∆t ≤ ∆x/v
Computational Magneto-Fluid Dynamics CMFD-30
• MacCormack method: dispersive
⇒ manifests Gibbs phenomenon
⇒ non-monotonicity preserving: monotone ρ(x, 0) develops extrema
Computational Magneto-Fluid Dynamics CMFD-31
�
�
�
Order of accuracy
• ‘Local Truncation Error’: insert exact solution in discretization formula
• consider upwind method
ρn+1i − ρni
∆t+ v
ρni − ρni−1
∆x= 0
⇒ LTE from LUP∆t = 1
∆t [ρ(x, t + ∆t) − ρ(x, t)] + v∆x [ρ(x, t) − ρ(x− ∆x, t)]
⇒ Taylor expand (assuming smooth solutions), use ∂tρ + v∂xρ = 0
⇒ LUP∆t = ∆t
2v
(v − ∆x
∆t
)ρxx + O
(∆t2,∆x2
)
⇒ goes to zero like ∆t for ∆t→ 0: first order method
• order of accuracy of MacCormack method:
⇒ LMC∆t = ∆t2
6v
(∆x2
∆t2− v2
)
ρxxx + O(∆t3,∆x3
)
⇒ MC is second order accurate
Computational Magneto-Fluid Dynamics CMFD-32
�
�
Lax-Friedrichs
• Lax-Friedrichs discretization
ρn+1i =
1
2(ρni+1 + ρni−1) −
∆t
2∆xv(ρni+1 − ρni−1)
⇒ Von Neumann stability analysis: ρ(x, tn) = Gnρ0 exp(ikx)
⇒ amplification ρn+1 = Gn+1
Gn ρn ≡ Gρn
⇒ | G |=| cos(k∆x) − iv∆t∆x
sin(k∆x) | ≤ 1 if ∆t ≤ ∆x/v
⇒ first order since LLF∆t = ∆t
2
(
v2 − ∆x2
∆t2
)
ρxx + O(∆t2,∆x2
)
Computational Magneto-Fluid Dynamics CMFD-33
�
�
�
Consistency
• Method with LTE → 0 for ∆t→ 0 is consistent
• smooth solution: LTE and global error are same order for stable method
• Lax equivalence theorem: for consistent method:
⇒ stability is necessary and sufficient for convergence!
Computational Magneto-Fluid Dynamics CMFD-34
�
�
Stencil
• Stencil of a method: graphically
Time
Space
First order Lax-Friedrichs
Second order MacCormack
First Order Upwind
Computational Magneto-Fluid Dynamics CMFD-35
�
�
�
Convergence
• Convergence of a method in accord with order of accuracy
• periodically advect a Gaussian Bell profile (one cycle)
⇒ error as true difference with t = 0 pulse
⇒ compare Upwind with MacCormack solution at N = [50, 100, 200, 400]
Computational Magneto-Fluid Dynamics CMFD-36
• comparison of two second order methods
⇒ periodic advection of Gaussian Bell and Square pulse
Computational Magneto-Fluid Dynamics CMFD-37
• MacCormack versus TVDLF (defined later)
⇒ smooth versus discontinuous initial profile
• both second order accurate methods render 1st order convergence!
Computational Magneto-Fluid Dynamics CMFD-38
�
�
�
Monotonicity
• Monotonicity preserving method:
⇒ monotone initial data remains monotone
⇒ MC: not monotonicity preserving; TVDLF: monotonicity preserving
⇒ for Riemann problem: no oscillations will appear
• Godunov theorem: linear monotonicity preserving method
⇒ at most 1st order accurate
• second order accuracy + monotonicity preserving:
⇒ TVDLF method depends nonlinearly on data ρni
Computational Magneto-Fluid Dynamics CMFD-39
�
�
�
TVD concept
• Numerical Total Variation
TVn ≡∑
i| ∆ρni+1/2 |
⇒ summed differences ∆ρi+1/2 = ρi+1 − ρi
⇒ TVD concept: TV diminishes with time:
TVn+1 ≤ TVn
• TVD → monotonicity preserving
⇒ TVD methods degenerate to 1st order accuracy at extrema
Computational Magneto-Fluid Dynamics CMFD-40
• TVDLF method: TVD hence monotonicity preserving
⇒ diffuses the discontinuity
⇒ monotone ρ(x, 0) develops no extrema!
⇒ first order at jump
Computational Magneto-Fluid Dynamics CMFD-41
�
�
�
Linear Hyperbolic Systems
• constant coefficient linear system
~qt + A~qx = 0
⇒ with ~q(x, t) ∈ ℜm and matrix A ∈ ℜm×m
• hyperbolic when matrix A is diagonalizable with real eigenvalues
⇒ strictly hyperbolic when distinct
⇒ m eigenvectors + m real eigenvalues
A~rp = λp~rp with p : 1, . . . , m
Computational Magneto-Fluid Dynamics CMFD-42
• write as
[A] [~r1 | ~r2 | . . . | ~rm] = [~r1 | ~r2 | . . . | ~rm]
λ1
λ2
. . .λm
⇒ or shorthand AR = RΛ with diagonal matrix Λ
⇒ matrix of right eigenvectors as columns R
• The solution to system ~qt + A~qx = 0 is equivalent to:
⇒ pre-multiply with R−1 or:
(R−1~q)t + R−1(RΛR−1)~qx = 0
⇒ redefine ~v ≡ R−1~q to get
~vt + Λ~vx = 0
⇒ m independent constant coefficient linear advection equatio ns!
Computational Magneto-Fluid Dynamics CMFD-43
• Each advection equation has trivial analytic solution:
vp(x, t) = vp(x− λpt, 0)
⇒ solution to the full linear hyperbolic system is then
⇒ ~q(x, t) =∑m
p=1vp(x− λpt, 0)~rp
⇒ depends on initial data at m discrete points
• nomenclature: ~v are ‘characteristic variables’
⇒ curves x = xo + λpt are “p-characteristics”
Computational Magneto-Fluid Dynamics CMFD-44
�
�
�
NonLinear scalar equation
• general equation form qt + f(q)x = 0
⇒ with nonlinear flux function f(q): Burgers equation f(q) = q2/2
⇒ with q ≡ ρ ‘advection’ speed increasing with density
• Demonstrates wave steepening (area conservation) and shock formation:
⇒ advect triangular pulse with MacCormack and TVDLF scheme
Computational Magneto-Fluid Dynamics CMFD-45
• Riemann problem has two cases:
⇒ ρl > ρr: shock traveling at speed s = ρl+ρr
2
⇒ ρl < ρr: rarefaction wave ρ(x, t) = ρ(x/t) =
ρl x < ρltx/t ρlt < x < ρrtρr x > ρrt
⇒ Numerically with TVDLF scheme:
Computational Magneto-Fluid Dynamics CMFD-46
�
�
�
End of day 1: summary and voluntary take-home assignment
• MHD equations intro
⇒ Explain difference between ideal-resistive MHD using induction equation alone
⇒ give (modern) examples where MHD simulations occur in astrophysical contexts
• Numerical algorithms and associated jargon:
⇒ derive stability constraints for mentioned schemes using von Neumann analysis
⇒ explain connection advection equation - linear hyperbolic system - Burgers