Commit 72c9a113 authored by Matheus Muller's avatar Matheus Muller Committed by Matheus Müller

Commit inical do Open Flatus

parents
from numpy import *
H = dict(name = "Hydrogen", mass = 1.0079, Z = 1, dist = zeros((50000), float), control = 0)
He = dict(name = "Helium", mass = 4.0026, Z = 2, dist = zeros((50000), float), control = 0)
Li = dict(name = "Lithium", mass = 6.941, Z = 3, dist = zeros((50000), float), control = 0)
Be = dict(name = "Beryllium", mass = 9.0122, Z = 4, dist = zeros((50000), float), control = 0)
B = dict(name = "Boron", mass = 10.811, Z = 5, dist = zeros((50000), float), control = 0)
C = dict(name = "Carbon", mass = 12.011, Z = 6, dist = zeros((50000), float), control = 0)
N = dict(name = "Nitrogen", mass = 14.007, Z = 7, dist = zeros((50000), float), control = 0)
O = dict(name = "Oxygen", mass = 15.999, Z = 8, dist = zeros((50000), float), control = 0)
F = dict(name = "Fluorine", mass = 18.998, Z = 9, dist = zeros((50000), float), control = 0)
Ne = dict(name = "Neon", mass = 20.180, Z = 10, dist = zeros((50000), float), control = 0)
Na = dict(name = "Sodium", mass = 22.990, Z = 11, dist = zeros((50000), float), control = 0)
Mg = dict(name = "Magnesium", mass = 24.305, Z = 12, dist = zeros((50000), float), control = 0)
Al = dict(name = "Aluminium", mass = 26.982, Z = 13, dist = zeros((50000), float), control = 0)
Si = dict(name = "Silicon", mass = 28.086, Z = 14, dist = zeros((50000), float), control = 0)
P = dict(name = "Phosphorus", mass = 30.974, Z = 15, dist = zeros((50000), float), control = 0)
S = dict(name = "Sulfur", mass = 32.066, Z = 16, dist = zeros((50000), float), control = 0)
Cl = dict(name = "Chlorine", mass = 35.453, Z = 17, dist = zeros((50000), float), control = 0)
Ar = dict(name = "Argon", mass = 39.948, Z = 18, dist = zeros((50000), float), control = 0)
K = dict(name = "Potassium", mass = 39.098, Z = 19, dist = zeros((50000), float), control = 0)
Ca = dict(name = "Calcium", mass = 40.078, Z = 20, dist = zeros((50000), float), control = 0)
Sc = dict(name = "Scandium", mass = 44.956, Z = 21, dist = zeros((50000), float), control = 0)
Ti = dict(name = "Titanium", mass = 47.867, Z = 22, dist = zeros((50000), float), control = 0)
V = dict(name = "Vanadium", mass = 50.942, Z = 23, dist = zeros((50000), float), control = 0)
Cr = dict(name = "Chromium", mass = 51.996, Z = 24, dist = zeros((50000), float), control = 0)
Mn = dict(name = "Manganese", mass = 54.938, Z = 25, dist = zeros((50000), float), control = 0)
Fe = dict(name = "Iron", mass = 55.845, Z = 26, dist = zeros((50000), float), control = 0)
Co = dict(name = "Cobalt", mass = 58.993, Z = 27, dist = zeros((50000), float), control = 0)
Ni = dict(name = "Nickel", mass = 58.693, Z = 28, dist = zeros((50000), float), control = 0)
Cu = dict(name = "Copper", mass = 63.546, Z = 29, dist = zeros((50000), float), control = 0)
Zn = dict(name = "Zinc", mass = 65.39, Z = 30, dist = zeros((50000), float), control = 0)
Ga = dict(name = "Gallium", mass = 69.723, Z = 31, dist = zeros((50000), float), control = 0)
Ge = dict(name = "Germanium", mass = 72.61, Z = 32, dist = zeros((50000), float), control = 0)
As = dict(name = "Arsenic", mass = 74.922, Z = 33, dist = zeros((50000), float), control = 0)
Se = dict(name = "Selenium", mass = 78.96, Z = 34, dist = zeros((50000), float), control = 0)
Br = dict(name = "Bromine", mass = 79.904, Z = 35, dist = zeros((50000), float), control = 0)
Kr = dict(name = "Krypton", mass = 83.80, Z = 36, dist = zeros((50000), float), control = 0)
Rb = dict(name = "Rubidium", mass = 85.468, Z = 37, dist = zeros((50000), float), control = 0)
Sr = dict(name = "Strontium", mass = 87.62, Z = 38, dist = zeros((50000), float), control = 0)
Y = dict(name = "Yttrium", mass = 88.906, Z = 39, dist = zeros((50000), float), control = 0)
Zr = dict(name = "Zirconium", mass = 91.224, Z = 40, dist = zeros((50000), float), control = 0)
Nb = dict(name = "Niobium", mass = 92.906, Z = 41, dist = zeros((50000), float), control = 0)
Mo = dict(name = "Molibdenium", mass = 95.94, Z = 42, dist = zeros((50000), float), control = 0)
Tc = dict(name = "Technetium", mass = 98.906, Z = 43, dist = zeros((50000), float), control = 0)
Ru = dict(name = "Ruthenium", mass = 101.07, Z = 44, dist = zeros((50000), float), control = 0)
Rh = dict(name = "Rhodium", mass = 102.91, Z = 45, dist = zeros((50000), float), control = 0)
Pd = dict(name = "Palladium", mass = 106.42, Z = 46, dist = zeros((50000), float), control = 0)
Ag = dict(name = "Silver", mass = 107.87, Z = 47, dist = zeros((50000), float), control = 0)
Cd = dict(name = "Cadmium", mass = 112.41, Z = 48, dist = zeros((50000), float), control = 0)
In = dict(name = "Indium", mass = 114.82, Z = 49, dist = zeros((50000), float), control = 0)
Sn = dict(name = "Tin", mass = 118.71, Z = 50, dist = zeros((50000), float), control = 0)
Sb = dict(name = "Antimony", mass = 121.76, Z = 51, dist = zeros((50000), float), control = 0)
Te = dict(name = "Tellurium", mass = 127.60, Z = 52, dist = zeros((50000), float), control = 0)
I = dict(name = "Iodine", mass = 126.90, Z = 53, dist = zeros((50000), float), control = 0)
Xe = dict(name = "Xenon", mass = 131.29, Z = 54, dist = zeros((50000), float), control = 0)
Cs = dict(name = "Caesium", mass = 132.91, Z = 55, dist = zeros((50000), float), control = 0)
Ba = dict(name = "Barium", mass = 137.33, Z = 56, dist = zeros((50000), float), control = 0)
import Tkinter as tk
from pylab import *
from ElementsDict import *
from subPTE import *
def plotdist(atom, button):
if atom['control']==0:
atom['control']=1
button['relief']='sunken'
print atom['control']
plot (distribution, atom['dist'])
show ()
if atom['control']==1:
atom['control']=0
button['relief']='raised'
print atom['control']
master = tk.Tk()
master.title('Periodic Table of Elements')
####################################################
q1a = lambda: plotdist(H, b1)
q1 = lambda: atomsubmenu(H, b1)
b1 = tk.Button(master, text="H", command=q1, width=1, height=1, bg='white')
b1.pack()
q2 = lambda: atomsubmenu(He, b2)
b2 = tk.Button(master, text="He", command=q2, width=1, height=1, bg='pink')
b2.pack()
q3 = lambda: atomsubmenu(Li, b3)
b3 = tk.Button(master, text="Li", command=q3, width=1, height=1, bg='yellow')
b3.pack()
q4 = lambda: atomsubmenu(Be, b4)
b4 = tk.Button(master, text="Be", command=q4, width=1, height=1, bg='brown')
b4.pack()
q5 = lambda: atomsubmenu(B, b5)
b5 = tk.Button(master, text="B", command=q5, width=1, height=1, bg='blue')
b5.pack()
q6 = lambda: atomsubmenu(C, b6)
b6 = tk.Button(master, text="C", command=q6, width=1, height=1, bg='green')
b6.pack()
q7 = lambda: atomsubmenu(N, b7)
b7 = tk.Button(master, text="N", command=q7, width=1, height=1, bg='green')
b7.pack()
q8 = lambda: atomsubmenu(O, b8)
b8 = tk.Button(master, text="O", command=q8, width=1, height=1, bg='green')
b8.pack()
q9 = lambda: atomsubmenu(F, b9)
b9 = tk.Button(master, text="F", command=q9, width=1, height=1, bg='red')
b9.pack()
q10 = lambda: atomsubmenu(Ne, b10)
b10 = tk.Button(master, text="Ne", command=q10, width=1, height=1, bg='pink')
b10.pack()
q11 = lambda: atomsubmenu(Na, b11)
b11 = tk.Button(master, text="Na", command=q11, width=1, height=1, bg='yellow')
b11.pack()
q12 = lambda: atomsubmenu(Mg, b12)
b12 = tk.Button(master, text="Mg", command=q12, width=1, height=1, bg='brown')
b12.pack()
q13 = lambda: atomsubmenu(Al, b13)
b13 = tk.Button(master, text="Al", command=q13, width=1, height=1, bg='purple')
b13.pack()
q14 = lambda: atomsubmenu(Si, b14)
b14 = tk.Button(master, text="Si", command=q14, width=1, height=1, bg='blue')
b14.pack()
q15 = lambda: atomsubmenu(P, b15)
b15 = tk.Button(master, text="P", command=q15, width=1, height=1, bg='green')
b15.pack()
q16 = lambda: atomsubmenu(S, b16)
b16 = tk.Button(master, text="S", command=q16, width=1, height=1, bg='green')
b16.pack()
q17 = lambda: atomsubmenu(Cl, b17)
b17 = tk.Button(master, text="Cl", command=q17, width=1, height=1, bg='red')
b17.pack()
q18 = lambda: atomsubmenu(Ar, b18)
b18 = tk.Button(master, text="Ar", command=q18, width=1, height=1, bg='pink')
b18.pack()
q19 = lambda: atomsubmenu(K, b19)
b19 = tk.Button(master, text="K", command=q19, width=1, height=1, bg='yellow')
b19.pack()
q20 = lambda: atomsubmenu(Ca, b20)
b20 = tk.Button(master, text="Ca", command=q20, width=1, height=1, bg='brown')
b20.pack()
q21 = lambda: atomsubmenu(Sc, b21)
b21 = tk.Button(master, text="Sc", command=q21, width=1, height=1)
b21.pack()
q22 = lambda: atomsubmenu(Ti, b22)
b22 = tk.Button(master, text="Ti", command=q22, width=1, height=1)
b22.pack()
q23 = lambda: atomsubmenu(V, b23)
b23 = tk.Button(master, text="V", command=q23, width=1, height=1)
b23.pack()
q24 = lambda: atomsubmenu(Cr, b24)
b24 = tk.Button(master, text="Cr", command=q24, width=1, height=1)
b24.pack()
q25 = lambda: atomsubmenu(Mn, b25)
b25 = tk.Button(master, text="Mn", command=q25, width=1, height=1)
b25.pack()
q26 = lambda: atomsubmenu(Fe, b26)
b26 = tk.Button(master, text="Fe", command=q26, width=1, height=1)
b26.pack()
q27 = lambda: atomsubmenu(Co, b27)
b27 = tk.Button(master, text="Co", command=q27, width=1, height=1)
b27.pack()
q28 = lambda: atomsubmenu(Ni, b28)
b28 = tk.Button(master, text="Ni", command=q28, width=1, height=1)
b28.pack()
q29 = lambda: atomsubmenu(Cu, b29)
b29 = tk.Button(master, text="Cu", command=q29, width=1, height=1)
b29.pack()
q30 = lambda: atomsubmenu(Zn, b30)
b30 = tk.Button(master, text="Zn", command=q30, width=1, height=1)
b30.pack()
q31 = lambda: atomsubmenu(Ga, b31)
b31 = tk.Button(master, text="Ga", command=q31, width=1, height=1, bg='purple')
b31.pack()
q32 = lambda: atomsubmenu(Ge, b32)
b32 = tk.Button(master, text="Ge", command=q32, width=1, height=1, bg='blue')
b32.pack()
q33 = lambda: atomsubmenu(As, b33)
b33 = tk.Button(master, text="As", command=q33, width=1, height=1, bg='blue')
b33.pack()
q34 = lambda: atomsubmenu(Se, b34)
b34 = tk.Button(master, text="Se", command=q34, width=1, height=1, bg='green')
b34.pack()
q35 = lambda: atomsubmenu(Br, b35)
b35 = tk.Button(master, text="Br", command=q35, width=1, height=1, bg='red')
b35.pack()
q36 = lambda: atomsubmenu(Kr, b36)
b36 = tk.Button(master, text="Kr", command=q36, width=1, height=1, bg='pink')
b36.pack()
q37 = lambda: atomsubmenu(Rb, b37)
b37 = tk.Button(master, text="Rb", command=q37, width=1, height=1, bg='yellow')
b37.pack()
q38 = lambda: atomsubmenu(Sr, b38)
b38 = tk.Button(master, text="Sr", command=q38, width=1, height=1, bg='brown')
b38.pack()
q39 = lambda: atomsubmenu(Y, b39)
b39 = tk.Button(master, text="Y", command=q39, width=1, height=1)
b39.pack()
q40 = lambda: atomsubmenu(Zr, b40)
b40 = tk.Button(master, text="Zr", command=q40, width=1, height=1)
b40.pack()
q41 = lambda: atomsubmenu(Nb, b41)
b41 = tk.Button(master, text="Nb", command=q41, width=1, height=1)
b41.pack()
q42 = lambda: atomsubmenu(Mo, b42)
b42 = tk.Button(master, text="Mo", command=q42, width=1, height=1)
b42.pack()
q43 = lambda: atomsubmenu(Tc, b43)
b43 = tk.Button(master, text="Tc", command=q43, width=1, height=1)
b43.pack()
q44 = lambda: atomsubmenu(Ru, b44)
b44 = tk.Button(master, text="Ru", command=q44, width=1, height=1)
b44.pack()
q45 = lambda: atomsubmenu(Rh, b45)
b45 = tk.Button(master, text="Rh", command=q45, width=1, height=1)
b45.pack()
q46 = lambda: atomsubmenu(Pd. b46)
b46 = tk.Button(master, text="Pd", command=q46, width=1, height=1)
b46.pack()
q47 = lambda: atomsubmenu(Ag, b47)
b47 = tk.Button(master, text="Ag", command=q47, width=1, height=1)
b47.pack()
q48 = lambda: atomsubmenu(Cd, b48)
b48 = tk.Button(master, text="Cd", command=q48, width=1, height=1)
b48.pack()
q49 = lambda: atomsubmenu(In, b49)
b49 = tk.Button(master, text="In", command=q49, width=1, height=1, bg='purple')
b49.pack()
q50 = lambda: atomsubmenu(Sn, b50)
b50 = tk.Button(master, text="Sn", command=q50, width=1, height=1, bg='purple')
b50.pack()
q51 = lambda: atomsubmenu(Sb, b51)
b51 = tk.Button(master, text="Sb", command=q51, width=1, height=1, bg='blue')
b51.pack()
q52 = lambda: atomsubmenu(Te, b52)
b52 = tk.Button(master, text="Te", command=q52, width=1, height=1, bg='blue')
b52.pack()
q53 = lambda: atomsubmenu(I, b53)
b53 = tk.Button(master, text="I", command=q53, width=1, height=1, bg='red')
b53.pack()
q54 = lambda: atomsubmenu(Xe, b54)
b54 = tk.Button(master, text="Xe", command=q54, width=1, height=1, bg='pink')
b54.pack()
q55 = lambda: atomsubmenu(Cs, b55)
b55 = tk.Button(master, text="Cs", command=q55, width=1, height=1, bg='yellow')
b55.pack()
q56 = lambda: atomsubmenu(Ba, b56)
b56 = tk.Button(master, text="Ba", command=q56, width=1, height=1, bg='brown')
b56.pack()
####################################################
b1.grid(row=0, column=0, padx=1, pady=1)
b2.grid(row=0, column=17, padx=1, pady=1)
b3.grid(row=1, column=0, padx=1, pady=1)
b4.grid(row=1, column=1, padx=1, pady=1)
b5.grid(row=1, column=12, padx=1, pady=1)
b6.grid(row=1, column=13, padx=1, pady=1)
b7.grid(row=1, column=14, padx=1, pady=1)
b8.grid(row=1, column=15, padx=1, pady=1)
b9.grid(row=1, column=16, padx=1, pady=1)
b10.grid(row=1, column=17, padx=1, pady=1)
b11.grid(row=2, column=0, padx=1, pady=1)
b12.grid(row=2, column=1, padx=1, pady=1)
b13.grid(row=2, column=12, padx=1, pady=1)
b14.grid(row=2, column=13, padx=1, pady=1)
b15.grid(row=2, column=14, padx=1, pady=1)
b16.grid(row=2, column=15, padx=1, pady=1)
b17.grid(row=2, column=16, padx=1, pady=1)
b18.grid(row=2, column=17, padx=1, pady=1)
b19.grid(row=3, column=0, padx=1, pady=1)
b20.grid(row=3, column=1, padx=1, pady=1)
b21.grid(row=3, column=2, padx=1, pady=1)
b22.grid(row=3, column=3, padx=1, pady=1)
b23.grid(row=3, column=4, padx=1, pady=1)
b24.grid(row=3, column=5, padx=1, pady=1)
b25.grid(row=3, column=6, padx=1, pady=1)
b26.grid(row=3, column=7, padx=1, pady=1)
b27.grid(row=3, column=8, padx=1, pady=1)
b28.grid(row=3, column=9, padx=1, pady=1)
b29.grid(row=3, column=10, padx=1, pady=1)
b30.grid(row=3, column=11, padx=1, pady=1)
b31.grid(row=3, column=12, padx=1, pady=1)
b32.grid(row=3, column=13, padx=1, pady=1)
b33.grid(row=3, column=14, padx=1, pady=1)
b34.grid(row=3, column=15, padx=1, pady=1)
b35.grid(row=3, column=16, padx=1, pady=1)
b36.grid(row=3, column=17, padx=1, pady=1)
b37.grid(row=4, column=0, padx=1, pady=1)
b38.grid(row=4, column=1, padx=1, pady=1)
b39.grid(row=4, column=2, padx=1, pady=1)
b40.grid(row=4, column=3, padx=1, pady=1)
b41.grid(row=4, column=4, padx=1, pady=1)
b42.grid(row=4, column=5, padx=1, pady=1)
b43.grid(row=4, column=6, padx=1, pady=1)
b44.grid(row=4, column=7, padx=1, pady=1)
b45.grid(row=4, column=8, padx=1, pady=1)
b46.grid(row=4, column=9, padx=1, pady=1)
b47.grid(row=4, column=10, padx=1, pady=1)
b48.grid(row=4, column=11, padx=1, pady=1)
b49.grid(row=4, column=12, padx=1, pady=1)
b50.grid(row=4, column=13, padx=1, pady=1)
b51.grid(row=4, column=14, padx=1, pady=1)
b52.grid(row=4, column=15, padx=1, pady=1)
b53.grid(row=4, column=16, padx=1, pady=1)
b54.grid(row=4, column=17, padx=1, pady=1)
b55.grid(row=5, column=0, padx=1, pady=1)
b56.grid(row=5, column=1, padx=1, pady=1)
####################################################
master.mainloop()
import pylab
from numpy import *
from scipy import *
from scipy.special import *
from matplotlib import*
x = arange(0,100,0.1)
y = i1(x)
pyplot.plot(x, y)
pyplot.show()
# 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 1
2 0.1
3 1
3 0.5
5 1
10 0.5
from pylab import *
PI=math.pi
## Primeiro defino algumas funcoes que sao usadas pela classe spectro
def gaussian(e, Em, sigma):
# Funcao que retorna uma gaussiana centrada em Em e largura sigma
return exp((-(e-Em)**2)/(2.*sigma))/sqrt(2.*PI*sigma)
def modbesselp(e, param,x):
# Funcao que retorna a perda de energia de acordo com a funcao
# modificada de bessel do primeiro tipo de ordem 1
# **** NAO FUNCIONA!! ****
alpha=2.*param['dedx']/param['dW2dx']
m = alpha * param['dedx']
lbd=m*x*alpha
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
class spectro_espalhamento:
def __init__(self, Emin, Emax, EPasso):
# Inicia o spectro no limite dado, com o passo EPasso
self.e = arange(Emin, Emax, EPasso)
self.Y= e*0.
def addbessel(self,param,peso,x):
# Adiciona uma funcao modificada de bessel do primeiro tipo:
# energia media Em, com variancia sigma com o peso dado
self.Y=self.Y+peso*modbesselp(self.e, param, x)
def addgauss(self,Em,sigma,peso):
# Adiciona uma gaussiana ao spectro:
# centrada em Em, com variancia sigma com o peso dado
self.Y=self.Y+peso*gaussian(self.e, Em, sigma)
def plot(self):
# Plota o spectro
# Ainda falta colocar os nomes nos eixos e outras descricoes
#
plot(self.e,self.Y)
show()
def setparam (self, parametros):
#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.dedx = parametros['dedx']
self.dW2dx = parametros['dW2dx']
self.Theta_in = parametros['Theta_in']
self.Theta_out = parametros['Theta_out']
self.fwhm0 = parametros['fwhm0']
self.sigma0 = pow(self.fwhm0/2.35,2.)
# self. = parametros['']
def addelements(self,arquivos, param,k,modelo):
# Adiciona ao spectro os elementos definidos nos arquivos com
# os parametros dados
# *** Eh preciso incluir o fator cinematico apropriadamente ***
# Argumentos para addelements sao:
# Lista de arquivos do tipo ['file1.dat','file2.dat']
# Parametros
# Modelo de perda de energia: 'gaussiana' ou 'bessel'
# ** Falta incluir informacoes de massa do elemento no arquivo
# ** quem sabe na primeira linha incluir numero atomico e massa
# ** e ao carregar o arquivo com np.loadtxt(), retirar estes valores
# ** dos vetores x e c
for arquivo in arquivos:
amostra = np.loadtxt(arquivo)
x=amostra[:,0]*0.01
c=amostra[:,1]*1.
self.setparam(param)
for i in x:
sigma=i*self.dW2dx*(k*k/cos(self.Theta_in*PI/180.) + 1/cos(self.Theta_out*PI/180.))+self.sigma0
Em=k*self.E0-i*self.dedx*(k/cos(self.Theta_in*PI/180.) + 1/cos(self.Theta_out*PI/180.))
if modelo == 'gaussiana':
self.addgauss(Em, sigma, c[i*100]*k)
if modelo == 'bessel':
self.addbessel(param, c[i*100]*k,x)
k=k-0.21
def addelements2(self,arquivos, param,k,modelo,passo):
# Adiciona ao spectro os elementos definidos nos arquivos com
# os parametros dados
# *** Eh preciso incluir o fator cinematico apropriadamente ***
# Argumentos para addelements sao:
# Lista de arquivos do tipo ['file1.dat','file2.dat']
# Parametros
# Modelo de perda de energia: 'gaussiana' ou 'bessel'
# ** Falta incluir informacoes de massa do elemento no arquivo
# ** quem sabe na primeira linha incluir numero atomico e massa
# ** e ao carregar o arquivo com np.loadtxt(), retirar estes valores
# ** dos vetores x e c
for arquivo in arquivos:
amostra = np.loadtxt(arquivo)
x,c = profile(amostra,passo)
self.setparam(param)
for i in x:
sigma=i*self.dW2dx*(k*k/cos(self.Theta_in*PI/180.) + 1/cos(self.Theta_out*PI/180.))+self.sigma0
Em=k*self.E0-i*self.dedx*(k/cos(self.Theta_in*PI/180.) + 1/cos(self.Theta_out*PI/180.))
if modelo == 'gaussiana':
self.addgauss(Em, sigma, c[int(i/passo)]*k)
if modelo == 'bessel':
self.addbessel(param, c[i*100]*k,x)
k=k-0.21
import Tkinter as tk
def atomsubmenu(atom, but):
sub = tk.Tk()
sub.title(atom['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 atom['control']==0:
atom['control']=1
but['relief']='sunken'
addremove['text']='Remove element'
else:
atom['control']=0
but['relief']='raised'
addremove['text']='Add element'
addremove = tk.Button(sub, width=16, bg='white', command=cmdadd, text='Add element')
addremove.pack(side='bottom')
L1 = tk.Label(sub, text = 'Mass - %f' %atom['mass']).pack()
L2 = tk.Label(sub, text = 'Z - %d' %atom['Z']).pack()
def cmdmass():
submass = tk.Tk()
submass.title('%s - Mass' %atom['name'])
def modmass():
atom['mass'] = float(E1.get())
submass.destroy()
sub.destroy()
atomsubmenu(atom, but)
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' %atom['name'])
def modz():
atom['Z'] = int(E2.get(), 10)
subz.destroy()
sub.destroy()
atomsubmenu(atom, but)
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' %atom['name'])
def modname():
atom['name'] = E3.get()
subname.destroy()
sub.destroy()
atomsubmenu(atom, but)
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 cmddraw():
print atom['mass']
def cmdnume():
print atom['name']
def cmdspecial():
print atom['Z']
edit.add_command(label='Mass', command=cmdmass)
edit.add_command(label='Name', command=cmdname)
edit.add_command(label='Z', command=cmdz)
editdist.add_command(label='Drawing', command=cmddraw)
editdist.add_command(label='Numerical', command=cmdnume)
editdist.add_command(label='Special', command=cmdspecial)
propbutton.pack()
propbutton.config(bg='white', bd=4, relief='raised')
distbutton.pack()
distbutton.config(bg='white', bd=4, relief='raised')
sub.mainloop()
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