forked from cherab/solps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolps_from_balance.py
More file actions
151 lines (134 loc) · 4.42 KB
/
solps_from_balance.py
File metadata and controls
151 lines (134 loc) · 4.42 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright 2014-2017 United Kingdom Atomic Energy Authority
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.
import matplotlib.pyplot as plt
import numpy as np
from cherab.core.atomic.elements import carbon, deuterium
from cherab.solps import load_solps_from_balance
plt.ion()
xl, xu = (0.0, 2.0)
yl, yu = (-2.0, 2.0)
print('CHERAB solps_from_balance demo')
print('Note: code assumes presence of deuterium and carbon species in SOLPS run')
print('Enter name of balance.nc file:')
filename = input()
sim = load_solps_from_balance(filename)
plasma = sim.create_plasma()
mesh = sim.mesh
d0 = plasma.composition.get(deuterium, 0)
d1 = plasma.composition.get(deuterium, 1)
c0 = plasma.composition.get(carbon, 0)
c1 = plasma.composition.get(carbon, 1)
c2 = plasma.composition.get(carbon, 2)
c3 = plasma.composition.get(carbon, 3)
c4 = plasma.composition.get(carbon, 4)
c5 = plasma.composition.get(carbon, 5)
c6 = plasma.composition.get(carbon, 6)
te_samples = np.zeros((500, 500))
ne_samples = np.zeros((500, 500))
d0_samples = np.zeros((500, 500))
d1_samples = np.zeros((500, 500))
c0_samples = np.zeros((500, 500))
c1_samples = np.zeros((500, 500))
c2_samples = np.zeros((500, 500))
c3_samples = np.zeros((500, 500))
c4_samples = np.zeros((500, 500))
c5_samples = np.zeros((500, 500))
c6_samples = np.zeros((500, 500))
xrange = np.linspace(xl, xu, 500)
yrange = np.linspace(yl, yu, 500)
for i, x in enumerate(xrange):
for j, y in enumerate(yrange):
ne_samples[j, i] = plasma.electron_distribution.density(x, 0.0, y)
te_samples[j, i] = plasma.electron_distribution.effective_temperature(x, 0.0, y)
d0_samples[j, i] = d0.distribution.density(x, 0.0, y)
d1_samples[j, i] = d1.distribution.density(x, 0.0, y)
c0_samples[j, i] = c0.distribution.density(x, 0.0, y)
c1_samples[j, i] = c1.distribution.density(x, 0.0, y)
c2_samples[j, i] = c2.distribution.density(x, 0.0, y)
c3_samples[j, i] = c3.distribution.density(x, 0.0, y)
c4_samples[j, i] = c4.distribution.density(x, 0.0, y)
c5_samples[j, i] = c5.distribution.density(x, 0.0, y)
c6_samples[j, i] = c6.distribution.density(x, 0.0, y)
mesh.plot_triangle_mesh()
plt.title('mesh geometry')
plt.figure()
plt.imshow(ne_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("electron density")
plt.figure()
plt.imshow(te_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("electron temperature")
plt.figure()
plt.imshow(d0_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("D0 density")
plt.figure()
plt.imshow(d1_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("DI density")
plt.figure()
plt.imshow(c0_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CI density")
plt.figure()
plt.imshow(c1_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CII density")
plt.figure()
plt.imshow(c2_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CIII density")
plt.figure()
plt.imshow(c3_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CIV density")
plt.figure()
plt.imshow(c4_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CV density")
plt.figure()
plt.imshow(c5_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CVI density")
plt.figure()
plt.imshow(c6_samples, extent=[xl, xu, yl, yu], origin='lower')
plt.colorbar()
plt.xlim(xl, xu)
plt.ylim(yl, yu)
plt.title("CVII density")
plt.ioff()
plt.show()