📄 lossgain_epsilon.tex
字号:
\section{Dielectric function of a material with loss and gain}\begin{comment}#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <meep.hpp>using namespace meep;const double a = 10.0;const int m = 0;const double eps_value = 2.25;const double pml_thickness = 1.0;const double rmax = 6.0/a;const double zsize = 2*pml_thickness+10.0/a;const double zmiddle = zsize/2.0;const double sourceloc = zmiddle - 4.0/a;const double r_look = 1.5/a, z_look = zmiddle, d = 1.0/a;double eps(const vec &) { return eps_value; }double one_in_middle(const vec &v) { const double midmax = r_look+2.0/a; const double midwid = 2.0/a; if (v.r() <= midmax && v.z() >= zmiddle-midwid && v.z() < zmiddle+midwid) { return 1; } else { return 0; }}int main(int argc, char **argv) { initialize mpi(argc, argv); deal_with_ctrl_c(); const char *dirname = make_output_directory(__FILE__); master_printf("Using pml of %g thickness.\n", pml_thickness); master_printf("Using an rmax of %g\n", rmax); structure s(volcyl(rmax + pml_thickness, zsize, a), eps, pml(pml_thickness)); s.set_output_directory(dirname);\end{comment}In this section, we demonstrate a better way to calculate the dielectricfunction, and illustrate it by computing the dielectric function of amaterial with a normal lossy resonance as well as a gain line. Gain in thePML is a bad idea, so we restrict the polarizabilities to exist only in themiddle of the system (which is surrounded by PML).\begin{figure}\label{lossgain_epsilon}\caption{Dielectric function of a material with loss and gain.}\includegraphics[width=8.8cm,clip=true]{lossgain_epsilon-out/eps}\end{figure}\begin{verbatim} s.add_polarizability(one_in_middle, 0.195, 0.03, 0.25*.25/.195); s.add_polarizability(one_in_middle, 0.25, 0.03,-0.25);\end{verbatim}\begin{comment} fields f(&s, m); f.output_hdf5(Dielectric, f.total_volume());\end{comment}For sources, we use a series of broad point sources covering the frequencyrange of interest.\begin{verbatim} f.add_point_source(Ep, 0.3, 0.8, 0.0, 8.0, veccyl(rmax*0.5,sourceloc));\end{verbatim}\begin{comment} master_printf("Working with a=%g...\n", a); monitor_point *left = NULL, *right = NULL, *middle = NULL, *top = NULL, *bottom = NULL; double next_printtime = 10; while (f.time() < 130 && !interrupt) { if (f.time() >= next_printtime) { next_printtime += 10; master_printf("Working on time %g... ", f.time()); master_printf("energy is %g\n", f.field_energy()); } f.step();\end{comment}The calculation proceeds as usual, except that we now keep track of a setof monitor points that will allow us to take a laplacian of the $H_z$ fieldcomponent. We choose $m=0$, so we won't have to deal with the $\phi$derivative.\begin{verbatim} left = f.get_new_point(veccyl(r_look , z_look - d), left); middle = f.get_new_point(veccyl(r_look , z_look ), middle); top = f.get_new_point(veccyl(r_look + d, z_look ), top); bottom = f.get_new_point(veccyl(r_look - d, z_look ), bottom); right = f.get_new_point(veccyl(r_look , z_look + d), right);\end{verbatim}\begin{comment} } grace g("eps", dirname); complex<double> *al, *ar, *am, *at, *ab, *freqs; int numl, numr; master_printf("Working on left fourier transform...\n"); double minfreq = 0.101, maxfreq = 0.5; int numfreqs = 300;\end{comment}We fourier transform $H_z$ at each point:\begin{verbatim} left->fourier_transform(Hz, &al, &freqs, &numl, minfreq, maxfreq, numfreqs);\end{verbatim}\begin{comment} delete[] freqs; master_printf("Working on middle fourier transform...\n"); middle->fourier_transform(Hz, &am, &freqs, &numr, minfreq, maxfreq, numfreqs); delete[] freqs; master_printf("Working on top fourier transform...\n"); top->fourier_transform(Hz, &at, &freqs, &numr, minfreq, maxfreq, numfreqs); delete[] freqs; master_printf("Working on bottom fourier transform...\n"); bottom->fourier_transform(Hz, &ab, &freqs, &numr, minfreq, maxfreq, numfreqs); delete[] freqs; master_printf("Working on right fourier transform...\n"); right->fourier_transform(Hz, &ar, &freqs, &numr, minfreq, maxfreq, numfreqs); if (numl != numr) master_printf("Aaack you need both nums to be the same!\n"); g.new_set(); g.set_legend("\\x\\e\\s1\\N"); complex<double> *epsilon = new complex<double>[numl];\end{comment}Finally, we calculate the laplacian of $H_z(\omega)$, which is equal to$-k^2 H_z(\omega)$, from which we extract epsilon.\begin{verbatim} for (int i=0;i<numl;i++) { complex<double> ksqr = -(ar[i]+al[i]-2.0*am[i] + at[i]*0.5*(1+(r_look+d)/r_look) + ab[i]*0.5*(1+(r_look-d)/r_look) - 2.0*am[i] - m*m*1.0*am[i]/r_look/r_look*a*a )*a*a/am[i]; epsilon[i] = ksqr/freqs[i]/freqs[i]/(2*pi*2*pi); }\end{verbatim}I've left out the bulk of this example from the manual itself, since itis pretty much the same as the previous examples. Among other features, weuse the grace functions to plot the result, which can be seen inFigure~\ref{lossgain_epsilon}.\begin{comment} for (int i=0;i<numl;i++) { g.output_point(real(freqs[i]), real(epsilon[i])); } g.new_set(); g.set_legend("\\x\\e\\s2\\N"); for (int i=0;i<numl;i++) { g.output_point(real(freqs[i]), imag(epsilon[i])); } g.new_set(); g.set_legend("analytic \\x\\e\\s1\\N"); for (int i=0;i<numl;i++) { g.output_point(real(freqs[i]), real(f.analytic_epsilon(real(freqs[i]),veccyl(r_look, z_look)))); } g.new_set(); g.set_legend("analytic \\x\\e\\s2\\N"); for (int i=0;i<numl;i++) { g.output_point(real(freqs[i]), imag(f.analytic_epsilon(real(freqs[i]),veccyl(r_look, z_look)))); }}\end{comment}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -