#ifndef FBMODE_H #define FBMODE_H /* * METRIC --- Mode expansion modeling in integrated optics / photonics * http://metric.computational-photonics.eu/ */ /* * fbmode.h * Floquet-Bloch-mode analysis of rectangular periodic dielectric waveguides * 2-D solver based on BEP expansions with Dirichlet boundary conditions */ /* a single guided Floquet-Bloch-mode */ class FBMode { public: // the supporting waveguide structure, // a period extends from st.hz(0) to st.hz(st.nz) // equal slices st(0), st(1), st(nz), and st(nz+1) are required SegWgStruct st; // length of one period double L; // polarization: TE, TM Polarization pol; // vacuum wavenumber double k0; // propagation constant double beta; // effective modal index double neff; // vector Mode int vM; // common y-wavenumber Complex ky; // e.m. field values at position (x, z), cp: EX - HZ Complex field(Fcomp cp, double x, double z) const; // FB mode profile at position (x, z), cp: EX - HZ Complex fbmprof(Fcomp cp, double x, double z) const; // the optical field, discretized on a regular rectangular mesh, // npx x npz points on a display window dwx x dwz // cp: one of EX, EY, EZ, HX, HY, HZ // foa: ORG, MOD, SQR, REP, IMP (ORG = REP) Cmatrix field(Fcomp cp, Interval dwx, int npx, Interval dwz, int npz) const; Dmatrix field(Fcomp cp, Afo foa, Interval dwx, int npx, Interval dwz, int npz) const; // ... np equidistant field values on the straight line // between (x0, z0) and (x1, z1) Cvector field(Fcomp cp, double x0, double z0, double x1, double z1, int np) const; Dvector field(Fcomp cp, Afo foa, double x0, double z0, double x1, double z1, int np) const; // map propagation coordinate to original period double wrap(double z) const; // optical power (per lateral unit length) carried by the mode, // x-integral of Sz evaluated at the first interface, // +1 / -1 for normalized modes double power() const; // polarization character of the mode, relevant for vM = 1 only, // relative incoming / outgoing power carried by TE fields; // return value > 0.5 / < 0.5: a more TE-like / more TM-like mode double polcharacter() const; // --------------------------------------------------------------- // preparation of physical field plots: // selection of the global phase / snapshot time 0 within one period // multiply the entire field by a phase factor exp(i phi), // the internal representation is modified accordingly void adjustphase(double phi); // adjust the global phase, such that a plot(cp, ORG) of the physical // basic field component (cp = EY for TE, cp = HY for TM) exhibits the // maximum field at position (x, z) void adjustphase(double x, double z); // adjust the global phase, such that a plot(cp, ORG) of the physical // basic field component (cp = EY for TE, cp = HY for TM) exhibits an // overall field maximum (-> time snapshot of an extremal state // in case of a configuration with partially standing waves) // ... determine the maximum on a regular mesh of numx * mumz points // on a reasonable computational window void adjustphase(int numx, int numz); // ... as before, with (coarse) defaults for numx, numz void adjustphase(); // --------------------------------------------------------------- // visualization: output to MATLAB .m files // evaluation of the mode interference pattern in the display window // xbeg <= x <= xend, zbeg <= z <= zend // npx, npz: number of plot points in the output mesh // ext0, ext1: filename id characters for the m.file // image plot corresponding to field component cp // cp: one of EX, EY, EZ, HX, HY, HZ, SX, SY, SZ // foa: MOD, SQR, REP, IMP void plot(Fcomp cp, Afo foa, double xbeg, double xend, double zbeg, double zend, int npx, int npz, char ext0, char ext1) const; // image plot of the relative phase // cp: one of EX, EY, EZ, HX, HY, HZ void phasemap(Fcomp cp, double xbeg, double xend, double zbeg, double zend, int npx, int npz, char ext0, char ext1) const; // fancy style surface plot corresponding to component cp // cp: one of EX, EY, EZ, HX, HY, HZ, SX, SY, SZ void fplot(Fcomp cp, double xbeg, double xend, double zbeg, double zend, int npx, int npz, char ext0, char ext1) const; // animation of the light propagation // the frames show images of EY (TE) resp. HY (TM), at // ntfr equidistant times over one time period void movie(double xbeg, double xend, double zbeg, double zend, int npx, int npz, int ntfr, char ext0, char ext1) const; // animation of the light propagation, fancy style ;-) // the frames show surfaces of EY component (TE) resp. HY (TM), at // ntfr equidistant times over one time period void fmovie(double xbeg, double xend, double zbeg, double zend, int npx, int npz, int ntfr, char ext0, char ext1) const; // export full field data ("everything") into a viewer MATLAB file void viewer(double xbeg, double xend, double zbeg, double zend, int npx, int npz, char ext0, char ext1) const; // alternate BEP / QUEP representations char type; // BEP field container, type 'B' BepField fldB; // QUEP field container, type 'Q' QuepField fldQ; }; /* an array of guided Floquet-Bloch modes */ class FBModeArray { public: // number of modes included int num; // initialize FBModeArray(); // destroy ~FBModeArray(); // copy constructor FBModeArray(const FBModeArray& ma); // assignment FBModeArray& operator=(const FBModeArray& s); // free allocated memory void clear(); // subscripting FBMode& operator() (int i); FBMode operator() (int i) const; // add a mode void add(FBMode m); // delete a mode entry void remove(int i); // add an entire FBModeArray nma void merge(FBModeArray& nma); // sort the array by propagation constants, highest first void sort(); private: FBMode *mvec; }; /* ---------------------------------------------------------------------- */ /* spectral reduction to avoid eigensolver failures: lowest number of spectral terms allowed */ extern int FBNUMMXMIN; /* filter erroneous modal solutions with large power attenuation due to a nonnegligible imaginary part in the exp(i*beta*L) eigenvalue, att = |exp(i*beta*L)|, discard modes with |att-1| > FBMAXATTLVL */ extern double FBMAXATTLVL; /* selection of valid FB modes: after projection onto "vertical" directional slab modes associated with the lower- and uppermost layers in the structures, with LIMD and LIMN boundary conditions on one period, FB modes are selected as valid if the outward modes in those sets are assigned a relative directional power below FBVOPLVL; FBOPLVL = 0.0: only modes "below the light line" are considered */ extern double FBVOPLVL; /* FB-mode solver, guided mode analysis, st: the structure under consideration, including wavelength pol: polarization type, TE or TM cw: computational window for the BEP expansion Mx: number of spectral discetization terms red = 0, 1: prevent, permit spectral reduction to avoid convergence failures of the eigenvalue solver; limit: Mx >= NUMMXMIN ma: the FB modes found (output) quiet == 1: suppress log output return value: >=0: the number of found modes, <0: failed */ int fbmsolve(SegWgStruct st, Polarization pol, Interval cw, int Mx, int red, FBModeArray& mam, int quiet); int fbmsolve(SegWgStruct st, Polarization pol, Interval cw, int Mx, FBModeArray& mam, int quiet); /* -- vBEP - implementation --------------------------------------------- */ /* include common lateral wavenumber ky */ int fbmsolve(SegWgStruct st, Polarization pol, Complex ky, Interval cw, int Mx, int red, FBModeArray& mam, int quiet); /* ... with ky given by the incidence of mode of polarization pol, of order oder ord, coming in at border bdr, at angle theta (^o) */ int fbmsolve(SegWgStruct st, Polarization pol, SBorder bdr, int ord, double theta, Interval cw, int Mx, int red, FBModeArray& mam, int quiet); /* -- vQUEP - implementation --------------------------------------------- */ /* include common lateral wavenumber ky */ int fbmsolveQ(SegWgStruct st, Polarization pol, Complex ky, Interval cwx, int Mx, int Mz, FBModeArray& mam, int quiet); /* ... with ky given by the incidence of mode of polarization pol, of order oder ord, coming in at border bdr, at angle theta (^o) */ int fbmsolveQ(SegWgStruct st, Polarization pol, SBorder bdr, int ord, double theta, Interval cwx, int Mx, int Mz, FBModeArray& mam, int quiet); #endif // FBMODE_H