AR Coating Sweep



This is regarding a problem that I am stuck with- I am hoping you could help me out. I am modelling an Anti-reflection Coating. The task is to model the reflectivity as a function of top layer thickness and wavelength and get a surface plot where X axis is thickness and Y Axis is Wavelength

I am able to run a single simulation properly and get reliable results but when I switch to Sweep two things happen

  1. The results of the single simulation after having run the sweep changes
  2. I do not get consistent data from the line scan of the sweep either

Thus, my question is how do I fix it. I want to get a Surface plot, which does not seem to work.
GS2.fsp (344.2 KB)



Further to the last post- I attempted doing the modelling using the transfer matrix. Attached is the script. However I am not able to sweep the thickness using the for loop- getting an error: matrix out of range. Could anyone check if the script is Okay ?

I am eagerly looking forward to getting a response on both the issues.

Thanks in advance

Transfer_Matrix_3.lsf (1.2 KB)


Hi @ghazi.syed

Your simulation file has a few issue:

  1. Under the For Sweep structure group, you need to modify your script so that it changes the thickness i.e. the z-values. Currently it modifies the y span.
  2. Sweep object has to have a proper start and stop.

Please visit the link below for a similar application example:

Regarding your script:
since the substrate extends through PML, you need to have only three layers. Also, you do not need to sweep over different angles if that’s not what you want. Here is a modified simulation file:

f = linspace(c/400e-9, c/1000e-9,100); # frequency vector
theta = 0;#:1:45; # angle vector
v = [10e-9;20e-9;30e-9];
t = [1;2;3]; #[0;10e-9; 50e-9;0]; # 4 layers (including air on top, bottom)
#n1 = [1; 1.5; 2.5; 1.5; 1]; # refractive index of each layer (non-dispersive)
# get RT using non-dispersive index data, and theta=0
#RT1 = stackrt(n1,d,f);
#field1 = stackfield(n1,d,f);

# alternate refractive index vector, for dispersive materials
nf = length(f);
nd = length(t);
n2 = matrix(nd,nf);
n2(1,1:nf) = 1; # air
n2(2,1:nf) = getfdtdindex("A",f,min(f),max(f));
n2(3,1:nf) = getfdtdindex("Pt (Platinum) - Palik",f,min(f),max(f));

#n2(4,1:nf) = getfdtdindex("SiO2 (Glass) - Palik",f,min(f),max(f));
#n2(4,1:nf) = 1; # air
# get RT using dispersive data (n2), and theta from 0 to 45 deg
for (i=1:3){
    d = [0;v(i);50e-9];
    eval("RT"+num2str(i)+"= stackrt(n2,d,f,theta);");
    field2 = stackfield(n2,d,f,theta);

Hope this was helpful.


Hi @bkhanaliloo

Thanks a lot for the prompt response and for working towards the answers

For the simulations (see attached). I have made changes as suggested and it still doesnt quite work well. For example: the reflection spectra for a given thickness of the top layer before I coded sweep is different from what sweep gives me and so is the 2D plot of thickness vs wavelength which doesnt show any variations and exceeds unity

For the script. I am only coding (1D model) without actually using the geometries defined in the layout. So I guess PML condition does not hold and I got to include the 4th layer Nevertheless I am still unable to get plots for thickness vs wavelength nor theta vs wavelengthGS2.fsp (343.6 KB)

Could you please suggest corrections and have a look


Hi @bkhanaliloo have you had a chance to look at these

Thanks in advance


Hi @ghazi.syed

Please see modified simulation file:
GS2_BK.fsp (344.7 KB)

I am getting identical results for a thickness of 0.1um and results do not exceed 1:

I also was not quite sure about your problem with scripting. Please elaborate on that and I will be glad to be of a help.



Hi @bkhanaliloo

Thanks for getting back and working on the script. Please run the script (attached-Transfer_Matrix_Model_1) that is on 1D transfer matrix model. This is the right result. Infact when I first made the FDTD file before I tried any sweep codes this is the result I got too and this is correct too from experiments that I have carried out. I hope the problem is clear now

For the Script-Could you help me fix the script attached to run the Tranfer Matrix for different thicknesses too alongside differenet theta

Thickness_Variation.lsf (942 Bytes)
Transfer Matrix_Main_Script.lsf (885 Bytes)

Thanks a lot


Hi @ghazi.syed

It looks like the y-span of film was very small and thus it was ignored in the simulation. I modified it and here is the result that I got from FDTD which matches with the script one:


and here is the modified simulation file:
(343.1 KB)

Hope this was helpful.


Hi @bkhanaliloo

Thanks a lot for finding the error and sorting it out. Quick question: did you increase the span by making the boundry periodic ?

Also could you please help me in fixing the script to perform the same task. I am sweeping across a lot of points and it is very time consuming to do it using FDTD solver. Transfer Matrix will be quicker and would help me run multiple simulations

Once again thanks a lot


Hi @ghazi.syed

I am not quite sure if I understood your inquiry. Since you have slabs as your geometry in the xy-plane, simulation will be independent of FDTD xy span with periodic boundaries.

The script works fine. You just need to modify the plotting part so that you are plotting the RT2 instead of unknown ST1 parameter:

plot(RT2.lambda*1e6,RT2.Rp,RT2.Rs,RT2.Tp,RT2.Ts,"wavelength (um)","Power","non-disperisive, theta=0");


Also, you need to set theta to zero if you were interested in normal incidence.


Hi @bkhanaliloo

Thanks a lot for your help. This works



Hi @bkhanaliloo

Is there a way I can extract all partial refection coefficients from the transfer matrix at a marticular wavelength.

I am attaching a figure which I want to replicate. The data here is plotted for in the complex plane for a single wavelength- I am not sure how I can extract the partial reflection coefficients (r0,r1,r2…)


Thanks for your help


Hi @ghazi.syed

Unfortunately not from the stackrt script commands. However, you may use Snell’s law to calculate the coefficients. It has a simple form for perpendicular incidence: