stability of the internal kink mode for jet plasma scenarios

27
´ Ecole polytechnique f´ ed´ erale de Lausanne (EPFL) Facult´ e des sciences de base Section de physique Centre de Recherches en Physique des Plasmas (CRPP) Association EURATOM Conf´ ed´ eration Suisse Doctoral school Stability of the internal kink mode for JET plasma scenarios described by an extended energy principle including kinetic additions CRPP internal report INT 210/04 Christian SCHLATTER PPB 310 CH-1015 Lausanne Switzerland 2004, 24 th of October Made with L A T E X2 ε

Upload: others

Post on 03-Feb-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Ecole polytechnique federalede Lausanne (EPFL)

Faculte des sciences de baseSection de physique

Centre de Recherches en Physique desPlasmas (CRPP)

Association EURATOMConfederation Suisse

Doctoral school

Stability of the internal kink mode forJET plasma scenarios described by anextended energy principle including

kinetic additions

CRPP internal reportINT 210/04

Christian SCHLATTER

PPB 310CH-1015 Lausanne

Switzerland

2004, 24th of October

Made with LATEX2ε

Contents

1 Instability of the internal kink mode 11.1 The internal kink mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Conditions for stability of the mode . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Stabilisation of the mode 32.1 Extension of the energy principle . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Calculation of δWk for JET parameters 63.1 Input parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Results and conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.3 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

A Analytic reduction of δWk 10

B Implementation 13B.1 Sourcecode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

C Matlab error function for complex arguments 21C.1 Imaginary error function erfi(x) . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

EPFL doctoral school ii Christian SCHLATTER

List of Figures

1.1 Displacement geometry of the internal kink. . . . . . . . . . . . . . . . . . . . . 2

2.1 Sawtooth stabilization using NBI and ICRF heating. . . . . . . . . . . . . . . . 3

3.1 Parametric input parameter profiles for the simulation. . . . . . . . . . . . . . . 73.2 δWk as a function of the mode frequency. . . . . . . . . . . . . . . . . . . . . . . 83.3 δWk as a function of the mode frequency. . . . . . . . . . . . . . . . . . . . . . . 8

B.1 Fn1(x) and Fn2(x) around x = 0. . . . . . . . . . . . . . . . . . . . . . . . . . . 14

EPFL doctoral school iii Christian SCHLATTER

Chapter 1

Instability of the internal kink mode

1.1 The internal kink mode

Magnetohydrodynamics (MHD) predicts instabilities in tokamak plasmas. In a perfectlyconducting plasma, described by ideal MHD, the presence of current and pressure gradientscan lead to, among others, kink modes, which cause a displacement of the magnetic surfacesof constant flux. More specific, the internal kink mode has the topology of an m = 1, n = 1mode, therefore, as m = nq, its resonant surface is located at the q = 1 surface, displacing theplasma contained inside the volume delimited by that surface.

These modes are experimentally observed on various plasma reactors, their presence resultsin sawteething plasma parameters. Sawteeth lead to energy loss of the plasma and thereforelower its confinement. With increasing pressure, the instabilities exceed the limit to let theplasma recover. As it will be shown in the following, theory predicts a pressure threshold forthe stability of the plasma [4].

1.2 Conditions for stability of the mode

The stability of the internal kink mode is evident if min (q(r)) > 0 since there will be no layerin the plasma where the mode could build up.

In the presence of a resonant surface the stability of the mode can be analyzed using the’energy principle’, a concept based on a variational formulation of the equations of motion ofthe plasma [2]. The principle reflects the fact that if a physically allowable perturbation of anequilibrium lowers the potential energy, then the equilibrium is unstable.

The energy change caused by a displacement ξ(x) due to a force F(x) of the plasma is definedby the volume integral

δW = −1

2

∫ξ · F d3x (1.1)

By expressing the perturbed quantities of the plasma in terms of the displacement for a volumeinside the plasma, δW is written as [11]

δW =1

2

plasma

(γ p0 (∇ · ξ)2 + (ξ · ∇p0)∇ · ξ +

B21

µ0

− j0 · (B1 × ξ)

)d3x (1.2)

EPFL doctoral school 1 Christian SCHLATTER

1.2 Conditions for stability of the mode 2

where the subscript 0 and 1 refer to the equilibrium and the perturbation respectively.

To study the stability of the internal kink it is convenient to develop equation 1.2 and thedisplacement in orders of ε, the aspect ratio of the tokamak ε = a/R ¿ 1

δW = δW0 + δW2 + δW4 (1.3)

ξ = ξ0 + ξ1 + ξ2 (1.4)

permitting to approximate further for a low pressure scenario with q ∝ O(1), p ∝ δW (ε2) andBφ ∝ δW (1).

Figure 1.1: Displacement ξ

(a) shows the displacementof a circular flux surface foran m = 1 perturbation. (b)shows the radial dependenceof ξ for an unstable displace-ment.

In the toric tokamak, a perturbation of the flux surfaces isconstraint by its poloidal and toroidal periodicity and maytherefore be written as a Fourier series

ξ(r, θ, φ) =∑m

ξ(r,m) exp (i (mθ − nφ− ωt)) (1.5)

In zeroth order of ε [7], assuming perpendicular incompress-ibility, the integral

δW0 =1

2

∫d3x

B2

µ0

(∇ · ξ⊥)2 (1.6)

vanishes. Instability must come from higher orders. In theframe of the low β approximation, δW2 writes

δW2 =2π2B2

0

µ0R0

∫ a

0

dr r3

(dξr0

dr

)2 (1− 1

q

)2

(1.7)

for the m = 1 mode.

For constant displacement dξr0

dr= 0 (except for the

singular layer at r1, see figure 1.1) the integral ispositive definite and reduces to zero for q(r1) = 1.Therefore, the internal kink is marginally stable toε2.

Rosenbluth et al. [10] showed that, for a cylindrical geometry, δW4 is minimized to zero too.

Bussac [4] demonstrated that the inclusion of toroidal effects (like the Shafranov-shiftedflux surfaces) leads to the loss of stability for the ideal internal m = n = 1 kink mode. Forquadratic safety factor profiles a poloidal βp > βc

p ≈ 0.3 makes the internal kink mode unstable.

A more realistic calculation (with a plasma surrounded by a vacuum layer) shows a strongertrend towards instability, [3] gives a critical β-threshold profile which cancels for an inversionradius r1 ≈ 0.5 .. 0.9 a.

EPFL doctoral school Christian SCHLATTER

Chapter 2

Stabilisation of the mode

Experiments in JET showed that the presence of energetic, trapped or passing particles canstabilize the internal kink mode [5], [6], [9] and [12]. Figure 2.1 shows a JET plasma, whosesawtooth activity is stabilized by the application of ICRF and NBI heating. The kinetics ofthe created fast particle populations permit to have a sawteeth-free tokamak even at high β.

TeTi

PNBIP ICRF

45 46 47 48 49 50 51 52 530

2400

4800

7200

9600

12000

time [s]

tem

pera

tures[k

eV]

45 46 47 48 49 50 51 52 530

4

8

12

16

20

inpu

tpo

wer

s[M

W]

Figure 2.1: Behaviour of central electron and ion temperatures during the longest period of saw-teeth stabilization observed in JET. When the neutral beam power (blue curve) is applied tothe plasma, the sawteeth on the electron temperature (green curve) disappear and the confinementimproves by about 20 % during a stationary phase of more than 3 seconds. The data shown wasacquired with JET plasma discharge #15697 with Ip = 3 MA, Bφ = 3.15 T.

To account for the effect of these particles, a kinetic contribution is added to the energy principleof the ideal MHD. J. Graves devoted his thesis [7] to this subject.

EPFL doctoral school 3 Christian SCHLATTER

2.1 Extension of the energy principle 4

2.1 Extension of the energy principle

The ideal MHD energy principle (equation 1.2, noted fluid term δWf ) is completed by a kineticcontribution, δWk,

δW = δWf + δWk (2.1)

with

δWk =1

2

∫d3x ξ∗ · (∇ · δPk) (2.2)

where Pk is the kinetic contribution of the energetic thermal ions to the perturbed ion pressuretensor (chapter 3.3 in [7]). The extension of the energy principle is valid for the description ofthe ideal internal kink stability boundary for the regime of collisionless ion populations. As thecritical boundary for stability lies in the outer regions of the plasma, the analysis must onlyinclude that region. This results in (equation 3.59 in [7])

δWk = −27/2π3mi

(ξ0

R0

)2 ∫ r1

0

dr r2

∫ 1

0

dk2I2q

Kb

∫ ∞

0

dε ε5/2∂fi

∂ε

[ω − ω∗i

ω − 〈ωmdi〉]

(2.3)

where ω∗i is the non-local ion diamagnetic frequency and k2 is the pitch angle variable definedby

k2 =1 + αB0 (ε− 1)

2εαB0

, α =µ

ε(2.4)

and 〈ωmdi〉 the bounce averaged magnetic precession drift frequency

〈ωmdi〉 =miq(r)ε

eZeffrB0R0

[F1

(k2

)+ 2s(r)F2

(k2

)− ζ

(1

4q2+ F3

(k2

))](2.5)

with q(r) the safety factor profile, Zeff the effective plasma charge,

s(r) =r

q

dq

dr(2.6)

the magnetic shear and the functions

F1 =2E (k2)

K (k2)− 1 (2.7)

F2 =2E (k2)

K (k2)+ 2

(k2 − 1

)(2.8)

F3 =4

3

(((2k2 − 1

)) E (k2)

K (k2)+

(1− k2

))(2.9)

where ζ reflects the modification of 〈ωmdi〉 due to the shifting of the magnetic surfaces, charac-terized by

ζ = −2Rµ0

B2

dp

drq2 (2.10)

where K (k2) and E (k2) are the complete elliptic integrals of the first and second kind respec-tively [1]. Further,

Kb

(k2

)=

1

π

√2

εK

(k2

)(2.11)

EPFL doctoral school Christian SCHLATTER

2.1 Extension of the energy principle 5

and(1)

Iq

(r, k2

)=

1

π

√2

εFq

(q, k2

)(2.12)

with

Fq

(q, k2

)= 2E

(k2

)−K(k2

)− 4(1− q)cos(πq)

1− 4(1− q)2

(E

(k2

)+

(k2 − 1

)K

(k2

))

−(1 + cos(πq))f1(q)

(E

(k2

)+

(k2 − 1

)K

(k2

)+

2

πE

(k2

)− 1

)(2.13)

−(1 + cos(πq))(E

(k2

)−K(k2

))− f2(q)(1−(k2

))(π

2−K

(k2

))

wheref1(q) =

π

2

(1.0841− 0.3193(1− q)2 − 0.0683(1− q)4

)(2.14)

and

f2(q) = 5.1

(q − 1

2

)(1− q)2 (1− 0.034(1− q)) (2.15)

J. Graves developed an analytic reduction of equation 2.3 which is reproduced in appendix Aand subsequently used for the calculations presented in the next chapter.

(1) this is equation 6.21 which interpolates equation 3.60, [7]

EPFL doctoral school Christian SCHLATTER

Chapter 3

Calculation of δWk for JET parameters

3.1 Input parameters

The real and imaginary parts of δWk have been calculated for parameters which are character-istic for JET. The following generic expressions for q-profile, toroidal magnetic field, pressuregradient, plasma rotation, ion temperature and density have been used:

q(r) = q0

(1 + d

(r

a

)2c)1/c

(3.1)

Bφ(r) = B0

(R0

R0 + r

)(3.2)

dp

dr= −Bφ(r)

µ0

dB

dr(3.3)

Ωr = Ω0

(1−

(2r

a

)2)

(3.4)

Ti(r) = Ti0

(1−

(r

a

)2)

+ Tia (3.5)

ni(r) = ni0

(1−

(r

a

)2)νn

(3.6)

The derivatives of the above quantities were calculated analytically for the points of the grid(if necessary).

3.2 Results and conclusions

δWk was calculated for a set of parameters B0 = 3 T, R0 = 2.96 m, a = 1.25 m, Zeff = 1, q0

= 0.7, c = 1.33, d = 9.09, Ti0 = 2 keV, Tia = 50 eV, ni0 = 4·10−19 m−3, νn = 6; resulting in r1

= 0.45 m. Figure 3.1 shows a compilation of these radial profiles for r ∈ [0, r1].

The calculation was carried out on a grid of 1000×1000 points, equally spaced and spanningthe intervals r = [0; r1] and k2 = [0; 1] respectively.

The plots do not include rotation of the plasma, i.e. Ω0 = 0.

EPFL doctoral school 6 Christian SCHLATTER

3.2 Results and conclusions 7

0 0.1 0.2 0.3 0.4 0.50.6

0.8

1

r [m]

q(r

)safety factor q

0 0.1 0.2 0.3 0.4 0.50

2

4

r [m]

dq/d

r(r)

dq/dr

0 0.1 0.2 0.3 0.4 0.50

0.5

1

r [m]

s(r)

plasma shear s(r)

0 0.1 0.2 0.3 0.4 0.52.6

2.8

3

r [m]

(r)

[T]

toroidal magnetic field Bφ(r)

0 0.1 0.2 0.3 0.4 0.5−1.5

−1

−0.5

r [m]

dB

/dr

dB/dr

0 0.1 0.2 0.3 0.4 0.51.5

2

2.5

r [m]

dp/d

r

derivative of plasma pressure

0 0.1 0.2 0.3 0.4 0.5−2

−1

0

r [m]

ζ

ζ

0 0.1 0.2 0.3 0.4 0.5−1

0

1

r [m]

Ω(r

)

plasma rotation

0 0.1 0.2 0.3 0.4 0.51.5

2

2.5

r [m]

Ti(r

)[k

eV

]

Ti

0 0.1 0.2 0.3 0.4 0.5−2

−1

0

r [m]

dT

i/d

r(r)

dTi/dr

0 0.1 0.2 0.3 0.4 0.50

2

4

r [m]

n i(r

)[1

0−19

m−

3 ni

0 0.1 0.2 0.3 0.4 0.5−0.2

−0.1

0

r [m]

n i(r

)/dr

dni/dr

Figure 3.1: Parametric input parameter profiles for the simulation. From top left to right bottom areplotted: q(r), dq

dr , s(r), Bφ(r), dBdr , dp

dr , η(r), Ω(r), Ti(r), dTi

dr , ni(r) and dni

dr .

Figure 3.2 shows the real and imaginary part of δWk for the selected parameters. Indeed thekinetic contribution to δW is positive, stabilizing the mode for a large range of possible modefrequencies. Whilst the real part of δW identifies the pure mode growth rate γ, its imaginarypart characterizes the mode rotation frequency (as a consequence of the Landau resonance ofbarely precessing ions) ωr = = (ω) at marginal stability.

In [7] the solution of the dispersion relation gives two types of existing modes, one of which islocated in the Alfven continuum (ω > ˜ω∗pi or ω < 0) and whose imaginary dispersion relationwrites

=D (ω) =s√

1 + ∆

3πε2

√ω (ω − ω∗pi)

ωA

∣∣∣∣∣r1

−=

δWk

= 0 (3.7)

and the other mode, called gap mode with 0 < ω < ˜ω∗pi giving

=D (ω) = 0 (3.8)

EPFL doctoral school Christian SCHLATTER

3.2 Results and conclusions 8

As =D (ω) > 0 in figure 3.2 the gap mode will not propagate. The frequency of the Alfvenmode could be determined using equation 3.7.

Figure 3.2: δWk as a function of the mode frequency. Plotted are the real (blue curve) and imaginarypart (red curve) for the input parameters stated in the text. The left figure shows a plot versuslogarithmic scale of the mode frequency, the right figure shows the same result with linear scaleof ω.

If we add a strong pressure (gradient) at q=1 by setting η = 2, the imaginary part of δWk getsstrongly negative for small negative mode frequencies, meaning that the resonance is causedby inverse precessing ions. This is plotted in figure 3.3. At ω = 0 the kinetic effects destabilizethe mode.

Figure 3.3: δWk as a function of the mode frequency for η = 2. Plotted are the real (blue curve) andimaginary part (red curve) as in figure 3.2.

EPFL doctoral school Christian SCHLATTER

3.3 Future work 9

3.3 Future work

For the future, the code should be extended to include anisotropic distribution functions(see equation A.2) with an exponent argument b(r, k) depending on radius and pitch anglecompatible with fast ion populations in plasmas heated by ICRF.

Further, the code could entirely be implemented in Fortran, to lower execution time.

An interface to fetch JET PPF data could replace the analytic profile expressions used so far.

Once done all this, scans in all relevant plasma parameters could then easily carried out andthe code could be integrated in existing MHD codes to account for the kinetic effects affectingstability.

EPFL doctoral school Christian SCHLATTER

Appendix A

Analytic reduction of δWk

This is a reproduction of the appendix B of [7]. This appendix describes the analytical methodsused to reduce the complexity of < ˆδW ki and = ˆδW ki.The kinetic perturbed potential energy term of equation 2.3, accounting for the rotation of theplasma Ωφ(r) can be written in the form,

δWki = −272 π3|ξr0|2mi

1

R20

∫ r1

0

drr2

∫ ∞

0

dEE 52

∫ 1

0

dk2I2q

(ωtot

∂fi

∂E − qrωci

∂fi

∂r

)

Kb[ωtot − ωmdi], (A.1)

with ωtot(r) = ω − ΩΦ(r) = ω + ΩΦ(r1)− ΩΦ(r) and ωci = eZB0/mi. The energy integral canbe evaluated analytically if the ions are distributed negative exponentially. Such distributionsdescribe ICRH and thermal ion populations:

fi(r, k, E) = N(r, k) exp(−b(r, k)E), (A.2)

where b = mi/Ti and N = nim3/2i /(2πTi)

3/2 for a Maxwellian thermal ion population. Bysubstituting Eq. (A.2) into Eq. (A.1), δWki contains energy integrals of the form,

∫ ∞

0

E 52 exp(−bE)

ωtot −DE dE ,

∫ ∞

0

E 72 exp(−bE)

ωtot −DE dE (A.3)

where 〈ωmdi〉 = D(r, k)E . At marginal stability

<∫ ∞

0

E 52 exp(−bE)

ωtot −DE dE

=

√π

4b72 ωtot

Fn1(x),

<∫ ∞

0

E 72 exp(−bE)

ωtot −DE dE

=

√π

4b92 ωtot

Fn2(x),

=∫ ∞

0

E 52 exp(−bE)

ωtot −DE dE

= − π

ωtotb72

Fn3(x),

=∫ ∞

0

E 72 exp(−bE)

ωtot −DE dE

= − π

ωtotb92

Fn4(x), (A.4)

EPFL doctoral school 10 Christian SCHLATTER

11

with x = D/(b ωtot). For x > 0, trapped ions magnetically precess in the same direction as ωtot

giving

Fn1+(x) = 4√

π1

x72

erfi

(1√x

)exp

(−1

x

)− 3

x− 2

x2− 4

x3,

Fn2+(x) = 4√

π1

x92

erfi

(1√x

)exp

(−1

x

)− 15

2x− 3

x2− 2

x3− 4

x4,

Fn3+(x) =1

x7/2exp

[−1

x

],

Fn4+(x) =1

x9/2exp

[−1

x

], (A.5)

where ‘+’ denotes x > 0,

erfi(x) = −ierf(ix) =2√π

∫ x

0

exp(z2)dz,

and erf(x) is the standard error function [1].For x < 0, the energy integral does not contain a residue. This follows from the fact that theresonance condition ωtot = DE cannot be met for any energy or radius if x ∝ D/ωtot < 0.However, the principle parts of Eq. (A.3) do not vanish:

Fn1− = −4√

π1

(−x)72

erfc

(1√−x

)exp

(−1

x

)− 3

x− 2

x2− 4

x3,

Fn2− = +4√

π1

(−x)92

erfc

(1√−x

)exp

(−1

x

)− 15

2x− 3

x2− 2

x3− 4

x4,

Fn3− = 0,

Fn4− = 0, (A.6)

where ‘−’ denotes x < 0 and erfc(x) = 1− erf(x). From inspection of Eqs. (A.5) and (A.6), nu-merical difficulties are clearly envisaged at the pitch angle k2

c for which the magnetic precessiondrift of trapped ions is nullified; i.e. k2

c is defined by x(kc) = 0. However, one can show thatin the limit x → 0 (or k2 → k2

c ), Fn3 and Fn4 vanish and Fn1 and Fn2 converge. Specifically,Fn1+(k2 = k2

c ) = Fn1−(k2 = k2c ) = 15/2 and Fn2+(k2 = k2

c ) = Fn2−(k2 = k2c ) = 105/4. To

remove the numerical difficulties that arise from the cancellation of singular terms as x → 0,Fn1 and Fn2 are numerically interpolated within the range −1 < x < 1.

The following normalised quantities are now used:

ni = ni/1019 m−3

Ti = Ti/1keV

ωtot = ωtot/1k rs−1.

Hence, referring to Eq. 2.5 for the definition of 〈ωmdi〉, yields

x(r, k2) =q(r)Ti(r)

[F1(k

2) + 2s(r)F2(k2)− ζ(r)

(1

4q(r)2+ F3(k

2))]

B0R0Zrωtot(r), (A.7)

EPFL doctoral school Christian SCHLATTER

12

and recalling the normalisation δW = 6π2R0B20ξ

20ε

41

ˆδW/µ0, one can now show that

<

ˆδW ki

= 0.151× 10−3

(1

B20ε

3/21 r

5/21

)∫ r1

0

drr12

×[

qTi

B0Zωtot

(Ti

dni

dr− 3

2ni

dTi

dr

)+ niTir

G1 +

qniTi

B0Zωtot

dTi

drG2

](A.8)

where 0.151× 10−3 = eµ0×1022

3√

2 π, and

G1(r) =

∫ 1

0

F 2q

K(k2)Fn1 dk2 and G2(r) =

∫ 1

0

F 2q

K(k2)Fn2 dk2, (A.9)

with Fq defined by Eq. 2.13.The pitch angle integrals are arranged as follows,

G1(r) =

∫ kb

ka

F 2q

K(k2)Fn1+ dk2 +

∫ ke

kd

F 2q

K(k2)Fn1 dk2 +

∫ kg

kf

F 2q

K(k2)Fn1− dk2, (A.10)

where Fn1 is interpolated between the limits kd and ke which correspond to the interval −1 <x < 1. Numerical values are assigned to the integral limits of Eq. (A.10) by noting that 〈ωmdi〉(and therefore |x|) is in general a monotonically decreasing function of k2 (at least for moderatevalues of ζ). For ωtot(r) > 0, the integration limits are defined: ka = 0, x(kb) = x(kd) = 1,x(ke) = x(kf ) = −1, kg = 1. For ωtot(r) < 0, the integration limits are defined: kf = 0,x(ke) = x(ka) = 1, x(kg) = x(kd) = −1, kb = 1.Since x is a function of r and k2, then the limits ka, kb, kd, ke, kf and kg are also functions ofr. Depending on the type of mode and the direction of the toroidal rotation, the sign of ωtot(r)may change with respect to r and hence the definitions of the pitch angle integral limits mustchange appropriately throughout the radial integration.The normalised imaginary kinetic potential energy is

=

ˆδW ki

=−1.071× 10−3

(1

B20ε

3/21 r

5/21

) ∫ r1

0

drr12

×[

qTi

B0Zωtot

(Ti

dni

dr− 3

2ni

dTi

dr

)+ niTir

G3 +

qniTi

B0Zωtot

dTi

drG4

](A.11)

where −1.071× 10−3 = 2√

2eµ0×1022

3√

π, and G3 and G4 are defined as follows. For ωtot(r) > 0:

G3(r) =

∫ kc

0

F 2q

K(k2)Fn3 dk2 and G4(r) =

∫ kc

0

F 2q

K(k2)Fn4 dk2, (A.12)

and for ωtot(r) < 0:

G3(r) =

∫ 1

kc

F 2q

K(k2)Fn3 dk2 and G4(r) =

∫ 1

kc

F 2q

K(k2)Fn4 dk2. (A.13)

The latter definitions of G3 and G4 emerge from the resonance of reverse magnetically precessingparticles and thus tend to be small.

EPFL doctoral school Christian SCHLATTER

Appendix B

Implementation

Radial profiles are stored as row vectors of length n, pitch angle dependent quantities ascolumn vectors of length m. Expressions depending on both r and k2 are stored in a matrixm×n.

The integration of the integral A.1 is done by summing along the column (pitch angleintegration) then by summing up the rows (integration over the radius).

The procedure is repeated for different values of the mode frequency.Special care is taken of the evaluation of the functions Fn1 and Fn2 close to the singularity at x= 0. Figure B.1 shows the behavior the functions in the interpolated region around the origin.

B.1 Sourcecode

Listing B.1: Main program code

% simu la t i on o f marg ina l l y s t a b l e i n t e r n a l k ink modes%clear a l l ;warning ( ’ o f f ’ , ’MATLAB: divideByZero ’ )% parameters% unperturbed t o r o i d a l magnetic f i e l dB 0= 3 ; %to r o i d a l magnetic f i e l d , [T] , max 3.5R 0= 2 . 9 6 ; %major radius , [m]a=1.25; %minor l im i t e r radius , [m]r 1= 0 . 4 5 ; % can be c a l c u l a t e d from q p r o f i l e%minor in v e r s i on rad ius ( l o c a t i o n o f q=1 sur f a c e )Z e f f =1;e p s i l o n 1=r 1 /R 0 ;e=1.6022E−19; %e l e c t r on chargemu 0=4∗pi∗1E−7;

% ca l c u l a t i o n g r i d d e f i n i t i o nnumradia lpo ints =1000;numpitchanglepoints =1000;

r spac ing=r 1 . / numradia lpo ints ;

EPFL doctoral school 13 Christian SCHLATTER

B.1 Sourcecode 14

Fn2(x )Fn1(x )

− 2 − 1.5 − 1 − 0.5 0 0.5 1 1.5 2− 30

− 15

0

15

30

45

60

x

Fn2(x

)

− 2 − 1.5 − 1 − 0.5 0 0.5 1 1.5 2− 10

− 5

0

5

10

15

20F

n1(x

)

Figure B.1: Fn1(x) and Fn2(x) around x = 0.The red curve (left axis) plots Fn1(x), the blue (right axis) Fn2(x).

k2spac ing =1./ numpitchanglepoints ;

disp ( ’ i n i t i a l i s a t i o n o f the g r id ’ )r ba s e =(0 . : r spac ing : r 1 ) ;k2 base =(0 . : k2spac ing : 1 . ) ;r=repmat ( r base , length ( k2 base ) , 1 ) ;dr=rspac ing .∗ ones ( s ize ( r ) ) ;R=R 0+r ;

k2=repmat ( k2 base ’ , 1 , length ( r ba s e ) ) ;dk2=k2spac ing .∗ ones ( s ize ( k2 ) ) ;

q 0 =0.7 ;c =1.33; d=9.09; % the f o l l ow i n g shou ld be modi f ied%q=q 0+(1−q 0 ) .∗ r . ˆ 2 ;q=q 0∗(1+d∗( r /a ) . ˆ ( 2 ∗ c ) ) . ˆ ( 1 / c ) ;%dq dr=2∗(1−q 0 ) .∗ r ;dq dr=(q 0 /c ) . ∗ ( 2∗ c∗d∗( r /a ) . ˆ ( 2 ∗ c−1)).∗(1+d∗( r /a ) . ˆ ( 2 ∗ c ) ) . ˆ ( ( 1 / c )−1);s=(r . / q ) . ∗ dq dr ;

%to r o i d a l magnetic f i e l d p r o f i l e B phi ( r )

EPFL doctoral school Christian SCHLATTER

B.1 Sourcecode 15

B=B 0 ∗(R 0 . /R) ;dB dr=−B 0∗R 0 ∗(R) .ˆ ( −2) ;dp dr=−B.∗ dB dr/mu 0 ;%cor r e c t i on due to the s h i f t o f magnetic f l u x su r f a c e seta=−2.∗R.∗mu 0 .∗ dp dr . ∗ ( q . ˆ 2 ) . / (B. ˆ 2 ) ;

%plasma ro t a t i on%Omega 0=28E3 ;Omega 0=0;Omega=Omega 0∗(1−(2∗ r . / a ) . ˆ 2 ) ;

%norma l i za t ionT i0 =2; %cen t r a l ion temperature , keVT ia =0.050; %l im i t e r temperature , keVT i=T i0 ∗(1−( r . / a ) . ˆ 2 ) + T ia ; % keVdT idr=−2∗T i0 .∗ r /a ˆ2 ; % rad i a l d e r i v a t i v e o f the ion temperaturen i 0 =4; % cen t r a l ion den s i t y in 1E−19 mˆ3nu n=6;n i=n i 0 ∗((1−( r . / a ) . ˆ 2 ) ) . ˆ nu n ;dn idr=−6∗n i 0 .∗ r .ˆ5/ a ˆ6 ; % rad i a l d e r i v a t i v e o f the ion den s i t y

% code

disp ( ’ eva lua t ing aux i l i a r y f unc t i on s ’ )disp ( ’ f 1 ( r ) and f 2 ( r ) ’ )

%f 1 ( q ) , f 2 ( q )f 1 =(pi /2)∗(1.0841−0.3193.∗(1−q).ˆ2−0.0683.∗(1−q ) . ˆ 4 ) ;f 2 =5.1∗(q−(1/2)).∗((1−q ).ˆ2) .∗(1−0.034∗(1−q ) ) ;

disp ( ’ e l l y p t i c i n t e g r a l s ’ )%k2 i s k ˆ2 , co lon vec t o r wi th e lements 0 :1[K,E] = el l ipke ( k2 ) ;

disp ( ’ F 1 (k ˆ2) , F 2 (kˆ2) and F 3 (kˆ2) ’ )%F 1 . . F 3 , dimension kˆ2F 1=2.∗(E. /K) − 1 ;F 2=2.∗(E. /K) + 2 .∗ ( k2 − 1 ) ;F 3 =(4 . /3 ) .∗ ( ( 2 .∗ k2 − 1 ) . ∗ (E. /K) + (1 − k2 ) ) ;plot ( k2 , F 1 , k2 , F 2 , k2 , F 3 )t i t l e ( ’ f un c t i on s F 1 , F 2 and F 3 de f ined by equat ion 6 .23 ’ )ylabel ( ’ F j , j =1. .3 ’ )xlabel ( ’ kˆ2 ’ )

disp ( ’ F q ( r , kˆ2) ’ )%F q : s i z e ( r x k ˆ2)F q=2∗E−K−(4∗(1−q ) . ∗ cos ( pi∗q)./(1−4∗(1−q ) . ˆ 2 ) ) . ∗ (E+(k2−1).∗K) . . .

−(1+cos ( pi∗q ) ) . ∗ f 1 . ∗ (E+(k2−1).∗K+2∗E./ pi − 1) . . .−(1+cos ( pi∗q ) ) . ∗ (E−K) . . .

EPFL doctoral school Christian SCHLATTER

B.1 Sourcecode 16

− f 2 .∗(1−k2 ) . ∗ ( pi/2 − K) ;

%x ( r , k ˆ2)%r−coord ina t e s : q , Ti , s , eta , omegatot

% t h i s i s the i t e r a t i o n parameteromega =10 . ˆ ( −1 : 0 . 01 : 2 . 5 ) ;omega=omega ’ ;omega 0 tot=omega−Omega 0/1000 ;

f igure (1 )set (0 , ’ D e f a u l t t e x t I n t e r p r e t e r ’ , ’ none ’ )subplot ( 8 , 2 , 1 ) , plot ( r ( 1 , : ) , q ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ q ( r ) ’ ) ; t i t l e ( ’ s a f e t y f a c t o r q ’ )subplot ( 8 , 2 , 2 ) , plot ( r ( 1 , : ) , dq dr ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ dq/dr ( r ) ’ ) ; t i t l e ( ’ dq/dr ’ )subplot ( 8 , 2 , 3 ) , plot ( r ( 1 , : ) , s ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ s ( r ) ’ ) ; t i t l e ( ’ plasma shear s ( r ) ’ )subplot ( 8 , 2 , 4 ) , plot ( r ( 1 , : ) ,B( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ B$ \phi$ ( r ) [T] ’ ) ; t i t l e ( ’ t o r o i d a l magnetic f i e l d B$ \phi$ ( r ) ’ )subplot ( 8 , 2 , 5 ) , plot ( r ( 1 , : ) , dB dr ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’dB/dr ’ ) ; t i t l e ( ’dB/dr ’ )subplot ( 8 , 2 , 6 ) , plot ( r ( 1 , : ) , dp dr ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ dp/dr ’ ) ; t i t l e ( ’ d e r i v a t i v e o f plasma pre s su r e ’ )subplot ( 8 , 2 , 7 ) , plot ( r ( 1 , : ) , e ta ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ $\ zeta$ ’ ) ; t i t l e ( ’ $\ zeta$ ’ )subplot ( 8 , 2 , 8 ) , plot ( r ( 1 , : ) ,Omega ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ $\Omega$( r ) ’ ) ; t i t l e ( ’ plasma ro t a t i on ’ )subplot ( 8 , 2 , 9 ) , plot ( r ( 1 , : ) , T i ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ T$ i$ ( r ) [ keV ] ’ ) ; t i t l e ( ’ T$ i$ ’ )subplot ( 8 , 2 , 10 ) , plot ( r ( 1 , : ) , dT idr ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ dT$ i$/dr ( r ) ’ ) ; t i t l e ( ’ dT$ i$/dr ’ )subplot ( 8 , 2 , 11 ) , plot ( r ( 1 , : ) , n i ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ n$ i$ ( r ) [ 10 $ˆ−19$ m$ˆ−3$ ’ ) ; t i t l e ( ’ n$ i$ ’ )subplot ( 8 , 2 , 12 ) , plot ( r ( 1 , : ) , dn id r ( 1 , : ) ) , xlabel ( ’ r [m] ’ ) ,ylabel ( ’ n$ i$ ( r )/ dr ’ ) ; t i t l e ( ’ dn$ i$ /dr ’ )drawnowmattola ( ’ input ’ ,6 ,−1 ,−1 ,1 ,1)

disp ( ’ i n t e r p o l a t i o n o f resonant parameter domain ’ )

return

for f f =1: length ( omega ) % normalzed to 1E3 r∗s−1

omega tot=omega ( f f )−Omega/1000 ;

xmatrix=q .∗ T i . ∗ ( F 1 + 2 .∗ s .∗ F 2 − eta . ∗ ( 1 . / ( 4 . ∗ q .∗ q ) + F 3 ) ) . . .. / ( B 0∗R 0∗ Z e f f .∗ r .∗ omega tot ) ;

EPFL doctoral school Christian SCHLATTER

B.1 Sourcecode 17

Fn 1=NaN∗ ones ( s ize ( xmatrix ) ) ;Fn 2=NaN∗ ones ( s ize ( xmatrix ) ) ;Fn 3=zeros ( s ize ( xmatrix ) ) ;Fn 4=zeros ( s ize ( xmatrix ) ) ;

Fn 3 ( find ( xmatrix >0))=(1./( xmatrix ( find ( xmatrix > 0 ) ) . ˆ ( 7 / 2 ) ) ) . . ..∗exp(−1./ xmatrix ( find ( xmatrix >0) ) ) ;

Fn 4 ( find ( xmatrix >0))=(1./( xmatrix ( find ( xmatrix > 0 ) ) . ˆ ( 9 / 2 ) ) ) . . ..∗exp(−1./ xmatrix ( find ( xmatrix >0) ) ) ;

for l ine =1: s ize ( xmatrix , 1 ) % i t e r a t i o n in kˆ2

f u l l x=xmatrix ( l ine , : ) ;

chooser=s e t d i f f ( find ( f u l l x >0.0015) , find ( f u l l x >0.029 & fu l l x <0 .046) ) ;i f ˜isempty ( chooser )

x=f u l l x ( chooser ) ;Fn 1 ( l ine , chooser )=4∗sqrt ( pi )∗ ( 1 . / x . ˆ ( 7 / 2 ) ) . ∗ ( e r f i ( 1 . / sqrt ( x ) ) ) . . .

.∗exp(−1./x)−(3./x)−(2./x .ˆ2)−(4 ./ x . ˆ 3 ) ;Fn 2 ( l ine , chooser )=4∗sqrt ( pi )∗ ( 1 . / x . ˆ ( 9 / 2 ) ) . ∗ ( e r f i ( 1 . / sqrt ( x ) ) ) . . .

.∗exp(−1./x )−(15./(2∗x ))−(3./x .ˆ2)−(2 ./ x .ˆ3)−(4 ./ x . ˆ 4 ) ;end

chooser=find ( f u l l x >0.029 & fu l l x <0 .046) ;i f ˜isempty ( chooser )

x=f u l l x ( chooser ) ;xbase = [ 0 . 0 2 : 0 . 0 0 1 : 0 . 0 2 9 0 . 0 4 6 : 0 . 0 0 1 : 0 . 0 5 5 ] ;Fn 1base=4∗sqrt ( pi )∗ ( 1 . / xbase . ˆ ( 7 / 2 ) ) . . .

. ∗ ( e r f i ( 1 . / sqrt ( xbase ) ) ) . . .

.∗exp(−1./ xbase )−(3./ xbase )−(2./ xbase .ˆ2)−(4 ./ xbase . ˆ 3 ) ;Fn 2base=4∗sqrt ( pi )∗ ( 1 . / xbase . ˆ ( 9 / 2 ) ) . . .

. ∗ ( e r f i ( 1 . / sqrt ( xbase ) ) ) . . .

.∗exp(−1./ xbase )−(15./(2∗ xbase ) ) − . . .( 3 . / xbase .ˆ2)−(2 ./ xbase . ˆ 3 ) . . .−(4./ xbase . ˆ 4 ) ;

Fn 1 ( l ine , chooser )=interp1 ( xbase , Fn 1base , x , ’ cub ic ’ ) ;Fn 2 ( l ine , chooser )=interp1 ( xbase , Fn 2base , x , ’ cub ic ’ ) ;

end

chooser=find ( f u l l x <−0.0015);i f ˜isempty ( chooser )

x=f u l l x ( chooser ) ;Fn 1 ( l ine , chooser )=−4∗sqrt ( pi )∗(1./(−x ) . ˆ ( 7 / 2 ) ) . ∗ ( erfc ( 1 . / sqrt(−x ) ) ) . . .

.∗exp(−1./x)−(3./x)−(2./x .ˆ2)−(4 ./ x . ˆ 3 ) ;Fn 2 ( l ine , chooser )=4∗sqrt ( pi )∗(1 ./((−x ) . ˆ ( 9 / 2 ) ) ) . ∗ ( erfc ( 1 . / sqrt(−x ) ) ) . . .

.∗exp(−1./x ) − (15 ./(2 .∗x ))− (3 ./( x .ˆ2 ) ) − (2 . / ( x .ˆ3 ) ) − (4 . / ( x . ˆ 4 ) ) ;end

EPFL doctoral school Christian SCHLATTER

B.1 Sourcecode 18

chooser=find ( f u l l x >=−0.0015 & fu l l x <=0.0015);%chooser=f i nd ( xmatr ix==0);i f ˜isempty ( chooser )

x=f u l l x ( chooser ) ;x b a s e l e f t =[ −0 .02 :0 .001 : −0 .002 ] ;xba s e r i gh t = [ 0 . 0 0 2 : 0 . 0 0 1 : 0 . 0 2 ] ;Fn 1ba s e l e f t=−4∗sqrt ( pi )∗(1./(− xba s e l e f t ) . ˆ ( 7 / 2 ) ) . . .

. ∗ ( erfc ( 1 . / sqrt(− xb a s e l e f t ) ) ) . . .

.∗exp(−1./ xb a s e l e f t )−(3./ x b a s e l e f t )−(2./ x b a s e l e f t . ˆ 2 ) . . .−(4./ x b a s e l e f t . ˆ 3 ) ;

Fn 2ba s e l e f t=4∗sqrt ( pi )∗(1 ./((− xba s e l e f t ) . ˆ ( 9 / 2 ) ) ) . . .. ∗ ( erfc ( 1 . / sqrt(− xb a s e l e f t ) ) ) . . ..∗exp(−1./ xb a s e l e f t ) − (15 ./(2 .∗ xba s e l e f t ) ) − . . .( 3 . / ( x b a s e l e f t . ˆ2 ) ) − (2 . / ( x b a s e l e f t . ˆ3 ) ) − (4 . / ( x b a s e l e f t . ˆ 4 ) ) ;

Fn 1baser ight=4∗sqrt ( pi )∗ ( 1 . / xbase r i gh t . ˆ ( 7 / 2 ) ) . . .. ∗ ( e r f i ( 1 . / sqrt ( xbase r i gh t ) ) ) . . ..∗exp(−1./ xbase r i gh t )−(3./ xbase r i gh t ) − . . .( 2 . / xbase r i gh t .ˆ2)−(4 ./ xbase r i gh t . ˆ 3 ) ;

Fn 2baser ight=4∗sqrt ( pi )∗ ( 1 . / xbase r i gh t . ˆ ( 9 / 2 ) ) . . .. ∗ ( e r f i ( 1 . / sqrt ( xbase r i gh t ) ) ) . . ..∗exp(−1./ xbase r i gh t )−(15./(2∗ xbase r i gh t ) ) − . . .( 3 . / xbase r i gh t .ˆ2)−(2 ./ xbase r i gh t .ˆ3)−(4 ./ xbase r i gh t . ˆ 4 ) ;

xbase=[ xb a s e l e f t 0 xbase r i gh t ] ;Fn 1base=[ Fn 1ba s e l e f t 15/2 Fn 1baser ight ] ;Fn 2base=[ Fn 2ba s e l e f t 105/4 Fn 2baser ight ] ;Fn 1 ( l ine , chooser )=interp1 ( xbase , Fn 1base , x , ’ cub ic ’ ) ;Fn 2 ( l ine , chooser )=interp1 ( xbase , Fn 2base , x , ’ cub ic ’ ) ;

end

end

Fn 1=real ( Fn 1 ) ;Fn 2=real ( Fn 2 ) ;

disp ( sprintf ( ’ i n t e g r a t i o n f o r data po int %i/%i ’ , f f , length ( omega ) ) )integrand1=(F q .∗ F q .∗ Fn 1 .∗ dk2 ) . /K;integrand1 ( find ( isnan ( integrand1 )) )=0 ;G 1=sum( integrand1 ) ;integrand2=(F q .∗ F q .∗ Fn 2 .∗ dk2 ) . /K;integrand2 ( find ( isnan ( integrand2 )) )=0 ;G 2=sum( integrand2 ) ;integrand3=(F q .∗ F q .∗ Fn 3 .∗ dk2 ) . /K;integrand3 ( find ( isnan ( integrand3 )) )=0 ;G 3=sum( integrand3 ) ;integrand4=(F q .∗ F q .∗ Fn 4 .∗ dk2 ) . /K;integrand4 ( find ( isnan ( integrand4 )) )=0 ;G 4=sum( integrand4 ) ;

EPFL doctoral school Christian SCHLATTER

B.1 Sourcecode 19

G 1=repmat (G 1 , length ( k2 base ) , 1 ) ;G 2=repmat (G 2 , length ( k2 base ) , 1 ) ;G 3=repmat (G 3 , length ( k2 base ) , 1 ) ;G 4=repmat (G 4 , length ( k2 base ) , 1 ) ;

r ea lde l taWki=(e∗mu 0∗1E22/(3∗ sqrt (2)∗ pi ) ) / ( B 0∗B 0 ∗( e p s i l o n 1 ˆ ( 3 / 2 ) ) ∗ . . .( r 1 ˆ ( 5 / 2 ) ) ) . ∗ . . .sum( dr .∗ sqrt ( r ) . ∗ ( . . .

( ( q .∗ T i . / ( B 0∗ Z e f f ∗omega tot ) ) . . .. ∗ ( T i .∗ dn idr − (3 ./2) .∗ n i .∗ dT idr ) . . .+ n i .∗ T i .∗ r ) . ∗G 1 + . . .

( q .∗ n i .∗ T i . / ( B 0∗ Z e f f ∗omega tot ) ) . . ..∗ dT idr .∗G 2 ) , 2 ) ;

imagdeltaWki=−(2∗sqrt (2)∗ e∗mu 0∗1E22/(3∗ sqrt ( pi ) ) ) / . . .( B 0∗B 0 ∗( e p s i l o n 1 ˆ (3/2 ) )∗ ( r 1 ˆ ( 5 / 2 ) ) ) . ∗ . . .sum( dr .∗ sqrt ( r ) . ∗ ( . . .

( ( q .∗ T i . / ( B 0∗ Z e f f ∗omega tot ) ) . . .. ∗ ( T i .∗ dn idr − (3 ./2) .∗ n i .∗ dT idr ) + n i .∗ T i .∗ r ) . ∗G 3 + . . .

( q .∗ n i .∗ T i . / ( B 0∗ Z e f f ∗omega tot ) ) . ∗ dT idr .∗G 4 ) , 2 ) ;

% p l o t t i n gf i n a l r e a l d e l t aWk i ( f f )=rea lde l taWki ( 1 ) ;f ina l imagde l taWki ( f f )=imagdeltaWki ( 1 ) ;end

figure (2 )plot ( log ( omega ) , f i n a l r e a l d e l t aWk i , log ( omega) ,− f ina l imagde l taWki )set (0 , ’ De f au l tTex t In t e rp r e t e r ’ , ’ none ’ )plot ( log ( omega ) , f i n a l r e a l d e l t aWk i , ’ g ’ )hold onplot ( log ( omega) ,− f ina l imagdeltaWki , ’b ’ )plot ( log ( omega ) , 0 , ’ k ’ )ax=axis ;ax(1)=min( log ( omega ) ) ;ax(2)=max( log ( omega ) ) ;axis ( ax ) ;xlabel ( ’ l o g$ 10$ ( $\omega$ ) ’ )ylabel ( ’ $\delta$W$ k$ ’ )legend ( ’ $\Re$ ( $\delta$W$ k$ ) ’ , ’−$\Im$ ( $\delta$W$ k$ ) ’ , 2 )save r e s u l t s omega f i n a l r e a l d e l t aWk i f ina l imagde l taWkidisp ( ’ f i n i s h e d ’ )

returnset (0 , ’ D e f a u l t t e x t I n t e r p r e t e r ’ , ’ none ’ )mattola ( ’ deltawk ’ ,6 ,−1 ,−1 ,1 ,1)

md=2.0147∗1.660539E−27; %kgne mean=2E19 ;

EPFL doctoral school Christian SCHLATTER

B.1 Sourcecode 20

rho=ne mean∗md;vA=B 0/sqrt ( rho∗mu 0)omegaA=vA/R 0sigma=(1/( r 1 )ˆ4)∗sum( ( r ( 1 , : ) ) . ˆ 3 . ∗ ( ( 1 . / q ( 1 , : ) . ˆ 2 ) − 1 ) . . .

.∗ dr ( 1 , : ) , 2 ) ;betap=−2∗mu 0/(B 0∗B 0∗ e p s i l o n 1 ∗ e p s i l o n 1 ∗ r 1 ∗ r 1 ) . . .

∗sum( r ( 1 , : ) . ˆ 2 . ∗10 .∗ dp dr ( 1 , : ) .∗ dr ( 1 , : ) , 2 ) ;DELTA=ep s i l o n 1 ∗( betap+sigma +1/4);DELTA=0.5 + 1.6/ sqrt ( e p s i l o n 1 )omegastarpi =0.1∗ dp dr (1 , length ( r ) ) / ( e∗ Z e f f ∗1E19 ∗ . . .

n i (1 , length ( r ) )∗B 0∗ r (1 , length ( r ) ) ) ;qq=s (1 , length ( r ) )∗ sqrt (1+DELTA)∗ sqrt ( omega . ∗ 1 0 0 0 . . .. ∗ ( omega.∗1000− omegastarpi ) )/ (3∗ pi∗omegaA∗( r (1 ,1001)/ R 0 ) ˆ 2 ) ;f igure (3 )plot ( log ( omega ) , qq , ’ k ’ )

EPFL doctoral school Christian SCHLATTER

Appendix C

Matlab error function for complexarguments

Matlab does not include the complex error function erfi(x). The code makes use of theidentity erfi(x) = −ierf(ix), but unfortunately the Matlab error function does not permitthe calculation with complex arguments.

The following algorithm was therefore used to calculate erf(z) for z ∈ C. This is essentially aMatlab implementation of the Fortran algorithm listed in [8]

C.1 Imaginary error function erfi(x)

Listing C.1: Imaginary error function erfi(x)

function [ c e r ]= e r f i ( z ) ;% Ca l cu l a t i on o f the imaginary error func t i on% of complex arguments e r f i ( z ) .% proper ty : e r f i ( z ) = −i ∗ e r f ( i z )%% Input : z −−− Complex argument% Output : CER −−− e r f i ( z )%% This a l gor i thm i s a Matlab implementat ion o f the code% given in Shan j i e Zhang and Jianming Jin , Computation% of s p e c i a l func t ions , John Wiley , New York , 1996.%% Centre de Recherches en Physique des Plasmas (CRPP)% Ecole po l y t e chn i que f e d e r a l e de Lausanne , Sw i t z e r l and%% Chr i s t i an SCHLATTER, 27 o f sepetember , 2004% Revis ion 1.0

z=i .∗ z ;a0=0;pi=0;

a0=abs ( z ) ;c0=exp(−z .∗ z ) ;

EPFL doctoral school 21 Christian SCHLATTER

C.1 Imaginary error function erfi(x) 22

pi=3.141592653589793d0 ;z1=z ;z1 ( find ( real ( z ) < 0.0))=− z ( find ( real ( z ) < 0 . 0 ) ) ;index1=find ( a0 <= 5 . 8 ) ;%save temp index1cs ( index1)=z1 ( index1 ) ;c r ( index1)=z1 ( index1 ) ;for k=1:120;c r ( index1)=cr ( index1 ) . ∗ z1 ( index1 ) . ∗ z1 ( index1 ) . / ( k+0.5d0 ) ;c s ( index1)=cs ( index1)+cr ( index1 ) ;i f (max(abs ( c r ( index1 ) . / cs ( index1 ) ) ) < 1 .0d−15) break ; end ;end ;c e r ( index1 )=2.0d0 .∗ c0 ( index1 ) . ∗ cs ( index1 ) . / sqrt ( pi ) ;

index2=s e t d i f f ( 1 : length ( z ) , index1 ) ;c l ( index2 )=1.0d0 . / z1 ( index2 ) ;c r ( index2)= c l ( index2 ) ;for k=1:13;c r ( index2)=−cr ( index2 ) . ∗ ( k−0.5d0 ) . / ( z1 ( index2 ) . ∗ z1 ( index2 ) ) ;c l ( index2)= c l ( index2)+cr ( index2 ) ;i f (max(abs ( c r ( index2 ) . / c l ( index2 ) ) ) < 1 .0d−15) break ; end ;end ;c e r ( index2 )=1.0d0−c0 ( index2 ) . ∗ c l ( index2 ) . / sqrt ( pi ) ;c e r ( find ( real ( z ) < 0.0))=− ce r ( find ( real ( z ) < 0 . 0 ) ) ;c e r=−i .∗ ce r ;return ;

EPFL doctoral school Christian SCHLATTER

Bibliography

[1] Milton Abramowitz, Handbook of mathematical functions, Dover Publications, New York,1972.

[2] I. B. Bernstein, E. A. Frieman, M. D. Kruskal, and R. M. Kulsrud, An energy principlefor hydromagnetic stability problems, Proceedings of the Royal Society of London. SeriesA, Mathematical and Physical Sciences 244 (1958), no. 1236, 17–40.

[3] A. Bondeson and M. N. Bussac, Stability of the n=1 ideal internal kink for large aspectratio shafranov equilibria, Nucl. Fus. 32 (1992), no. 3, 513.

[4] M. N. Bussac, R. Pellat, D. Edery, and J. L. Soule, Internal kink modes in toroidal plasmaswith circular cross sections, Phys. Rev. Lett. 35 (1975), no. 24, 1638–1641.

[5] D. J. Campbell, J. G. Cordey, A. W. Edwards, R. D. Gill, E. Lazzaro, G. Magyar, A. L.McCarthy, J. O’Rourke, F. Pegoraro, F. Porcelli, P. Smeulders, D. F. H. Start, P. Stub-berfield, J. A. Wesson, E. Westerhof, and D. Zasche, Sawtooth activity and current densityprofiles in jet, Plasma physics and controlled nuclear fusion research 1988 (Nice, France),International Atomic Energy Agency, International Atomic Energy Agency, Vienna, 1988,pp. 377–385.

[6] D. J. Campbell, D. F. H. Start, J. A. Wesson, D. V. Bartlett, V. P. Bhatnagar, M. Bures,J. G. Cordey, G. A. Cottrell, P. A. Dupperex, A. W. Edwards, C. D. Challis, C. Gormezano,C. W. Gowers, R. S. Granetz, J. H. Hammen, T. Hellsten, J. Jacquinot, E. Lazzaro, P. J.Lomas, N. Lopes Cardozo, P. Mantica, J. A. Snipes, D. Stork, P. E. Stott, P. R. Thomas,E. Thompson, K. Thomsen, , and G. Tonetti, Stabilization of sawteeth with additionalheating in the jet tokamak, Physical Review Letters 60 (1988), no. 21, 2148–2151.

[7] Jonathan Peter Graves, Kinetic stabilisation of the internal kink mode for fusion plas-mas, Ph.D. thesis, School of Mathematical Sciences, Division of Theoretical Mechanics,University of Nottingham, December 1999.

[8] Shan jie Zhang and Jianming Jin, Computation of special functions, John Wiley, NewYork, 1996.

[9] K. G. McClements, R. O. Dendy, C. G. Gimblett, R. J. Hastie, and T. J. Martin, Stabi-lization of the ideal m=1 internal kink by alpha particles and icrf heated ions, Nucl. Fus.35 (1995), no. 12, 1761–1768.

[10] M. N. Rosenbluth, P. Y. Dagazian, and P. H. Rutherford, Nonlinear properties of theinternal m = 1 kink instability in the cylindrical tokamak, Physics of fluids 16 (1973),no. 11, 1894–1902.

[11] John Wesson, Tokamaks, Clarendon Press, Oxford, 2004.

EPFL doctoral school 23 Christian SCHLATTER

BIBLIOGRAPHY 24

[12] R. B. White, P. H. Rutherford, P. Colestock, and M. N. Bussac, Sawtooth stabilization byenergetic trapped particles, Physical Review Letters 60 (1988), no. 20, 2038–2041.

EPFL doctoral school Christian SCHLATTER