-
Notifications
You must be signed in to change notification settings - Fork 0
/
transmute_data.py
91 lines (81 loc) · 2.45 KB
/
transmute_data.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
import json
import warnings
import numpy as np
warnings.simplefilter('ignore')
from pyne.utils import toggle_warnings
toggle_warnings()
from pyne import nucname
from pyne import data
from pyne import rxname
DECAY_RXS = ['bminus', 'bplus', 'ec', 'alpha', 'it', 'sf', 'bminus_n']
XS_RXS = ['gamma', 'z_2n', 'z_3n', 'alpha', 'fission', 'proton', 'gamma_1',
'z_2n_1']
def add_child_decays(nuc, symbols):
try:
childname = nucname.name(nuc)
except RuntimeError:
return
for rx in DECAY_RXS:
try:
parent = rxname.parent(nuc, rx, b'decay')
except RuntimeError:
continue
if data.branch_ratio(parent, nuc) < 1e-16:
continue
parname = nucname.name(parent)
symbols['lambda_' + parname] = data.decay_const(parent)
gamma = 'gamma_{0}_{1}_{2}'.format(parname, childname, rx)
symbols[gamma] = data.branch_ratio(parent, nuc)
def add_child_xss(nuc, channels, parents):
try:
childname = nucname.name(nuc)
except RuntimeError:
return
channels[childname] = rxs = {}
for rx in XS_RXS:
try:
parent = rxname.parent(nuc, rx)
except RuntimeError:
continue
if parent not in parents:
continue
try:
parname = nucname.name(parent)
except RuntimeError:
continue
rxs[rx] = parname
def main():
# get list of nuclides
data.atomic_mass('U235')
nucs = set(data.atomic_mass_map.keys())
for nuc in data.atomic_mass_map:
nucm = nuc + 1
if nucname.anum(nuc) == 0 or data.decay_const(nucm) < 1e-16 or \
data.decay_const(nuc) == data.decay_const(nucm):
continue
nucs.add(nucm)
nucs = [nuc for nuc in nucs if nucname.anum(nuc) > 0]
#and
# not np.isnan(data.decay_const(nuc)) and
# nuc < 200000000]
nucs.sort()
# get symbols
symbols = {}
channels = {}
for nuc in nucs:
add_child_decays(nuc, symbols)
add_child_xss(nuc, channels, nucs)
# print symbols
ns = []
for nuc in nucs:
try:
nname = nucname.name(nuc)
except RuntimeError:
continue
ns.append(nname)
nucs = ns
d = {'symbols': symbols, 'nucs': nucs, 'channels': channels}
s = json.dumps(d, indent=4, sort_keys=True)
print(s)
if __name__ == '__main__':
main()