MatScat is a MATLAB package which contains different solutions for the
scattering of electromagnetic radiation by a sphere (Mie theory) or an
infinite circular cylinder. Most of the code has been developed during my PhD
work [3]. The multiple cylinder near field solution has been implemented
afterwards and has been presented in a seperate publication [4].

Make sure that the root folder and the folders '/bessel', '/expcoeff' and
'/util' are in the MatlabPath. The files in '/test' can be run to check if
everything works fine.
The functions to start the calculation can be found in the root folder.
These are:
calccyl.m  calculate the far field solution for a single (stratified) cylinder
calccyl_nf.m  calculate the near field solution for a single (stratified) cylinder
calccyl_multi.m  calculate the far field solution for multiple cylinders
calccyl_multi_nf.m  calculate the near field solution for multiple cylinders
calcmie.m  calculate the far field solution for a single (stratified) sphere
calcmie_nf.m  calculate the near field solution for a single (stratified) sphere

If you use these functions in your research work please cite my work [3,4].
Please also cite the theoretical work underlying my implementation which is:
calccyl, calccyl_nf, calcmie and calcmie_nf are implemented based on [1].
calccyl_multi and calccyl_multi_nf are implemented based on [2,4].
The stratified cylinder/sphere solution is implemented based on [1,5].

[1] Bohren, C. F. and Huffman, D. R., Absorption and scattering of light by
small particles, WileyInterscience, New York, 1998.
[2] Lee, S.C., Dependent scattering of an obliquely incident plane wave by a
collection of parallel cylinders. J. Appl. Phys. 68(10), 1990.
[3] Schäfer, J.P.,Implementierung und Anwendung analytischer und numerischer
Verfahren zur Lösung der Maxwellgleichungen für die Untersuchung der
Lichtausbreitung in biologischem Gewebe, PhD thesis, Univerität Ulm, 2011,
http://vts.uniulm.de/doc.asp?id=7663
[4] Schäfer, J. and Lee, S.C. and Kienle, A,, Calculation of the near
fields for the scattering of electromagnetic waves by multiple infinite
cylinders at perpendicular incidence, J. Quant. Spectrosc. Radiat. Trans.
113(16), 2012.
[5] Kerker, M., The scattering of light and other electromagnetic
radiation, Academic Press, 1969

If you have questions or remarks about the MatScat package or if you find any
bugs in the code please send an email to jan.schaefer(at)maxwellsolutions.de.
Take a look at my website at http://www.maxwellsolutions.de.
Have fun!

Copyright 2012 Jan Schäfer, Institut für Lasertechnologien (ILM)
Author: Jan Schäfer (jan.patrick.schaefer(at)gmail.com)
Organization: Institut für Lasertechnologien in der Medizin und Meßtechnik an
der Universität Ulm (http://www.ilmulm.de)

1.4.0.0  changed contact information, added website 

1.4.0.0  edited contact information 

1.4.0.0   dependency on Wavelet Toolbox removed


1.3.0.0  Near and far field solutions for nlayered (stratified, coated) particles (single cylinder and sphere) added. 

1.2.0.0  Error in asmmie.m for calculation of cross sections corrected.

Inspired: to generate 16 combination of 1 and 1, Mie Electric Field Simulation for Spheres, IMPLEMENTATION OF FIXED POINT THEORY ON IMAGE INTEGRITY AUTHENTICATION, verify_magic( A )
Create scripts with code, output, and formatted text in a single executable document.
Homa Bayat (view profile)
shuai wang (view profile)
Refet Ali YALCIN (view profile)
Thank you for sharing this code with us.
The codes in asmcyl.m should change. The present form in v 1.4 is this;
C.sca(1) = 4/k*(abs(bnp(1)).^2 + 2*sum(abs(bnp(2:end)).^2));
C.sca(2) = 4/k*(abs(ann(1)).^2 + 2*sum(abs(ann(2:end)).^2));
it should be like this:
C.sca(1) = 4/k*(abs(bnp(1)).^2 + 2*sum(abs(bnp(2:end)).^2+abs(anp(2:end)).^2));
C.sca(2) = 4/k*(abs(ann(1)).^2 + 2*sum(abs(ann(2:end)).^2+abs(bnn(2:end)).^2));
Zhihao Wu (view profile)
Dear Jan Schäfer, thank you for your excellent work and it helps a lot in my graduation project. However, I found there is a small mistake in the calculation of scattering coefficient a extinction coefficient. in the file 'assmie.m'. The error happens on the 44th and 45th row, where the corrected code should be 'C.ext = 2/x^2*sum(n2.*real(an + bn));' and 'C.sca = 2/x^2*sum(n2.*(abs(an).^2 + abs(bn).^2));'. And don't forget to import variable x given by 'x=k*r' in 'calcmie.m' into 'asmmie.m' before running the modified code. I modified the code on my PC and verified the result by comparing the one given by online mie theory calculator found on 'https://omlc.org/calc/mie_calc.html' and the result can match with the modification aforementioned applied.
Best regards!
kim yu (view profile)
Thank you. It's a great help to me.This code is very interesting.
Xiaoxuan Liang (view profile)
Dear Dr. Schäfer, thanks for sharing your code in the public domain. With its clarity, simplicity, it helps me a lot understanding the Mie code! Well done!
However I got a problem in understanding the nearfield enhancement result. By executing the file test_calcmie_nf.m, I got the Poynting amplitude (intensity) in the xy plain, for lamda = 800nm and R_np = 50 nm. By normalizing the intensity to the incident intensity, which I calculated from the formula E0^2*n_m/Z0=3.53e3. Here, E0 is the incident Efield in x polarization direction, n_m is the refractive index in water and Z0 is the wave impedance in vacuum. After doing so, I have a maximum nearfield enhancement about 1.3, which is far below the value of 20 calculated from this source: Tejerina et.al. (2014), "Nanosphere Optics Lab Field Simulator,“https://nanohub.org/resources/nsoptics3D, DOI: 10.4231/D3FF3M064. I'm thinking where comes the discrepancy... I check the codes. Everything seems O.K.
Looking forward to your reply.
Joe
Uni Luebeck
yingying qiao (view profile)
an excellent working, thanks very much!
Simbathree (view profile)
This is absolutely a 5 star work!
I haven't used it yet , but the code style is really fascinating!
roy nicolas (view profile)
Junard Landingin (view profile)
This help me a lot in my research. Thank you very much.
Sina Talebi (view profile)
juzimm (view profile)
mcrane (view profile)
My apologies, I had a mistake in my code! Please ignore my comment in August 2014, the bessel functions are properly calculated.
Konstantin Ladutenko (view profile)
It seems to be a bug in expcoeff_mie( x, m, conv ) using Octave
x = 0.0010000
xix =
Columns 1 through 3:
3.3333e07  1.0000e+03i 2.6645e10  3.0000e+06i
the second order differs from wolfram alpha SphericalHankelH1[2, 0.001]*0.001 = 6.66667 × 10^11 3.00000 × 10^6 i
imanol uria (view profile)
Hi Jan,
I´m a student and I´m using your programmes. They´re fantastics! I have one question: I´m plotting the maps of the near field for a single sphere, and I want to plot not the total E but E/Eincoming. I can´t find the value of Eincoming in the programmes, if you can help me...
Thank you for your attention!
M Santos (view profile)
Can anybody explain this? (in test_calcmie). What is fctr?
%% Differential scattering cross sections
fctr = 2/pi/C.k;
dCsdOp = fctr*squeeze(abs(S(1,1,:).^2)); % parallel
dCsdOn = fctr*squeeze(abs(S(2,2,:).^2)); % perpendicular
dCsdO = 0.5*(dCsdOp + dCsdOn); % unpolarized
mcrane (view profile)
I believe the derivatives of the RicattiBessel functions are implemented incorrectly. When differentiating by parts, the sqrt(pi/(2x)) term on the spherical bessel functions is left out when dbesselj is called.
mcrane (view profile)
RICARDO (view profile)
I downloaded and extract this code and when I tried to run the tests from the test directory, I have got the following messages:
>> test_calccyl
Undefined function 'dbesselj' for input arguments of type 'double'.
Error in expcoeff_cyl (line 47)
djneta = dbesselj(n, eta);
Error in calccyl (line 91)
[anp, ann, bnp, bnn] = expcoeff_cyl(x, m, zeta, 1, conv);
Error in test_calccyl (line 30)
[T, C, ang] = calccyl(dia/2., ns, nm, lambda, nang, zeta);
>> test_calccyl_multi
Undefined function 'dbesselj' for input arguments of type 'double'.
Error in expcoeff_cyl (line 47)
djneta = dbesselj(n, eta);
Error in calccyl (line 91)
[anp, ann, bnp, bnn] = expcoeff_cyl(x, m, zeta, 1, conv);
Error in test_calccyl_multi (line 25)
[ Ts, Cs, angs ] = calccyl( dia/2., ns, nm, lambda, nang);
Undefined function 'calccyl_nf' for input arguments of type 'double'.
Error in test_calccyl_nf (line 45)
[Ep, En, Hp, Hn, Sp, Sn, T, C, ang] = calccyl_nf(dia/2., ns, nm, ...
>> test_calccyl_nf_multi
Undefined function 'calccyl_nf' for input arguments of type 'double'.
Error in test_calccyl_nf_multi (line 53)
[ Ep1, En1, Hp1, Hn1, Sp1, Sn1, T1, C1, ang1] = calccyl_nf( dia/2., ...
>> test_calcmie
Undefined function 'calcmie' for input arguments of type 'double'.
Error in test_calcmie (line 30)
[S, C, ang] = calcmie(rad, ns, nm, lambda, nang, ...
>> test_calcmie_nf
Undefined function 'calcmie_nf' for input arguments of type 'double'.
Error in test_calcmie_nf (line 49)
[E, H, P, S, C, ang] = calcmie_nf(dia/2., ns, nm, ...
Is anything that I have to update?
Jakub (view profile)
Thank you for the submission. While I don't want go through the theory behind I want to make myselft sure about the interpretation of the results for the near field solution. Light is incident upon the particle from the z direction, the particle is placed in [0,0,0], right?
So if I want to obtain solution of the Efield in the plane behind the sphere with radius 25um, I have to set all values of zf to 25 um (file test_calcmie_nf.m). Is this correct?
Thank you in advance.