Meep FAQ
From AbInitio
Revision as of 14:51, 21 May 2009 (edit) Stevenj (Talk | contribs) (→Why does my simulation diverge if ε < 0? - clarification) ← Previous diff |
Current revision (04:09, 22 February 2017) (edit) Ardavan (Talk | contribs) |
||
Line 1: | Line 1: | ||
{{Meep}} | {{Meep}} | ||
- | The following are frequently asked questions about Meep. Or, at any rate, they will be, now that Meep has been released. | + | The following are frequently asked questions about Meep. |
==General== | ==General== | ||
Line 20: | Line 20: | ||
===How does the current amplitude relate to the resulting field amplitude?=== | ===How does the current amplitude relate to the resulting field amplitude?=== | ||
There is no simple formula relating the input current amplitude ('''J''' in Maxwell's equations) to the resulting fields ('''E''') etcetera, even at the same point as the current. The exact same current will produce a different field (and radiate a different total power) depending upon the surrounding materials/geometry, and depending on the frequency. (This is a physical consequence of the geometry's effect on the local density of states; it can also be thought of as feedback from reflections on the source. As a simple example, if you put a current source inside a perfect electric conductor, the resulting field will be zero. As another example, the frequency-dependence of the radiated power in vacuum is part of the reason why the sky is blue.) | There is no simple formula relating the input current amplitude ('''J''' in Maxwell's equations) to the resulting fields ('''E''') etcetera, even at the same point as the current. The exact same current will produce a different field (and radiate a different total power) depending upon the surrounding materials/geometry, and depending on the frequency. (This is a physical consequence of the geometry's effect on the local density of states; it can also be thought of as feedback from reflections on the source. As a simple example, if you put a current source inside a perfect electric conductor, the resulting field will be zero. As another example, the frequency-dependence of the radiated power in vacuum is part of the reason why the sky is blue.) | ||
+ | |||
+ | See also our online book chapter on [http://arxiv.org/abs/arXiv:1301.5366 Wave source conditions]. | ||
If you are worried about this, then you are probably setting up your calculation in the wrong way. Especially in linear materials, the absolute magnitude of the field is useless; the only meaningful quantities are dimensionless ratios like the fractional transmission (the transmitted power relative to the transmitted power in some reference calculation). Almost always, you want to perform two calculations, one of which is a reference, and compute the ratio of a result in one calculation to the result in the reference. For nonlinear calculations, see [[Units and nonlinearity in Meep]]. | If you are worried about this, then you are probably setting up your calculation in the wrong way. Especially in linear materials, the absolute magnitude of the field is useless; the only meaningful quantities are dimensionless ratios like the fractional transmission (the transmitted power relative to the transmitted power in some reference calculation). Almost always, you want to perform two calculations, one of which is a reference, and compute the ratio of a result in one calculation to the result in the reference. For nonlinear calculations, see [[Units and nonlinearity in Meep]]. | ||
Line 30: | Line 32: | ||
===Why does my simulation diverge if ε < 0?=== | ===Why does my simulation diverge if ε < 0?=== | ||
- | Maxwell's equations are unstable for a frequency-independent negative ε. For any physical medium with negative ε, there must be dispersion, and you must likewise use dispersive materials in Meep to have negative ε at some desired frequency. (The requirement of dispersion to obtain negative ε follows from the Kramers–Kronig relations, and also follows from thermodynamic considerations that the energy in the electric field must be positive; see, for example, ''Electrodynamics of Continuous Media'' by Landau, Pitaevskii, and Lifshitz.) | + | Maxwell's equations have exponentially growing solutions for a frequency-independent negative ε. For any physical medium with negative ε, there must be dispersion, and you must likewise use dispersive materials in Meep to have negative ε at some desired frequency. (The requirement of dispersion to obtain negative ε follows from the Kramers–Kronig relations, and also follows from thermodynamic considerations that the energy in the electric field must be positive; see, for example, ''Electrodynamics of Continuous Media'' by Landau, Pitaevskii, and Lifshitz. At an even more fundamental level, it can be derived from [http://arxiv.org/abs/arXiv:1405.0238 passivity constraints].) |
If you solve Maxwell's equations in a homogenous-epsilon material at some real wavevector '''k''', you get a dispersion relation <math>\omega^2 = c^2 |\mathbf{k}|^2 / \varepsilon</math>. If ε is positive, there are two real solutions <math>\omega^2 = \pm c |\mathbf{k}| / \sqrt{\varepsilon}</math>, giving oscillating solutions. If ε is negative, there are two ''imaginary'' solutions ω, corresponding to exponentially decaying and ''exponentially growing solutions'' from any current source (which can always be spatially decomposed into a superposition of real-'''k''' values via a spatial Fourier transform). | If you solve Maxwell's equations in a homogenous-epsilon material at some real wavevector '''k''', you get a dispersion relation <math>\omega^2 = c^2 |\mathbf{k}|^2 / \varepsilon</math>. If ε is positive, there are two real solutions <math>\omega^2 = \pm c |\mathbf{k}| / \sqrt{\varepsilon}</math>, giving oscillating solutions. If ε is negative, there are two ''imaginary'' solutions ω, corresponding to exponentially decaying and ''exponentially growing solutions'' from any current source (which can always be spatially decomposed into a superposition of real-'''k''' values via a spatial Fourier transform). | ||
- | If you do a simulation of any kind in the time domain (not just FDTD), you pretty much can't avoid exciting both the decaying and the growing solutions. | + | If you do a simulation of any kind in the time domain (not just FDTD), you pretty much can't avoid exciting both the decaying and the growing solutions. This is ''not'' a numerical instability, it is a real solution of the underlying equations (for an unphysical material). |
See [[Materials in Meep]] for how to include dispersive materials (which can have negative ε and loss) in Meep. | See [[Materials in Meep]] for how to include dispersive materials (which can have negative ε and loss) in Meep. | ||
- | (If you have ''both'' negative ε and negative μ ''everywhere'', the famous case of a negative-index material, then the simulation is fine. However at the boundary between negative- and positive-index materials, you will encounter instabilities: because of the way Maxwell's equations are discretized in FDTD, the ε and μ are discretized on different spatial grids, and you will get a half-pixel or so of εμ <0 at the boundary between negative and positive indices, which will cause the simulation to diverge. But of course, any physical negative-index metamaterial also involves dispersion.) | + | (If you have ''both'' negative ε and negative μ ''everywhere'', the famous case of a negative-index material, then the simulation is fine. However at the boundary between negative- and positive-index materials, you will encounter instabilities: because of the way Maxwell's equations are discretized in FDTD, the ε and μ are discretized on different spatial grids, so you will get a half-pixel or so of εμ < 0 at the boundary between negative and positive indices, which will cause the simulation to diverge. But of course, any physical negative-index metamaterial also involves dispersion.) |
+ | |||
+ | Note also that, as a consequence of the above analysis, ε must go to a positive value in the <math>\omega\to\pm\infty</math> limits to get non-diverging solutions of Maxwell's equations. So the <math>\epsilon_\infty</math> in your [[Materials in Meep|dispersion model]] must be positive. | ||
==Usage== | ==Usage== | ||
+ | ===Why doesn't turning off subpixel averaging work?=== | ||
+ | By default, when Meep assigns a dielectric constant ε (or μ) to each "pixel", it uses a carefully designed average of the ε values within that pixel. This subpixel averaging generally improves the accuracy of the simulation—perhaps counter-intuitively, for geometries with discontinous ε it is ''more'' accurate (i.e. closer to the exact Maxwell result for the ''discontinuous'' case) to do the simulation with the subpixel-averaged (''smoothed'') ε, as long as the averaging is done properly. (See [[Citing Meep|our papers]] for more information.) | ||
+ | |||
+ | Still, there are times when, for whatever reason, you might not want this feature. (For example, if your accuracy is limited by other issues, or if you want to skip the wait at the beginning of the simulation for it do to the averaging.) In this case, you can disable the subpixel averaging by doing <code>(set! eps-averaging? false)</code> in your control file (see the [[Meep Reference]]). | ||
+ | |||
+ | Even if you disable the subpixel averaging, however, when you output the dielectric function to a file and plot it, you may notice that there are some pixels with intermediate ε values, right at the boundary between two materials. This has a completely different source. Internally, Meep's simulation is performed on a [[Yee grid]], in which every field component is stored on a slightly different grid (offset from one another by half-pixels), and the ε values are also stored on this Yee grid. For output purposes, however, it is more user-friendly to output all fields etcetera on the same grid (the center of each pixel), so all quantities are interpolated onto this grid for output. Therefore, even though the internal ε values are indeed discontinuous when you disable subpixel averaging, the ''output'' file will still contain some "averaged" values at interfaces due to the interpolation from the Yee grid to the center-pixel grid. | ||
[[Category:Meep]] | [[Category:Meep]] |
Current revision
Meep |
Download |
Release notes |
FAQ |
Meep manual |
Introduction |
Installation |
Tutorial |
Reference |
C++ Tutorial |
C++ Reference |
Acknowledgements |
License and Copyright |
The following are frequently asked questions about Meep.
Contents |
General
What is Meep?
Meep is our free software for finite-difference time-domain simulation. For the meaning of the name "Meep", see Meep acronym expansions.
Installation
Where can I install Meep?
Meep should run on any Unix-like system, from individual machines to clusters to large parallel supercomputers. We do most of our development on GNU/Linux systems, and precompiled packages are available for Debian and Ubuntu. It should also be possible to install Meep on Windows using the free Cygwin Unix-compatibility environment. Installing Meep from source code requires some understanding of Unix, however, especially to install the various prerequisites, and we recommend consulting a local Unix guru at your institution if you run into trouble.
Guile is installed, but configure complains that it can't find guile
With most GNU/Linux distributions (and Cygwin), packages like Guile are split into two pieces: a guile
package that just contains the libraries and executables, and a guile-dev
or guile-devel
package that contains the header files and other things needed to compile programs using Guile. Usually, the former is installed by default, by the latter is not. You need to install both, which means that you probably need to install guile-dev
. (Similarly for any other library packages needed by Meep.)
Physics
How does the current amplitude relate to the resulting field amplitude?
There is no simple formula relating the input current amplitude (J in Maxwell's equations) to the resulting fields (E) etcetera, even at the same point as the current. The exact same current will produce a different field (and radiate a different total power) depending upon the surrounding materials/geometry, and depending on the frequency. (This is a physical consequence of the geometry's effect on the local density of states; it can also be thought of as feedback from reflections on the source. As a simple example, if you put a current source inside a perfect electric conductor, the resulting field will be zero. As another example, the frequency-dependence of the radiated power in vacuum is part of the reason why the sky is blue.)
See also our online book chapter on Wave source conditions.
If you are worried about this, then you are probably setting up your calculation in the wrong way. Especially in linear materials, the absolute magnitude of the field is useless; the only meaningful quantities are dimensionless ratios like the fractional transmission (the transmitted power relative to the transmitted power in some reference calculation). Almost always, you want to perform two calculations, one of which is a reference, and compute the ratio of a result in one calculation to the result in the reference. For nonlinear calculations, see Units and nonlinearity in Meep.
How do I set the imaginary part of ε?
If you only care about the imaginary part of ε in a narrow bandwidth around some frequency ω, you should set it by using the electric conductivity as described in Conductivity in Meep. If you care about the imaginary part of ε over a broad bandwidth, then for any physical material the imaginary part will be frequency-dependent and you will have to fit it to Meep's dispersive-ε support (see Material dispersion in Meep).
Meep doesn't implement a frequency-independent complex ε. Not only is this not physical, but it also leads to both exponentially decaying and exponentially growing solutions in Maxwell's equations from positive- and negative-frequency Fourier components, respectively, so it cannot be simulated in the time domain.
Why does my simulation diverge if ε < 0?
Maxwell's equations have exponentially growing solutions for a frequency-independent negative ε. For any physical medium with negative ε, there must be dispersion, and you must likewise use dispersive materials in Meep to have negative ε at some desired frequency. (The requirement of dispersion to obtain negative ε follows from the Kramers–Kronig relations, and also follows from thermodynamic considerations that the energy in the electric field must be positive; see, for example, Electrodynamics of Continuous Media by Landau, Pitaevskii, and Lifshitz. At an even more fundamental level, it can be derived from passivity constraints.)
If you solve Maxwell's equations in a homogenous-epsilon material at some real wavevector k, you get a dispersion relation . If ε is positive, there are two real solutions , giving oscillating solutions. If ε is negative, there are two imaginary solutions ω, corresponding to exponentially decaying and exponentially growing solutions from any current source (which can always be spatially decomposed into a superposition of real-k values via a spatial Fourier transform).
If you do a simulation of any kind in the time domain (not just FDTD), you pretty much can't avoid exciting both the decaying and the growing solutions. This is not a numerical instability, it is a real solution of the underlying equations (for an unphysical material).
See Materials in Meep for how to include dispersive materials (which can have negative ε and loss) in Meep.
(If you have both negative ε and negative μ everywhere, the famous case of a negative-index material, then the simulation is fine. However at the boundary between negative- and positive-index materials, you will encounter instabilities: because of the way Maxwell's equations are discretized in FDTD, the ε and μ are discretized on different spatial grids, so you will get a half-pixel or so of εμ < 0 at the boundary between negative and positive indices, which will cause the simulation to diverge. But of course, any physical negative-index metamaterial also involves dispersion.)
Note also that, as a consequence of the above analysis, ε must go to a positive value in the limits to get non-diverging solutions of Maxwell's equations. So the in your dispersion model must be positive.
Usage
Why doesn't turning off subpixel averaging work?
By default, when Meep assigns a dielectric constant ε (or μ) to each "pixel", it uses a carefully designed average of the ε values within that pixel. This subpixel averaging generally improves the accuracy of the simulation—perhaps counter-intuitively, for geometries with discontinous ε it is more accurate (i.e. closer to the exact Maxwell result for the discontinuous case) to do the simulation with the subpixel-averaged (smoothed) ε, as long as the averaging is done properly. (See our papers for more information.)
Still, there are times when, for whatever reason, you might not want this feature. (For example, if your accuracy is limited by other issues, or if you want to skip the wait at the beginning of the simulation for it do to the averaging.) In this case, you can disable the subpixel averaging by doing (set! eps-averaging? false)
in your control file (see the Meep Reference).
Even if you disable the subpixel averaging, however, when you output the dielectric function to a file and plot it, you may notice that there are some pixels with intermediate ε values, right at the boundary between two materials. This has a completely different source. Internally, Meep's simulation is performed on a Yee grid, in which every field component is stored on a slightly different grid (offset from one another by half-pixels), and the ε values are also stored on this Yee grid. For output purposes, however, it is more user-friendly to output all fields etcetera on the same grid (the center of each pixel), so all quantities are interpolated onto this grid for output. Therefore, even though the internal ε values are indeed discontinuous when you disable subpixel averaging, the output file will still contain some "averaged" values at interfaces due to the interpolation from the Yee grid to the center-pixel grid.