Repository navigation
Expand file tree
/
Copy pathMONKEY.py
More file actions
369 lines (342 loc) · 16.9 KB
/
Copy pathMONKEY.py
File metadata and controls
369 lines (342 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# -*- coding: utf-8 -*-
from tkinter import *
from MONK import *
from tkinter.messagebox import *
from tkinter import messagebox
import warnings
import pylab
import numpy
###########################
# The material dictionary
# The key is the function name in MONK.pylab
# The value is in format of 'A, B, C'
# where A is the name of the material same as the function
# B is the wavelength in format of min-max um.
# note must not add space
# must use um as unit
# C is a general remark/ the long name of the material
###########################
# MOconst is the dictionary for wavelength-independent materials
MOconst = {Air: 'Air, wavelength-independent', BCB: 'BCB, cyclotone'}
# MOw is the dictionary for n only result, 1 input (wavelength) only
MOw = {Si:'Si, 0.400-1.200 um', AlAs: 'AlAs, 0.56-2.2 um', GaAs: 'GaAs, 1.4-11 um',\
GaAs_mIR: 'GaAs_mIR, 0.97-17 um', InAs_fIR: 'InAs_fIR, 3.7-31.3 um', InAs: 'InAs, 0.5299-1.907 um',\
InP:'InP, 0.950-10 um', GaP:'GaP, 0.800-10 um', JAW_ThermalSiO2:'JAW_ThermalSiO2, 0.3-2 um, J.A. Woolam thermal oxide model', \
FusedSiO2:'FusedSiO2, 0.3-2 um, Fused silica', IBD_Ta2O5_DJ2007: 'IBD_Ta2O5_DJ2007, 0.3-2 um, Ion-Beam Sputtered Ta2O5',\
IBD_SiO2_DJ2011:'IBD_SiO2_DJ2011, 0.3-2 um, Ion-Beam Sputtered oxide', IBD_SiN_DJ2010:'IBD_SiN_DJ2010, 0.3-2 um, Ion-Beam Sputtered nitride', \
PECVD_SiN:'PECVD_SiN, 0.3-2 um, PECVD nitride', PECVD_SiO:'PECVD_SiO, 0.3-2 um, PECVD oxide',NbO:'NbO, 0.295-2.5 um', a_Si:'a_Si, 2.254-4.959 um, amorphous silicon'}
# MOw is the dictionary for n+k result, 1 input (wavelength) only
MOwk = {AlAs_interp: 'AlAs_interp, 0.206-2.480 um', GaAs_interp: 'GaAs_interp, 0.206-2.066 um', GaSb_interp: 'GaSb_interp, 0.2066-0.8266 um'}
# MOcomplex is the dictionary for n only result, 2 inputs (component ratio, wavelength)
MOcomplex = {AlGaAs:'AlGaAs, 0.970-2.2 um, complex material', InGaAs: 'InGaAs, 0.970-1.907 um, complex material', InGaP:'InGaP, 0.950-1.907 um, complex material',\
GaAsP: 'GaAsP, 0.970-2.2 um, complex material', AlInGaAs: 'AlInGaAs, 0.900-2.100 um, x: 0.3-1.0, complex material'}
# MOcomplexk is the dictionary for n+k result, 2 inputs (component ratio, wavelength)
MOcomplexk = {AlGaAs_interp: 'AlGaAs_interp, 0.206-2.066 um, complex material'}
datapoints = 501
class MOGUI(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.parent = master
self.parent.resizable(width=False, height=False)
self.pack()
self.create_widgets()
# Create main GUI window
def create_widgets(self):
self.search_var = StringVar()
self.search_var.trace("w", lambda name, index, mode: self.update_list())
self.entry = Entry(self, textvariable=self.search_var, width=20)
self.lbox = Listbox(self, width=45, height=15)
self.entry.grid(row=0, column=0, padx=10, pady=3,columnspan=3)
self.lbox.grid(row=1, column=0, padx=10, pady=3,columnspan=3)
self.WLE = Entry(self)
self.WLE.grid(row=2, column=1)
self.WLE.insert(0,'0.670')
self.WLEunit = Label(self, text = 'µm')
self.WLEunit.grid(row=2, column=2)
self.XPE = Entry(self)
self.XPE.grid(row=3, column=1)
self.XPE.insert(0,'0.3')
self.XPEunit = Label(self, text = 'x')
self.XPEunit.grid(row=3, column=2)
self.ShowBtn = Button(self, text=' Show ', command=self.ShowNK)
self.ShowBtn.grid(row=4, column=0, padx=10, pady=3)
self.PlotBtn = Button(self, text=' Plot ', command=self.PlotNK)
self.PlotBtn.grid(row=4, column=1, padx=10, pady=3)
self.TohoBtn = Button(self, text='Export to Toho', command=self.TohoNK)
self.TohoBtn.grid(row=4, column=2, padx=10, pady=3)
# Function for updating the list/doing the search.
# It needs to be called here to populate the listbox.
self.MatDetail = Label(self, text = '')
self.MatDetail.grid(row=5, column=0, columnspan=2)
self.MatNK = Label(self, text = '')
self.MatNK.grid(row=6, column=0, columnspan=2)
self.update_list()
def update_list(self):
search_term = self.search_var.get()
lbox_list = ['Si', 'Air',
'AlAs', 'AlAs_interp', 'GaAs', 'GaAs_interp', 'GaSb_interp', 'InP',\
'GaP', 'AlGaAs', 'AlGaAs_interp', 'InGaAs', 'InGaP', 'GaAsP', 'AlInGaAs', \
'JAW_ThermalSiO2', 'FusedSiO2', \
'IBD_Ta2O5_DJ2007', 'IBD_SiO2_DJ2011', 'IBD_SiN_DJ2010', 'PECVD_SiN', 'PECVD_SiO',\
'NbO', 'a_Si', 'PR']
self.lbox.delete(0, END)
for item in lbox_list:
if search_term.lower() in item.lower():
self.lbox.insert(END, item)
def ShowNK(self):
sel = self.lbox.curselection()
if len(sel) != 1:
return
idx = int(sel[0])
text=self.lbox.get(idx)
for key, val in MOconst.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key)
return
for key, val in MOw.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
try:
self.MatNK.configure(text=key(float(self.WLE.get().strip())))
except:
messagebox.showerror('Error', 'The specified wavelength is out of the available data range. The result might be invalid. , ', detail='', type=OK)
return
for key, val in MOwk.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
try:
self.MatNK.configure(text=key(float(self.WLE.get().strip()), True))
except:
messagebox.showerror('Error', 'The specified wavelength is out of the available data range. The result might be invalid. , ', detail='', type=OK)
return
for key, val in MOcomplex.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
self.MatNK.configure(text=key(float(self.XPE.get().strip()),float(self.WLE.get().strip())))
w = filter(lambda i: issubclass(i.category, UserWarning), w)
if len(list(w)):
messagebox.showerror('Error', 'The specified wavelength or component ratio is out of the available data range. The result might be invalid. , ', detail='', type=OK)
return
for key, val in MOcomplexk.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
try:
self.MatNK.configure(text=key(float(self.XPE.get().strip()),float(self.WLE.get().strip()), True))
except:
messagebox.showerror('Error', 'The specified wavelength or component ratio is out of the available data range. The result might be invalid. , ', detail='', type=OK)
return
def PlotNK(self):
sel = self.lbox.curselection()
if len(sel) != 1:
return
idx = int(sel[0])
text=self.lbox.get(idx)
for key, val in MOconst.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key)
fig1, ax1 = pylab.subplots(nrows=1, ncols=1, sharex=True)
ax1.set_title(r'%s' % (Mat[0]))
ax1.plot(range(20), [key for i in range(20)], '-g')
ax1.set_xlabel('wavelength (um)')
ax1.set_ylabel('n value')
ax1.grid(True)
fig1.show()
pylab.show()
return
for key, val in MOw.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.WLE.get().strip())))
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
fig1, ax1 = pylab.subplots(nrows=1, ncols=1, sharex=True)
ax1.set_title(r'%s' % (Mat[0]))
xr = numpy.linspace(min,max,50)
yr = [key(i).real for i in xr]
#yi = [key(i).imag for i in xr]
ax1.plot(xr, yr, '-g', label='n value')
#ax1.plot(xr, yi, '-', label='k value')
ax1.set_xlabel('wavelength (um)')
ax1.set_ylabel('n & k value')
ax1.legend(loc='upper right')
ax1.grid(True)
fig1.show()
pylab.show()
return
for key, val in MOwk.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.WLE.get().strip()),True))
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
fig1, ax1 = pylab.subplots(nrows=1, ncols=1, sharex=True)
ax1.set_title(r'%s' % (Mat[0]))
xr = numpy.linspace(min,max,50)
yr = [key(i, True).real for i in xr]
yi = [key(i, True).imag for i in xr]
ax1.plot(xr, yr, '-g', label='n value')
ax1.plot(xr, yi, '-', label='k value')
ax1.set_xlabel('wavelength (um)')
ax1.set_ylabel('n & k value')
ax1.legend(loc='upper right')
ax1.grid(True)
fig1.show()
pylab.show()
return
for key, val in MOcomplex.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.XPE.get().strip()),float(self.WLE.get().strip())))
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
fig1, ax1 = pylab.subplots(nrows=1, ncols=1, sharex=True)
ax1.set_title(r'%s' % (Mat[0]))
xr = numpy.linspace(min,max,50)
yr = [key(float(self.XPE.get().strip()),i).real for i in xr]
#yi = [key(float(self.XPE.get().strip()),i).imag for i in xr]
ax1.plot(xr, yr, '-g', label='n value')
#ax1.plot(xr, yi, '-', label='k value')
ax1.set_xlabel('wavelength (um)')
ax1.set_ylabel('n & k value')
ax1.legend(loc='upper right')
ax1.grid(True)
fig1.show()
pylab.show()
return
for key, val in MOcomplexk.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.XPE.get().strip()),float(self.WLE.get().strip()), True))
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
fig1, ax1 = pylab.subplots(nrows=1, ncols=1, sharex=True)
ax1.set_title(r'%s' % (Mat[0]))
xr = numpy.linspace(min,max,50)
yr = [key(float(self.XPE.get().strip()),i,True).real for i in xr]
yi = [key(float(self.XPE.get().strip()),i,True).imag for i in xr]
ax1.plot(xr, yr, '-g', label='n value')
ax1.plot(xr, yi, '-', label='k value')
ax1.set_xlabel('wavelength (um)')
ax1.set_ylabel('n & k value')
ax1.legend(loc='upper right')
ax1.grid(True)
fig1.show()
pylab.show()
return
def TohoNK(self):
global datapoints
sel = self.lbox.curselection()
if len(sel) != 1:
return
idx = int(sel[0])
text=self.lbox.get(idx)
f = open(text + '.mat',"w+")
for key, val in MOconst.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key)
f.write(text + '\nnm\nNK')
xr = numpy.linspace(0,2,datapoints)
for i in xr:
f.write('\n%.2f\t%.6f\t0' %(i*1000,key))
f.close()
messagebox.showinfo("Export to Toho", "\
Toho material definition file exported! \n\
Find it in the same folder where this program is. \n\
%d datapoints used. " % datapoints)
return
for key, val in MOw.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.WLE.get().strip())))
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
f.write(text + '\nnm\nNK')
xr = numpy.linspace(min,max,datapoints)
for i in xr:
f.write('\n%.2f\t%.6f\t0' %(i*1000,key(i).real))
f.close()
messagebox.showinfo("Export to Toho", "\
Toho material definition file exported! \n\
Find it in the same folder where this program is. \n\
%d datapoints used. " % datapoints)
return
for key, val in MOwk.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.WLE.get().strip()),True))
minmax = Mat[1].split(' ')[1]
f.write(text + '\nnm\nNK')
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
xr = numpy.linspace(min,max,datapoints)
for i in xr:
f.write('\n%.2f\t%.6f\t%.10f' %(i*1000,key(i, True).real,key(i, True).imag))
f.close()
messagebox.showinfo("Export to Toho", "\
Toho material definition file exported! \n\
Find it in the same folder where this program is. \n\
%d datapoints used. " % datapoints)
return
for key, val in MOcomplex.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.XPE.get().strip()),float(self.WLE.get().strip())))
f.write(text + '\nnm\nNK')
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
xr = numpy.linspace(min,max,datapoints)
for i in xr:
f.write('\n%.2f\t%.6f\t%.10f' %(i*1000,key(float(self.XPE.get().strip()),i).real,key(float(self.XPE.get().strip()),i).imag))
f.close()
messagebox.showinfo("Export to Toho", "\
Toho material definition file exported! \n\
Find it in the same folder where this program is. \n\
%d datapoints used. " % datapoints)
return
for key, val in MOcomplexk.items():
Mat = val.split(',')
if text == Mat[0]:
self.MatDetail.configure(text=val)
self.MatNK.configure(text=key(float(self.XPE.get().strip()),float(self.WLE.get().strip()), True))
f.write(text + '\nnm\nNK')
minmax = Mat[1].split(' ')[1]
min = float(minmax.split('-')[0].strip())
max = float(minmax.split('-')[1].strip())
xr = numpy.linspace(min,max,datapoints)
for i in xr:
f.write('\n%.2f\t%.6f\t%.10f' %(i*1000,key(float(self.XPE.get().strip()),i,True).real,key(float(self.XPE.get().strip()),i,True).imag))
f.close()
messagebox.showinfo("Export to Toho", "\
Toho material definition file exported! \n\
Find it in the same folder where this program is. \n\
%d datapoints used. " % datapoints)
return
root = Tk()
root.title('MONKEY (Material Optical N & K EnquirY)')
app = MOGUI(master=root)
app.mainloop()