/
energy_cons_1d.tex
91 lines (83 loc) · 2.97 KB
/
energy_cons_1d.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
\begin{comment}
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
\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
demostrates how to use a 1D system.
\begin{figure}
\label{econs_1d}
\caption{Energy vs. Time.}
\epsfig{file=energy_cons_1d-out/energy.eps,width=8.8cm}
\end{figure}
\begin{comment}
#include "meep.h"
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}
mat ma(volone(20.0, a), eps);
\end{verbatim}
\begin{comment}
const char *dirname = make_output_directory(argv[0]);
ma.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}
ma.add_polarizability(one, 0.25, 0.0001, 3.0);
fields f(&ma);
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 %lg... ", f.time());
master_printf("energy is %lg\n", f.total_energy() - ezero);
master_printf("thermo energy is %lg\n", f.thermo_energy_in_box(f.v.surroundings()) - ezero);
//f.eps_slices();
\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}