calculation.py 12.8 KB
Newer Older
Lucas Laplanche's avatar
Lucas Laplanche committed
1
import numpy as np
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
2
import pandas as pd
3
from scipy.interpolate import splrep, splev
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
4
from tqdm import tqdm
Lucas Laplanche's avatar
Lucas Laplanche committed
5
6


7
import epitaxy as epx
Lucas Laplanche's avatar
Lucas Laplanche committed
8
9
10
import oes as oe
import optic as op
import pandas_tools as pt
11
import plot as plt
Lucas Laplanche's avatar
Lucas Laplanche committed
12
import quantum as qt
13
import scipy.io
Lucas Laplanche's avatar
Lucas Laplanche committed
14
import super_lattice_structure as st
15
import vertex_70 as vtx
Lucas Laplanche's avatar
piou  
Lucas Laplanche committed
16
17
18
19




Lucas Laplanche's avatar
Lucas Laplanche committed
20
def refra_doping(bypass_dbr=True, electric_field=0., wavelength=850e-9):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
21
    sl = st.structure_eam_vcsel(eam_only=True, bypass_dbr=bypass_dbr)
Lucas Laplanche's avatar
Lucas Laplanche committed
22
    sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength)
23
    plt.plot_refra_doping(sl)
Lucas Laplanche's avatar
Lucas Laplanche committed
24
25


Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
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
def dbr_refra_doping(electric_field=0., wavelength=850e-9):
    sl = pd.DataFrame(columns = ['name', 'thickness', 'al', 'na', 'nd', 'refractive_index', 'ga6', 'ga11', 'al5', 'al12'])

    sl = sl.append(pd.DataFrame([['air', 1000e-9, 0., 0., 0., False, False, False, False]],
                                columns=['name', 'thickness', 'al', 'na', 'nd', 'ga6', 'ga11', 'al5', 'al12']),
                   ignore_index=True)



    l_dbr_low_al = 850e-9 / (4 * op.algaas_refractive_index(0.15, 0., 850e-9))
    l_dbr_high_al = 850e-9 / (4 * op.algaas_refractive_index(0.9, 0., 850e-9))
    sl = sl.append(st.structure_dbr(period=20,
                          grading_type='linear slope',
                          l_dbr_low_al=l_dbr_low_al,
                          l_dbr_high_al=l_dbr_high_al))

    sl = sl.append(pd.DataFrame([['substrate', 600e-6, 0., 0., 0., False, False, False, False]],
                                columns=['name', 'thickness', 'al', 'na', 'nd', 'ga6', 'ga11', 'al5', 'al12']),
                   ignore_index=True)

    sl = op.algaas_super_lattice_refractive_index(sl, electric_field, 850e-9, lengyel=True)

    plt.plot_refra_doping(sl)


Lucas Laplanche's avatar
Lucas Laplanche committed
51
def al_doping(bypass_dbr=True):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
52
    sl = st.structure_eam_vcsel(eam_only=True, bypass_dbr=bypass_dbr)
53
    plt.plot_al_doping(sl)
Lucas Laplanche's avatar
Lucas Laplanche committed
54
55
56
57




Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
58
59
60
def reflectivity(bypass_dbr=False,
                 start_wavelength=840e-9,
                 stop_wavelength=860e-9,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
61
                 electric_field=0.,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
62
63
                 n_points=100,
                 l_eam_clad=15e-9,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
64
                 l_vcsel_clad=15e-9,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
65
66
67
68
69
70
71
                 plot=True):
    wavelength = np.linspace(start_wavelength, stop_wavelength, num=n_points)
    r = np.zeros(len(wavelength))

    # wavelength in [m]
    # wavelength must be a numpy array
    for i in tqdm(range(len(wavelength))):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
72
73
74
        sl = st.structure_eam_vcsel(bypass_dbr=bypass_dbr, vcsel_only=True, grading_type='none', mqw_alloy_type='none',
                                    l_eam_clad=l_eam_clad, l_vcsel_clad=l_vcsel_clad)

Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
75
76
77
78
79
80
81
82
83
84
        sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength[i], lengyel=True)

        n = sl['refractive_index'].to_numpy(dtype=np.complex128)
        d = sl['thickness'].to_numpy(dtype=float)

        r[i] = op.reflection(n, d, wavelength[i])

    if plot:
        plt.plot_reflectivity(wavelength, r)
    else:
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
85
        return r
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
86
87
88
89


def dbr_reflectivity(start_wavelength=700e-9,
                 stop_wavelength=1000e-9,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
90
91
                 electric_field=0.,
                 n_points=100,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
92
                 plot=True):
Lucas Laplanche's avatar
Lucas Laplanche committed
93
    wavelength = np.linspace(start_wavelength, stop_wavelength, num=n_points)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
94
95
96
97
98
    r = np.zeros(len(wavelength))

    # wavelength in [m]
    # wavelength must be a numpy array
    for i in tqdm(range(len(wavelength))):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
99
        sl = st.structure_dbr(period=20, grading_type = 'linear slope')
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
100
101
102
103
104
105
106
107
108
109
110
        sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength[i], lengyel=True)

        n = sl['refractive_index'].to_numpy(dtype=np.complex128)
        d = sl['thickness'].to_numpy(dtype=float)

        r[i] = op.reflection(n, d, wavelength[i])

    if plot:
        plt.plot_reflectivity(wavelength, r)
    else:
        return
Lucas Laplanche's avatar
Lucas Laplanche committed
111
112


113
114
115
116
117
118
119
120
121
122
def reflectivity_heatmap(bypass_dbr=True,
                         start_wavelength=700e-9,
                         stop_wavelength=1000e-9,
                         electric_field=0.,
                         n_wavelength=90,
                         n_time=160,
                         v_ga6=100,
                         v_ga11=850,
                         v_al5=900,
                         v_al12=150,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
123
                         r_file_name='heatmap_r'):
124
125
126
127
128
129
130
131
132
133
134
    time, wavelength, r = epx.reflectivity_heatmap(bypass_dbr=bypass_dbr,
                                                   start_wavelength=start_wavelength,
                                                   stop_wavelength=stop_wavelength,
                                                   electric_field=electric_field,
                                                   n_wavelength=n_wavelength,
                                                   n_time=n_time,
                                                   v_ga6=v_ga6,
                                                   v_ga11=v_ga11,
                                                   v_al5=v_al5,
                                                   v_al12=v_al12)
    np.savez_compressed(r_file_name, r)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
135
136
    np.savez_compressed('heatmap_time', time)
    np.savez_compressed('heatmap_wavelength', wavelength)
137
138
139
    plt.plot_reflectivity_heatmap(time, wavelength, r)


Lucas Laplanche's avatar
Lucas Laplanche committed
140
141


Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
142
def electromagnetic_amplitude(bypass_dbr=False, electric_field=0., wavelength=850e-9, algo='transmission'):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
143
    l_eam_clad = 15e-9
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
144
    l_vcsel_clad = 15e-9
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
145
    sl = st.structure_eam_vcsel(bypass_dbr=bypass_dbr, vcsel_only=True, grading_type='none', mqw_alloy_type='none', l_eam_clad = l_eam_clad, l_vcsel_clad=l_vcsel_clad)
Lucas Laplanche's avatar
Lucas Laplanche committed
146
    sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
147
148
149
150
151
152
153
154
155
156
157
158
159
    sl = pt.cut_in_equal_layers_thickness(sl, 1e-8)

    # scattering matrix or transmission matrix for transfer method
    if 'scattering' in algo:
        em = op.em_amplitude_smm(sl, wavelength)
    elif 'transmission' in algo:
        em = op.em_amplitude_tmm(sl, wavelength)
    elif 'potato' in algo:
        em = op.em_amplitude_potato(sl, wavelength)
    else:
        em = op.em_amplitude_tmm(sl, wavelength)

    # insert the electromagnetic amplitude within the super lattice
160
    sl.insert(sl.shape[1], 'electromagnetic_amplitude', value=em)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
161
    plt.plot_refra_em(sl, ' - eam_clad=' +str(l_eam_clad) +' - alox_end=55nm - vcsel_clad=' +str(l_vcsel_clad))
Lucas Laplanche's avatar
Lucas Laplanche committed
162
163


Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
164
def vcsel_electromagnetic_resonnance(electric_field=0.,
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
165
166
167
                                     start_wavelength=845e-9,
                                     stop_wavelength=855e-9,
                                     n_points=100):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
168
169
170
171
    wavelength = np.linspace(start_wavelength, stop_wavelength, num=n_points)
    max_em_amp = np.zeros(n_points)

    for i in tqdm(range(len(wavelength))):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
172
        sl = st.structure_eam_vcsel(grading_type='linear slope', mqw_alloy_type='mean', l_eam_clad = 15.5e-9, l_vcsel_clad=8.5e-9)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
173
174
175
176
177
178
179
180
181
182
183
184
185
        sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength[i], lengyel=False)
        sl['refractive_index'] = sl['refractive_index'].apply(np.real).astype(float)
        sl = pt.cut_in_equal_layers_thickness(sl, 1e-8)
        em = op.em_amplitude_smm(sl, wavelength[i], normalize=False)
        max_em_amp[i] = np.max(em)

    # normalize
    max_em_amp = max_em_amp / np.max(max_em_amp)

    np.savez_compressed('max_vcsel_em_amp_' +str(n_points) +'_pts', max_em_amp)
    plt.plot_xy(wavelength, max_em_amp)


Lucas Laplanche's avatar
Lucas Laplanche committed
186
def clad_coupling_electromagnetic_amplitude(bypass_dbr=False, electric_field=0., wavelength=850e-9):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
187
188
189
    sl1 = st.structure_eam_vcsel(bypass_dbr=bypass_dbr, grading_type='linear slope', mqw_alloy_type='mean', l_eam_clad = 1e-9, l_vcsel_clad=8.5e-9)
    sl2 = st.structure_eam_vcsel(bypass_dbr=bypass_dbr, grading_type='linear slope', mqw_alloy_type='mean', l_eam_clad = 5e-9, l_vcsel_clad=8.5e-9)
    sl3 = st.structure_eam_vcsel(bypass_dbr=bypass_dbr, grading_type='linear slope', mqw_alloy_type='mean', l_eam_clad = 10e-9, l_vcsel_clad=8.5e-9)
Lucas Laplanche's avatar
Lucas Laplanche committed
190
191
192
193
194

    sl1 = op.algaas_super_lattice_refractive_index(sl1, electric_field, wavelength)
    sl2 = op.algaas_super_lattice_refractive_index(sl2, electric_field, wavelength)
    sl3 = op.algaas_super_lattice_refractive_index(sl3, electric_field, wavelength)

Lucas Laplanche's avatar
Lucas Laplanche committed
195
196
197
    sl1 = pt.cut_in_equal_layers_thickness(sl1, 1e-8)
    sl2 = pt.cut_in_equal_layers_thickness(sl2, 1e-8)
    sl3 = pt.cut_in_equal_layers_thickness(sl3, 1e-8)
Lucas Laplanche's avatar
Lucas Laplanche committed
198

Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
199
    #sl1 = sl1[::-1].reset_index(drop=True)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
200
    #sl2 = sl2[::-1].reset_index(drop=True)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
201
202
    #sl3 = sl3[::-1].reset_index(drop=True)

Lucas Laplanche's avatar
Lucas Laplanche committed
203
204
205
206
207
208
209
210
    em1 = op.em_amplitude_smm(sl1, wavelength)
    em2 = op.em_amplitude_smm(sl2, wavelength)
    em3 = op.em_amplitude_smm(sl3, wavelength)

    sl1.insert(sl1.shape[1], 'electromagnetic_amplitude', value=em1)
    sl2.insert(sl2.shape[1], 'electromagnetic_amplitude', value=em2)
    sl3.insert(sl3.shape[1], 'electromagnetic_amplitude', value=em3)

Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
211
    #sl1 = sl1[::-1].reset_index(drop=True)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
212
    #sl2 = sl2[::-1].reset_index(drop=True)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
213
214
    #sl3 = sl3[::-1].reset_index(drop=True)

Lucas Laplanche's avatar
Lucas Laplanche committed
215
    plt.plot_refra_clad_coupling_em(sl1, sl2, sl3)
216
217


Lucas Laplanche's avatar
Lucas Laplanche committed
218
def animation_clad_coupling(bypass_dbr=False, electric_field=0., wavelength=850e-9):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
219
    cladding = np.linspace(9.9e-9, 10.1e-9, 9)
Lucas Laplanche's avatar
Lucas Laplanche committed
220
221

    for cl in cladding:
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
222
223
224
        sl = st.structure_eam_vcsel(bypass_dbr=bypass_dbr, vcsel_only=True, grading_type='none', mqw_alloy_type='none', l_vcsel_clad=cl)
        sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength)
        sl = pt.cut_in_equal_layers_thickness(sl, 5e-9)
Lucas Laplanche's avatar
Lucas Laplanche committed
225
226
        em = op.em_amplitude_smm(sl, wavelength)
        sl.insert(sl.shape[1], 'electromagnetic_amplitude', value=em)
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
227
        plt.plot_refra_em(sl, str(cl))
Lucas Laplanche's avatar
Lucas Laplanche committed
228
229


Lucas Laplanche's avatar
Lucas Laplanche committed
230
231
232
def zandberg_electromagnetic_amplitude(electric_field=0., wavelength=1e-6):
    sl = st.structure_zandbergen()
    sl = op.algaas_super_lattice_refractive_index(sl, electric_field, wavelength)
233
    sl = pt.cut_in_equal_layers_thickness(sl, 1e-9)
234
235
    em = op.em_amplitude_smm(sl, wavelength)
    sl.insert(sl.shape[1], 'electromagnetic_amplitude', value=em)
236
    plt.plot_refra_em(sl)
Lucas Laplanche's avatar
Lucas Laplanche committed
237
238
239
240




Lucas Laplanche's avatar
Lucas Laplanche committed
241
def ftir_reflectivity(filename='eam_2', document_folder=True, linux=True):
242
    # import data
Lucas Laplanche's avatar
Lucas Laplanche committed
243
    wavelength, r = vtx.import_vertex_70_data(filename, document_folder=document_folder, linux=linux)
244
245
246
247
248
249
250

    # smooth the curve (I know it is cheating but ftir currently is out of service, so data is disgusting)
    bspl = splrep(wavelength, r, s=4.5)
    r = splev(wavelength, bspl)

    #  correct data
    r_max = np.max(r)
Lucas Laplanche's avatar
Lucas Laplanche committed
251
    r = r * 0.96 / r_max
252
253
254
255
256

    # plot
    plt.plot_reflectivity(wavelength, r)


257
def ftir_theory_comparison_reflectivity(filename='eam_2', electric_field=0., document_folder=True, linux=True):
258
    # import data
259
    wavelength, r = vtx.import_vertex_70_data(filename, document_folder=document_folder, linux=linux)
260
261

    # smooth the curve (I know it is cheating but ftir currently is out of service, so data is disgusting)
262
    bspl = splrep(wavelength, r, s=5)
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
    r = splev(wavelength, bspl)

    #  correct data
    r_max = np.max(r)
    r = r * 0.99 / r_max

    # get index of 750nm and 950nm
    idx_750 = np.abs(wavelength -750e-9).argmin()
    idx_950 = np.abs(wavelength -950e-9).argmin()

    # slice the arrays
    r = r[idx_750:idx_950]
    wavelength = wavelength[idx_750:idx_950]

    # calculate the theorical reflectivity according
    wavelength_theory = np.linspace(750e-9, 950e-9, num=500)

    if 'eam_2' in filename:
        r_theory = op.reflectivity(True, electric_field, wavelength_theory)
    else:
        r_theory = op.reflectivity(False, electric_field, wavelength_theory)

    # plot
    plt.plot_mult_reflectivity(wavelength, r, wavelength_theory, r_theory)


289
290


Lucas Laplanche's avatar
Lucas Laplanche committed
291
def mqw_psi(lz=0.01e-9, electric_field=0., wavelength=850e-9):
Lucas Laplanche's avatar
maj    
Lucas Laplanche committed
292
    sl = st.structure_eam_vcsel(eam_mqw_only=True, amount_eam_qw=5)
Lucas Laplanche's avatar
Lucas Laplanche committed
293
    sl = pt.cut_in_equal_layers_thickness(sl, lz)
294
    v_e, v_hh, eig_e, psi_e, eig_hh, psi_hh = qt.solve_schrodinger(sl)
295
296
297
    np.savez_compressed('v_e', v_e)
    np.savez_compressed('v_hh', v_hh)
    np.savez_compressed('eig_e', eig_e)
298
    np.savez_compressed('psi_e', psi_e[0, :])
299
300
    np.savez_compressed('eig_hh', eig_hh)
    np.savez_compressed('psi_hh', psi_hh[0, :])
301
    plt.plot_psie()
Lucas Laplanche's avatar
roucoul    
Lucas Laplanche committed
302
303


304
305
def benchmark_refractive_index():
    al = np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
Lucas Laplanche's avatar
Lucas Laplanche committed
306
    wavelength = np.arange(500e-9, 1500e-9, 1e-9)
307
    indices_array = np.empty([al.size, wavelength.size])
308

309
    for x in range(al.size):
310
311
312
        n = np.array([])

        for w in wavelength:
313
            n = np.append(n, op.afromovitz_varshni_real_algaas_refractive_index(al[x], w))
314

315
316
        indices_array[x] = n
        name = 'indices_array_' +str(x) +'.mat'
317
318
319
320
321
322
323
        scipy.io.savemat(name, mdict={'arr': n})

    name = 'al_array.mat'
    scipy.io.savemat(name, mdict={'arr': al})
    name = 'wavelength_array.mat'
    scipy.io.savemat(name, mdict={'arr': wavelength})

324
325
    plt.plot_refra_bench(al, wavelength, indices_array)

326

Lucas Laplanche's avatar
roucoul    
Lucas Laplanche committed
327
328


Lucas Laplanche's avatar
Lucas Laplanche committed
329
def oes_test():
Lucas Laplanche's avatar
roucoul    
Lucas Laplanche committed
330
331
332
333
    time, wavelength, peaks, data_mean_sample, data_empty, data_diff = oe.import_data_march_2021()
    data_mean_sample = oe.temporal_mean(data_mean_sample)
    data_empty = oe.temporal_mean(data_empty)
    data_diff = oe.temporal_mean(data_diff)
334
335
    plt.plot_eos_spectrum_gold_plate(wavelength, data_mean_sample, data_empty, data_diff)