Configuration and customization¶
:meep_adjoint
is highly customizable, offering a large number
of user-configurable options and a convenient hierarchical framework
for setting and updating their values.
What are the configurable options? How do they affect the behavior of the package?¶
At the bottom of this page you’ll find an exhaustive bleeding-edge list
autogenerated from the most recent version of the meep_adjoint
source code,
but for starters here are some of the more useful options, categorized by the
sector of meep_adjoint
behavior they affect:
- Options governing FDTD calculations and simulation geometries
res
: Yee grid resolution
dpml
: Width of PML layers
dft_reltol
: Continue timestepping until frequency-domain fields have converged to within this relative error- Options governing design optimization
element_type
: type (family and order) of finite-element basis function, as tabulated e.g. in the FENICS documentation or the periodic table of finite elements.
element_length
: lengthscale of finite-element discretization
alpha
: relaxation parameter for simple gradient-descent optimizer- Options governing console and file output
filebase
: base name of output files
silence_meep
: suppress :codename:meep console messagesduring timestepping
- Options governing graphical visualization
latex
: Use math:LaTeX
formatting for graph axes and titles
linecolor
: Color of lines and curves (default)
src_region_linecolor
: Color of lines and curves in plots of source regions
flux_region_linecolor
: Color of lines and curves in plots of flux regions
flux_data_linecolor
: Color of lines and curves in plots of flux data
How do I fetch current option settings from meep_adjoint
driver scripts?¶
By calling meep_adjoint.get_adjoint_option
or
meep_adjoint.get_visualization_option
:
from meep_adjoint import get_adjoint_option as adj_opt
from meep_adjoint import get_visualization_option as vis_opt
fcen = adj_opt('fcen')
src_lc = vis_opt('src_region_linecolor')
foo = adj_opt('bar')
if foo is None:
print('Whoops! There is no option named --bar.')
How does meep_adjoint
determine settings for configuration options?¶
meep_adjoint
begins by setting each option to the
hard-coded default value provided as part of the option’s
definition (see below), then looks for updates in each of
the following places, in the following sequence, with
each update overriding the previous setting.
- 2. Script-level defaults
The python script you write to drive
meep_adjoint
may callmeep_adjoint.set_option_defaults
to specify problem-specific default values for certain options.- 3. User-level defaults: Global configuration files
The global configuration files are
~/.meep_adjoint.rc
,~/.meep_visualization.rc
. Typically this would be for options on which you have a personal preference that differs from themeep_adjoint
default and which you want to configure once and for all and have it be generally active in all yourmeep_adjoint
sessions, except where overruled by a setting from a higher-priority source like command-line. Example: If you love chartreuse and hate cyan, you will want to change the default colors used by the visualization module to draw Poynting-flux monitors, and you’ll want this change to be generally in effect in all your sessions unless specifically overridden.- 4. Project-level defaults: Local configuration files
The local configuration files are
meep_adjoint.rc
,meep_visualization.rc
in the current working directory. These are for updates that you want to be in effect for all work on a particular project.- 5. Session-level settings: Environment variables
- 6. Run-level settings: Command-line arguments
- 7. Console-level / function-call level settings
Adjoint options¶
Option |
Default |
Description |
---|---|---|
|
20.0 |
Yee grid resolution |
|
0.0 |
source center frequency |
|
0.0 |
source frequency width |
|
Ez |
forward source component (str) |
|
1 |
forward source eigenmode index |
|
1 |
number of DFT frequencies |
|
-1.0 |
PML width (-1 –> auto-select) |
|
-1.0 |
gap width between material bodies and PMLs (-1 –> auto-select) |
|
1.0 |
function of (x,y,z) giving initial design permittivity |
|
1e-06 |
convergence tolerance for terminating timestepping |
|
10.0 |
max runtime in units of last_source_time |
|
0.25 |
meep time between DFT convergence checks in units of last_source_time |
|
False |
use complex fields in forward calculation |
|
False |
reuse (do not reallocate) simulation data structure |
Option |
Default |
Description |
---|---|---|
|
0.0 |
lower bound on basis expansion coefficient |
|
inf |
upper bound on basis expansion coefficient |
|
CG 1 |
finite-element family and degree |
|
0.0 |
finite-element discretization length |
Option |
Default |
Description |
---|---|---|
|
1.0 |
initial value of alpha (update relaxation parameter) |
|
0.001 |
minimum value of alpha |
|
10.0 |
maximum value of alpha |
|
1.25 |
sometimes you just gotta live a little (explain me) |
|
0.75 |
can’t be too cautious in this dangerous world (explain me) |
|
100 |
max number of optimization iterations |
Option |
Default |
Description |
---|---|---|
|
base name of output files |
|
|
True |
suppress MEEP console messages when timestepping |
|
info |
[‘info’|’debug’] |
|
auto |
[‘on’|’off’|’auto’] to enable/disable/automate graphical visualization |
|
True |
output colorized terminal text |
|
auto |
[‘on’|’off’|’auto’] to enable/disable/automate GUI dashboard |
|
0.5 |
GUI dashboard size relative to screen size |
|
top right |
GUI dashboard position |
|
Fantasque Sans Mono |
GUI dashboard font family |
|
1.0 |
GUI dashboard font scale factor |
|
True |
GUI dashboard stays on top of other windows |
|
2000 |
GUI dashboard CPU usage update interval (ms) |
|
localhost |
GUI dashboard server hostname |
|
37673 |
GUI dashboard server port |
|
info |
‘info’ | ‘debug’ |
Visualization options¶
Sectioned visualization options¶
Option |
Default |
Description |
---|---|---|
|
plasma |
default colormap |
|
1.0 |
default transparency |
|
25 |
font size for labels and titles |
|
gouraud |
shading style |
|
gaussian |
interpolation method |
|
contourf |
contourf | imshow |pcolormesh |
|
100 |
number of contours |
|
#ff0000 |
default line color |
|
4.0 |
default line width |
|
default line style |
|
|
#ffffff |
default fill color |
|
-inf |
colormap minimum |
|
inf |
colormap maximum |
|
0.6 |
|
|
0.8 |
|
|
0.04 |
colorbar padding |
|
0.6 |
colorbar shrink factor |
|
True |
LaTeX text formatting |
|
True |
display plots on screen |