There is an error in calculation, please help to have a look

Thank you for contacting Lumerical support. Before proceeding, please note that this is a public forum and anything you post will be visible to the general public. For users residing in the United States, please ensure that the files and information contained within your posts are not International Traffic in Arms Regulations (ITAR) or export controlled.

To help us solve your issue as quickly as possible, please provide the following information:

1. What device are you trying to simulate? Include diagrams if available.
Dispersion

2. What results are you trying to obtain? Be as specific as possible.

3. Description of the problem or issue.

Error: C:/Users/ZHAIY0B/Documents/Simulation/metalens-zemax-interoperability-dispersionok -circular/0522/0714dispersion/group_delay_fdtd.lsf line 38: matrix arguments of - are not the same size

4. Lumerical product and software version.

5. Please attach your simulation files, including any logs.

Hey,

You can change your line 37 for:

gdp=gd(2:length(gd))-gd(1:length(gd)-1);

There is another error in your line 41, in this expression

... -2w(2:nw-1))

Hope it helps,

Juan

Thank you Jev, please help to have a look

I change to
gdp=gd(2:length(gd))-gd(1:length(gd)-1);

gdp=gdp/(w(2:length(w)-1)-w(1:length(w)-2));

nw=length(w);

gdp0=(phi(1:nw-2)+phi(3:nw)-2w(2:nw-1))/(w(1:nw-2)+w(3:nw)-2w(2:nw-1));

plot(l21e9,gdp1e12,“Wavelength (nm)”,“Group delay dispersion”);

still some error
Error: C:\Users\ZHAIY0B\Documents\Simulation\metalens-zemax-interoperability-dispersionok -circular\0522\0730dispersion\group_delay_fdtd.lsf line 41: syntax error

Hey, I hope you found your error. In any case this is the same error I guided you before. The expression “2w” is incorrect, you should use 2*w if what you want is to multiply by 2. I will recommend this thread to be closed.

Regards

Thank you
but sitll previous error

When you compute gdp, again you are reducing the size of your vector by one unit hence you need to generate a new wavelength axis that is one unit smaller as well. You could do this creating a new variable for your frequency and wavelength and then use them to plot, something like:

w3 = 0.5*(w2(2:length(w2))+w2(1:length(w2)-1));
l3 = c/(w3)*2*pi;
nw=length(w);
gdp0=(phi(1:nw-2)+phi(3:nw)-2*phi(2:nw-1))/(w(1:nw-2)+w(3:nw)-2*w(2:nw-1));
plot(l3,gdp*1e12,"Wavelength (nm)","Group delay dispersion");

Thank you very much, where to query the meaning of this code.
Like w3 = 0.5*(w2(2:length(w2))+w2(1:length(w2)-1));
What does this code mean that I can’t find it here https://support.lumerical.com/hc/en-us/articles/360037228834-Lumerical-scripting-language-By-category

It’s very easy :wink:. Just take a step back. w is your frequency (it’s named w to refer to \omega), and there you are just computing the average between two frequencies, that is w2 and w2 shifted by one position. Namely calculating

(\omega_i + \omega_{i-1})/2

The final effect is that you get a vector that is one unit shorter and instead of erasing one of your values to get this, you recalculated each new frequency as the average of the frequencies around the same iterator. For a very large vector (like yours) this makes mostly no difference, so you could just do w3 = w2(2:length(w2)), and you would still be in general fine.

2 Likes

Thank you very much!