Skip to content

Commit

Permalink
Merge branch 'DEV' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghakim committed Oct 10, 2022
2 parents 59df822 + e6b6602 commit ffa5610
Show file tree
Hide file tree
Showing 14 changed files with 954 additions and 135 deletions.
42 changes: 1 addition & 41 deletions JLAB/run_metasurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,6 @@ def acs_run_reti(self):

return poi, refl, tran

def fourier_order_sweep_(self, fourier_array):

reti_r, reti_t, meent_r, meent_t = [], [], [], []

fourier_order = self.fourier_order

for f_order in fourier_array:
self.fourier_order = f_order
a = self.acs_run_reti()
b = self.acs_run_meent()

reti_r.append(a[1])
reti_t.append(a[2])
meent_r.append(b[1])
meent_t.append(b[2])

self.fourier_order = fourier_order

reti_r = np.array(reti_r)
reti_t = np.array(reti_t)
meent_r = np.array(meent_r)
meent_t = np.array(meent_t)

for i in range(3):
plt.plot(fourier_array, reti_r[:, i], marker='x')
plt.plot(fourier_array, meent_r[:, i], marker='x')
plt.title(f'reflectance, {i - 1}order')
plt.legend(['reti', ' meent'])
plt.show()

for i in range(3):
plt.plot(fourier_array, reti_t[:, i], marker='x')
plt.plot(fourier_array, meent_t[:, i], marker='x')
plt.title(f'transmittance, {i - 1}order')
plt.legend(['reti', ' meent'])
plt.show()

plt.hist(np.array([meent_r - reti_r, meent_t - reti_t]).flatten())
plt.title('histogram of errors')
plt.show()

def fourier_order_sweep(self, fourier_array):

self.reti_r, self.reti_t, self.meent_r, self.meent_t = [], [], [], []
Expand Down Expand Up @@ -218,6 +177,7 @@ def fourier_order_sweep_meent_2d(self, fourier_array):

fourier_array = [1, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180]
AA.fourier_order_sweep(fourier_array)
AA.fourier_order_sweep_plot()

# Time comparison

Expand Down
14 changes: 8 additions & 6 deletions JLAB/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
import numpy as np

from meent.on_numpy.rcwa import RCWALight as RCWA
from meent.on_numpy.convolution_matrix import put_n_ridge_in_pattern_fill_factor, to_conv_mat, find_n_index
from meent.on_numpy.convolution_matrix import to_conv_mat, find_nk_index


class JLABCode(RCWA):
def __init__(self, grating_type=0, n_I=1.45, n_II=1., theta=0, phi=0, psi=0, fourier_order=40, period=100,
wls=np.linspace(900, 900, 1), pol=1, patterns=None, ucell=None, thickness=(325,), algo='TMM'):
wls=np.linspace(900, 900, 1), pol=1, patterns=None, ucell=None, ucell_materials=None, thickness=(325,), algo='TMM'):

super().__init__(0, grating_type, n_I, n_II, theta, phi, psi, fourier_order, period, wls, pol, patterns, ucell,
ucell_materials,
thickness, algo)

def reproduce_acs_cell(self, n_ridge, n_groove):

if type(n_ridge) == str:
n_ridge = find_n_index(n_ridge, self.wls)

# self.ucell = np.array([[self.patterns]])
n_ridge = find_nk_index(n_ridge, self.mat_table, self.wls)

self.ucell = (self.ucell + 1) / 2
self.ucell = self.ucell * (n_ridge ** 2 - n_groove ** 2) + n_groove ** 2

de_ri, de_ti = self.run_ucell()
e_conv_all = to_conv_mat(self.ucell, self.fourier_order)
o_e_conv_all = to_conv_mat(1 / self.ucell, self.fourier_order)

de_ri, de_ti = self.solve(self.wls, e_conv_all, o_e_conv_all)

if self.grating_type == 0:
center = de_ti.shape[0] // 2
Expand Down
6 changes: 3 additions & 3 deletions benchmark/interface/Reticolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from meent.on_numpy.convolution_matrix import find_n_index
from meent.on_numpy.convolution_matrix import find_nk_index

try:
import matlab.engine
Expand Down Expand Up @@ -68,7 +68,7 @@ def run(self):

def run_acs(self, pattern, n_si='SILICON'):
if type(n_si) == str and n_si.upper() == 'SILICON':
n_si = find_n_index(n_si, self.wls)
n_si = find_nk_index(n_si, self.mat_table, self.wls)

abseff, effi_r, effi_t = self.eng.Eval_Eff_1D(pattern, self.wls, self.deflected_angle, self.fourier_order,
self.n_I, self.n_II, self.thickness, self.theta, n_si, nout=3)
Expand All @@ -83,7 +83,7 @@ def run_acs_loop_wavelength(self, pattern, deflected_angle, wls=None, n_si='SILI
self.wls = wls # TODO: handle better.

if type(n_si) == str and n_si.upper() == 'SILICON':
n_si = find_n_index(n_si, self.wls)
n_si = find_nk_index(n_si, self.mat_table, self.wls)

self.init_spectrum_array()

Expand Down
23 changes: 12 additions & 11 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Examples

## Homogenous layer

### 1. single layer

#### 1. single layer with fill_factor in 1D

#### 2. single layer with cell pattern in 1D

## 2. 1-dimensional grating
## 3. 1-dimensional grating with conical mounting
## 4. 2-dimensional grating
ex1
---
generates reflected and transmitted spectra from grating
structure generated by 'fill factor' method.
This will be deprecated and replaced by 'unit cell' method.

ex2
---
generates reflected and transmitted spectra from grating
structure generated by 'unit cell' method. With this method,
user can design any pattern.

8 changes: 5 additions & 3 deletions examples/ex2_ucell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import time

import matplotlib.pyplot as plt
import numpy as np

from meent.on_numpy.rcwa import RCWALight as RCWA
from meent.rcwa import call_solver, sweep_wavelength


Expand Down Expand Up @@ -41,7 +42,7 @@
],
])

ucell_materials = ['SILICON', 1]
ucell_materials = ['Si__real', 1]

AA = call_solver(mode=0, grating_type=grating_type, pol=pol, n_I=n_I, n_II=n_II, theta=theta, phi=phi, psi=psi,
fourier_order=fourier_order, wls=wls, period=period, ucell=ucell, ucell_materials=ucell_materials,
Expand All @@ -54,4 +55,5 @@
a, b = sweep_wavelength(wls, mode=0, grating_type=grating_type, pol=pol, n_I=n_I, n_II=n_II, theta=theta, phi=phi, psi=psi,
fourier_order=fourier_order, period=period, ucell=ucell, ucell_materials=ucell_materials, thickness=thickness)

print(a)
plt.plot(wls, a.sum((1, 2)), wls, b.sum((1, 2)))
plt.show()
58 changes: 58 additions & 0 deletions examples/ex3_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import time

import matplotlib.pyplot as plt
import numpy as np

from meent.rcwa import call_solver, sweep_wavelength


grating_type = 2 # 0: 1D, 1: 1D conical, 2:2D.
pol = 1 # 0: TE, 1: TM

n_I = 1 # n_incidence
n_II = 1 # n_transmission

theta = 0 # in degree, notation from Moharam paper
phi = 0 # in degree, notation from Moharam paper
psi = 0 if pol else 90 # in degree, notation from Moharam paper

wls = np.linspace(900, 900, 1) # wavelength

period = [700, 700]
fourier_order = 2

thickness = [460, 660]

ucell_x, ucell_y = 100, 100

ucell = np.zeros((2, ucell_x, ucell_y), dtype=int)

x = np.arange(ucell_x) - ucell_x // 2
y = np.arange(ucell_y) - ucell_y // 2

hole = x**2 + y[:, None]**2 < 20 ** 2
ucell[0, hole] = 1

hole = x**2 + y[:, None]**2 < 15 ** 2
ucell[1, hole] = 1

plt.imshow(ucell[0])
plt.show()
plt.imshow(ucell[1])
plt.show()

ucell_materials = [1, 'p_si', 'p_si__real']

AA = call_solver(mode=0, grating_type=grating_type, pol=pol, n_I=n_I, n_II=n_II, theta=theta, phi=phi, psi=psi,
fourier_order=fourier_order, wls=wls, period=period, ucell=ucell, ucell_materials=ucell_materials,
thickness=thickness)
de_ri, de_ti = AA.run_ucell()
print(de_ri, de_ti)

wls = np.linspace(500, 1000, 10)

de_ri, de_ti = sweep_wavelength(wls, mode=0, grating_type=grating_type, pol=pol, n_I=n_I, n_II=n_II, theta=theta, phi=phi, psi=psi,
fourier_order=fourier_order, period=period, ucell=ucell, ucell_materials=ucell_materials, thickness=thickness)

plt.plot(wls, de_ri.sum((1, 2)), wls, de_ti.sum((1, 2)))
plt.show()
57 changes: 57 additions & 0 deletions meent/nk_data/filmetrics/Al2O3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Wavelength(nm) n k
206.64 1.83 0
210.14 1.83 0
213.77 1.83 0
217.52 1.83 0
221.4 1.83 0
225.43 1.83 0
229.6 1.83 0
233.93 1.83 0
238.43 1.83 0
243.11 1.83 0
247.97 1.83 0
253.03 1.83 0
258.3 1.83 0
263.8 1.83 0
269.53 1.83 0
275.52 1.83 0
281.78 1.82 0
288.34 1.82 0
295.2 1.82 0
302.4 1.81 0
309.96 1.81 0
317.91 1.81 0
326.28 1.8 0
335.1 1.8 0
344.4 1.8 0
354.24 1.8 0
364.66 1.79 0
375.71 1.79 0
387.45 1.79 0
399.95 1.79 0
413.28 1.78 0
427.54 1.78 0
442.8 1.78 0
459.2 1.78 0
476.87 1.78 0
495.94 1.78 0
516.6 1.77 0
539.07 1.77 0
563.57 1.77 0
590.41 1.77 0
619.93 1.77 0
652.55 1.77 0
688.81 1.76 0
729.32 1.76 0
774.91 1.76 0
826.57 1.76 0
885.61 1.76 0
953.73 1.76 0
1033.21 1.75 0
1127.14 1.75 0
1239.85 1.75 0
1377.61 1.75 0
1549.81 1.75 0
1771.22 1.74 0
2066.42 1.74 0
2479.7 1.73 0
Loading

0 comments on commit ffa5610

Please sign in to comment.