Meep Reference
From AbInitio
Revision as of 06:11, 7 November 2005 (edit) Stevenj (Talk  contribs) (→Predefined Variables) ← Previous diff 
Revision as of 06:12, 7 November 2005 (edit) Stevenj (Talk  contribs) (→Constants (enumerated types)) Next diff → 

Line 78:  Line 78:  
: Specify a particular field (or other) component. One of <code>Ex</code>, <code>Ey</code>, <code>Ez</code>, <code>Er</code>, <code>Ep</code>, <code>Hx</code>, <code>Hy</code>, <code>Hz</code>, <code>Hy</code>, <code>Hp</code>, <code>Hz</code>, <code>Dx</code>, <code>Dy</code>, <code>Dz</code>, <code>Dr</code>, <code>Dp</code>, <code>Dielectric</code>, for: <math>E_x</math>, <math>E_y</math>, <math>E_z</math>, <math>E_r</math>, <math>E_\phi</math>, <math>H_x</math>, <math>H_y</math>, <math>H_z</math>, <math>H_r</math>, <math>H_\phi</math>, <math>D_x</math>, <math>D_y</math>, <math>D_z</math>, <math>D_r</math>, <math>D_\phi</math>, <math>\varepsilon</math>, respectively.  : Specify a particular field (or other) component. One of <code>Ex</code>, <code>Ey</code>, <code>Ez</code>, <code>Er</code>, <code>Ep</code>, <code>Hx</code>, <code>Hy</code>, <code>Hz</code>, <code>Hy</code>, <code>Hp</code>, <code>Hz</code>, <code>Dx</code>, <code>Dy</code>, <code>Dz</code>, <code>Dr</code>, <code>Dp</code>, <code>Dielectric</code>, for: <math>E_x</math>, <math>E_y</math>, <math>E_z</math>, <math>E_r</math>, <math>E_\phi</math>, <math>H_x</math>, <math>H_y</math>, <math>H_z</math>, <math>H_r</math>, <math>H_\phi</math>, <math>D_x</math>, <math>D_y</math>, <math>D_z</math>, <math>D_r</math>, <math>D_\phi</math>, <math>\varepsilon</math>, respectively.  
; <code>derivedcomponent</code> constants  ; <code>derivedcomponent</code> constants  
  : These are additional components, which are not actually stored by Meep but are computed as needed, mainly for use in output functions. One of <code>Sx</code>, <code>Sy</code>, <code>Sz</code>, <code>Sr</code>, <code>Sp</code>, <code>EnergyDensity</code>, <code>DEnergyDensity</code>, <code>HEnergyDensity</code> for: <math>S_x</math>, <math>S_y</math>, <math>S_z</math>, <math>S_r</math>, <math>S_\phi</math> (components of the Poynting vector <math>\mathrm{Re}\,\mathbf{E}^* \times \mathbf{H}</math>), <math>\mathbf{E}^* \cdot \mathbf{D}/2</math>, <math>\mathbf{H}^2/2</math>, respectively.  +  : These are additional components, which are not actually stored by Meep but are computed as needed, mainly for use in output functions. One of <code>Sx</code>, <code>Sy</code>, <code>Sz</code>, <code>Sr</code>, <code>Sp</code>, <code>EnergyDensity</code>, <code>DEnergyDensity</code>, <code>HEnergyDensity</code> for: <math>S_x</math>, <math>S_y</math>, <math>S_z</math>, <math>S_r</math>, <math>S_\phi</math> (components of the Poynting vector <math>\mathrm{Re}\,\mathbf{E}^* \times \mathbf{H}</math>), <math>(\mathbf{E}^* \cdot \mathbf{D} + \mathbf{H}^2)/2</math>, <math>\mathbf{E}^* \cdot \mathbf{D}/2</math>, <math>\mathbf{H}^2/2</math>, respectively. 
== Classes ==  == Classes == 
Revision as of 06:12, 7 November 2005
Meep 
Download 
Release notes 
FAQ 
Meep manual 
Introduction 
Installation 
Tutorial 
Reference 
C++ Tutorial 
C++ Reference 
Acknowledgements 
License and Copyright 
Here, we document the features exposed to the user by the Meep package. We do not document the Scheme language or the functions provided by libctl (see also the libctl User Reference section of the libctl manual).
This page is simply a compact listing of the functions exposed by the interface; for a gentler introduction, see the Meep tutorial. Also, we note that this page is not, and probably never will be, a complete listing of all functions. In particular, because of the SWIG wrappers, every function in the C++ interface is accessible from Scheme, but not all of these functions are documented or intended for end users.
Contents 
Input Variables
These are global variables that you can set to control various parameters of the Meep computation. In brackets after each variable is the type of value that it should hold. (The classes, complex datatypes like geometricobject
, are described in a later subsection. The basic datatypes, like integer
, boolean
, cnumber
, and vector3
, are defined by libctl.)

geometry
[list ofgeometricobject
class]  Specifies the geometric objects making up the structure being simulated. When objects overlap, later objects in the list take precedence. Defaults to no objects (empty list).

sources
[list ofsource
class]  Specifies the current sources to be present in the simulation; defaults to none.

symmetries
[list ofsymmetry
class]  Specifies the spatial (mirror/rotation) symmetries to exploit in the simulation (defaults to none). The symmetries must be obeyed by both the structure and by the sources. See also: Exploiting symmetry in Meep.

pmllayers
[list ofpml
class]  Specifies the absorbing PML boundary layers to use; defaults to none.

defaultmaterial
[materialtype
class]  Holds the default material that is used for points not in any object of the geometry list. Defaults to
air
(ε of 1). 
geometrylattice
[lattice
class]  Specifies the the size of the unit cell (which is centered on the origin of the coordinate system). If any dimension of the lattice
size
is the special valuenosize
, then the dimension of the lattice is reduced (i.e. it becomes two or onedimensional) by default. Defaults to a cubic cell of unit size. 
dimensions
[integer
]  Explicitly specifies the dimensionality of the simulation, if the value is less than 3. If the value is 3 (the default), then the dimensions are automatically reduced if possible when any of the
geometrylattice
sizes arenosize
. Ifdimensions
is the special value ofCYLINDRICAL
, then cylindrical coordinates are used and the x and z dimensions are interpreted as r and z, respectively. 
m
[number
]  For
CYLINDRICAL
simulations, specifies that the angular φ dependence of the fields is of the form e^{imφ} (default ism=0
). If the simulation cell includes the origin r = 0, thenm
must be an integer. 
resolution
[number
orvector3
]  Specifies the computational grid resolution, in pixels per distance unit. Defaults to
10
. 
ensureperiodicity
[boolean
] 
kpoint
[false
orvector3
]  If
false
(the default), then the boundaries are perfect metallic (zero electric field). If a vector, then the boundaries are Blochperiodic: the fields at one side are times the fields at the other side, separated by the lattice vector . Thekpoint
vector is specified in Cartesian coordinates, in units of 2π/distance. (This is different from MPB, equivalent to taking MPB'skpoints
through the functionreciprocal>cartesian
.) 
ensureperiodicity
[boolean
]  If
true
(the default), and if the boundary conditions are periodic (kpoint
is notfalse
), then the geometric objects are automatically repeated periodically according to the lattice vectors (the size of the computational cell). 
forcecomplexfields?
[boolean
]  By default, Meep runs its simulations with purely real fields whenever possible. It uses complex fields (which require twice the memory and computation) if the
kpoint
is nonzero or ifm
is nonzero. However, by settingforcecomplexfields?
totrue
, Meep will always use complex fields. See also: Complex fields in Meep. 
filenameprefix
[string
]  A string prepended to all output filenames. Defaults to the name of the current ctl file, with ".ctl" replaced by "" (e.g.
foo.ctl
uses a"foo"
prefix). 
Courant
[number
]  Specify the Courant factor S which relates the time step size to the spatial discretization
 cΔt = SΔx. Default is
0.5
. For numerical stability, the Courant factor must be at most Failed to parse (unknown error): 1/\sqrt{\textrm{# dimensions}}
, and in practice should be slightly smaller.

outputvolume
[meep::geometric_volume*
]  Specifies the default region of space that is output by the HDF5 output functions (below); see also the
(volume ...)
function to createmeep::geometric_volume*
objects. The default is'()
(null), which means that the whole computational cell is output. Normally, you should use the(involume ...)
function to modify the output volume instead of settingoutputvolume
directly. 
progressinterval
[number
]  Time interval (seconds) after which Meep prints a progress message; default is 4 seconds.
The require a bit more understanding of the inner workings of Meep to use (see also the SWIG wrappers).

structure
[meep::structure*
]  Pointer to the current structure being simulated; initialized by
(initstructure)
which is called automatically by(initfields)
which is called automatically by any of the(run)
functions. 
fields
[meep::fields*
]  Pointer to the current fields being simulated; initialized by
(initfields)
which is called automatically by any of the(run)
functions. 
numchunks
[integer
]  Minimum number of "chunks" (subarrays) to divide the structure/fields into (default 0); actual number is determined by number of processors, PML layers, etcetera. (Mainly useful for debugging.)
Predefined Variables
Variables predefined for your convenience and amusement.

air
,vacuum
[materialtype
class]  Two aliases for a predefined material type with a dielectric constant of 1.

metal
[materialtype
class]  A predefined material type corresponding to a perfectly conducting metal (in which the electric field is zero).

nothing
[materialtype
class]  A material that, effectively, punches a hole through other objects to the background (
defaultmaterial
orepsiloninputfile
). 
infinity
[number
]  A big number (1.0e20) to use for "infinite" dimensions of objects.

pi
[number
]  π (3.14159...).
Constants (enumerated types)
Several of the functions/classes in Meep ask you to specify e.g. a field component or a direction in the grid. These should be one of the following constants:

direction
constants  Specify a direction in the grid. One of
X
,Y
,Z
,R
,P
for: x, y, z, r, φ, respectively. 
boundaryside
constants  Specify particular boundary in some direction (e.g. + x or − x). One of
Low
orHigh
. 
component
constants  Specify a particular field (or other) component. One of
Ex
,Ey
,Ez
,Er
,Ep
,Hx
,Hy
,Hz
,Hy
,Hp
,Hz
,Dx
,Dy
,Dz
,Dr
,Dp
,Dielectric
, for: E_{x}, E_{y}, E_{z}, E_{r}, E_{φ}, H_{x}, H_{y}, H_{z}, H_{r}, H_{φ}, D_{x}, D_{y}, D_{z}, D_{r}, D_{φ}, , respectively. 
derivedcomponent
constants  These are additional components, which are not actually stored by Meep but are computed as needed, mainly for use in output functions. One of
Sx
,Sy
,Sz
,Sr
,Sp
,EnergyDensity
,DEnergyDensity
,HEnergyDensity
for: S_{x}, S_{y}, S_{z}, S_{r}, S_{φ} (components of the Poynting vector ), , , , respectively.
Classes
Classes are complex datatypes with various "properties" which may have default values. Classes can be "subclasses" of other classes; subclasses inherit all the properties of their superclass, and can be used any place the superclass is expected. An object of a class is constructed with:
(make class (prop1 val1) (prop2 val2) ...)
See also the libctl manual.
Meep defines several types of classes, the most numerous of which are the various geometric object classes (which are the same as those used in MPB. You can also get a list of the available classes, along with their property types and default values, at runtime with the (help)
command.
lattice
The lattice class is normally used only for the geometrylattice
variable, which sets the size of the computational cell. In MPB, you can use this to specify a variety of affine lattice structures. In Meep, only rectangular Cartesian computational cells are supported, so the only property of lattice that you should normally use is its size
.

lattice
 Properties:

size
[vector3
]  The size of the computational cell. Defaults to unit lengths.
If any dimension has the special size nosize
, then the dimensionality of the problem is (essentially) reduced by one; strictly speaking, the dielectric function is taken to be uniform along that dimension.
Because Maxwell's equations are scaleinvariant, you can use any units of distance you want to specify the cell size: nanometers, inches, parsecs, whatever. However, it is usually convenient to pick some characteristic lengthscale of your problem and set that length to 1. See also Meep Introduction#Units in Meep.
materialtype
This class is used to specify the materials that geometric objects are made of. Currently, there are three subclasses, dielectric
, perfectmetal
, and materialfunction
.

dielectric
 A uniform, isotropic, possibly nonlinear or dispersive, dielectric material; see also Dielectric materials in Meep. It has three properties:

epsilon
[number
]  The dielectric constant (must be positive). No default value. You can also use
(index n)
as a synonym for(epsilon (* n n))
. 
chi2
[number
]  The Kerr susceptibility
\chi^{(2)}
.  polarizations [list of
polarizability
class]  List of dispersive polarizabilities (see below) added to the dielectric constant, in order to model material dispersion; defaults to none.


perfectmetal
 A perfectly conducting metal; this class has no properties and you normally just use the predefined
metal
object, above. (To model imperfect conductors, use a dispersive dielectric material.) 
materialfunction
 This material type allows you to specify the material as an arbitrary function of position. It has one property:

materialfunc
[function
]  A function of one argument, the position
vector3
, that returns the material at that point. Note that the function you supply can return any material; wild and crazy users could even return anothermaterialfunction
object (which would then have its function invoked in turn).

Dispersive dielectric materials, above, are specified via a list of objects of type polarizability
, which is another class with four properties:

polarizability
 Specifies a single dispersive polarizability of damped harmonic form (see Material dispersion), with the parameters:

omega
[number
]  The resonance frequency ω_{n}.

gamma
[number
]  The resonance frequency γ_{n}.

sigma
[number
]  The scale factor σ_{n}.

energysaturation
[number
]  See Saturable gain in Meep.

geometricobject
This class, and its descendants, are used to specify the solid geometric objects that form the dielectric structure being simulated. The base class is:

geometricobject
 Properties:

material
[materialtype
class]  The material that the object is made of (usually some sort of dielectric). No default value (must be specified).

center
[vector3
]  Center point of the object. No default value.

One normally does not create objects of type geometricobject
directly, however; instead, you use one of the following subclasses. Recall that subclasses inherit the properties of their superclass, so these subclasses automatically have the material
and center
properties (which must be specified, since they have no default values).
In a twodimensional calculation, only the intersections of the objects with the xy plane are considered.

sphere
 A sphere. Properties:

radius
[number
]  Radius of the sphere. No default value.


cylinder
 A cylinder, with circular crosssection and finite height. Properties:

radius
[number
]  Radius of the cylinder's crosssection. No default value.

height
[number
]  Length of the cylinder along its axis. No default value.

axis
[vector3
]  Direction of the cylinder's axis; the length of this vector is ignored. Defaults to point parallel to the z axis.


cone
 A cone, or possibly a truncated cone. This is actually a subclass of
cylinder
, and inherits all of the same properties, with one additional property. The radius of the base of the cone is given by theradius
property inherited fromcylinder
, while the radius of the tip is given by the new property:
radius2
[number
]  Radius of the tip of the cone (i.e. the end of the cone pointed to by the
axis
vector). Defaults to zero (a "sharp" cone).


block
 A parallelepiped (i.e., a brick, possibly with nonorthogonal axes). Properties:

size
[vector3
]  The lengths of the block edges along each of its three axes. Not really a 3vector, but it has three components, each of which should be nonzero. No default value.

e1
,e2
,e3
[vector3
]  The directions of the axes of the block; the lengths of these vectors are ignored. Must be linearly independent. They default to the three lattice directions.


ellipsoid
 An ellipsoid. This is actually a subclass of
block
, and inherits all the same properties, but defines an ellipsoid inscribed inside the block.
Here are some examples of geometric objects created using the above classes, assuming mat
is some material we have defined:
; A cylinder of infinite radius and height 0.25 pointing along the x axis, ; centered at the origin: (make cylinder (center 0 0 0) (material mat) (radius infinity) (height 0.25) (axis 1 0 0))
; An ellipsoid with its long axis pointing along (1,1,1), centered on ; the origin (the other two axes are orthogonal and have equal ; semiaxis lengths): (make ellipsoid (center 0 0 0) (material mat) (size 0.8 0.2 0.2) (e1 1 1 1) (e2 0 1 1) (e3 2 1 1))
; A unit cube of material m with a spherical air hole of radius 0.2 at ; its center, the whole thing centered at (1,2,3): (set! geometry (list (make block (center 1 2 3) (material mat) (size 1 1 1)) (make sphere (center 1 2 3) (material air) (radius 0.2))))
symmetry
This class is used for the symmetries
input variable, to specify symmetries (which must preserve both the structure and the sources) for Meep to exploit. Any number of symmetries can be exploited simultaneously, but there is no point in specifying redundant symmetries: the computational cell can be reduced by at most a factor of 4 in 2d and 8 in 3d. See also Exploiting symmetry in Meep.

symmetry
 A single symmetry to exploit. This is the base class of the specific symmetries below, so normally you don't create it directly. However, it has two properties which are shared by all symmetries:

direction
[direction
constant]  The direction of the symmetry (the normal to a mirror plane or the axis for a rotational symmetry). e.g.
X
,Y
, ... (only Cartesian/grid directions are allowed). No default value. 
phase
[cnumber
]  An additional phase to multiply the fields by when operating the symmetry on them; defaults to
1.0
. e.g. a phase of1
for a mirror plane corresponds to an odd mirror. (Technically, you are essentially specifying the representation of the symmetry group that your fields and sources transform under.)

The specific symmetry subclasses are:

mirrorsym
 A mirror symmetry plane. Here, the
direction
is the direction normal to the mirror plane. 
rotate2sym
 A 180° (twofold) rotational symmetry (a.k.a. C_{2}). Here, the
direction
is the axis of the rotation. 
rotate2sym
 A 90° (fourfold) rotational symmetry (a.k.a. C_{4}). Here, the
direction
is the axis of the rotation.
pml
This class is used for specifying the PML absorbing boundary layers around the cell, if any, via the pmllayers
input variable. See also Perfectly matched layers. pmllayers
can be zero or more pml
objects, with multiple objects allowing you to specify different PML layers on different boundaries.

pml
 A single PML layer specification, which sets up one or more PML layers around the boundaries according to the following four properties.

thickness
[number
]  The spatial thickness of the PML layer (which extends from the boundary towards the inside of the computational cell). The thinner it is, the more numerical reflections become a problem. No default value.

direction
[direction
constant]  Specify the direction of the boundaries to put the PML layers next to. e.g. if
X
, then specifies PML on the boundaries (depending on the value ofside
, below). Default is the special valueALL
, which puts PML layers on the boundaries in all directions. 
side
[boundaryside
constant]  Specify which side,
Low
orHigh
of the boundary or boundaries to put PML on. e.g. if side isLow
and direction isX
, then a PML layer is added to the − x boundary. Default is the special valueALL
, which puts PML layers on both sides. 
strength
[number
]  A strength (default is
1.0
) to multiply the PML absorption coefficient by. A strength of2.0
will square the theoretical reflection coefficient of the PML (making it smaller), but will also increase numerical reflections.
