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

import Tkinter as tk
4
from Ewindow import *
Matheus Müller's avatar
Matheus Müller committed
5
from numerical import *
6
import sys
7

Matheus Müller's avatar
Matheus Müller committed
8
##############################################################################
9
# Initial parameters
Matheus Müller's avatar
Matheus Müller committed
10
param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0.) #, FWHM0=180.)
11
12
ionb = dict(Z=1, mass=1.0079)

Matheus Müller's avatar
Matheus Müller committed
13
##############################################################################
14
15
16
17
# Calculation callback
# Defines parameters

def init_calc():
18
    global modelvar
19
20
21
22
23
    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())
Matheus Müller's avatar
Matheus Müller committed
24
    #param['FWHM0'] = float(EntryFWHM0.get())
25
26
27
    ionb['mass'] = float(Entryionmass.get())
    ionb['Z'] = float(EntryionZ.get())

Matheus Müller's avatar
Matheus Müller committed
28
    spectro(param, str(modelvar.get()), ionb, float(EntryEmin.get()),float(EntryEmax.get()), float(EntryEstep.get()), float(EntryDstep.get()), int(LSvar.get()) )
29

Matheus Müller's avatar
Matheus Müller committed
30
##############################################################################
31
32
33
# Main window

root = tk.Tk()
34
root.minsize(375,270)
35
root.title('Open Flatus')
36
root.geometry('375x270+200+400')
37

Matheus Müller's avatar
Matheus Müller committed
38
##############################################################################
39
# Elements window
40

41
ewin = tk.Tk()
42
ewin.minsize(810,550)
43
44
ewin.title('Elements')
ewin.geometry('600x400+600+400')
45

Matheus Müller's avatar
Matheus Müller committed
46
##############################################################################
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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')

Matheus Müller's avatar
Matheus Müller committed
63
Iframel = tk.Frame(Label3, width=9)
64
Iframel.pack(side='left')
Matheus Müller's avatar
Matheus Müller committed
65
Iframee = tk.Frame(Label3, width=11)
66
Iframee.pack(side='right')
67

Matheus Müller's avatar
Matheus Müller committed
68
##############################################################################
69
70
# Parameters
# Labels
71
72
73
74
Labeldedx = tk.Label(Pframel, width=9, text='dƐ/dx', pady=2)
LabeldW2dx = tk.Label(Pframel, width=9, text='dω²/dx', pady=2)
LabelT_out = tk.Label(Pframel, width=9, text='θ out', pady=2)
LabelT_in = tk.Label(Pframel, width=9, text='θ in', pady=2)
Matheus Müller's avatar
Matheus Müller committed
75
#LabelFWHM0 = tk.Label(Pframel, width=9, text='FWHM0')
76
77
78
LabelEmin = tk.Label(Pframel, width=9, text='Emin', pady=2)
LabelEmax = tk.Label(Pframel, width=9, text='Emax', pady=2)
LabelEstep = tk.Label(Pframel, width=9, text='Estep', pady=2)
79
LabelDstep = tk.Label(Pframel, width=9, text='Depth step', pady=2)
80
81
82
83
Labeldedx.pack()
LabeldW2dx.pack()
LabelT_out.pack()
LabelT_in.pack()
Matheus Müller's avatar
Matheus Müller committed
84
#LabelFWHM0.pack()
85
86
LabelEmin.pack()
LabelEmax.pack()
Matheus Müller's avatar
Matheus Müller committed
87
88
LabelEstep.pack()
LabelDstep.pack()
89
90

# Entries
Matheus Müller's avatar
Matheus Müller committed
91
92
93
94
95
96
97
98
99
Entrydedx = tk.Entry(Pframee, width=11)
EntrydW2dx = tk.Entry(Pframee, width=11)
EntryT_out = tk.Entry(Pframee, width=11)
EntryT_in = tk.Entry(Pframee, width=11)
#EntryFWHM0 = tk.Entry(Pframee, width=11)
EntryEmin = tk.Entry(Pframee, width=11)
EntryEmax = tk.Entry(Pframee, width=11)
EntryEstep = tk.Entry(Pframee, width=11)
EntryDstep = tk.Entry(Pframee, width=11)
100
101
102
103
Entrydedx.pack()
EntrydW2dx.pack()
EntryT_out.pack()
EntryT_in.pack()
Matheus Müller's avatar
Matheus Müller committed
104
#EntryFWHM0.pack()
105
EntryEmin.pack()
106
EntryEmax.pack()
Matheus Müller's avatar
Matheus Müller committed
107
108
EntryEstep.pack()
EntryDstep.pack()
109
110

#Ion
Matheus Müller's avatar
Matheus Müller committed
111
112
113
114
LabelE0 = tk.Label(Iframel, width=9, text='Energy')
Labelionmass = tk.Label(Iframel, width=9, text='Mass')
LabelionZ = tk.Label(Iframel, width=9, text='Z')
LabelE0.pack()
115
116
Labelionmass.pack()
LabelionZ.pack()
Matheus Müller's avatar
Matheus Müller committed
117
118
119
120
EntryE0 = tk.Entry(Iframee, width=11)
Entryionmass = tk.Entry(Iframee, width=11)
EntryionZ = tk.Entry(Iframee, width=11)
EntryE0.pack()
121
122
123
124
125
126
127
128
129
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'])
Matheus Müller's avatar
Matheus Müller committed
130
#EntryFWHM0.insert(0,param['FWHM0'])
131
EntryEmin.insert(0,70000)
132
EntryEmax.insert(0,100000) 
Matheus Müller's avatar
Matheus Müller committed
133
134
EntryEstep.insert(0,20) 
EntryDstep.insert(0,0.01) 
135
136
137
Entryionmass.insert(0, ionb['mass'])
EntryionZ.insert(0, ionb['Z'])

Matheus Müller's avatar
Matheus Müller committed
138
##############################################################################
139
140
141
142
143
144
145
# 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()
146
R2.select()
147

Matheus Müller's avatar
Matheus Müller committed
148
149
150
151
152
153
##############################################################################
# Line shape checkbox

LSvar = tk.IntVar()
C1 = tk.Checkbutton(Label4, text="Use Line Shape", variable=LSvar)
C1.pack()
154
C1.select()
Matheus Müller's avatar
Matheus Müller committed
155
156

##############################################################################
157
158
159
160
161
162
163

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')

Matheus Müller's avatar
Matheus Müller committed
164
##############################################################################
165
166
# Elements callback

Matheus Müller's avatar
Matheus Müller committed
167
ewin_build(ewin, 15, float(EntryDstep.get()))
168

Matheus Müller's avatar
Matheus Müller committed
169
##############################################################################
170

Matheus Müller's avatar
Matheus Müller committed
171
spectro(param, 'gaussiana', ionb, float(EntryEmin.get()), float(EntryEmax.get()), float(EntryEstep.get()), float(EntryDstep.get()), int(LSvar.get()) )
172
173

root.mainloop()
174
ewin.mainloop()
175

Matheus Müller's avatar
Matheus Müller committed
176
##############################################################################