Sweep parameter for various thickness


Hi Nlui,

I’ve swept incidence angle from 36 to 80 degree in this design sp_film_resonance Cu -Palik.fsp (276.9 KB)

and later I want to sweep the various thickness of Cu from 20nm to 80 nm in resulting reflection vs incidence angle which the nested sweep example shows the various wavelength sweep_nested_example.fsp (837.3 KB)

How to define the sweep parameter for various thickness? Can you demo/ explain the step of nested sweep for various thickness?

Can I get the result from sweep tool or the script?
reflection = getsweepresult(“wavelength”, “R”);
R = -reflection.T;
lambda = reflection.lambda_sweep*1e9;

plot(reflection.source_angle, pinch(R,3,1),
“angle of incidence (degrees)”,“Reflection”,“Reflection vs angle”);
legend('lambda = ’ + num2str(lambda(1)), 'lambda = ’ + num2str(lambda(2)), 'lambda = ’ + num2str(lambda(3)));

Thank you for your cooperation.

How to define Graphene in normal rectangle or 2D rectangle?

Dear @nurakmar

If you want to sweep the thickness of the Cu (copper), you can select the xmax value of the object to change from -30 to 50 nm which represents thickness of 20-80nm. If these are independent sweeps, you can Add the new parameter to existing sweep, and if they are dependent i.e. you want to sweep over all angles for every copper thickness, you can Insert parameter sweep by right clicking on the existing sweep to add a new sweep.

If you want to visualize data, easiest option is to right click on the sweep (after you finished running simulations) and then selecting the parameter of interest. If you want to use scripts, please refer to this link, and then search for the proper command. For example, this page shows you how to use getsweepresult command.



Hi @bkhanaliloo,

Thank you for your respond. It’s very helpful. Noticed that for running the sweep it took long time.Do you have any suggestion to reduce the time consuming?

Thank you


Dear @bkhanaliloo,

I’ve swept the thickness but there’s an error.

Is it correct what I did about sweeping the various thickness and the angle if these value are independent? Why the result appeared as the new result at the y axis?
How to the get the graph of the various thickness vs the various incidence angle as shown in this paper Copper-graphene SPR-based biosensor for urea.pdf (863.8 KB)

Thank you for your cooperation.


Dear @nurakmar

If you want to have the current resolution in your sweep file, you can modify your available resources. For this simulation where each of them take only a few seconds to run and are memory inexpensive, you can run concurrent simulations by specifying the 1 or 2 cores for each simulations. I didn’t have time to study it in your case but for my computer which has 12 cores, I set it to be like the screenshot below:

I thought that this recorded webinar on sweep and optimization might be of an interest to you to watch.

Regarding the error: It is explained in this post. The problem occurs because mesh size changes during the sweep. When you use thicker copper a finer mesh is employed compared to cases where no metal was available, thus the matrix size for field analysis group changes. To overcome the problem use a mesh override with x-max of 50 nm (matching the thickest copper that you use in your sweep).

After Visualizing the data, you can make line plots of transmission vs angle for different copper thicknesses:

I have attached the modified simulation file for your review.

sp_film_resonance Cu -Palik_modified.fsp (555.6 KB)


Dear @bkhanaliloo,

Thank you for your help.
1)But I am still confusing the value of copper thickness xmax -30nm to 50 nm which represent 20-80 nm. Which thickness will be represented by the value of -3e-08 and so on ? Can you explain it? How can I plot for all value of transmission vs angle for different copper thickness in one window? I have modified geometry ofcopper from x min =0 and x max =100 and used the same value to sweep the copper thickness. sp_film_resonance Cu -Palik_modified (2).fsp (639.2 KB)
Correct me if I’m wrong.

  1. I have tried to sweep the other design. I need to sweep reflection vs 1Layer, 2Layer and 3Layer of graphene, which each layer is 0,34 nm. But I didn’t see any differences of reflection between each layer. How can I define the sweep range of xmax of graphene?
    sp_film_resonance 7950 Au 3Gr Al2O3.fsp (342.5 KB)

Thank you for your cooperation.


Dear @nurakmar

We are setting the xmax in the sweep. So copper thickness will be xmax-xmin. In the most recent file, since your xmin=0, then xmax will represent thickness thus you will need a sweep over xmax from 20-80nm.

There were better ways to setup your simulation file (like this link), but here how you can do it:

Tr=getsweepresult("copper thickness", "T");

for (i=1:length(th)) {

I assume this should be the same as before. A good practice to run simulations where you manually change the layers and make sure that results make sense. Then you can set a parameter sweep as we discussed before. I think it will be a good idea to look at more into our documentations for parameter sweep and even look into our getting started example and scripting language and watch this video.


Dear @bkhanaliloo,

Thanks for your support.

  1. In your recent file, sp_film_resonance Cu -Palik_modified (2).fsp (639.2 KB)
    ,there’s an error of E2 and x which is not match to mesh. I’ve tried to change the value but remain the same. Can you suggest any possible adjustments, where should I adjust the setting?

2)Regarding to the reflection results with various thickness of copper , how can I get the smooth grarph?

  1. Is it a must for xmax in a field analysis group to be set as xmax = 0? Or is it depends on the value of the mesh region ? what is the effect of this value to the result?

Thanking you in advance for your cooperation and support.


Dear @nurakmar

I explained this on my earlier post: Since the thickest copper layer used in your simulation is 80nm, please choose a mesh override with xmin=0, and xmax of 80nm (matching the thickest copper boundaries). Doing this should resolve the problem.

You need to use a higher sweep value for the source angle. [quote=“nurakmar, post:8, topic:4648”]
Or is it depends on the value of the mesh region ? what is the effect of this value to the result?

This is a linear monitor on the x direction that you are using to capture the electric field data and xmax defines how big your monitor to be.


Dear @bkhanaliloo,

Thank you for your respond.
Referring to the same design, I’ve tried to run in the different background such as n=1.33 and n=1.49. But I failed to get the result for n=1.49 which I assumed the graph should be the same and shifted, correct me if I’m wrong. How can I manage to get the significant graph without ripple?

Thank you in advance for your cooperation.


Dear @nurakmar

I was working with a similar case recently where I want to remove the ripples. Can you please take a look at it:

and follow the steps (such as mesh, material fit, BCs etc) and see if you can remove ripples.If it was not successful, please update me with what you have tried, and I am glad to take a look at it again.

Please note that there is not a simple and easy answer for this type of simulation and you will need to try a few things to remove the ripples.



Dear @bkhanaliloo,

Thanks for advise. I’ve tried to change the simulation time = 15000fs and the steep angle to 64 and set the simulation bandwidth to 785nm.

The graph looks good without ripple until n=1.49, it shows no resonance angle. How can I fix this problem?

Attached the filesp_film_resonance 7950 Au Gr.fsp (279.4 KB)

Can you explain how to make sure that the material that I used is fit with theory? I’ ve tried to di some change at material fit but I don’t how to interpret the graph.

Thank you for your cooperation.


Dear @nurakmar

In most recent uploaded simulation file and attached screenshots, I noticed that you have added a graphene layer into your simulations. This layer is very thin (0.34nm) and mesh oevrride is still quite coarse to capture its effects. This means that you need to use a finer mesh with at least five mesh cells in the graphene layer to resolve it. Another way to introduce graphene is to use 2D graphene:

We have a chapter in KB that talks about graphene and will be a good place to learn more about graphene (I noticed that you have introduced your own graphene material).



Dear @bkhanaliloo [quote=“bkhanaliloo, post:13, topic:4648”]
This means that you need to use a finer mesh with at least five mesh cells in the graphene layer to resolve it.

How to do the setting? Can you attach a screenshot?

Thank you


Dear @bkhanaliloo and @nlui,

Recent file, I ran the design in 2d simualation. What is the differences between 2d and 3d simulation ? Any significant reason and setting adjustment in the design if I want to run it in 3d simulation?

Thank you for your cooperation.


Dear @nurakmar

If you look at the screenshot below (taken from your original file), you can see that graphene layer is not resolved and the current mesh is coarse:

You can use a second override mesh region on the graphene layer: (I decreased the min mesh step from FDTD to 0.025 and maximum mesh step of override mesh to 0.068):

Please note that you can use 2D graphene in 2D or 3D simulations and when I said you can use 2D graphene, I meant something in lines of the links I already provided or you can watch this video to learn more: