## File: energy_cons_1d.tex

package info (click to toggle)
meep 0.10-2.1
 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 \begin{comment} #include #include #include \end{comment} \section{Energy conservation in one dimension} In this example, we compute the total energy over time for a polaritonic material in one dimension to verify that it is indeed conserved. This also demonstrates how to use a 1D system. \begin{figure} \label{econs_1d} \caption{Energy vs. Time.} \includegraphics[width=8.8cm,clip=true]{energy_cons_1d-out/energy} \end{figure} \begin{comment} #include using namespace meep; const double a = 10; \end{comment} For our example polaritonic material, we'll use an $\epsilon(0)$ of 13.4. We will put the polaritons in just one quarter of our system to add a little extra excitement. \begin{verbatim} double eps(const vec &) { return 13.4; } double one(const vec &p) { return (p.z() > 15.0)?1:0; } \end{verbatim} \begin{comment} int main(int argc, char **argv) { initialize mpi(argc, argv); deal_with_ctrl_c(); const double ttot = 600.0; \end{comment} We create a 1D system by making the volume with the \verb!volone!'' function, and making sure any vecs we use are one dimensional. \begin{verbatim} structure s(volone(20.0, a), eps); \end{verbatim} \begin{comment} const char *dirname = make_output_directory(__FILE__); s.set_output_directory(dirname); \end{comment} The polarizability is added as usual... in this case we use a very sharp resonance, which means that our energy will only be very slowly absorbed. \begin{verbatim} s.add_polarizability(one, 0.25, 0.0001, 3.0); fields f(&s); grace g("energy", dirname); \end{verbatim} We use several point sources, to cover a broad frequency range, just for the heck of it. \begin{verbatim} f.add_point_source(Ex, 0.6 , 1.8, 0.0, 8.0, vec(2.0)); f.add_point_source(Ex, 0.4 , 1.8, 0.0, 8.0, vec(2.0)); f.add_point_source(Ex, 0.33, 1.8, 0.0, 8.0, vec(2.0)); \end{verbatim} \begin{comment} const double ezero = f.total_energy(); double next_printtime = 10; while (f.time() < ttot && !interrupt) { if (f.time() >= next_printtime) { next_printtime += 10; master_printf("Working on time %g... ", f.time()); master_printf("energy is %g\n", f.total_energy() - ezero); master_printf("thermo energy is %g\n", f.thermo_energy_in_box(f.v.surroundings()) - ezero); \end{comment} We plot the total energy, the electromagnetic energy and the thermodynamic energy'' which is the energy that is either stored in the polarization, or has been converted into heat, or (if we had a saturating gain system) perhaps is stored in a population inversion. \begin{verbatim} g.output_out_of_order(0, f.time(), f.total_energy() - ezero); g.output_out_of_order(1, f.time(), f.electric_energy_in_box(f.v.surroundings()) + f.magnetic_energy_in_box(f.v.surroundings())); g.output_out_of_order(2, f.time(), f.thermo_energy_in_box(f.v.surroundings()) - ezero); \end{verbatim} \begin{comment} } f.step(); } } \end{comment}