BYUCamachoLab / emepy

https://emepy.rtfd.io
MIT License
33 stars 8 forks source link

Why does the number of mesh affect the propagation so much? #33

Open 694856790 opened 1 year ago

694856790 commented 1 year ago

@hammy4815 Hello, under your guidance, I tried to modify the limit of removing spurious modes, and found that the propagation result with this limit is more correct, spurious modes has a great influence on the calculation result. Later, when I tried to propagate the fundamental TM mode of the waveguide, I discovered a new problem, the number of mesh has a considerable effect on electric field intensity distribution. As shown in the attached picture, the mesh numbers from left to right are 200, 201, and 401, but their electric field intensity distributions look so different, what do you think is the reason for this? Here are my files. Thank you! :) image image image

test-propagate.zip

694856790 commented 1 year ago

Not only that, there is a problem with the S parameter calculated in the above file. The calculated S parameter of the fundamental TE mode at the input port relative to the fundamental TE mode at the output port is about 0.99, which is similar to the results of Lumerical FDTD and EME calculations; The S parameter value of the fundamental TE mode at the input port relative to the fundamental TE mode at the output port is about 0.72, but the results calculated by FDTD and EME are 0.413 and 0.448 respectively. image

hammy4815 commented 1 year ago

Hi @694856790,

It's possible there is a bug, but at first glance I predict the results you've found are both related to mesh density for this particular device. Because you are defining your own field profile and not using the build in waveguide support, the subpixel smoothing routine in EMEPy is not applied. Thus, when you have multiple devices in one index profile like you do here, varying the mesh has more significant impact on the simulation results. 200 points without sub pixel does not seem like enough for this device. 400 is more reasonable, but I would still try for a bit more. I predict a mesh convergence analysis might help here.

Although looking at your field profiles from the monitors, the discontinuity is a little strange. These double waveguide profiles require more modes to accurately capture coupling correctly. I wonder if this is related to the results being shown. This would make more sense for the S parameter discrepancy. I will spend some time playing with the script and seeing if I can realize what is happening for sure. If there is a bug for some reason I will try to address it immediately. Thanks!

hammy4815 commented 1 year ago

Not only that, there is a problem with the S parameter calculated in the above file. The calculated S parameter of the fundamental TE mode at the input port relative to the fundamental TE mode at the output port is about 0.99, which is similar to the results of Lumerical FDTD and EME calculations; The S parameter value of the fundamental TE mode at the input port relative to the fundamental TE mode at the output port is about 0.72, but the results calculated by FDTD and EME are 0.413 and 0.448 respectively. image

Hi @694856790, forgot to ask, were you looking at the mode S-matrix or the user S-matrix in Lumerical EME and also how many modes did you use in Lumerical EME?

694856790 commented 1 year ago

Not only that, there is a problem with the S parameter calculated in the above file. The calculated S parameter of the fundamental TE mode at the input port relative to the fundamental TE mode at the output port is about 0.99, which is similar to the results of Lumerical FDTD and EME calculations; The S parameter value of the fundamental TE mode at the input port relative to the fundamental TE mode at the output port is about 0.72, but the results calculated by FDTD and EME are 0.413 and 0.448 respectively. image

Hi @694856790, forgot to ask, were you looking at the mode S-matrix or the user S-matrix in Lumerical EME and also how many modes did you use in Lumerical EME?

@hammy4815 1.user S-matrix. 2. 10 modes.

hammy4815 commented 1 year ago

Hi @694856790,

Are you by chance looking at $|S|^2$? I just ran with 600 mesh points, and the following mode counts {layer1: 3, layer2: 6, layer3: 3}. Doing so, the field profiles look as expected for TM input:

Screen Shot 2022-09-28 at 10 23 14 AM

Screen Shot 2022-09-28 at 9 44 02 AM

And I get the following |S|^2 with TE0->TE0 and TM0->TM0 ports bolded:

[[[2.62493779e-09 5.44657341e-24 6.85672510e-07 9.96389500e-01 2.07094093e-24 4.75517247e-05] [3.80236904e-22 3.34621784e-06 1.43002743e-18 7.57896445e-25 4.52985589e-01 1.60441137e-18] [1.31079021e-07 6.07983312e-20 3.12673395e-07 4.74189454e-05 1.43137010e-18 1.79294471e-01] [9.96389500e-01 6.24489188e-25 4.75527300e-05 2.62485364e-09 4.91936833e-24 6.85563635e-07] [3.78710435e-24 4.52985589e-01 1.43587300e-18 3.50752210e-22 3.34621784e-06 1.69156057e-18] [4.74179389e-05 1.60077790e-18 1.79294471e-01 1.31058711e-07 4.12749527e-20 3.12674347e-07]]]

These numbers seem consistent with the results you sent from Lumerical. Let me know if I am missing anything. Note I got this matrix above using

print(np.abs(eme.s_parameters())**2)