jonfanlab / Metagrating-Topology-Optimization

50 stars 25 forks source link

Questions #2

Closed EvanSimmonsUML closed 2 years ago

EvanSimmonsUML commented 2 years ago

Hi,

I am trying to recreate the simulation performed in the Nano-Letters paper that uses a 75 degree output transmission mode grating for the first diffractive order.

Paper: Large-Angle, Multifunctional Metagratings Based on Freeform Multimode Geometries

On occasion, I do run in to an issue in the Reticolo solver where the solver exceeds the dimensions of the matrix "uuu". Is this an error you have seen before? I can try recreating the issue and providing more detail.

I was curious, do you know the parameters (periodicity, structure height) that go into this model? Thank you for this code!

evanwang13 commented 2 years ago

Hello,

For that particular structure, 75 degree deflection at 1050nm wavelength, the period in the x-direction can be calculated as 1050/sin(75) = 1087nm. The period in the y-direction is set to be 525nm. The device layer thickness is 325nm.

As for the issue with the solver, I cannot say what is causing that without more information.

Cheers, Evan

EvanSimmonsUML commented 2 years ago

temp

Thank you for the prompt reply!

So, here is the error I have using v8 of reticolo (I've tried v9 too). I have my period as Period=[1087,525] with a 75 degree deflection error and a device height of 325nm. I have the robustness set to the standard of [-5nm 0 5nm] and weights [0.5 1 0.5] and haven't changed anything in the Initalize() function. I have increased the Fourier Orders to [20 20] thinking that that would get me towards the device in the paper.

I can send my version of the code (only the files where I've made changes) if you'd like to see that. I am not sure what I am doing wrong. Thank you again!

huangtingying commented 2 years ago

Hello, I had the same problem as Evan when trying to reproduce this model, the solver I used was reticolo_v9, and the rest of the parameters were the same as given in the source code.

After 214 iterations of topology optimization, an error is reported. When matlab reports an error, it shows that the index at position 2 exceeds the bounds of the array (can not exceed 28).

I checked and found that there is a problem with the retu.m file in reticolo_v9. Line 344 of the source code retu.m shows that Iy exceeds 28. I want to reproduce the model given in the paper, but I can't solve this problem,

Did you encounter this problem when writing code? How did you solve it? thank you very much

paper: Large-Angle, Multifunctional Metagratings Based on Freeform Multimode Geometrie

ZRTS`J5A 12 C9URD@ T A1 s

evanwang13 commented 2 years ago

I am investigating this problem right now. If you have more information on the parameters that were used for the optimization and/or specific scenarios that seem to cause this issue, that would be very helpful.

huangtingying commented 2 years ago

The period is 1050nm, the deflection is 50 degrees, the thickness of the device is 325nm, and the number of iterations is 350. All parameters are the same as the source code given in the paper. At present, I want to reproduce the model of the source code

~) R$A21EIS%1Q7YSB)K247 .

EvanSimmonsUML commented 2 years ago

One thing I think that is mentioned in the supp. information of the paper is that the blurring radius is set to 80nm? It doesn't look like the current github submission reflects that definition, though I am not entirely sure how the blurring is implemented (I get the concept, just don't understand why the code has both a "small" and "large" blurring. If you have resources on that, I'd love to try and understand it, thank you!)

huangtingying commented 2 years ago

What I think is the subfile in question is retelimine.m, which causes yyy to have dimensions beyond the bounds of uu

huangtingying commented 2 years ago

retu.m calls retelimine.m on line 325, there is a problem with the dimension of yyy, but xxx is correct

evanwang13 commented 2 years ago

Update: I am still looking into the situation. It seems the issue is arising from differences in the current version of the Reticolo package to the version that this optimization code was built upon (pre version 8) as the issue disappears when I copy in an older version of Reticolo.

EvanSimmonsUML commented 2 years ago

Makes sense. v9 of Reticolo includes anisotropic materials which probably changed the majority of the matrix manipulation necessary to perform RCWA. I imagine the optimization script works with the version of Reticolo that does not handle anisotropic/birefringent materials

huangtingying commented 2 years ago

I have modified the code, and the modified code can fully achieve 350 iterations. The following is the modified part. The file I modified is retelimine.m, but I don't know if this modification will affect the model

DEIV}XBCIZWKW3L ~3OB6QH {E(R3L1$W2F35C7@Y5JU1(8 .

huangtingying commented 2 years ago

In order to realize the model of the original paper, I changed the TM polarization to TE polarization and TM polarization, the deflection angle was changed to 75°, and other parameters remained unchanged, but the final optimized model was completely different from the original paper, I am not sure where the problem occurred. , I hope you can help me take a look, the following is the code part of RunOpt.m I changed and the result I ran

H0XQO8F7DF8W`)P(C0@D%ZW

2_VD@6H4 _G{N)5VDM6I$NB A{URUA3_YV~ QG)JBT@5F4J LC7C )~L9TU(25$E~AK6WUD

evanwang13 commented 2 years ago

Ok, I have found the difference in reticolo that was causing these issues between v8 and pre-v8. It seems that, at some point, the tolerance terms in retu.m on lines 324 and 325 were changed from 5000 to 100 (screenshot is of the old retu.m file). Its still unclear what in the pattern geometry or refractive index profile is causing this to go out of tolerance or why this causes a crash though.

For now, I will upload the older version of retu.m which should be stable, although you are free to increase the tolerance in retu.m yourself manually. This older retu.m file is compatible with both reticolo v8 and v9a.

The change huangtingying made to retelimine.m may work as well, but I am also unsure of how it may impact the accuracy or stability of the code.

image

evanwang13 commented 2 years ago

In order to realize the model of the original paper, I changed the TM polarization to TE polarization and TM polarization, the deflection angle was changed to 75°, and other parameters remained unchanged, but the final optimized model was completely different from the original paper, I am not sure where the problem occurred. , I hope you can help me take a look, the following is the code part of RunOpt.m I changed and the result I ran

In your RunOpt.m file, the target should be [1 1] as this tells the optimizer to send both polarizations to the +1 diffraction order. What you have will send the TE to the +1 and TM to the 0 diffraction orders respectively.

Also its important to the note that while the optimization process is deterministic, the starting point is random, so even with the same parameters, you will most likely end up with a different final pattern.

huangtingying commented 2 years ago

thank you very much. If the target is [1 1], the period will become a 1×3 vector. In the calculation of the seventeenth line of optimizeDevice.m, the calculation error of NFourier will be caused because the number of columns of the vector is different. image

There is a model in the paper that can realize TE polarization of 1000nm and TM polarization of 1300nm at the same time, I would like to ask how this is achieved

evanwang13 commented 2 years ago

The RunOpt.m file is intended more as a example of how to use the code. If the target has two components, then the line computing the period will need to be adjusted accordingly. In general, its left to the user to determine the period of the device based on the desired functionality.

If you want to work with multiple wavelengths, you will need to modify OptimizeDevice.m where appropriate to add another for-loop iterating through the target wavelengths.

EvanSimmonsUML commented 2 years ago

Thank you for your assistance with this. Will use the old code and retry with the scripts!

Best,

Evan S.

xiaoniaoxiao commented 1 year ago

谢谢。如果目标是 [1 1],则周期将变为 1×3 向量。在 optimizeDevice.m 第 <> 行的计算中,由于向量的列数不同,会导致 NFourier 的计算误差。 图像

您好,我在复现时与您遇到同样的问题请问您具体怎么修改的呢