In [1]:
from IPython.core.display import HTML
import markdown2
Wims keys are obtained from: WIMS Library Update Project.
In [2]:
wims_key = {3001:'H', 3:'He3', 4:'He4', 6:'Li6', 7:'Li7', 9:'Be', 10:'B10',
1010:'B10', 11:'B11', 1011:'B', 2012:'C', 14:'N', 6016:'O', 19:'F',
23:'Na', 24:'Mg', 27:'Al', 29:'Si', 31:'P', 32:'S', 35:'Cl', 40:'Ca',
48:'Ti', 51:'V', 52:'Cr', 55:'Mn', 2056:'Fe', 58:'Ni', 1059:'Co59',
3063:'Cu', 91:'Zr', 93:'Nb93', 96:'Mo', 3109:'Ag', 2113:'Cd', 2115:'In',
118:'Sn', 121:'Sb121', 123:'Sb123', 152:'Eu', 2154:'Gd154', 2155:'Gd155',
2156:'Gd156', 2157:'Gd157', 2158:'Gd158', 160:'Dy160', 161:'Dy161',
162:'Dy162', 163:'Dy163', 164:'Dy164', 165:'Ho165', 2166:'Er166',
2167:'Er167', 2176:'Hf176', 2177:'Hf177', 2178:'Hf178', 2179:'Hf179',
2180:'Hf180', 178:'Hf', 181:'Ta', 183:'W', 207:'Pb', 4083:'Kr83',
4095:'Mo95', 4099:'Tc99', 4101:'Ru101', 5103:'Ru103', 4106:'Ru106',
4103:'Rh103', 4105:'Rh105', 5105:'Pd105', 4107:'Pd107', 4108:'Pd108',
4109:'Ag109', 4113:'Cd113', 4115:'In115', 4125:'Sb125', 5127:'Te127m',
4127:'I127', 4131:'Xe131', 4133:'Cs133', 4134:'Cs134', 4137:'Cs137',
6135:'I135', 5134:'Xe134', 4135:'Xe135', 5135:'Cs135', 4136:'Xe136',
4143:'Nd143', 4145:'Nd145', 4147:'Pm147', 5147:'Pm147', 6147:'Sm147',
4148:'Pm148m', 5148:'Pm148', 6148:'Sm148', 5149:'Pm149', 4149:'Sm149',
4150:'Sm150', 4151:'Sm151', 4152:'Sm152', 5151:'Eu151', 5152:'Eu152',
4153:'Eu153', 4154:'Eu154', 4155:'Eu155', 2232:'Th232', 4232:'U232',
232:'U232', 9233:'U233', 1231:'Pa231', 1233:'Pa233', 234:'U234',
2235:'U235', 236:'U236', 4927:'U237', 927:'U237', 8238:'U238', 937:'Np237',
1939:'Np239', 948:'Pu238', 6239:'Pu239', 1240:'Pu240', 1241:'Pu241',
242:'Pu242', 1242:'Pu242', 951:'Am241', 1952:'Am242', 952:'Am242m',
953:'Am243', 962:'Cm242', 963:'Cm243', 964:'Cm244', 1055:'Mn55',
1054:'Fe54', 3058:'Fe58', 2059:'Co59', 1058:'Ni58', 1063:'Cu63', 84:'Kr84',
2103:'Rh103', 1115:'In115', 3115:'In115', 1151:'Eu151', 1164:'Dy164',
176:'Lu176', 197:'Au197', 1232:'Th232', 3232:'Th232', 1235:'U235',
1003:'U235', 1238:'U238', 3238:'U238', 1237:'Np237', 1239:'Pu239',
1632:'Th232', 1633:'U233', 1635:'U235', 1638:'U238', 1639:'Pu239',
1640:'Pu240', 1641:'Pu241', 1642:'Pu242', 4902: 'FP' }
In [3]:
def dupli(the_list):
count = the_list.count # this optimization added courtesy of Sven's comment
result = [(item, count(item)) for item in set(the_list)]
result.sort()
return result
def dupli_v2(the_list):
"""
Like dupli but now just consider when items in set are > 1
"""
count = the_list.count # this optimization added courtesy of Sven's comment
result = [(item, count(item)) for item in set(the_list) if count(item) > 1]
result.sort()
return result
def wims(item):
try:
return wims_key[int(item)]
except ValueError:
return item
def solo(the_list):
"""
Like dupli but now just consider when items in set are = 1
And return just the list, formatting WIMS keys as necessary
"""
count = the_list.count # this optimization added courtesy of Sven's comment
result = [wims(item) for item in set(the_list) if count(item) == 1]
result.sort()
return result
Note that a truncated DATA structure file was used here
In [4]:
lines = []
with open('pwrcel.burn.001', 'r') as f:
for line in f:
# ignore lines beginning with
if not line.startswith(' ') and not line.startswith('->'):
if 'COMPO' not in line and 'SIGNA' not in line:
lines.append(line.split().pop(0))
struct = str(dupli_v2(lines))
def bulletize(string):
string = string.replace("('"," - ")
string = string.replace("), ",'\n')
string = string.replace("',",":")
string = string.replace('[','')
string = string.replace(')]','')
return string
struct = 'Detected DRAGON DATA Structures\n-----\n\n' + struct
HTML(markdown2.markdown(bulletize(struct)))
Out[4]:
In [5]:
nuclides = solo(lines)
nuclides.remove('BURN')
nuclides.remove('SCAT01')
nuclides.remove('SIGS01')
nuclides.remove('NJJS01')
nuclides.remove('IJJS01')
num_nuclides = len(nuclides)
nuclides = str(nuclides)
nuclides = 'Detected Nuclides Accounted for in Burnup\n-----\n* ' + str(num_nuclides) + ' nuclides counted' + nuclides
def n_bulletize(string):
string = string.replace("'",'').replace("[","\n - ").replace("]","")
string = string.replace(',','\n - ')
return string
#print(n_bulletize(nuclides))
HTML(markdown2.markdown(n_bulletize(nuclides)))
Out[5]:
In [87]:
string = ""
nuclides = solo(lines)
def show_false(target_list):
string = ""
for target in target_list:
if target not in nuclides:
string += ' ' + str(target) + ' '
else:
string += ""
return string
print show_false(['U238','Np239','Pu239','Pu240','Pu241','Pu242','Am241','Pu243',
'Am243', 'Am244', 'Cm244', 'U235', 'U236', 'U237', 'Np237',
'Nd147', 'Pm147', 'Pm148m', 'Pm148', 'Sm147', 'Sm148', 'Pm148m',
'Pm149', 'Sm149', 'Pm150', 'Sm150', 'Sm151', 'Eu151', 'Sm152',
'Sm153', 'Eu152', 'Eu153', 'Sm154', 'Eu154', 'Eu155', 'Eu156',
'As77','Se77','Se78', 'Br81', 'Br82', 'Kr82', 'Kr83', 'Kr84',
'Kr85', 'Rb85', 'Sr90','Y90', 'Zr90', 'Y91', 'Zr91', 'Zr93', 'Zr94',
'Nb93', 'Zr95', 'Nb95', 'Mo95', 'Mo96', 'Mo97', 'Mo98', 'Mo99', 'Tc99',
'Ru99', 'Ru100', 'Ru101', 'Ru102', 'I135', 'Xe135', 'Xe136', 'I133',
'Xe133', 'Cs133', 'Cs134', 'Cs135', 'Ba135', 'Ba136', 'Cs137', 'Ba137',
'Ba140', 'La140', 'Ce140', 'Ce141', 'Pr141', 'Ce143', 'Pr143', 'Nd145',
'Nd146', 'Gd157', 'Gd158', 'Sr89', 'Y89', 'Rh103', 'Pd104', 'Ru106',
'Pd106', 'Pd107', 'Ag107', 'Ag111', 'Cd111', 'I131', 'Xe131',
'Sn115', 'Sn116', 'Nd143', 'Nd144', 'Te127m', 'I127', 'Te129m',
'Te130', 'I129', 'Cd113', 'Cd114'])
In [ ]: