File Exchange

image thumbnail

Waveguide Mode Solver

version 1.2 (36.1 KB) by

Calculate the electromagnetic modes of optical waveguides.



View License

Calculate the electromagnetic eigenmodes and propagation constants of optical waveguides using the finite difference method. Features:

1. Includes vector, semivector, and scalar versions.

2. Can solve for all components of E and H.

3. Allows for perfectly-matched boundary layers.

4. Can model transverse anisotropic materials.

5. Several examples included

Also available at:

Published in:

A. B. Fallahkhair, K. S. Li and T. E. Murphy, "Vector Finite Difference Modesolver for Anisotropic Dielectric Waveguides", J. Lightwave Technol. 26(11), 1423-1431, (2008).

Comments and Ratings (43)

hsiang cheng

Does anyone knows how to solve this problem?
Write a MatLab script for a symmetric slab waveguide that solves the dispersion relation and plots the modal field in the transverse plane (i.e. a section along the




Jesse (view profile)

Hello there, the program itself is quite nice. I couldn't find any information on perfectly matched layers, just hardwall boundaries (unless I am misinterpreting and that is perfectly matched layers) and I was wondering if the code or method was easily extensible to graded or non-step like index profiles for comparison to things like waveguides written by direct-write or similar whose refractive index profiles can be highly non regular. I think if you include these that the toolkit would be excellent. Also, I'm not sure if I missed this as well but is there an easy way of outputting the refractive index profile?


Great Design method. I'm using it to model SOI waveguides but I am getting error while executing waveguidemesh function in line 50 :
imesh(mrw+1:mrw+mside,my) = n(nlayers)^2*ones(mside,1);
What I have to do now ?


Could I use it to plot the characteristic functions to study the cutting-off condition of modes? Thanks.

do anyone knows how to plot the radiation pattern of the circular waveguide???


srr (view profile)

Anyway I can use this for solving modes in a partially filled rectangular waveguide?


Ole (view profile)

Which function handles the hybrid modes ?
Thank you.

Alvin Hui

Are the symmetric mode and antisymmetric mode that would be set in the wgmodes.m the same as even (fundamental) mode, n_even, and odd (first order) mode, n_odd, for calculating the beating length, Lb

Lb = lambda / 2*(n_even - n_odd)


Ole (view profile)

How does it handle circular waveguides ?


How can we use this for diffused and graded index waveguides?


I think I've an error in the function "fiber".

The 2 first lines
nx = round((sum(r)+side)/dx);
ny = round((sum(r)+side)/dy);
must be replaced by
nx = round((max(r)+side)/dx);
ny = round((max(r)+side)/dy);
as r is the radius of the layer and not its thickness.

Nice job, and looks to be very useful.
I'am interested by scalar solutions, but I see only semi-vectorial or full-vectorial solutions. Where is the scalar method hidden
Does a tutorial exist which may describe the exact role and definition of each variable describing the guide? My application is for scalar modes of optical fiber.
Thank you for your help.


its really great

Long Wang

 Hi, thanks for posting this package online. I wonder that if you can tell me what references used for the formulation in 'svmode'. I am using the book 'Introduction to Optical Waveguide Analysis:Solving Maxwell's Equations and the Schrodinger Equation' by Kenji Kawano. It seems the equations used here for aw, ae, an and as are partially different from that in the book.


Jiali (view profile)

I want to calculate two supermodes of silicon coupler. I can do it by semivector. But I fail for fullvector methods. Can someone help me?


Jiali (view profile)


Rizwan (view profile)


I am new to waveguide and I want to plot the mode profiles of slab waveguide as shown in this figure
Can some one please help me in this manner. I have made a code but it was not working. Code is given below. Thanks in advance

   for i=1:length(x)
    if (x(i)<0)
% Ef1=Ey;

    elseif (0<=x(i) )&& (x(i)<=2*d)
% Ef2=Ey;

% Ef3=Ey;
% Ef=[Ef1 Ef2 Ef3];
mesh (abs(Ey));

Nam Tran

That's great! But I am wondering how to calculate the effective refractive indices of the regions in and out (A and B) of the waveguide, as shown in this picture

Nam Tran

This is great! I am new to waveguide terminology and conventions, if I'm trying to simulate a rectangular waveguide, should I set rH = h2 or rH = 0?


KF (view profile)


James (view profile)

Great model. I'm using it to model SOI waveguides, and some preliminary benchmarking against published results shows good agreement for effective index calculations. Easy to use. Helpful examples show how to define waveguides.


James (view profile)

Great work by Thomas Murphy. Good job


Well this mode solver is briliant, however I was wondering if it is possible to extract mode area from the mode solver. Means, I calculate modes with wgmodes and after get somehow the modal area? I am looking forward to hearing from you as soon as you have some time to answer.


Li (view profile)

Gabby Nzulu

I am trying to run the polymer waveguide example but I keep on receiving error messages as shown below:
generating index mesh...
??? Undefined command/function 'waveguidemeshfull'.

Error in ==> polymer_waveguide at 39
[x,y,xc,yc,nx,ny,epsxx] = waveguidemeshfull([n1,sqrt(e2xx),n3], ...
rror in ==> waveguidemesh at 31
ih = round(h/dy);

generating index mesh...
??? Undefined command/function 'waveguidemesh'.

Error in ==> silicon_channel at 23
[x,y,xc,yc,nx,ny,eps] = ...

can you please help me on what to do?


Vidya (view profile)

good work. Can u pl. upload matlab codes for simulation of circular and rectangular waveguides? I am trying to work on the paper:"Analysing electromagnetic structures with curved boundaries on cartesian FDTD meshes" by Yang Hao and Chris J. Railton. Hope I get some help in this regard.

yogesh kumar

this is good

Dingshan Gao

Yeah,it's a good frequency domain mode solver in the web. It's excellent for dielectric waveguide structures like SOI ridge waveguide.
But I find that it can not solve waveguide structures including metal material. Hope to find the improvement at this point.

Thomas Murphy

I have recently updated the code to correct an algebraic error in the expressions for Axy(E), Axy(W), Ayx(N) and Ayx(S). Many thanks to for pointing out this bug.

Yuchun Lu

There may be some errors in the formulation of axye axyw ayxn ayxs in "wgmodes.m".

They can't reduce to the formulation presented in "P.Lusse; P.Stuwe; etc., "Analysis of vectorial mode fields in optical waveguides by a new finite difference method," Lightwave Technology, Journal of , vol.12, no.3, pp.487-494, Mar 1994"

Satomi Ono

I find it hard to start using it from the very beginning. A bit more explanation about how to use the code would be of great help.

muzafar ismail

do you know how to analysis optical buried waveguide channel using finite difference method

Vajira S

Excellent work

Liamin Mohd Daffy

This is great. Do you know how to analyse the optical waveguide using finite element method?

Mohamed Farhat

it is very good work it helps me so much

cao xiangjie

it is what i need!

eze reginald

Felipe Vallini

It's an excellent problem for solving waveguides without difficult.
Simple and fast to use with a clean code.



Corrected bug in stretchmesh routine for south and west boundaries. Also corrected a bug in wgmodes and svmodes in which dy was incorrected conjugated.

(Thanks to Jiri Petracek for discovering this bug.)


Minor modifications in the examples, and contour plotting subroutine.

New version includes several significant improvements, including the ability to model anisotropic waveguides. Interface has been simplified.

Fixed bug in auxilliary file: stretchmesh.m

MATLAB Release
MATLAB 7.9 (R2009b)

Inspired: FFT Beam Propagation Method

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video