-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplasma_generator.py
More file actions
99 lines (69 loc) · 2.23 KB
/
plasma_generator.py
File metadata and controls
99 lines (69 loc) · 2.23 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import numpy as np
import matplotlib.pyplot as plt
from plasma import Plasmas, get_params
# Major Radius (m)
Rmajor = np.array([2.5, 2.6])
# Aspect ration (R/a)
aspect_ratio = np.array([1.5, 1.6])
# Minor radius
aminor = np.outer(Rmajor, 1/aspect_ratio)
# Elongation
elong = ([2.8, 2.9])
# triangularity
tri = ([0.0, 0.1])
# Core temp in keV
T0 = ([20.0, 22.0, 25.0])
# Temperature pedestal height fraction
Tped_height = ([0.2, 0.3, 0.4])
# Separatrix temeperature
Tsep_height = [0.01, 0.02]
# Temperature peaking factor
alpha_T = ([1.0, 1.1])
# Density in core (#10^19)
n0 = ([14.0, 16.0])
# Density pedestal height fraction
nped_height = ([0.8, 0.9])
# Density pedestal height fraction
nsep_height = [0.01, 0.02]
# Density peaking factor
alpha_n = ([1.0, 1.1])
# Pedestal radial position
ped_rad = ([0.85, 0.9])
# No. of radial zones
nrhos = 100
# No. of poloidal points
ntheta = 1000
# Create Plasmas class with these values
pl = Plasmas(Rmajor, aspect_ratio, elong, tri, T0,
Tped_height, Tsep_height,
n0, nped_height, nsep_height, ped_rad,
alpha_n, alpha_T, nrhos, ntheta)
# Parameter to filter
key = 'pfus'
# Point to filter around
value = 1.0
# Tolerance of parameters
tol = 0.2
#
fustype = ['Fausser', 'Wesson', 'SCENE']
# Loop through different ways of calculating fusion power
for i in range(3):
print('!!! {} Method !!!'.format(fustype[i]))
# Calculate fusion powers of different scenarios
pl.calc_fusion_power(fuspow_type=i)
# Filter around given parameter
filter_da = pl.filter_params(key='pfus', value=1.0, tol=0.2)
# Get list of suitable parameters
filter_params = get_params(filter_da)
nparams = len(filter_params)
names = filter_da.coords.to_index().names
# for i in range(len(filter_params)):
# print(filter_params[i])
print('There are {} permutations that are are with {} of {} for {} '.format(
nparams, tol, value, key))
# Get first value in form to be read by datarray
d = {name: par for name, par in zip(names, filter_params[0])}
for key, val in zip(d.keys(), d.values()):
print('{} = {}'.format(key, val))
print('{} method for fusion power {:.3f} GW\n'.format(
fustype[i], filter_da.sel(d).data))