tuttelikz

Mie scattering [+]

Sep 1st, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.91 KB | None | 0 0
  1. clear all; close all; clc;
  2. %%
  3. diameter = input('Diameter of sphere (e.g., 579 nm):')*1e-9;
  4. radius = diameter/2;
  5. lambda = input('Wavelength (e.g., 400 nm):')*1e-9;
  6. n_s = input('Refractive index of sphere (e.g., 1.57):');
  7. n_b = input('Refractive index of background (e.g., 1.33):');
  8. w_s = input('Specific weight of sphere(e.g., 1.05 g/cc):')*1e3;
  9. w_b = input('Specific weight of background(e.g., 1.0 g/cc):')*1e3;
  10. concentration = input('Concentration by weight (e.g., 0.002):');
  11. %%
  12. k = 2*pi*n_b/lambda
  13. x = k*radius
  14. n_rel = n_s/n_b
  15. y = n_rel*x
  16. % Calculate the summations
  17. err = 1e-8
  18. Qs = 0;
  19. gQs = 0;
  20. %%
  21. for n = 1:100000
  22.     Snx = sqrt(pi*x/2)*besselj(n+0.5,x);
  23.     Sny = sqrt(pi*y/2)*besselj(n+0.5,y);
  24.     Cnx = -sqrt(pi*x/2)*bessely(n+0.5,x);
  25.     Zetax = Snx+i*Cnx;
  26.     % Calculate the first-order derivatives
  27.     Snx_prime = - (n/x)*Snx+sqrt(pi*x/2)*besselj(n-0.5,x);
  28.     Sny_prime = - (n/y)*Sny+sqrt(pi*y/2)*besselj(n-0.5,y);
  29.     Cnx_prime = - (n/x)*Cnx-sqrt(pi*x/2)*bessely(n-0.5,x);
  30.     Zetax_prime = Snx_prime + i*Cnx_prime;
  31.     an_num = Sny_prime*Snx-n_rel*Sny*Snx_prime;
  32.     an_den = Sny_prime*Zetax-n_rel*Sny*Zetax_prime;
  33.     an = an_num/an_den;
  34.     bn_num = n_rel*Sny_prime*Snx-Sny*Snx_prime;
  35.     bn_den = n_rel*Sny_prime*Zetax-Sny*Zetax_prime;
  36.     bn = bn_num/bn_den;
  37.     Qs1 = (2*n+1)*(abs(an)^2+abs(bn)^2);
  38.     Qs = Qs+Qs1;
  39.     if n > 1
  40.         gQs1 = (n-1)*(n+1)/n*real(an_1*conj(an)+bn_1*conj(bn))+(2*n-1)/((n-1)*n)*real(an_1*conj(bn_1));
  41.         gQs = gQs+gQs1;
  42.     end
  43.     an_1 = an;
  44.     bn_1 = bn;
  45.     if abs(Qs1)<(err*Qs) & abs(gQs1)<(err*gQs)
  46.         break;
  47.     end
  48. end
  49. %%
  50. Qs = (2/x^2)*Qs;
  51. gQs = (4/x^2)*gQs;
  52. g = gQs/Qs;
  53. vol_s = 4*pi/3*radius^3
  54. N_s = concentration*w_b/(vol_s*w_s)
  55. sigma_s = Qs*pi*radius^2;
  56. mu_s = N_s*sigma_s
  57. mu_s_prime = mu_s*(1-g);
  58. % Output results
  59. {'wavelength(nm)','Qs ( - )','g (-)','mus (/cm)','mus_prime(/cm)';lambda*1e9,Qs,g,mu_s*1e-2,mu_s_prime*1e-2}
Advertisement
Add Comment
Please, Sign In to add comment