Commit 609091a0 authored by Matheus Müller's avatar Matheus Müller

Link entre interface e cálculos numéricos usando Tkinter

parent 72c9a113
from numpy import *
SLOT = dict(ELEa = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEb = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEc = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEd = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEe = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEf = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEg = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEh = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEi = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEj = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEk = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEl = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEm = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEn = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0),
ELEo = dict(name = "New", symbol = "-", mass = 0.00, Z = 0, dist = zeros((1000), float), control = 0))
import Tkinter as tk
from Edict import *
from PTE import *
from Eprop import *
def elemw(elewindow):
####################################################
# Button building on received frame
co1 = lambda: PTable(SLOT['ELEa'], bu1)
co1a = lambda: atomsubmenu(SLOT['ELEa'], bu1)
bu1 = tk.Menubutton(elewindow, text=SLOT['ELEa']['symbol'], width=3, height=1, relief='raised')
m1 = tk.Menu(bu1)
bu1.config(menu=m1)
m1.add_command(label='Choose by PTE', command=co1)
m1.add_command(label='Properties', command=co1a)
co2 = lambda: PTable(SLOT['ELEb'], bu2)
co2a = lambda: atomsubmenu(SLOT['ELEb'], bu2)
bu2 = tk.Menubutton(elewindow, text=SLOT['ELEb']['symbol'], width=3, height=1, relief='raised')
m2 = tk.Menu(bu2)
bu2.config(menu=m2)
m2.add_command(label='Choose by PTE', command=co2)
m2.add_command(label='Properties', command=co2a)
co3 = lambda: PTable(SLOT['ELEc'], bu3)
co3a = lambda: atomsubmenu(SLOT['ELEc'], bu3)
bu3 = tk.Menubutton(elewindow, text=SLOT['ELEc']['symbol'], width=3, height=1, relief='raised')
m3 = tk.Menu(bu3)
bu3.config(menu=m3)
m3.add_command(label='Choose by PTE', command=co3)
m3.add_command(label='Properties', command=co3a)
co4 = lambda: PTable(SLOT['ELEd'], bu4)
co4a = lambda: atomsubmenu(SLOT['ELEd'], bu4)
bu4 = tk.Menubutton(elewindow, text=SLOT['ELEd']['symbol'], width=3, height=1, relief='raised')
m4 = tk.Menu(bu4)
bu4.config(menu=m4)
m4.add_command(label='Choose by PTE', command=co4)
m4.add_command(label='Properties', command=co4a)
co5 = lambda: PTable(SLOT['ELEe'], bu5)
co5a = lambda: atomsubmenu(SLOT['ELEe'], bu5)
bu5 = tk.Menubutton(elewindow, text=SLOT['ELEe']['symbol'], width=3, height=1, relief='raised')
m5 = tk.Menu(bu5)
bu5.config(menu=m5)
m5.add_command(label='Choose by PTE', command=co5)
m5.add_command(label='Properties', command=co5a)
co6 = lambda: PTable(SLOT['ELEf'], bu6)
co6a = lambda: atomsubmenu(SLOT['ELEf'], bu6)
bu6 = tk.Menubutton(elewindow, text=SLOT['ELEf']['symbol'], width=3, height=1, relief='raised')
m6 = tk.Menu(bu6)
bu6.config(menu=m6)
m6.add_command(label='Choose by PTE', command=co6)
m6.add_command(label='Properties', command=co6a)
co7 = lambda: PTable(SLOT['ELEg'], bu7)
co7a = lambda: atomsubmenu(SLOT['ELEg'], bu7)
bu7 = tk.Menubutton(elewindow, text=SLOT['ELEg']['symbol'], width=3, height=1, relief='raised')
m7 = tk.Menu(bu7)
bu7.config(menu=m7)
m7.add_command(label='Choose by PTE', command=co7)
m7.add_command(label='Properties', command=co7a)
co8 = lambda: PTable(SLOT['ELEh'], bu8)
co8a = lambda: atomsubmenu(SLOT['ELEh'], bu8)
bu8 = tk.Menubutton(elewindow, text=SLOT['ELEh']['symbol'], width=3, height=1, relief='raised')
m8 = tk.Menu(bu8)
bu8.config(menu=m8)
m8.add_command(label='Choose by PTE', command=co8)
m8.add_command(label='Properties', command=co8a)
co9 = lambda: PTable(SLOT['ELEi'], bu9)
co9a = lambda: atomsubmenu(SLOT['ELEi'], bu9)
bu9 = tk.Menubutton(elewindow, text=SLOT['ELEi']['symbol'], width=3, height=1, relief='raised')
m9 = tk.Menu(bu9)
bu9.config(menu=m9)
m9.add_command(label='Choose by PTE', command=co9)
m9.add_command(label='Properties', command=co9a)
co10 = lambda: PTable(SLOT['ELEj'], bu10)
co10a = lambda: atomsubmenu(SLOT['ELEj'], bu10)
bu10= tk.Menubutton(elewindow, text=SLOT['ELEj']['symbol'], width=3, height=1, relief='raised')
m10 = tk.Menu(bu10)
bu10.config(menu=m10)
m10.add_command(label='Choose by PTE', command=co10)
m10.add_command(label='Properties', command=co10a)
co11 = lambda: PTable(SLOT['ELEk'], bu11)
co11a = lambda: atomsubmenu(SLOT['ELEk'], bu11)
bu11 = tk.Menubutton(elewindow, text=SLOT['ELEk']['symbol'], width=3, height=1, relief='raised')
m11 = tk.Menu(bu11)
bu11.config(menu=m11)
m11.add_command(label='Choose by PTE', command=co11)
m11.add_command(label='Properties', command=co11a)
co12 = lambda: PTable(SLOT['ELEl'], bu12)
co12a = lambda: atomsubmenu(SLOT['ELEl'], bu12)
bu12 = tk.Menubutton(elewindow, text=SLOT['ELEl']['symbol'], width=3, height=1, relief='raised')
m12 = tk.Menu(bu12)
bu12.config(menu=m12)
m12.add_command(label='Choose by PTE', command=co12)
m12.add_command(label='Properties', command=co12a)
co13 = lambda: PTable(SLOT['ELEm'], bu13)
co13a = lambda: atomsubmenu(SLOT['ELEm'], bu13)
bu13 = tk.Menubutton(elewindow, text=SLOT['ELEm']['symbol'], width=3, height=1, relief='raised')
m13 = tk.Menu(bu13)
bu13.config(menu=m13)
m13.add_command(label='Choose by PTE', command=co13)
m13.add_command(label='Properties', command=co13a)
co14 = lambda: PTable(SLOT['ELEn'], bu14)
co14a = lambda: atomsubmenu(SLOT['ELEn'], bu14)
bu14 = tk.Menubutton(elewindow, text=SLOT['ELEn']['symbol'], width=3, height=1, relief='raised')
m14 = tk.Menu(bu14)
bu14.config(menu=m14)
m14.add_command(label='Choose by PTE', command=co14)
m14.add_command(label='Properties', command=co14a)
co15 = lambda: PTable(SLOT['ELEo'], bu15)
co15a = lambda: atomsubmenu(SLOT['ELEo'], bu15)
bu15 = tk.Menubutton(elewindow, text=SLOT['ELEo']['symbol'], width=3, height=1, relief='raised')
m15 = tk.Menu(bu15)
bu15.config(menu=m15)
m15.add_command(label='Choose by PTE', command=co15)
m15.add_command(label='Properties', command=co15a)
####################################################
bu1.grid(row=0, column=0, padx=1, pady=1)
bu2.grid(row=0, column=1, padx=1, pady=1)
bu3.grid(row=0, column=2, padx=1, pady=1)
bu4.grid(row=0, column=3, padx=1, pady=1)
bu5.grid(row=0, column=4, padx=1, pady=1)
bu6.grid(row=1, column=0, padx=1, pady=1)
bu7.grid(row=1, column=1, padx=1, pady=1)
bu8.grid(row=1, column=2, padx=1, pady=1)
bu9.grid(row=1, column=3, padx=1, pady=1)
bu10.grid(row=1, column=4, padx=1, pady=1)
bu11.grid(row=2, column=0, padx=1, pady=1)
bu12.grid(row=2, column=1, padx=1, pady=1)
bu13.grid(row=2, column=2, padx=1, pady=1)
bu14.grid(row=2, column=3, padx=1, pady=1)
bu15.grid(row=2, column=4, padx=1, pady=1)
####################################################
import Tkinter as tk
from Edict import *
from pylab import *
xsum=0.
xdep=0.
def atomsubmenu(elem, but):
sub = tk.Tk()
sub.title(elem['name'])
propbutton = tk.Menubutton(sub, width=20, text='Edit properties')
edit = tk.Menu(propbutton)
propbutton.config(menu=edit)
distbutton = tk.Menubutton(sub, width=20, text='Edit distribution')
editdist = tk.Menu(distbutton)
distbutton.config(menu=editdist)
def cmdadd():
if elem['control']==0:
elem['control']=1
but['text'] = elem['symbol']
but['relief'] = 'sunken'
addremove['text']='Remove element'
else:
elem['control']=0
but['relief'] = 'raised'
addremove['text']='Add element'
addremove = tk.Button(sub, width=16, bg='white', command=cmdadd, relief='raised', bd=4)
if elem['control']==0:
addremove['text']='Add element'
else:
addremove['text']='Remove element'
addremove.pack(side='bottom')
L1 = tk.Label(sub, text = 'Mass - %f' %elem['mass'])
L1.pack()
L2 = tk.Label(sub, text = 'Z - %d' %elem['Z'])
L2.pack()
L3 = tk.Label(sub, text = 'Symbol - %s' %elem['symbol'])
L3.pack()
def cmdmass():
submass = tk.Tk()
submass.title('%s - Mass' %elem['name'])
def modmass():
elem['mass'] = float(E1.get())
submass.destroy()
L1.configure(text = 'Mass - %f' %elem['mass'])
E1 = tk.Entry(submass, bd =2, width=20)
E1.pack()
B1 = tk.Button(submass, text ='Modify', command=modmass, width=18)
B1.pack()
E1.focus_force()
F1 = tk.Frame(submass, width=300)
F1.pack()
submass.mainloop()
def cmdz():
subz = tk.Tk()
subz.title('%s - Z' %elem['name'])
def modz():
elem['Z'] = int(E2.get(), 10)
subz.destroy()
L2.configure(text = 'Z - %d' %elem['Z'])
E2 = tk.Entry(subz, bd =2, width=20)
E2.pack()
B2 = tk.Button(subz, text ='Modify', command=modz, width=18)
B2.pack()
E2.focus_force()
subz.mainloop()
def cmdname():
subname = tk.Tk()
subname.title('%s - Name' %elem['name'])
def modname():
elem['name'] = E3.get()
subname.destroy()
sub.title(elem['name'])
E3 = tk.Entry(subname, bd =2, width=20)
E3.pack()
B3 = tk.Button(subname, text ='Modify', command=modname, width=18)
B3.pack()
E3.focus_force()
subname.mainloop()
def cmdsymbol():
subsymbol = tk.Tk()
subsymbol.title('Symbol - %s' %elem['symbol'])
def modsymbol():
elem['symbol'] = E4.get()
subsymbol.destroy()
L3.configure(text = 'Symbol - %s' %elem['symbol'])
but['text'] = elem['symbol']
E4 = tk.Entry(subsymbol, bd =2, width=20)
E4.pack()
B4 = tk.Button(subsymbol, text ='Modify', command=modsymbol, width=18)
B4.pack()
E4.focus_force()
subsymbol.mainloop()
def cmddraw():
print elem['mass']
def cmdnume():
global xsum
xsum = 0
subnume = tk.Tk()
subnume.title('%s - Distribution' %elem['name'])
subnume.minsize(295,95)
subnume.resizable(width='false', height='false')
F6 = tk.Frame(subnume, width=100)
F6b = tk.Frame(subnume, width=100)
F6.grid(column=0, row=0, sticky='w')
F6b.grid(column=0, row=0, sticky='e')
def modnume():
global xsum
global xdep
xdep=float(E6.get())
L6.configure(text='Current depth = %fnm' %(xdep+xsum/100))
for j in range(int(xsum), int(xsum + xdep*100)):
if j > 999:
print "Reached maximum depth"
break
else:
elem['dist'][j]=float(E6b.get())
xsum+=xdep*100
E6.delete(0, 'end')
E6.insert(0, 0)
E6 = tk.Entry(F6b, bd =2, width=10)
E6.pack()
E6b = tk.Entry(F6b, bd =2, width=10)
E6b.pack()
B6 = tk.Button(subnume, text ='Add depth/concentration', command=modnume, width=33)
B6.grid(column=0, row=2)
E6.focus_force()
L6 = tk.Label(subnume, text = 'Current depth = %f' %xdep)
L6.grid(column=0, row=1)
L6b = tk.Label(F6, text = 'Depth Amount', width=25)
L6b.pack()
L6c = tk.Label(F6, text = 'Concentration factor (0 to 1)', width=25)
L6c.pack()
subnume.mainloop()
def cmdspecial():
plot (elem['dist'])
show()
edit.add_command(label='Mass', command=cmdmass)
edit.add_command(label='Name', command=cmdname)
edit.add_command(label='Z', command=cmdz)
edit.add_command(label='Symbol', command=cmdsymbol)
editdist.add_command(label='Drawing', command=cmddraw)
editdist.add_command(label='Numerical', command=cmdnume)
editdist.add_command(label='Special', command=cmdspecial)
F2 = tk.Frame(sub, width=250, height=4)
F2.pack()
sub.resizable(width='true', height='false')
propbutton.pack()
propbutton.config(bg='white', bd=4, relief='raised')
distbutton.pack()
distbutton.config(bg='white', bd=4, relief='raised')
sub.mainloop()
# -*- coding: iso-8859-15 -*-
import Tkinter as tk
from Elements import *
from numpy import *
from pylab import *
from spectro import *
#######################################
# Initial parameters
param = dict(dedx=287. ,Theta_out=70., dW2dx=35000., E0= 100000., Theta_in=0., FWHM0=300.)
ionb = dict(Z=1, mass=1.0079)
#######################################
# Calculation callback
# Defines parameters
def init_calc():
param['dedx'] = float(Entrydedx.get())
param['dW2dx'] = float(EntrydW2dx.get())
param['Theta_out'] = float(EntryT_out.get())
param['Theta_in'] = float(EntryT_in.get())
param['E0'] = float(EntryE0.get())
param['FWHM0'] = float(EntryFWHM0.get())
ionb['mass'] = float(Entryionmass.get())
ionb['Z'] = float(EntryionZ.get())
data=spectro_espalhamento(float(EntryEmin.get()),float(EntryEmax.get()),20)
#data.addelements2(['profHf.dat','profO.dat'],param,0.9,'gaussiana',0.01)
data.sweepelements(param, 'gaussiana', ionb)
data.plot()
#######################################
# Main window
root = tk.Tk()
root.minsize(385,355)
root.title('Open Flatus')
Label1 = tk.Label(root, text = 'Elements', relief='raised', bd=2)
Label1.grid(column=0, row=9)
Label2 = tk.Label(root, text = 'Parameters', relief='raised', bd=2)
Label2.grid(column=0, row=0)
Label3 = tk.Label(root, text = 'Ion parameters', relief='raised', bd=2)
Label3.grid(column=0, row=2)
CalcButton = tk.Button(root, text = 'Calculate', command = init_calc, bd=4, width=20, height=4)
CalcButton.grid(column=10, row=10)
#######################################
# Frames
Eframe = tk.Frame(root)
Eframe.grid(column=0, row=10)
Pframel = tk.Frame(root)
Pframel.grid(column=0, row=1, sticky='w')
Pframee = tk.Frame(root)
Pframee.grid(column=0, row=1, sticky='e')
Iframel = tk.Frame(root, width=8)
Iframel.grid(column=0, row=3, sticky='w')
Iframee = tk.Frame(root, width=12)
Iframee.grid(column=0, row=3, sticky='e')
#######################################
# Elements callback
elemw(Eframe)
#######################################
# Parameters
# Labels
Labeldedx = tk.Label(Pframel, width=8, text='dƐ/dx')
LabeldW2dx = tk.Label(Pframel, width=8, text='dω²/dx')
LabelT_out = tk.Label(Pframel, width=8, text='θ out')
LabelT_in = tk.Label(Pframel, width=8, text='θ in')
LabelE0 = tk.Label(Pframel, width=8, text='E0')
LabelFWHM0 = tk.Label(Pframel, width=8, text='FWHM0')
LabelEmin = tk.Label(Pframel, width=8, text='Emin')
LabelEmax = tk.Label(Pframel, width=8, text='Emax')
Labeldedx.pack()
LabeldW2dx.pack()
LabelT_out.pack()
LabelT_in.pack()
LabelE0.pack()
LabelFWHM0.pack()
LabelEmin.pack()
LabelEmax.pack()
# Entries
Entrydedx = tk.Entry(Pframee, width=12)
EntrydW2dx = tk.Entry(Pframee, width=12)
EntryT_out = tk.Entry(Pframee, width=12)
EntryT_in = tk.Entry(Pframee, width=12)
EntryE0 = tk.Entry(Pframee, width=12)
EntryFWHM0 = tk.Entry(Pframee, width=12)
EntryEmin = tk.Entry(Pframee, width=12)
EntryEmax = tk.Entry(Pframee, width=12)
Entrydedx.pack()
EntrydW2dx.pack()
EntryT_out.pack()
EntryT_in.pack()
EntryE0.pack()
EntryFWHM0.pack()
EntryEmin.pack()
EntryEmax.pack()
#Ion
Labelionmass = tk.Label(Iframel, width=8, text='Mass')
LabelionZ = tk.Label(Iframel, width=8, text='Z')
Labelionmass.pack()
LabelionZ.pack()
Entryionmass = tk.Entry(Iframee, width=12)
EntryionZ = tk.Entry(Iframee, width=12)
Entryionmass.pack()
EntryionZ.pack()
#Initial values
Entrydedx.insert(0,param['dedx'])
EntrydW2dx.insert(0,param['dW2dx'])
EntryT_out.insert(0,param['Theta_out'])
EntryT_in.insert(0,param['Theta_in'])
EntryE0.insert(0,param['E0'])
EntryFWHM0.insert(0,param['FWHM0'])
EntryEmin.insert(0,50000)
EntryEmax.insert(0,100000)
Entryionmass.insert(0, ionb['mass'])
EntryionZ.insert(0, ionb['Z'])
#######################################
root.mainloop()
#######################################
This diff is collapsed.
H = dict(name = "Hydrogen", mass = 1.0079, Z = 1, symbol = 'H')
He = dict(name = "Helium", mass = 4.0026, Z = 2, symbol = 'He')
Li = dict(name = "Lithium", mass = 6.941, Z = 3, symbol = 'Li')
Be = dict(name = "Beryllium", mass = 9.0122, Z = 4, symbol = 'Be')
B = dict(name = "Boron", mass = 10.811, Z = 5, symbol = 'B')
C = dict(name = "Carbon", mass = 12.011, Z = 6, symbol = 'C')
N = dict(name = "Nitrogen", mass = 14.007, Z = 7, symbol = 'N')
O = dict(name = "Oxygen", mass = 15.999, Z = 8, symbol = 'O')
F = dict(name = "Fluorine", mass = 18.998, Z = 9, symbol = 'F')
Ne = dict(name = "Neon", mass = 20.180, Z = 10, symbol = 'Ne')
Na = dict(name = "Sodium", mass = 22.990, Z = 11, symbol = 'Na')
Mg = dict(name = "Magnesium", mass = 24.305, Z = 12, symbol = 'Mg')
Al = dict(name = "Aluminium", mass = 26.982, Z = 13, symbol = 'Al')
Si = dict(name = "Silicon", mass = 28.086, Z = 14, symbol = 'Si')
P = dict(name = "Phosphorus", mass = 30.974, Z = 15, symbol = 'P')
S = dict(name = "Sulfur", mass = 32.066, Z = 16, symbol = 'S')
Cl = dict(name = "Chlorine", mass = 35.453, Z = 17, symbol = 'Cl')
Ar = dict(name = "Argon", mass = 39.948, Z = 18, symbol = 'Ar')
K = dict(name = "Potassium", mass = 39.098, Z = 19, symbol = 'K')
Ca = dict(name = "Calcium", mass = 40.078, Z = 20, symbol = 'Ca')
Sc = dict(name = "Scandium", mass = 44.956, Z = 21, symbol = 'Sc')
Ti = dict(name = "Titanium", mass = 47.867, Z = 22, symbol = 'Ti')
V = dict(name = "Vanadium", mass = 50.942, Z = 23, symbol = 'V')
Cr = dict(name = "Chromium", mass = 51.996, Z = 24, symbol = 'Cr')
Mn = dict(name = "Manganese", mass = 54.938, Z = 25, symbol = 'Mn')
Fe = dict(name = "Iron", mass = 55.845, Z = 26, symbol = 'Fe')
Co = dict(name = "Cobalt", mass = 58.993, Z = 27, symbol = 'Co')
Ni = dict(name = "Nickel", mass = 58.693, Z = 28, symbol = 'Ni')
Cu = dict(name = "Copper", mass = 63.546, Z = 29, symbol = 'Cu')
Zn = dict(name = "Zinc", mass = 65.39, Z = 30, symbol = 'Zn')
Ga = dict(name = "Gallium", mass = 69.723, Z = 31, symbol = 'Ga')
Ge = dict(name = "Germanium", mass = 72.61, Z = 32, symbol = 'Ge')
As = dict(name = "Arsenic", mass = 74.922, Z = 33, symbol = 'As')
Se = dict(name = "Selenium", mass = 78.96, Z = 34, symbol = 'Se')
Br = dict(name = "Bromine", mass = 79.904, Z = 35, symbol = 'Br')
Kr = dict(name = "Krypton", mass = 83.80, Z = 36, symbol = 'Kr')
Rb = dict(name = "Rubidium", mass = 85.468, Z = 37, symbol = 'Rb')
Sr = dict(name = "Strontium", mass = 87.62, Z = 38, symbol = 'Sr')
Y = dict(name = "Yttrium", mass = 88.906, Z = 39, symbol = 'Y')
Zr = dict(name = "Zirconium", mass = 91.224, Z = 40, symbol = 'Zr')
Nb = dict(name = "Niobium", mass = 92.906, Z = 41, symbol = 'Nb')
Mo = dict(name = "Molibdenium", mass = 95.94, Z = 42, symbol = 'Mo')
Tc = dict(name = "Technetium", mass = 98.906, Z = 43, symbol = 'Tc')
Ru = dict(name = "Ruthenium", mass = 101.07, Z = 44, symbol = 'Ru')
Rh = dict(name = "Rhodium", mass = 102.91, Z = 45, symbol = 'Rh')
Pd = dict(name = "Palladium", mass = 106.42, Z = 46, symbol = 'Pd')
Ag = dict(name = "Silver", mass = 107.87, Z = 47, symbol = 'Ag')
Cd = dict(name = "Cadmium", mass = 112.41, Z = 48, symbol = 'Cd')
In = dict(name = "Indium", mass = 114.82, Z = 49, symbol = 'In')
Sn = dict(name = "Tin", mass = 118.71, Z = 50, symbol = 'Sn')
Sb = dict(name = "Antimony", mass = 121.76, Z = 51, symbol = 'Sb')
Te = dict(name = "Tellurium", mass = 127.60, Z = 52, symbol = 'Te')
I = dict(name = "Iodine", mass = 126.90, Z = 53, symbol = 'I')
Xe = dict(name = "Xenon", mass = 131.29, Z = 54, symbol = 'Xe')
Cs = dict(name = "Caesium", mass = 132.91, Z = 55, symbol = 'Cs')
Ba = dict(name = "Barium", mass = 137.33, Z = 56, symbol = 'Ba')
Python libraries needed to run Open Flatus
Tkinter
scipy
numpy
pylab
matlibplot
To run simply type on the terminal >> python OpenFlatus.py
function CrsSecRf(Z1, Z2: byte; Ein, M1, M2, Theta: double): double;
{****************************************************************************
Calcula a seção de choque Rutherford
----------------------------------------------------------------------------
Z1 -- número atômico do projétil
Z2 -- número atômico do alvo
Ein -- energia do projétil imediatamente antes da colisão em eV
M1 -- massa do projétil em a.m.u.
M2 -- massa do alvo em a.m.u.
****************************************************************************}
begin
if M1 < M2 then
result := sqr((Z1*Z2*e2*1e8)/Ein)/4 * power(sin(Theta),-4)
* sqr(sqrt(1 - sqr((M1/M2)*sin(Theta))) + cos(Theta))
/ sqrt(1 - sqr((M1/M2)*sin(Theta))) {angstrom^2}
else
result := 0;
end;
// ----------------------------------------------------------------------------
Calcular sc: chama a funo
get_cross_ratio(Fx.Z, Fx.M, Elem[iEl].Z, Elem[iEl].M, Fx.Q,
Fx.E/1e3/Fx.M, 2, 500, 1e-5, Sim.Amin,Rd(dA_cH),nChAn+1,
CrossR);
This diff is collapsed.
def cross():
return 1
# Versao 0.1 do Gauss usando python
# Usando classes e carregando varios arquivos
from pylab import *
from spectro import *
# Iniciando o espectro de espalhamento vazio
data=spectro_espalhamento(50000,100000,30)
# Definindo os parametros experimentais e de interacao dos ions com a materia
param = dict(dedx=287. , dW2dx=35000 , E0= 100000, Theta_in=0, Theta_out=70, fwhm0=300 )
# Adicionando os sinais correspondentes aos elementos do alvo
# ** Ainda nao considera as massas dos elementos **
#data.addelements(['distHf.dat','distO.dat'],param,0.9,'gaussiana')
data.addelements2(['profHf.dat','profO.dat'],param,0.9,'gaussiana',0.01)
#pares = array([[1,1],[3,0.5],[1,1]])
#print pares
#x,c = profile(pares, 0.1)
#print x
#print c
# Apresenta o resultado em um grafico
data.plot()
3 0.5
5 1
10 0.5
from pylab import * from pylab import *
from scipy.special import i1
from Edict import *
PI=math.pi PI=math.pi
## Primeiro defino algumas funcoes que sao usadas pela classe spectro ## funcoes usadas pela classe spectro
def gaussian(e, Em, sigma): def gaussian(e, Em, sigma):
# Funcao que retorna uma gaussiana centrada em Em e largura sigma # Funcao que retorna uma gaussiana centrada em Em e largura sigma
return exp((-(e-Em)**2)/(2.*sigma))/sqrt(2.*PI*sigma) return exp((-(e-Em)**2)/(2.*sigma))/sqrt(2.*PI*sigma)
...@@ -16,24 +18,6 @@ def modbesselp(e, param,x): ...@@ -16,24 +18,6 @@ def modbesselp(e, param,x):
lbd=m*x*alpha lbd=m*x*alpha
return (lbd*exp(-m*x-alpha*e)/(sqrt(lbd*e)))*i1(2.*sqrt(lbd*e)) return (lbd*exp(-m*x-alpha*e)/(sqrt(lbd*e)))*i1(2.*sqrt(lbd*e))
def profile(pares, passo):
# Funcao que retorna os vetores espessura e perfil de concentracao
# a partir dos pares de pontos fornecidos.
# pares deve ser uma matriz de duas colunas: [espessura, concentracao]
# Modos: degraus - distribuicao do tipo escada. Ex. [10 , 1]
# representa uma amostra com 10 angstroms de espessura
# com concentracao constante
depth = sum(pares[:,0]) # A espessura total eh a soma da primeira coluna
x = arange(0,depth, passo) # Monta o eixo X
c = [] # Inicia o vetor concentracao vazio
for i in range(len(pares)): # popula o vetor concentracao
temp = ones(pares[i][0]/passo)*pares[i][1]
c.extend(temp.tolist())
return x,c
## Definindo classe referente a objetos de espectro de espalhamento ## Definindo classe referente a objetos de espectro de espalhamento
class spectro_espalhamento: class spectro_espalhamento:
def __init__(self, Emin, Emax, EPasso): def __init__(self, Emin, Emax, EPasso):
...@@ -54,83 +38,43 @@ class spectro_espalhamento: ...@@ -54,83 +38,43 @@ class spectro_espalhamento:
def plot(self): def plot(self):
# Plota o spectro # Plota o spectro
# Ainda falta colocar os nomes nos eixos e outras descricoes
#
plot(self.e,self.Y) plot(self.e,self.Y)
suptitle('Signal received', fontsize=12)
xlabel("Enegy (eV)")
ylabel("Yield")
show() show()
def setparam (self, parametros): def setparam (self, parametros):
#Define os parametros fixos do spectro # Define os parametros fixos do spectro
# parametros eh um dicionario definido com algo como
# param = dict(dedx=287. , dW2dx=35000 , E0= 100000, Theta_in=0, Theta_out=70, fwhm0=300 )
self.E0 = parametros['E0'] self.E0 = parametros['E0']
self.dedx = parametros['dedx'] self.dedx = parametros['dedx']
self.dW2dx = parametros['dW2dx'] self.dW2dx = parametros['dW2dx']
self.Theta_in = parametros['Theta_in'] self.Theta_in = parametros['Theta_in']
self.Theta_out = parametros['Theta_out'] self.Theta_out =