/* * METRIC-Application: * A three layer waveguide: mode analysis, mode object handling */ #include #include #include #include"metric.h" #define Wgpns 1.5 // substrate refractive index #define Wgpnf 2.0 // film refractive index #define Wgpnc 1.0 // cover: air #define Wgpt 1.0 // slab thickness #define Wavel 1.55 // vacuum wavelength /* waveguide definition */ Waveguide wgdef() { // a waveguide with one inner layer Waveguide g(1); // positions of the dielectric interfaces g.hx(0) = 0.0; g.hx(1) = Wgpt; // refractive index values g.n(0) = Wgpns; g.n(1) = Wgpnf; g.n(2) = Wgpnc; // the vacuum wavelength g.lambda = Wavel; return g; } /* calculate the guided modes, write profile data */ int main() { ModeArray ma; // define the waveguide Waveguide wg = wgdef(); // display window Interval disp(wg.hx(0)-2.0, wg.hx(wg.nx)+2.0); // inspect the refractive index profile wg.plot(disp, '0', '0'); // find all guided TE modes modeanalysis(wg, TE, ma); // // access properties of individual modes: // Mode m; // m = ma(0); // // the propagation constant, effective index // double beta = m.beta; // double neff = m.neff; // // the field profile, real version: component EY at x = 0.0 // double f_ey = m.field(EY, 0.0); // // directional field profile, complex: // // component HZ of the forward propagating mode at x = 1.0 // Complex f_hz = m.cfield(HZ, FORW, 1.0); // plots of the mode profiles for(int i=0; i<=ma.num-1; ++i) { char t = 'L'; if(i>=1) t = 'V'; ma(i).plot(EY, ORG, disp, 500, dig10(i), dig1(i), t); } // data files for the principal components for(int i=0; i<=ma.num-1; ++i) ma(i).writeprofile(EY, ORG, disp, 500, dig10(i), dig1(i)); // ... the same for the TM fields modeanalysis(wg, TM, ma); for(int i=0; i<=ma.num-1; ++i) { char t = 'L'; if(i>=1) t = 'V'; ma(i).plot(HY, ORG, disp, 500, dig10(i), dig1(i), t); } for(int i=0; i<=ma.num-1; ++i) ma(i).writeprofile(HY, ORG, disp, 500, dig10(i), dig1(i)); fprintf(stderr, "Ok.\n"); return 0; }