-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCooling.py
123 lines (113 loc) · 4.64 KB
/
Cooling.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
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
import numpy as np
from scipy.interpolate import interp2d
import pkg_resources
IEAA_DATA_PATH = pkg_resources.resource_filename('MagPy.Cooling',\
'iaea_cooling_curves/')
class IaeaTable:
''' Class to generate a function which radiative power loss to plasma
density and temperature. Function interpolates over lookup tables
which were produced using the nLTE code FLYCHK. They were downloaded from
the database hosted at [1].
The database includes the following caveat about the validity of tabulated
data:
FLYCHK calculations are known to give better results for highly ionized
plasmas and intermediate electron densities.
Cite as:
FLYCHK: Generalized population kinetics and spectral model for rapid
spectroscopic analysis for all elements, H.-K. Chung, M.H. Chen,
W.L. Morgan, Y. Ralchenko and R.W. Lee,
High Energy Density Physics, Volume 1, Issue 1, December 2005
Data exists for all elements with atomic numbers in the range 1 (Hydrogen)
through to 79 (Gold).
************************************************
| Access the generated function by calling |
| self.model(Te, ne) |
| where: |
| Te = electron temperature [eV] |
| ne = electron density [cm^-3] |
|Returns radiative power loss in [ergs/s/atom] |
************************************************
[1] - https://www-amdis.iaea.org/FLYCHK/ZBAR/csd014.php
'''
extension='.zvd'
def __init__(self, AtomicNumber):
''' Description of arguments:
1) AtomicNumber - atomic number of desired element (in the range [1,79]
inclusive).
'''
dpath = IEAA_DATA_PATH + 'default/' + str(AtomicNumber) + self.extension
ne = []
Pw = []
Te = []
with open(dpath, 'r') as f:
lines = list(f)
i = 0
while(i<637):
i += 1
line = lines[i]
ne.append( float(line[10:17]) )
i += 11
j=0
Z_row = []
while(j<36):
line = lines[i+j]
s=line.strip()
TT, ZZ = s.split()
Te.append( float(TT) )
Z_row.append( float(ZZ) )
j += 1
Pw.append(np.array(Z_row))
i += 37
self.Pw = np.array(Pw)
self.ne = np.array(ne)
self.Te = np.array(Te[0:36])
self.model = interp2d(self.Te, self.ne, self.Pw)
class IaeaTableMod:
''' Class to generate a function which relates total radiative loss to plasma
density and temperature. Function interpolates over lookup tables of
radiative loss which were produced using the nLTE code FLYCHK.
Tables generated to have a better curve resolution.
************************************************
| Access the generated function by calling |
| self.model(Te, ne) |
| where: |
| Te = electron temperature [eV] |
| ne = electron density [cm^-3] |
************************************************
'''
extension='.dat'
def __init__(self, AtomicNumber, Model):
''' Description of arguments:
1) AtomicNumber - atomic number of desired element (in the range [1,79]
inclusive).
'''
if Model == 'ss':
dpath = IEAA_DATA_PATH + 'ss/' + str(AtomicNumber) + self.extension
elif Model == 'lte':
dpath = IEAA_DATA_PATH + 'lte/' + str(AtomicNumber) + self.extension
ne = []
Pw = []
Te = []
with open(dpath, 'r') as f:
lines = list(f)
i = 0
while(i<45):
i += 3
line = lines[i]
ne.append( float(line[8:14]) )
i += 2
j=0
Z_row = []
while(j < 20):
line = lines[i+j]
s=line.strip()
TT, ZZ = s.split()
Te.append( float(TT) )
Z_row.append( float(ZZ) )
j += 1
Pw.append(np.array(Z_row))
i += 20
self.Pw = np.array(Pw)
self.ne = np.array(ne)
self.Te = np.array(Te[0:20])
self.model = interp2d(self.Te, self.ne, self.Pw)