#ifndef BEND_H #define BEND_H /* * METRIC --- Mode expansion modeling in integrated optics / photonics * http://metric.computational-photonics.eu/ */ /* * bend.h * 2-D modes of curved slab waveguides */ /* ------------------------------------------------------------------------ */ #define BF_CIRC // use routines for cylindrical functions adapted from the // Circurs-package /* ------------------------------------------------------------------------ */ /* a bend mode */ class BDMode { public: // Polarization Polarization pol; // bend radius double R; // center position double x0; double z0; // refractive index profile; positions relative to radius R Waveguide wg; // the bend structure OvlStruct bend; // vacuum wavenumber double k0; // 1/(omega*mu0) double invommu0; // 1/(omega*epsilon0) double invomep0; // phase propagation constant double beta; // attenuation constant double alpha; // effective index inline Complex c_neff() const { return Complex(beta, -alpha)/k0; }; // complex angular propagation constant inline Complex c_gamma() const { return Complex(beta, -alpha); }; // complex angular order of the BDM inline Complex c_m() const { return Complex(R*beta, -R*alpha); }; // BDM field Complex field(Fcomp cp, double x, double z) const; Complex field(Fcomp cp, double r) const; void emfield(double x, double z, Complex &ex, Complex &ey, Complex &ez, Complex &hx, Complex &hy, Complex &hz) const; void emfield_r(double x, double z, Complex &er, Complex &ey, Complex &ep, Complex &hr, Complex &hy, Complex &hp) const; // ... values on a rectangular mesh Cmatrix field(Fcomp cp, Interval dwx, int npx, Interval dwz, int npz) const; // radial order: // number of interior nodes in the real part of the radial profile int ord; // token of the mode char ids[16]; // determine the radial order: rough lookup; set mode id void classify(); // power transported in angular direction // on infinite radial interval at angle theta double power(double theta) const; // normalize to unit angular power at angle 0 void normalize(); // power normalization factor Complex nrm; // translate the BDM: shift the origin by dx, dz void translate(double dx, double dz); // direction of propagation: FORW (clockwise, default), BACK (anticlockwise) Propdir dir; // reverse the BDM: clockwise propagation -> anticlockwise propagation void reverse(); // ----------------------------------------------------------- // visualization: output to MATLAB .m files // evaluation of the field pattern in the display window // xbeg <= x <= xend, zbeg <= z <=zend // npx, npz: number of points in output mesh // ext0, ext1: filename id characters for the .m file // profile plot corresponding to component cp (static, t=0) // cp: EX, EY, EZ, HX, HY, HZ, ER EP, HR, HP // 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; // export full field data ("everything") into a viewer MATLAB file // animation ignoring the field decay void viewer(double xbeg, double xend, double zbeg, double zend, int npx, int npz, char ext0, char ext1) const; // piecewise internal representation by Bessel functions, // coefficients Cvector cA; Cvector cB; // evaluate transverse resonance condition, set cA, cB accordingly Complex travres(); Complex travres(Complex g); double tr_error; Complex tr_Ainit; void tr_init(Complex tg); // radial profile, principal component Complex profile(double r) const; // ... and its derivative Complex d_profile(double r) const; // typical interior and exterior crop radii double cRi; double cRe; // use discretized versions (1) of the radial profile int disc_prof; // initialize discrete profiles // on radial interval [ir < wg.hx(.) < re] with nr steps void discretize(double ri, double re, int nr); private: // storage space for discretized profiles Ivector n_rad; Dmatrix v_rad; Cmatrix v_prf; Cmatrix v_dpr; Cmatrix d_prf; Cmatrix d_dpr; double d_ri; double d_re; }; /* default profile crop radii: */ /* contributions for radii below (radius of the innermost interface)-BDMp_R_CROP_IN*(vacuum wavelength) will be neglected */ extern double BDMp_R_CROP_IN; /* contributions for radii above (radius of the outermost interface)+BDMp_R_CROP_OUT*(vacuum wavelength) will be neglected */ extern double BDMp_R_CROP_OUT; /* ------------------------------------------------------------------------ */ /* an array of BDMs */ class BDModeArray { public: // number of modes included int num; // initialize BDModeArray(); // destroy ~BDModeArray(); // copy constructor BDModeArray(const BDModeArray& ma); // assignment BDModeArray& operator=(const BDModeArray& s); // free allocated memory void clear(); // subscripting BDMode& operator() (int i); BDMode operator() (int i) const; // add a mode void add(BDMode m); // delete a mode entry void remove(int i); // add an entire BDModeArray nma void merge(BDModeArray& nma); // sort the array by phase propagation constants: highest first void sort(); /* sort the array by mode order, lowest first, invalid last */ void order(); private: BDMode *mvec; }; /* ------------------------------------------------------------------------ BDM mode analysis procedures ------------------------------------------------------------------------ */ /* Heuristics for mode finding: mode order identification by solving an equivalent straight problem with Dirichlet boundary conditions */ // staircase approximation of the equiv. st. problem, number of slices extern int BDMsP_NumSlices; // radial distance of interior boundary to pos. R, in vacuum wavelengths extern double BDMsP_IntBd; // radial distance of exterior boundary to pos. R, in vacuum wavelengths extern double BDMsP_ExtBd; // number of spectral terms examined extern int BDMsP_NSpT; /* complex root finding */ // initial attenuation, upper level */ extern double BDMsP_IniMaxAtt; // initial attenuation, lower level */ extern double BDMsP_IniMinAtt; // secant method, terminal distance of root prototypes extern double BDMsP_RootAcc; /* solver procedure */ /* for the bend with radial layering w, radius r, centered at (xc, zc), try to find pol-polarized BDMs of lowest order, consider ntre * ntim trial values for complex effective mode indices, lorm=1: consider modes of lowest radial order only, quiet = 0, 1, 2: all, less, no log output */ int bdmsolve(Waveguide w, double r, double xc, double zc, Polarization pol, int lorm, int ntre, int ntim, BDModeArray& bdma, int quiet); /* Bessel functions, complex order, real argument, wrapper functions */ Complex BfJ(Complex o, double a); Complex BfY(Complex o, double a); Complex dBfJ(Complex o, double a); Complex dBfY(Complex o, double a); #endif // BEND_H