Commit 2b033c2a authored by 6h6's avatar 6h6
Browse files

modifications to codes

parent 6ea3f2ca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import pandas as pd
from tabulate import tabulate


attenuation_df = pd.read_excel('Attenuation_book.xlsx')    
attenuation_df = pd.read_excel(r'\\ornl.gov\files\NEIT\Personal_Folders\TBirri\Molten Salt\MSR Campaign Work\X-ray system\ethan_code\Attenuation Codes\Attenuation_book.xlsx')    


print("Select the x-ray energy")
+124 −8
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ def element_attenuation(energies, element, empty, index):
    end = len(energies)
    
    for i in energies:
        dataframe = pd.read_excel('tabulated_attenuation.xlsx', element)
        dataframe = pd.read_excel(r'\\ornl.gov\files\NEIT\Personal_Folders\TBirri\Molten Salt\MSR Campaign Work\X-ray system\ethan_code\Attenuation Codes\tabulated_attenuation.xlsx', element)
        mass_attenuation = interpolate(i,dataframe)
        attenuation_list.append(mass_attenuation)
        
@@ -87,6 +87,7 @@ stainless_density = 8.027
#NaF-UF4 (0.778-0.222)
NaF_UF4 = ['Na', 'F', 'U']
NaF_UF4_cont = [0.1747, 0.3092, 0.5161]
NaF_UF4_density=4.02

#NaF-KF-UF4 (0.5705-0.1604-0.2691)
NaF_KF_UF4 = ['Na', 'K', 'U', 'F']
@@ -96,6 +97,11 @@ NaF_KF_UF4_cont = [0.1137, 0.0533, 0.5438, 0.2916]
tungsten_list = ['W', 'C']
tungsten_cont = [0.938674, 0.061326]

#Glass
glass_list=['Si','O']
glass_cont=[0.467,0.533]
glass_density=2.2

#Energy Spectrum of XRS4 (Use this list)
energy = [0.0101,0.0123,0.0154,0.0185,0.022,0.026,0.031,0.0366,0.0438,0.0521,0.0615,0.0733,0.087,0.1034,0.123,0.14607,0.1736,0.2061,0.2451,0.2913,0.3459]

@@ -104,14 +110,19 @@ fluence_percent = [0.00121317452223333,0.00729311050848389,0.013374026839684,0
fluence = [1050.40277526783,6314.59314224956,11579.6323212009,20713.8393950476,32634.2717592037,48888.5965716274,67465.4124016195,83721.2933693209,92549.9281341009,87141.1567949589,184653.241740663,63017.9206180832,50649.7399399474,39212.847461157,28707.5261190352,20062.8006143416,12660.5943645243,7894.09074906888,4217.17876529466,1785.47394096723,909.358519647794]
kev_energy = [10,12,15,19,22,26,31,37,44,52,62,73,87,103,123,146,174,206,245,291,346]

salt = percent(salt_list,energy,salt_contribution, 0.652, fluence_percent, salt_density)
steel = percent(stainless_list,energy,stainless_cont, 0.652, fluence_percent, stainless_density)

#energy_bin is for graphing purposes, it indicates the unattenuated energy bins, x is the ticks for the x axis of a bar graph
energy_bin = []
unattenuated = []
for i in range(0, len(energy)):
   photons = energy[i] * fluence[i] * 54000
   energy_bin.append(photons)
   unattenuated.append(photons)

steel_crucible_empty = percent(stainless_list,energy,stainless_cont, 0.14, fluence_percent, stainless_density)
steel_crucible_plus_ball = percent(stainless_list,energy,stainless_cont, 0.652+0.14, fluence_percent, stainless_density)
steel_crucible_plus_salt=percent(salt_list,energy,salt_contribution,0.652,fluence_percent,salt_density)

for i in range(len(unattenuated)):
   steel_crucible_plus_salt[i]=steel_crucible_plus_salt[i]*(steel_crucible_empty[i]/unattenuated[i])


x = np.arange(len(energy))

@@ -124,7 +135,112 @@ plt.rcParams.update({'font.size': 16})
plt.xlabel('Average Bin Energy (MeV)')
plt.ylabel('Photon Fluence (cm$^-$$^2$)')
plt.title('Photons Produced from Scintillator Reaction of Detector Plate')
plt.bar(x - 0.35, salt, width=0.25, align='edge', label= 'Through NaCl-UCl3', color='tab:orange')
plt.bar(x - 0.2, unattenuated, width=0.2, align='center', label='Unattenuated', color='tab:green')
plt.bar(x -0.1, steel_crucible_empty, width=0.2, align='edge', label= 'Through Steel Crucible', color='tab:orange')
plt.bar(x + 0.2, steel_crucible_plus_ball, width=0.2, align='center', label= 'Through Steel Crucible + Ball', color='tab:blue')
plt.bar(x+0.4,steel_crucible_plus_salt,width=0.2,align='center',label= 'Through Steel Crucible + NaCl-UCl$_3$', color='tab:red')



plt.xticks(x, myList)
plt.legend()
plt.show()



total_unattenuated = sum(unattenuated)
total_steel_crucible_empty = sum(steel_crucible_empty)
total_steel_crucible_plus_ball = sum(steel_crucible_plus_ball)
total_steel_crucible_plus_salt = sum(steel_crucible_plus_salt)

position = [1,2,3,4]
totals = [total_unattenuated, total_steel_crucible_empty, total_steel_crucible_plus_ball,total_steel_crucible_plus_salt]

labels = ['Unattenuated','Through Steel Crucible', 'Through Steel Crucible + Ball','Through Steel Crucible + NaCl-UCl$_3$']
bars = plt.bar(position, totals, align='center')
plt.xticks(position, labels)
bars[0].set_color('tab:green')
bars[1].set_color('tab:orange')
bars[2].set_color('tab:blue')
bars[3].set_color('tab:red')
plt.title('Photons per cm$^2$ for All Energy Bins')
plt.yscale('log')
plt.show()



##################################################################################



glass_crucible_empty = percent(glass_list,energy,glass_cont, 0.4, fluence_percent, glass_density)
glass_crucible_plus_tube = percent(stainless_list,energy,stainless_cont, 0.18, fluence_percent, stainless_density)
for i in range(len(unattenuated)):
   glass_crucible_plus_tube[i]=glass_crucible_plus_tube[i]*(glass_crucible_empty[i]/unattenuated[i])
glass_crucible_plus_tube_plus_ball=percent(stainless_list,energy,stainless_cont, 0.652, fluence_percent, stainless_density)
for i in range(len(unattenuated)):
   glass_crucible_plus_tube_plus_ball[i]=glass_crucible_plus_tube_plus_ball[i]*(glass_crucible_plus_tube[i]/unattenuated[i])
glass_crucible_plus_tube_plus_salt=percent(salt_list,energy,salt_contribution,0.652,fluence_percent,salt_density)
for i in range(len(unattenuated)):
   glass_crucible_plus_tube_plus_salt[i]=glass_crucible_plus_tube_plus_salt[i]*(glass_crucible_plus_tube[i]/unattenuated[i])


#MAKE FONT BIGGER
plt.rcParams.update({'font.size': 16})
plt.xlabel('Average Bin Energy (MeV)')
plt.ylabel('Photon Fluence (cm$^-$$^2$)')
plt.title('Photons Produced from Scintillator Reaction of Detector Plate')
plt.bar(x - 0.2, unattenuated, width=0.2, align='center', label='Unattenuated', color='tab:green')
plt.bar(x -0.1, glass_crucible_empty, width=0.2, align='edge', label= 'Through Glass Crucible', color='tab:orange')
plt.bar(x + 0.2, glass_crucible_plus_tube, width=0.2, align='center', label= 'Through Glass Crucible + SS Tube', color='tab:blue')
plt.bar(x+0.4,glass_crucible_plus_tube_plus_ball,width=0.2,align='center',label= 'Through Glass Crucible + SS Tube + Ball', color='tab:purple')
plt.bar(x+0.6,glass_crucible_plus_tube_plus_salt,width=0.2,align='center',label= 'Through Glass Crucible + SS Tube + NaCl-UCl$_3$', color='tab:red')


plt.xticks(x, myList)
plt.legend()
plt.show()



total_unattenuated = sum(unattenuated)
total_glass_crucible_empty = sum(glass_crucible_empty)
total_glass_crucible_plus_tube = sum(glass_crucible_plus_tube)
total_glass_crucible_plus_tube_plus_ball = sum(glass_crucible_plus_tube_plus_ball)
total_glass_crucible_plus_tube_plus_salt = sum(glass_crucible_plus_tube_plus_salt)

position = [1,2,3,4,5]
totals = [total_unattenuated, total_glass_crucible_empty, total_glass_crucible_plus_tube,total_glass_crucible_plus_tube_plus_ball,total_glass_crucible_plus_tube_plus_salt]

labels = ['Unattenuated','Glass Crucible', 'Glass Crucible + SS Tube','Glass Crucible + SS Tube + Ball','Glass Crucible + SS Tube + NaCl-UCl$_3$']
bars = plt.bar(position, totals, align='center')
plt.xticks(position, labels)
bars[0].set_color('tab:green')
bars[1].set_color('tab:orange')
bars[2].set_color('tab:purple')
bars[3].set_color('tab:blue')
bars[4].set_color('tab:red')
plt.title('Photons per cm$^2$ for All Energy Bins')
plt.yscale('log')
plt.show()

quit()


quit()

salt = percent(NaF_UF4,energy,NaF_UF4_cont, 0.652, fluence_percent, NaF_UF4_density)






plt.rcParams.update({'font.size': 16})
plt.xlabel('Average Bin Energy (MeV)')
plt.ylabel('Photon Fluence (cm$^-$$^2$)')
plt.title('Photons Produced from Scintillator Reaction of Detector Plate')
plt.bar(x - 0.35, salt, width=0.25, align='edge', label= 'Through NaF-UF4', color='tab:orange')
plt.bar(x, steel, width=0.25, align='center', label= 'Through SS 316L', color='tab:blue')
plt.bar(x + 0.2, energy_bin, width=0.25, align='center', label='Unattenuated', color='tab:green')

@@ -140,7 +256,7 @@ total = sum(energy_bin)
position = [1,2,3]
totals = [total_salt, total_steel, total]

labels = ['NaCl-UCl$_3$','SS 316L', 'Unattenuated']
labels = ['NaF-UF$_4$','SS 316L', 'Unattenuated']
bars = plt.bar(position, totals, align='center')
plt.xticks(position, labels)
bars[0].set_color('tab:orange')