Commit eb3daf3b authored by Matheus Müller's avatar Matheus Müller

Melhorias no codigo e estrutura

parent fff04e14
...@@ -52,7 +52,7 @@ def elem_select(i, button): ...@@ -52,7 +52,7 @@ def elem_select(i, button):
############################################################################## ##############################################################################
# Init # Init
def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar): def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, Labelframe):
############################################################################## ##############################################################################
# Element addition # Element addition
...@@ -266,6 +266,15 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar): ...@@ -266,6 +266,15 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar):
RL['state']='disabled' RL['state']='disabled'
OFlabentries[9]['state']='disabled' OFlabentries[9]['state']='disabled'
OFlabentries[10]['state']='disabled' OFlabentries[10]['state']='disabled'
for i in arange(6, 12):
Labentrys[i]['state']='disabled'
but['state']='disabled'
butrmv['state']='disabled'
butPTE['state']='disabled'
BUpdate['state']='disabled'
for n in arange(0, len(Ebuttons)):
Ebuttons[n]['state'] = 'disabled'
elif str(distvar.get()) == 'drawing': elif str(distvar.get()) == 'drawing':
BLayer['state']='disabled' BLayer['state']='disabled'
BUpdateD['state']='normal' BUpdateD['state']='normal'
...@@ -273,6 +282,14 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar): ...@@ -273,6 +282,14 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar):
RL['state']='normal' RL['state']='normal'
OFlabentries[9]['state']='normal' OFlabentries[9]['state']='normal'
OFlabentries[10]['state']='normal' OFlabentries[10]['state']='normal'
for i in arange(6, 12):
Labentrys[i]['state']='normal'
but['state']='normal'
butrmv['state']='normal'
butPTE['state']='normal'
BUpdate['state']='normal'
for n in arange(0, len(Ebuttons)):
Ebuttons[n]['state'] = 'normal'
def call_layers(): def call_layers():
layers() layers()
...@@ -294,6 +311,33 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar): ...@@ -294,6 +311,33 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar):
RDra = tk.Radiobutton(Frames[7], text="Drawing", command=lambda i=int(Econtrol) :changestate(), variable=distvar, value='drawing') RDra = tk.Radiobutton(Frames[7], text="Drawing", command=lambda i=int(Econtrol) :changestate(), variable=distvar, value='drawing')
RDra.pack(side='right') RDra.pack(side='right')
##############################################################################
# Experiment variations
def changemode():
if str(modevar.get()) == 'IONS':
for n in range(len(Ebuttons)):
Ebuttons[n]['state']='normal'
but['state'] = 'normal'
butrmv['state'] = 'normal'
butPTE['state'] = 'normal'
RLay['state'] = 'normal'
elif str(modevar.get()) == 'RRNA':
RDra.invoke()
elem_select(0,Ebuttons)
but['state'] = 'disabled'
butrmv['state'] = 'disabled'
RLay['state'] = 'disabled'
for n in arange(1, len(Ebuttons)):
Ebuttons[n]['state'] = 'disabled'
Rions = tk.Radiobutton(Labelframe, text="Ion Scattering", command=lambda i=i :changemode(), variable=modevar, value='IONS', width=18)
Rions.pack()
Rrrna = tk.Radiobutton(Labelframe, text="Resonant RNA", command=lambda i=i :changemode(), variable=modevar, value='RRNA', width=18)
Rrrna.pack()
Rions.select()
############################################################################## ##############################################################################
# Init # Init
......
No preview for this file type
0 0 0 0
1.22580645161 0.308673469388 1.22580645161 0.308673469388
1.38461538462 0.188775510204 1.38461538462 0.188775510204
2.03970223325 0.234693877551
2.55583126551 0.135204081633
4.20347394541 0.614540816327
6.04962779156 0.454081632653
8.23325062035 0.262755102041
9.20595533499 0.108214285714
9.841191067 0.0463775510204
10.0 0 10.0 0
This diff is collapsed.
...@@ -25,21 +25,24 @@ def init_calc(): ...@@ -25,21 +25,24 @@ def init_calc():
ionb['mass'] = float(OFlabentries[22].get()) ionb['mass'] = float(OFlabentries[22].get())
ionb['Z'] = float(OFlabentries[23].get()) ionb['Z'] = float(OFlabentries[23].get())
for i in range(len(Edict)): if str(modevar.get()) == 'IONS':
Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof") if str(distvar.get()) == 'drawing':
for i in range(len(Edict)):
Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof")
spectro(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()))
elif str(distvar.get()) == 'layer':
spectrolayer(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()))
if str(distvar.get()) == 'drawing': elif str(modevar.get()) == 'RRNA':
spectro(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get())) return 0
elif str(distvar.get()) == 'layer':
spectrolayer(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()))
############################################################################## ##############################################################################
# Main window # Main window
root = tk.Tk() root = tk.Tk()
root.minsize(670,470) root.minsize(670,550)
root.title('Open Flatus') root.title('Open Flatus')
root.geometry('670x470+200+400') root.geometry('670x500+200+400')
############################################################################## ##############################################################################
# Frames # Frames
...@@ -48,6 +51,8 @@ MasterFrame1.pack(side='left') ...@@ -48,6 +51,8 @@ MasterFrame1.pack(side='left')
MasterFrame2 = tk.Frame(root) MasterFrame2 = tk.Frame(root)
MasterFrame2.pack(side='top') MasterFrame2.pack(side='top')
Label0 = tk.LabelFrame(MasterFrame1, text = 'Experiment', relief='raised', bd=2)
Label0.pack(side='top')
Label2 = tk.LabelFrame(MasterFrame1, text = 'Parameters', relief='raised', bd=2) Label2 = tk.LabelFrame(MasterFrame1, text = 'Parameters', relief='raised', bd=2)
Label2.pack(side='top') Label2.pack(side='top')
Label3 = tk.LabelFrame(MasterFrame1, text = 'Ion parameters', relief='raised', bd=2) Label3 = tk.LabelFrame(MasterFrame1, text = 'Ion parameters', relief='raised', bd=2)
...@@ -133,6 +138,8 @@ OFlabentries[23].insert(0, ionb['Z']) ...@@ -133,6 +138,8 @@ OFlabentries[23].insert(0, ionb['Z'])
############################################################################## ##############################################################################
# Energy loss models # Energy loss models
modevar = tk.StringVar()
modevar.set('IONS')
modelvar = tk.StringVar() modelvar = tk.StringVar()
R1 = tk.Radiobutton(Label4, text="Gaussian", variable=modelvar, value='gaussiana') R1 = tk.Radiobutton(Label4, text="Gaussian", variable=modelvar, value='gaussiana')
R1.pack() R1.pack()
...@@ -163,7 +170,7 @@ CalcButton.pack() ...@@ -163,7 +170,7 @@ CalcButton.pack()
distvar = tk.StringVar() distvar = tk.StringVar()
distvar.set('drawing') distvar.set('drawing')
ewin_build(Label1, OFlabentries, root, CalcButton, distvar) ewin_build(Label1, OFlabentries, root, CalcButton, distvar, modevar, Label0)
############################################################################## ##############################################################################
......
This diff is collapsed.
No preview for this file type
...@@ -7,30 +7,11 @@ from PTE import * ...@@ -7,30 +7,11 @@ from PTE import *
Frms = list() Frms = list()
Ldict = list() Ldict = list()
Laycount = 0 Laycount = 0
currdepht = 0
############################################################################## ##############################################################################
############################################################################## ##############################################################################
# Common Functions # Common Functions
def Dminchange(layernum):
number = float(Ldict[layernum]['LandE'][6].get())
Ldict[layernum]['Dmin'] = number
if layernum > 0:
Ldict[layernum-1]['Dmax'] = number
Ldict[layernum-1]['LandE'][7].delete(0, 'end')
Ldict[layernum-1]['LandE'][7].insert(0, number)
def Dmaxchange(layernum):
number = float(Ldict[layernum]['LandE'][7].get())
Ldict[layernum]['Dmax'] = number
if layernum < len(Ldict):
Ldict[layernum+1]['Dmin'] = number
Ldict[layernum+1]['LandE'][6].delete(0, 'end')
Ldict[layernum+1]['LandE'][6].insert(0, number)
##############################################################################
def elem_callback(x, edict , ebutton, Labentrys): def elem_callback(x, edict , ebutton, Labentrys):
PTable(edict[x] , ebutton[x], Labentrys) PTable(edict[x] , ebutton[x], Labentrys)
...@@ -93,13 +74,13 @@ class Layer: ...@@ -93,13 +74,13 @@ class Layer:
# 2 // 8 = Z (Atomic number) # 2 // 8 = Z (Atomic number)
# 3 // 9 = Symbol # 3 // 9 = Symbol
# 4 // 10 = Line shape # 4 // 10 = Line shape
# 5 // 11 = Max Depht # 5 // 11 = Max Depht (Not used)
Labentrys.insert(0, tk.Label(Frames[3], width=23, pady=2, text='%s' %self.Elements[i]['name']) ) Labentrys.insert(0, tk.Label(Frames[3], width=23, pady=2, text='%s' %self.Elements[i]['name']) )
Labentrys.insert(1, tk.Label(Frames[3], width=23, pady=2, text='Mass - %f' %self.Elements[i]['mass']) ) Labentrys.insert(1, tk.Label(Frames[3], width=23, pady=2, text='Mass - %f' %self.Elements[i]['mass']) )
Labentrys.insert(2, tk.Label(Frames[3], width=23, pady=2, text='Z - %f' %self.Elements[i]['Z']) ) Labentrys.insert(2, tk.Label(Frames[3], width=23, pady=2, text='Z - %f' %self.Elements[i]['Z']) )
Labentrys.insert(3, tk.Label(Frames[3], width=23, pady=2, text= 'Symbol - %s' %self.Elements[i]['symbol']) ) Labentrys.insert(3, tk.Label(Frames[3], width=23, pady=2, text= 'Symbol - %s' %self.Elements[i]['symbol']) )
Labentrys.insert(4, tk.Label(Frames[3], width=23, pady=2, text='Line Shape α - %f' %self.Elements[i]['LineShape']) ) Labentrys.insert(4, tk.Label(Frames[3], width=23, pady=2, text='Line Shape α - %f' %self.Elements[i]['LineShape']) )
Labentrys.insert(5, tk.Label(Frames[3]) ) Labentrys.insert(5, tk.Label(Frames[3]) ) #To fill structure of function called
for n in range(5): for n in range(5):
Labentrys[n].pack() Labentrys[n].pack()
...@@ -141,7 +122,7 @@ class Layer: ...@@ -141,7 +122,7 @@ class Layer:
del self.Spinboxes[self.Ecount] del self.Spinboxes[self.Ecount]
def __init__(self, canvas, count): def __init__(self, canvas, count):
global Ldict, currdepht global Ldict
self.Number=count self.Number=count
self.Ecount=0 self.Ecount=0
...@@ -151,8 +132,7 @@ class Layer: ...@@ -151,8 +132,7 @@ class Layer:
self.Frames=list() self.Frames=list()
self.LandE=list() self.LandE=list()
self.Buttons=list() self.Buttons=list()
self.Dmin=currdepht self.Depht=1.
self.Dmax=currdepht+1.
self.LabelFrm = tk.LabelFrame(canvas, text = 'Layer %d' %int(Laycount+1), relief='raised', bd=2) self.LabelFrm = tk.LabelFrame(canvas, text = 'Layer %d' %int(Laycount+1), relief='raised', bd=2)
self.LabelFrm.grid(column=(Laycount%4), row=int(math.floor(Laycount/4)) ) self.LabelFrm.grid(column=(Laycount%4), row=int(math.floor(Laycount/4)) )
...@@ -176,15 +156,13 @@ class Layer: ...@@ -176,15 +156,13 @@ class Layer:
self.LandE.insert(0, tk.Label(self.Frames[4], width=14, pady=2, text='dƐ/dx') ) self.LandE.insert(0, tk.Label(self.Frames[4], width=14, pady=2, text='dƐ/dx') )
self.LandE.insert(1, tk.Label(self.Frames[4], width=14, pady=2, text='dω²/dx') ) self.LandE.insert(1, tk.Label(self.Frames[4], width=14, pady=2, text='dω²/dx') )
self.LandE.insert(2, tk.Label(self.Frames[4], width=14, pady=2, text='Depht min(nm)') ) self.LandE.insert(2, tk.Label(self.Frames[4], width=14, pady=2, text='Depht(nm)') )
self.LandE.insert(3, tk.Label(self.Frames[4], width=14, pady=2, text='Depht max(nm)') )
for i in arange(4,6): for i in arange(3,5):
self.LandE.insert(i, tk.Entry(self.Frames[5], width=11) ) self.LandE.insert(i, tk.Entry(self.Frames[5], width=11) )
self.LandE.insert(6, tk.Entry(self.Frames[5], width=11, )) self.LandE.insert(5, tk.Entry(self.Frames[5], width=11, ))
self.LandE.insert(7, tk.Entry(self.Frames[5], width=11, ))
for i in range(8): for i in range(6):
self.LandE[i].pack() self.LandE[i].pack()
self.Buttons.insert(0, tk.Button(self.Frames[4], command=lambda i=i :Ldict[self.Number].addel(), text='Add element',width=11)) self.Buttons.insert(0, tk.Button(self.Frames[4], command=lambda i=i :Ldict[self.Number].addel(), text='Add element',width=11))
...@@ -192,12 +170,9 @@ class Layer: ...@@ -192,12 +170,9 @@ class Layer:
for i in range(2): for i in range(2):
self.Buttons[i].pack() self.Buttons[i].pack()
self.LandE[4].insert(0, 200.) self.LandE[3].insert(0, 200.)
self.LandE[5].insert(0, 20000.) self.LandE[4].insert(0, 20000.)
self.LandE[6].insert(0, self.Dmin) self.LandE[5].insert(0, self.Depht)
self.LandE[7].insert(0, self.Dmax)
currdepht = currdepht + 1.
############################################################################## ##############################################################################
############################################################################## ##############################################################################
......
...@@ -10,6 +10,8 @@ from Ewindow import Edict ...@@ -10,6 +10,8 @@ from Ewindow import Edict
from layers import Ldict from layers import Ldict
PI=math.pi PI=math.pi
#xx = arange(0,1, 0.1)
#tempor, = plot(xx,xx*0)
#################################################################################################################################################### ####################################################################################################################################################
# Seção de choque Rutherford # Seção de choque Rutherford
...@@ -152,7 +154,11 @@ def spectro(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol): ...@@ -152,7 +154,11 @@ def spectro(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol):
if CGausscontrol == 1: if CGausscontrol == 1:
X, gshift = convoluiGauss(X,resol/2.35482,EPasso) X, gshift = convoluiGauss(X,resol/2.35482,EPasso)
plt.plot(e-gshift,X*dose, linecolor) plt.plot(e-gshift,X*dose, linecolor)
ylim([0,max(X*dose)*1.1]) #tempor.set_xdata(e-gshift)
#tempor.set_ydata(X*dose)
#tempor.set_color(linecolor)
ylim([0,max(X*dose)*1.1])
xlim([0,max(e-gshift)*1.05])
suptitle('Signal received', fontsize=12) suptitle('Signal received', fontsize=12)
xlabel("Enegy (eV)") xlabel("Enegy (eV)")
ylabel("Yield") ylabel("Yield")
...@@ -166,7 +172,7 @@ def spectro(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol): ...@@ -166,7 +172,7 @@ def spectro(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol):
xxx= amostra[:,0]*1000 xxx= amostra[:,0]*1000
ccc=amostra[:,1] ccc=amostra[:,1]
plot (xxx, ccc, 'r.') #plot (xxx, ccc, 'r.')
show() show()
#################################################################################################################################################### ####################################################################################################################################################
...@@ -181,21 +187,23 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol): ...@@ -181,21 +187,23 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol):
X = e*0. X = e*0.
dose = 12e34 dose = 12e34
gshift=0. gshift=0.
antizerodiv=0. curdepht=passox #Avoid zero division
Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180 Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180
mi = ion['mass'] mi = ion['mass']
for camada in Ldict: for camada in Ldict:
xfinal = curdepht + float(camada.LandE[5].get())
## Calcula o espectro de cada elemento da amostra ## Calcula o espectro de cada elemento da amostra
for componente in range(len(camada.Elements)): for componente in range(len(camada.Elements)):
mt = camada.Elements[componente]['mass'] mt = camada.Elements[componente]['mass']
c = float(camada.Spinboxes[componente].get()) c = float(camada.Spinboxes[componente].get())
alpha_lineshape = camada.Elements[componente]['LineShape'] alpha_lineshape = camada.Elements[componente]['LineShape']
dedx = float(camada.LandE[4].get()) dedx = float(camada.LandE[3].get())
dW2dx = float(camada.LandE[5].get()) dW2dx = float(camada.LandE[4].get())
k = ((sqrt (mt**2+mi**2*(sin(Theta_s)**2)) + mi*cos(Theta_s) ) / (mi+mt) )**2 k = ((sqrt (mt**2+mi**2*(sin(Theta_s)**2)) + mi*cos(Theta_s) ) / (mi+mt) )**2
dedxef=dedx*(k/cos(p['Theta_in']*PI/180.) + 1/cos(p['Theta_out']*PI/180.)) dedxef=dedx*(k/cos(p['Theta_in']*PI/180.) + 1/cos(p['Theta_out']*PI/180.))
...@@ -204,28 +212,14 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol): ...@@ -204,28 +212,14 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol):
sinalbessel = e*0 sinalbessel = e*0
sinalgaussiana = e*0 sinalgaussiana = e*0
xinit = float(camada.LandE[6].get()) # Calcula a contribuição de cada passo
xfinal = float(camada.LandE[7].get()) for x in arange(curdepht, xfinal, passox):
if xinit == 0:
antizerodiv = passox
else:
antizerodiv = 0
# Calcula a contribuição de cada camada
for x in arange(xinit+antizerodiv, xfinal, passox):
# Seção de choque - CSRf(Z1, Z2, Ein, M1, M2, Theta): # Seção de choque - CSRf(Z1, Z2, Ein, M1, M2, Theta):
CS = c*k*CSRf(ion['Z'], camada.Elements[componente]['Z'], k*p['E0']-dedxef*x, mi, mt, Theta_s)*passox CS = c*k*CSRf(ion['Z'], camada.Elements[componente]['Z'], k*p['E0']-dedxef*x, mi, mt, Theta_s)*passox
# É multiplicada pelo passo para manter a escala do gráfico independente do mesmo. # É multiplicada pelo passo para manter a escala do gráfico independente do mesmo.
# Bessel: # Bessel:
# Ainda falta incluir a delta de Dirac na origem
# Existe um valor máximo em energia no qual a função de Bessel pode ser computada em função
# da precisão numérica. Uma possível solução pode ser trabalhar em outras unidades que não
# resultem em argumentos tão grandes para a função exponencial.
# Também temos um problema com a primeira camada, que tem profundidade zero.
# Perceba que os cálculos de Bessel correspondentes às camadas mais fundas estão truncados
# para uma perda de energia maior que 25 keV. (Observado com Theta_in=70, para x > 30)
if modelo == 'bessel': if modelo == 'bessel':
alpha=dedxef*(2./dw2dxef) alpha=dedxef*(2./dw2dxef)
m=alpha*dedxef m=alpha*dedxef
...@@ -253,6 +247,8 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol): ...@@ -253,6 +247,8 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol):
X = sinalgaussiana + X X = sinalgaussiana + X
linecolor='b' linecolor='b'
curdepht = xfinal
if CGausscontrol == 1: if CGausscontrol == 1:
X, gshift = convoluiGauss(X,resol/2.35482,EPasso) X, gshift = convoluiGauss(X,resol/2.35482,EPasso)
plt.plot(e-gshift,X*dose, linecolor) plt.plot(e-gshift,X*dose, linecolor)
......
No preview for this file type
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment