## File: simplebands.tex

package info (click to toggle)
meep 0.10-2.1
 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 \begin{comment} /* \end{comment} \section{Baby's First Bandstructure} \begin{comment} */ \end{comment} \begin{comment} #include #include #include using namespace meep; double eps(const vec &) { return 1.0; } const int rad = 10; const int ttot = 1500*rad; \end{comment} In this example we calculate the lowest four TE modes of a simple hollow metallic waveguide of radius one. \begin{verbatim} int main(int argc, char *argv[]) { initialize mpi(argc, argv); FILE *ban = master_fopen("bands", "w"); structure s(volcyl(1.0, 0.0, rad), eps); for (int m=0;m<3;m++) { for (double k=0.0; k<= 1.01; k += 0.25) { master_printf("Working on k of %g and m = %d with a=%d...\n", k, m, rad); fields f(&s, m); f.use_bloch(k); \end{verbatim} There are a few tricks you should know before you decide to go about calculating a band structure. One of the biggest problems in calculating a band structure in a time domain code is that of exciting all the modes you are interested in. Meep makes this easy with a couple of fields'' methods, \verb-initialize_with_n_te-, and \verb-initialize_with_n_tm-. These initialize the field with the n lowest TE and TM modes respectively. \begin{verbatim} f.initialize_with_n_te(4); \end{verbatim} The band structure code itself begins with a call to \verb-prepare_for_bands-, which allocates space to store the field data, which is later used for the band structure calculation. Its third argument is the maximum frequency you are interested in. \begin{verbatim} double fmax = 1.0, qmin = 200; f.prepare_for_bands(0, ttot, fmax, qmin); for (int t=0;t