OpenFlatus.py 4.4 KB
Newer Older
1
2
3
# -*- coding: iso-8859-15 -*-

import Tkinter as tk
4
from Ewindow import *
5
6
from numpy import *
from spectro import *
7
import sys
8
9
10

#######################################
# Initial parameters
11
param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0., FWHM0=180.)
12
13
14
15
16
17
18
ionb = dict(Z=1, mass=1.0079)

#######################################
# Calculation callback
# Defines parameters

def init_calc():
19
    global modelvar
20
21
22
23
24
25
26
27
28
29
    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)
30
    data.sweepelements(param, str(modelvar.get()), ionb)
31
32
33
34
35
36
    data.plot()

#######################################
# Main window

root = tk.Tk()
37
root.minsize(385,260)
38
root.title('Open Flatus')
39
root.geometry('385x260+200+400')
40
41

#######################################
42
# Elements window
43

44
45
46
47
ewin = tk.Tk()
ewin.minsize(600,400)
ewin.title('Elements')
ewin.geometry('600x400+600+400')
48
49

#######################################
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Frames
MasterFrame1 = tk.Frame(root)
MasterFrame1.pack(side='left')

Label2 = tk.LabelFrame(MasterFrame1, text = 'Parameters', relief='raised', bd=2)
Label2.pack(side='top')
Label3 = tk.LabelFrame(MasterFrame1, text = 'Ion parameters', relief='raised', bd=2)
Label3.pack(side='left')
Label4 = tk.LabelFrame(root, text = 'Energy loss model', relief='raised', bd=2)
Label4.pack(side='right')

Pframel = tk.Frame(Label2)
Pframel.pack(side='left')
Pframee = tk.Frame(Label2)
Pframee.pack(side='right')

Iframel = tk.Frame(Label3, width=8)
Iframel.pack(side='left')
Iframee = tk.Frame(Label3, width=12)
Iframee.pack(side='right')
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

#######################################
# 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()
107
EntryEmax.pack()
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

#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'])
126
EntryEmin.insert(0,70000)
127
128
129
130
131
EntryEmax.insert(0,100000) 
Entryionmass.insert(0, ionb['mass'])
EntryionZ.insert(0, ionb['Z'])

#######################################
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Energy loss models

modelvar = tk.StringVar()
R1 = tk.Radiobutton(Label4, text="Gaussian", variable=modelvar, value='gaussiana')
R1.pack()
R2 = tk.Radiobutton(Label4, text="Bessel", variable=modelvar, value='bessel')
R2.pack()

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

CalcButton = tk.Button(Label4, text = 'Calculate', command = init_calc, bd=4, width=20, height=4)
CalcButton.pack()

ExitButton = tk.Button(Label4, text = 'Exit', command = sys.exit, bd=4, width=20, height=2)
ExitButton.pack(side='bottom')

#######################################
# Elements callback

ewin_build(ewin)

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

data=spectro_espalhamento(float(EntryEmin.get()),float(EntryEmax.get()),20)
data.sweepelements(param, 'bessel', ionb)
data.plot()
158
159

root.mainloop()
160
ewin.mainloop()
161
162

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