# This script file reads the scattering and absorption
# cross-sections from the (scat) EM field monitor
# and calculates the Mie efficiency as a function of size parameter
# It also compares the DGTD results with mie theory
?" Calculating scattering and absorption cross sections";
flux = getresult("DGTD::scat","flux");
r = getnamed("sphere","radius"); # the radius of the mie particle
# Calculate cross-sections normalized to the particle area
# factor of 4 included since simulation region includes a quarter of the particle
Qscat = 4*flux.sigma_front/(pi*r^2);
Qabs = 4*flux.sigma_back/(pi*r^2);
lambda = flux.lambda;
# calculate the size parameter
n2 = getdgtdindex(getnamed("sphere","material"),c/lambda,c/max(lambda),c/min(lambda));
n1 = 1;
size_parameter = 2*pi*r/lambda * n1;
# compare with analytic based on material fit
m = n2/n1;
Qtheory = mie3d(m,size_parameter);
# Plot results
plot(size_parameter,Qscat,Qtheory.Qscat,"size parameter","Mie efficiency","Scattering cross section");
legend("DGTD","Mie theory");
plot(size_parameter,Qabs,Qtheory.Qabs, "size parameter","Mie efficiency","Absorption cross section");
legend("DGTD","Mie theory");