File Exchange

image thumbnail

2D FDTD code with TF/SF interface and UPML absorbing borders

version 1.1 (4.78 KB) by

Simple example implements FDTD + UPML + Total Field/Scattered Field interface

12 Ratings



View License

The example contains:
1. 2D FDTD algorithm for simultaneously TE and TM modes calculation,
2. Uniaxial PML absorbing border conditions,
3. Total Field/Scattered field (TF/SF) interface for plane EM-waves scattering problems investigations.

Works well for free-form scatterers with constant permittivities, permeabilities and conductivities. Number of materials isn't limited.
For more details see Allen Taflove's "bible".

Comments and Ratings (17)

josef vahab

Thanks for the code, its great.
I tried to use incident plane wave but with Gaussian profile for the amplitude (zero at the sides and maximum at the center). Thus, I multiplied Hy_1D and Ez_1D incident waves by exp(-abs((1:nx_b)'-nx_b/2)*dx). But, It creates lots of scatterings from the boundaries (absence of any scaterrer) and also the amplitude doesn't vary the way I expect. Anyone has idea about this? Thanks a lot.

Thank you for the comments! Yes, it works only for normal incidence. I have the code for arbitrary angle of incidence both for TE and TM waves.
If you like my codes - consider the donation. I will help me to post new free codes.

Jimmy Ling

josef vahab

Thanks for the code. I think it works for only normal incident wave. I'm trying to have oblique incident wave, but I couldn't realize how can I change the incident angle. Does anyone knows how it can be done?


how to extract s parameters from this code

Irfan Yousuf

Can this code be used to cloak a square shape?

Arnie Chang


jpadam (view profile)

Thanks for the correction of the TE mode, everything works fine now !

Yes, L in [meters].
UPML FDTD for TE mode needs three Index matrixes due to the fact that in FDTD Ex, Ey and Hz have different space grids. You may apply single Index, but it'll cause distortions at low space resolution.
"My" implementation based on original Gedney's work


arnold (view profile)

great implementation, seems to work well.

L is in meters too, I guess.
I don't get why there are three indices, why should material 2 not be congruent in space for all three, doesn't make sense in my head.

Maybe it'd make sense to add the ability to give complex refractive index, many users of FDTD do optics only and might not be physicists :)

....oh and there is no paper to cite your implementation, so I can give it to my students, is there?


jpadam (view profile)

Really nice and well written script. Ready to study the EM scattering of 2D structures.

However, I think there is a problem in the TE mode. I simulated a cylinder (just removed "&& (L(1)-I*dx<=J*dy", line 63) and observed that the Hz pattern isn't quite symmetric...


jpadam (view profile)


jpadam (view profile)


Ulrich (view profile)

Great, thanks!





TE mode corrected (grid collocation)

MATLAB Release
MATLAB 8.1 (R2013a)

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

» Watch video