forked from bendudson/pyTokamak
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_01.py
40 lines (29 loc) · 945 Bytes
/
example_01.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
# Some tests of the equilibrium and neoclass routines
#
from tokamak.equilibrium import FluxSurface
from tokamak import neoclass
from numpy import linspace, pi, zeros, sin, cos, sqrt
Rmaj = 5. # Major radius
amin = 1. # Minor radius
Bt0 = 10.
Bp0 = 1.
nth = 20
theta = linspace(0,2*pi, nth, endpoint=False)
r = Rmaj + amin * cos(theta)
z = sin(theta)
Bp = zeros(nth) + Bp0
# Create a flux surface object
f = FluxSurface(Rmaj*Bt0, r, z, Bp)
q = Bt0*amin / (Bp0 * Rmaj) # Large aspect-ratio approximation
eps = amin / Rmaj
print("Inverse aspect ratio eps = ", eps)
print("")
print("Large aspect ratio q = ", q)
print("q = ", f.integral(lambda x: f.Bt(x) / (f.Bp(x) * f.R(x))) / (2 * pi))
print("")
print("Large aspect ratio qR = ", q * Rmaj)
print("Connection length = ", neoclass.connectionLength(f))
print("")
print("Large aspect-ratio trapped = ", 1.46 * sqrt(eps))
print("Trapped fraction = ", neoclass.trappedFraction(f))