⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplebands.tex

📁 采用FDTD时域有限差分法计算电磁波的传播问题等。
💻 TEX
字号:
\begin{comment}/*\end{comment}\section{Baby's First Bandstructure}\begin{comment}*/\end{comment}\begin{comment}#include <stdio.h>#include <stdlib.h>#include <meep.hpp>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 hollowmetallic waveguide of radius one.\begin{verbatim}int main(int argc, char *argv[]) {  initialize mpi(argc, argv);  file *ban = everyone_open_write("bands");  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 aboutcalculating a band structure.  One of the biggest problems in calculating aband structure in a time domain code is that of exciting all the modes youare 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 fielddata, which is later used for the band structure calculation.  Its thirdargument 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<ttot;t++) {\end{verbatim}The second band structure function is \verb-record_bands-, which justcopies the fields into the already allocated arrays for future use.\begin{verbatim}        f.record_bands();        f.step();      }\end{verbatim}Finally, the band structure is actually computed and output by the method\verb-output_bands-.  The key thing to know about\verb-output_bands- is that its last argument should be something liketwice the number of modes which have a frequency below your maximum.Rounding this number up slows the code down considerably, but can sometimesfix problems where harminv (which is used internally) doesn't find themodes correctly.  Usually, however, when harminv fails it means you aremisunderstanding something (for example, fmax may be less than the lowestfrequency mode).\begin{verbatim}      f.output_bands(ban, "band", 35);    }  }  everyone_close(ban);}\end{verbatim}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -