/* * METRIC-Application: * Plane wave reflection from a dielectric slab */ #include #include #include #include"metric.h" #define Pol TM // light polarization #define SPnb 1.0 // backgound refractive index #define SPng 2.0 // refractive index of high index region double SPt = 0.3; // slab thickness double Wavel = 1.0; // vacuum wavelength double Theta = 45.0; // incidence angle, in degrees #define DWx 5.0 // display window, distances from the origin #define DWz 5.0 // /* layer stack definition */ Waveguide stdef() { Waveguide g(1); g.n(0) = SPnb; g.n(1) = SPng; g.n(2) = SPnb; g.hx(0) = 0.0; g.hx(1) = SPt; g.lambda = Wavel; return g; } /* calculate the plane wave reflection & transmission */ int main() { ModeArray fld; Cvector amp(2); double in, ref, trans; Fcomp fc = principalcomp(Pol); // define the layer stack Waveguide st = stdef(); // solve the problem in = 1.0; mlref(st, Pol, Theta*PI/180.0, in, ref, trans, fld, amp); fprintf(stderr, "I = %g\n", in); fprintf(stderr, "R = %g\n", ref); fprintf(stderr, "T = %g\n", trans); // field plots Interval disp(-DWx, DWx); fld(0).plot(fc, ORG, disp, 500, 'r', 'e', 'L'); fld(1).plot(fc, ORG, disp, 500, 'i', 'm', 'V'); Cvector bamp(amp.nel); bamp.init(CC0); fld.plot(amp, bamp, fc, REP, -DWx, DWx, -DWz, DWz, 150, 150, '0', '0'); fld.plot(amp, bamp, fc, IMP, -DWx, DWx, -DWz, DWz, 150, 150, '0', '0'); fld.plot(amp, bamp, SX, REP, -DWx, DWx, -DWz, DWz, 150, 150, '0', '0'); fld.plot(amp, bamp, SZ, REP, -DWx, DWx, -DWz, DWz, 150, 150, '0', '0'); fld.movie(amp, bamp, -DWx, DWx, -DWz, DWz, 150, 150, 30, '0', '0'); fld.viewer(amp, bamp, -DWx, DWx, -DWz, DWz, 150, 150, '0', '0'); fprintf(stderr, "\nOk.\n"); return 0; }