-
I was perviously using S4 to solve my problem but now i‘m trying to use meent |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, Do you want something like 0000001111110000000 where 0 is air 1 is Si? If so, this can be done in vector modeling. import time
import torch
import meent
def modelling(rcwa_options, modeling_options, instructions):
mee = meent.call_mee(fft_type=2, **rcwa_options)
layer_info_list = []
for i, layer in enumerate(instructions):
obj_list_per_layer = []
for j, _ in enumerate(layer):
instructions_new = []
instructions_target = instructions[i][j]
for k, inst in enumerate(instructions_target):
if k == 0:
func = getattr(mee, inst)
elif inst in modeling_options:
instructions_new.append(modeling_options[inst])
else:
raise ValueError
obj_list_per_layer += func(*instructions_new)
layer_info_list.append([modeling_options[f'l{i + 1}_n_base'], obj_list_per_layer])
mee.draw(layer_info_list)
return mee, layer_info_list
def run_vector(rcwa_options):
# YX view
modeling_options = dict(
l1_n_base=1,
l1_o1_c_x=450, l1_o1_c_y=450, l1_o1_length_x=300, l1_o1_length_y=900,
l1_o1_n_index=4.97 + 1j*4.2, l1_o1_angle=0 * torch.pi / 180, l1_o1_n_split_x=0, l1_o1_n_split_y=0,
)
# instruction
instructions = [
# layer 1
[
# obj 1
['rectangle', 'l1_o1_c_x', 'l1_o1_c_y', 'l1_o1_length_x', 'l1_o1_length_y', 'l1_o1_n_index',
'l1_o1_angle', 'l1_o1_n_split_x', 'l1_o1_n_split_y'],
],
]
mee, layer_info_list = modelling(rcwa_options, modeling_options, instructions)
de_ri, de_ti = mee.conv_solve()
return de_ri, de_ti
def run_raster(rcwa_options):
ucell = torch.tensor([
[
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
],
]) * (3.97 + 1j*4.2) + 1
mee = meent.call_mee(**rcwa_options)
mee.ucell = ucell
mee.fft_type = 1 # 0: Discrete Fourier series; 1 is for Continuous FS which is used in vector modeling.
de_ri, de_ti = mee.conv_solve()
return de_ri, de_ti
if __name__ == '__main__':
rcwa_options_setting = dict(backend=2, grating_type=2, thickness=[100], period=[900, 900], fourier_order=[2, 2],
n_I=1, n_II=1, wavelength=900)
de_ri_vector, de_ti_vector = run_vector(rcwa_options_setting)
de_ri_raster, de_ti_raster = run_raster(rcwa_options_setting)
print(de_ri_vector)
print(de_ti_vector)
print(torch.norm(de_ri_vector-de_ri_raster))
print(torch.norm(de_ti_vector-de_ti_raster))
print(0) Use Units can be nm or um as long as consistent through whole input(wavelength, period, etc.). Hope this can help. |
Beta Was this translation helpful? Give feedback.
Hi,
Didn't notice this. Sorry for the late reply.
Do you want something like 0000001111110000000 where 0 is air 1 is Si?
If so, this can be done in vector modeling.