Import refractive index into the model


Hi all,
I’m trying to import the refractive index into my model but I’m getting an error.
I wnat to calculate the modes of a metal diffused lithium niobate waveguide
I’ve created a script in matlab to generate my 2D spatial refractive index distribution, by generating 2D meshgrid with the values of the refractive index n(x,y).

By following what reported here:

I’ve generated a vector in matlab and then save it into a txt file. After that I’ve edited the header of my txt file.

Since I’ve a 2D spatial refractive index n(x,y), which is invariant in z-direction (propagation direction) my header would be:

n X1 Xn
m Y1 Ym

but when I try to import the files it says that it isn’t valid.

I’ve also tried to define a 3rd dimension z. and repeating the cross section distribution of the refractive index p-times, so to have:

p Z1 Zp

For example, I’ve defined:

x=linspace (-10, 10, 100)
y=linspace (-10, 0 ,100)
z= linspace (0, 100, 100)

so, the header of my txt file will be

100 -10 10
100 -10 0
100 0 100

followed by a vector of n(x1,y1,z1)…(xn,ym,zp)

But it doesn’t work.
Anyone has any clue?

Thank you.


@dtulli: Here is a simple example of a text file with isotropic index data for a 2D spatial profile (uniform in the z-direction) and the .fsp file where it was imported: example_importnk_2d.txt (150 Bytes) and example_importnk_2d.fsp (240.9 KB).Note a few important things:

  1. Even though there is no variation along the z-direction it is necessary to include at least two points in the z-direction.
  2. You need to include both the real and imaginary parts (n and k) of the refractive index. In the attached example, the index is real, so all the values for k are zero.

Hope this helps.


Thank you Federico.
After adding a column of zeros to the k values I was able to import my profile.
Very helpful.
Best Regards,


Important detail: you have to keep the area symmetrical to 0. Thus x = linspace(0, 10, 100) won’t work. It has to be x = linspace(-10, 10, 100)