View License

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

» Watch video

Highlights from
Waveguide Mode Solver

4.5 | 26 ratings Rate this file 78 Downloads (last 30 days) File Size: 36.1 KB File ID: #12734 Version: 1.2
image thumbnail

Waveguide Mode Solver



20 Oct 2006 (Updated )

Calculate the electromagnetic modes of optical waveguides.

| Watch this File

File Information

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).


This file inspired Fft Beam Propagation Method.

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (43)
19 Feb 2017 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

Comment only


30 Nov 2016 Jesse

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?

Comment only
23 Nov 2016 Daniel Stavrevski

20 Nov 2016 Daniel Stavrevski

08 Aug 2016 SNEHA KUMARI

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 ?

03 Jun 2016 Xiaodong

Xiaodong (view profile)

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

23 May 2016 muhammad faheem

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

Comment only
15 Apr 2016 srr

srr (view profile)

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

Comment only
30 Apr 2015 Ole

Ole (view profile)

Which function handles the hybrid modes ?
Thank you.

Comment only
09 Apr 2015 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)

Comment only
10 Mar 2015 Ole

Ole (view profile)

How does it handle circular waveguides ?

Comment only

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

Comment only
05 Dec 2014 Philippe DI BIN


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.

Comment only
01 Dec 2014 Philippe DI BIN

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.

20 Jul 2014 Raqibul Hossen

its really great

03 Jul 2014 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.

05 Sep 2013 Jiali

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?

Comment only
05 Sep 2013 Jiali

Jiali (view profile)

17 Jul 2013 Rizwan

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));

Comment only
25 Apr 2013 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

Comment only
25 Apr 2013 Nam Tran

07 Apr 2013 Michelle Rybak

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?

Comment only
15 Oct 2012 KF

KF (view profile)

15 Jun 2012 James

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.

Comment only
15 Jun 2012 James

James (view profile)

17 Nov 2011 Muddassir Iqbal

Great work by Thomas Murphy. Good job

03 Nov 2011 Andrzej

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.

18 Oct 2011 Li

Li (view profile)

27 Oct 2009 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?

Comment only
08 Oct 2009 Vidya

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.

Comment only
19 Aug 2008 yogesh kumar

this is good

16 Feb 2008 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.

11 Jan 2008 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.

Comment only
08 Jan 2008 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"

18 Dec 2007 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.

29 Nov 2007 muzafar ismail

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

10 Sep 2007 Vajira S

Excellent work

18 Feb 2007 Liamin Mohd Daffy

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

05 Feb 2007 Mohamed Farhat

it is very good work it helps me so much

03 Feb 2007 cao xiangjie

it is what i need!

29 Nov 2006 eze reginald

27 Oct 2006 Felipe Vallini

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

02 Jan 2007

Fixed bug in auxilliary file: stretchmesh.m

10 Oct 2007

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

28 Mar 2011 1.1

Minor modifications in the examples, and contour plotting subroutine.

22 Apr 2011 1.2

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.)

Contact us