1 Chapter 1: Introduction This document describes a set of scattering tools which were developed by Jon W. Wallace at Brigham Young University to solve electromagnetic scattering problems. The tools contain the following basic elements: 1. 2D/3D FDTD Simulator 2. 2D Dielectric Waveguide Mode Solver 3. Discrete Ordinate Radiative Transfer Sovler for Layered Media 1 Compilation The following libraries UNIX architectures: Library Version binutils 2.8.1 egs w/ g77 1.0.3 gmake 3.76.1 octave 2.0.14 gdb 4.17 byacc flex sed 2.05 (not included with the tools) are required to compile the tools on Download Location ftp://egcs.cygnus.com/pub/egcs/ ftp://ftp.che.wisc.edu/pub/octave/ ftp://metalab.unc.edu/gnu ftp://metalab.unc.edu/gnu/sed 2 Chapter 2: FDTD Simulator 1 Introduction This document briefly explains the use and operation of the FDTD simulator. The document first explains the command-line invocation of the program. Next, the format of the input file is specified. Finally, the data file formats are explained. 2 Command-Line The FDTD simulator is invoked using the following command-line: Syntax: fdtd 2d { [mem size] { [tmp dir] } } < [input file] fdtd 3d { [mem size] { [tmp dir] } } < [input file] This command either invokes the 2d simulator or the 3d simulator. The mem size parameter sets the amount of memory available for the simulator in MB. If more memory is required, the simulator will return an error message and stop execution. Specifying a value of 0 will turn off the memory cap. tmp dir specifies the directory where temporary simulation files will be stored. These files should be stored on a local drive with fast access, since these temporary files are often used as swap space for intermittently-used structures. If this parameter is omitted, the files are stored in /tmp. 3 Input File The input file contains standard ASCII text. Environment variable references of the form ${env var name} may appear in the the file. These environment variables are looked up and their values are inserted in the input file text stream. The input file parser is case sensitive. The input file is divided into a number of sections. The input file must contain a single Global Section followed by a number of other sections that control the generation of simulation structures, simulation sources, and data manipulation. Each section begins with a keyword, and is terminated by the start of a new section or the end of file. The following section keywords are recognized: global simulate Denotes the beginning of the section that contains global simulation variables. Every input file must contain one and only one global section. Denotes the beginning of the section that contains information about the simulation space. This section is used to define objects. Denotes the beginning of section containing information about sources to be driven in the simulation. This section is used to specify a point where a simulation should be executed. data This section is used to manipulate, save, and load data. debug This section is used to view internal variables. space source Also, certain “transcending” statements are allowed in any section. Each section in the FDTD file is described in detail in the following subsections. 3 3.1 Transcending Statements These statements are allowed in any section. 3.1.1 Assigment Syntax: [var id] = [expression] ; Description: Sets the variable var id to the expression expression. 3.1.2 Dangling Expression Syntax: [expression] ; Description: Executes the expression, but does not perform any assignment. 3.1.3 Load Syntax: load [filename] [type] ; Parameters: filename type String containing name of data file Type of data being loaded. Currently matlab and irit are supported Description: This command loads data into memory which was previously stored using the save command. Also, these data files may be generated by other programs. See section 8 for more information. 3.1.4 Save Syntax: save [filename] [type] {append} [identifier] ...; Parameters: filename String containing name under which the data is saved type Format to save with. Supported formats are matlab and irit. identifier Variables to write to disk. If no identifiers are specified, all user variables are written. Description: This command saves data out to a file in a format which can be read using the load command. This data is not (necessarily) stored in a format which will be understandable by humans. See section 8 for the format. 4 3.1.5 System Syntax: system [command]; Parameters: command A string containing the command to execute Description: Executes the specified command in the system shell. 3.1.6 Write Syntax: write [filename] [type] {append} [identifier] ...; Parameters filename String containing name of file to write. type The output format of the data. identifier Variables to write out to disk. If no identifiers are specified, all user variables are written. Description: This command writes a list of identifiers to a file on disk in a format more usable by humans. The type matlab is currently the only one supported. See section 8 for the format. 3.2 Global Section The global section begins with the keyword global, and determines the simulation grid parameters and the time steps. These values are required in order to know how much memory to allocate for the simulation grids. At the end of the global section, the simulation grids are allocated and initialized to 0. Note that in order for the PML to be updated, a space section (maybe empty) must be defined. 3.2.1 Bound Syntax: bound {<x> [x flag] {[x flag]}} {<y> [y flag] {[y flag]}} {<z> [z flag] {[z flag]}} ; Parameters: x flag, z flag y flag, A boundary flag for the specified direction. The possible values are conductor, peridoic, decay1, and pml. Description: This command sets the type of boundary seen in each of the principal directions. A boundary definition consists of a grid truncation condition (one of the following: conductor, peridoic, or decay1), and the PML type. For example, the following definition is valid: bound <x> pml conductor <y> pml peridoic <z> decay1 ; 5 3.2.2 c0 Syntax: c0 [c0 value] ; Parameters: c0 value The new value for wavespeed in freespace. Description: This command sets the free space wave speed. The units are length/time. 3.2.3 Cells Syntax: cells [x cells] [y cells] {[z cells]} {scattered|scattered2} ; Parameters: x cells, y cells, z cells The number of cells in each of the principal axis directions. scattered Indicates that a scattered-field grid should be created as opposted to a total field grid. Background parameters are constant for the entire simulation space. scattered2 Same as scattered option, except that background parameters are defined for each point in the simulation region. The background parameters are set using the background command (Section 3.3.1). Description: This command normally appears first in the global section to define how many cells should be created in the simulation grid. For the 2D simulator, the z cells parameter is omitted. Note: Currently only changes in permittivity are supported for scattered grids. 3.2.4 Coords Syntax: coords [coord lo] [coord hi] ; Parameters: coord lo Defines the logical lower corner of the simulation box (or rectangle in 2D). coord hi Defines the logical upper corner of the simulation box (or rectangle in 2D). Description: This command creates the logical coordinate system which is used when drawing objects, placing sources, and storing data in the simulation cube. The logical coordinates also specify the mapping from physical distance to number of cells. 6 3.2.5 Decay1 Syntax: decay1 [dir] [k] [kz] ; Parameters: dir Specifies the direction of the propagating wave or mode. The radial distance R will be computed as the distance from the point in space to the line {[dir] = < x >, < y >, < z >} = 0. k Propagation constant for a plane wave in the medium at the boundary. kz Propagation constant for the propagating mode. Description: This command sets the options for the decay1 boundary condition. This condition truncates fields √ at the boundary −αR assuming a decay of / R for 3D and e−αR √ the form e 2 2 for 2D, where α = kz − k . 3.2.6 Eta0 Syntax: eta0 [eta0 val] ; Parameters: eta0 val The new value for the characteristic impedance of free space. Description: This command allows you to change the characteristic impedance of free space. The default is value is 377.0 ohms. 3.2.7 PML Syntax: pml [sigma] [delta cells] {isotropic} {scattered}; pml [n] [R] [delta cells] {isotropic} {scattered} ; Parameters: sigma Maximum conductivity at the outside boundary of the PML. delta cells Thickness of the PML in cells. n Exponent in conductivity gradient (default is 1.0 = linear). R Normal reflectivity of free-space/PML boundary. 7 Description: This command is used to create a PML outside of the simulation region. The characteristics of the PML can be defined by specifying the maximum conductivity directly or by specifying a reflection coefficient at normal incidence. The keyword isotropic makes a PML in which σ x = σy = σz which may work better for absorbing guided modes. The keyword scattered specifies that the scattered field equations should be used in the PML (as opposed to total field). This will create a source anywhere where materials extend into the PML. 3.2.8 Time Syntax: time [total time] [time steps] {[stored steps] {[skip]}} ; Parameters: total time A real number indicating the total time (in the simulation time units) for the simulation. time steps An integer giving the number of discrete time steps for the simulation. stored steps Number of time steps to keep (default is to keep all time steps) skip Number of time steps from one stored sample to the next (default is 1) Description: This command is used to set up the amount of time to simulate and the number of corresponding simulation steps. If too few time steps are specified, a warning will be issued telling that the stability criterion was not met. 3.3 Space Section At the beginning of the space section, the simulation cells are read into RAM for manipulation. At the end, the PML is recalculated (if applicable), average physical parameter values are calculated and stored, and the cells are written back to disk. 3.3.1 Background Syntax: background {[epsilon] [mu] [sigma]} ; Parameters: epsilon Background relative permittivity. mu Background relative permeability. sigma Background conductivity. 8 Description: Sets all background physical constants to the specified epsilon, mu, and sigma values for a scattered grid, or to the values currently defined in the drawing grid for a scattered2 grid. 3.3.2 Clear Syntax: clear ; Description: This command sets all cells in the simulation grid to free space. 3.3.3 Conductor Syntax: conductor [polygon] [dir] [pos] ; conductor [polygon|polyhedron] ; conductor clear [polygon|polyhedron] ; Parameters: polygon Polygon which defines the outside boundary of the sheet. polygon | polyhedron Polygon (2D) or polyhedron (3D) which defines the conducting surface. dir Direction which the sheet is perpendicular to. pos Coordinate along the dir axis where the sheet lies. Description: Creates a perfectly conducting sheet in the simulation region. For the first form of the command, the sheet must lie in a plane and be perpendicular to one of the principal axes. The second form of the command takes an arbitrary polygon (in 2D) or polyhedron (in 3D). For each E field component in the volume, the face normal to the component is computed. If this face is cut by the polygon/polyhedron, the component is said to lie tangential on the perfect conductor. The clear form of the command erases tangential components lying on the polygon/polyhedron. Conductors are simulated as follows. For total field grids, tangential E components lying on a conductor will be forced to 0. For scattered grids, tangential E components on sheets which are part of the background are forced to 0. Tangential components which are part of the foreground are set to −E inc . 3.3.4 Cube Syntax: cube [epsilon] [mu] [sigma] [coord lo] [coord hi] {wrap}{merge} ; 9 Parameters: epsilon Relative permittivity mu Relative permeability sigma Conductivity (Siemens/length) coord lo Lower coordinate of box coord hi Upper coordinate of box Description: This command creates a box in the simulation region filled with the specified physical parameters. wrap specifies that a box occurring on the boundary should be wrapped to the other side of the simulation region. merge specifies that the box should be merged with existing objects, otherwise shared cells will be overwritten by the new box. 3.3.5 Cubes Syntax: cubes [epsilon] [mu] [sigma] [coord lo] [coord hi] [mean] [std] [fill fraction] {wrap} {penetrate} {bound} {merge} ; Parameters: epsilon Relative permittivity mu Relative permeability sigma Conductivity (Siemens/length) coord lo Lower coordinate of bounding box coord hi Upper coordinate of bounding box mean Mean “radius” of the cube std standard deviation of the cube “radius” fill fraction Fraction of space to be filled by cubes Description: Generates a collection of cubes. See description for the spheres command (Section 3.3.16). 3.3.6 Drawpoly Syntax: drawpoly ([polygon] | [polyhedron]) ; Parameters: polygon polyhedron If specified, adds a polygon. If specified, adds a polyhedron. 10 Description: Adds a polygon or polyhedron to the debug drawing. Used only to enhance your plots made in the debug section. 3.3.7 Imesh Syntax: imesh [var id] [coord lo] [coord hi] {[keep steps] {[skip steps]}} Parameters: var id coord lo, ord hi Variable prefix for the x and y current grids co- Lower and upper coordinate defining the extreme corners of the current sheet keep steps Number of time steps to keep (default is to keep all) skip steps Skip factor between time steps (default is 1) Description: Defines a current sampling mesh which stores currents on the simulation grid over time. The x and y current components are stored in the 2D grid variables var id x var id y. The number of time steps to keep and the skip factor may also be specified (see time command in Section 3.2.8). Note that the coordinates define a plane which must be aligned with the principal axes. 3.3.8 Initial Syntax: initial ; Description: Initializes the field sources using initial conditions defined by sources. This option can cut down on time required for the simulation to reach a steady-state value. Only the forced and additive sources support this option. 3.3.9 Mur Syntax: mur [order] [c] [coord lo] [coord hi] ; Parameters: order Order of the Mur boundary condition c coord lo, ord hi Speed (length/time) co- Coordinates defining extreme corners of the absorbing sheet. One of the components must be equal for the two coordinates. 11 Description: Creates a Mur absorbing boundary condition in the simulation region. The coordinates must define a sheet aligned with one of the principal axes (i.e., two of the components must be equal). The wave speed c defines the speed and direction of the wave to be absorbed. A positive or negative c indicates travel along or opposite to the principal axis, respectively. Currently, only first order Mur boundaries are supported. 3.3.10 Raw Syntax: raw [var id] [field id] [coord1] [coord2] [keep] [skip] {[start]}; Parameters: var id 2D grid variable to store fields in field id Field component to store coord1, coord2 Opposite coordinates of a box enclosing the fields to be stored. keep Number of time steps to store skip Skip value between time steps start Optional start time step. If omitted, the start time step is ntotal −nkeep nskip , which just takes time samples at the end of the simulation. Description: Defines a raw field sample mesh that stores the time varying fields during the simulation. This command provides better accuracy than the field command in the data section which operates on averaged fields. The enclosing coordinates can be chosen to store a 1D, 2D, or 3D section of the simulation. Specifying zero length for any dimension will store a single node in that direction. Fields are stored in a 4D grid indexed by [x, y, z, t]. Units on electric field are V/length. Magnetic fields are multiplied by η0 and also have units V/length. 3.3.11 Resistor Syntax: resistor [R] [dir] [coord lo] [coord hi] ; Parameters: R dir Resistance (ohms) Principal direction that the resistor is aligned with. 12 coord lo, ord hi co- Coordinates that define the region which the distributed resistor occupies. Description: Defines a distributed resistor in the simulation region bounded by the specified coordinates and with the given resistance. Note that the resistor must align with one of the principal axes. 3.3.12 Resolution Syntax: resolution ([x cells] [y cells] [z cells] | [cells]) ; Parameters: x cells, y cells, z cells cells Number of cells in each of the principal directions. Number of cells in all directions. Description: This command sets the size of the internal drawing grid in cells. Objects are drawn at this high resolution. The small drawing cells are then volume averaged to obtain the value to use in the simulation grid. This averaging can be turned off by making the number of cells here smaller than the number of simulation cells. For example, resolution 1 1 1 ; will turn off any averaging. 3.3.13 Seed Syntax: seed [seed int] ; Parameters: seed int New value for the seed. Description: This command sets the random number generator seed. Note that the seed is initialized using the time-of-day when the FDTD simulator starts. 3.3.14 Solid Syntax: solid [eps exp] [mu exp] [sigma exp] [poly1 exp] [poly2 exp] {merge}; Parameters: eps exp A real expression for the relative permittivity mu exp A real expression for the relative permeability sigma exp A real expression for the conductivity (S/length) 13 poly1 exp A polygon/polyhedron expression defining space to be included in the solid. Set to 0 to include all space. poly2 exp A polygon/polyhedron expression defining space to be excluded from the solid. Set to 0 to exclude no space. Description: This command can be used to create solid objects in the simulation grid defined by general expressions for physical parameters. The expressions can be functions of position in the space. The bounds on the object are defined using a symmetric diffecence of (poly1 - poly2), which are polygons (2D) or polyhedra (3D). See the Section 6 on functions and expressions for more information. 3.3.15 Sphere Syntax: sphere [epsilon] [mu] [sigma] [origin coord] [radius] {merge} {wrap} ; Parameters: epsilon Relative permittivity mu Relative permeability sigma Conductivity (S/length) origin coord Coordinate of the center of the sphere (in logical coords) radius Radius of the sphere (in logical coords) Description: This command creates a sphere at the specified location with the given physical parameters. Flags are explained in the spheres command (Section 3.3.16). 3.3.16 Spheres Syntax: spheres [epsilon] [mu] [sigma] [lo coord] [hi coord] [mean] [std] ([fill fraction] | count [count]) {wrap} {penetrate} {bound} {merge} ; Parameters: epsilon Relative permittivity mu Relative permeability sigma Conductivity (S/length) lo coord Lower coordinate for the bounding box 14 hi coord Upper coordinate for the bounding box mean Mean radius of the spheres std Standard deviation of the spheres fill fraction Fraction of space to be filled by spheres count Number of spheres Description: This command generates a boxed region that is filled with a collection of spheres. The number of spheres may be specified either by a fill fraction or by the number of spheres. wrap specifies that spheres on the boundary should wrap to the other side of the bounding box. penetrate allows the spheres to penetrate. bound forces the spheres to be placed completely inside of the bounding box. merge merges the high-resolution grid with existing objects. 3.3.17 Vsrc Syntax: vsrc [source exp] [res val] [dir] [coord-] [coord+] ; Parameters: source exp A lumped element source defined with the source lumped function (Section 6.3.14). res val Internal resistance of source in ohms dir Direction of source coord- Negative terminal coord+ Positive terminal Description: Defines a lumped voltage element source. The source must be aligned along one of the principal axes, thus coord- and coord+ must have two points in common. 3.4 Source Section The source section begins with the keyword source. This section is used to define sources for a simulation. 3.4.1 Add Syntax: add [src exp] [coord lo] [coord hi] {[field id]}...{odd|even} ; add point [src exp] [coord] [field id] ; 15 Parameters: src exp Source expression defined with one of the source functions. coord lo Lower coordinate enclosing the source plane coord hi Upper coordinate enclosing the source plane field id One or more source field IDs coord Location of the point source. Will snap to the nearest compatible node. Description: Creates an additive (current) source to be excited during the simulation. If no field IDs are specified, the source assumes that all field IDs are to be added. For plane sources, this command computes proper currents (magnetic or electric) to obtain the fields for the specified source function. The kewords odd and even specify whether the source should be snapped to an odd or even node plane. The coordinates coord lo and coord hi specify the plane where the source should be driven. This plane must be aligned along one of the principal axes. For the point source, the source expression should be a lumped source. 3.4.2 Clear Syntax: clear ; Description: This command clears any sources that have been defined. 3.4.3 Forced Syntax: forced [src exp] [coord lo] [coord hi] {[field id]} ...; forced point [src exp] [coord] [field id] ; Parameters: src exp Source expression defined with one of the source functions coord lo Lower coordinate enclosing the source plane coord hi Upper coordinate enclosing the source plane field id One or more source field IDs to force coord Coordinate where the point source should be located 16 Description: Creates a forced field source for the simulation. If no field IDs are specified, the statement assumes that all field IDs are to be forced. The first form is for plane sources and the second is for point sources. 3.4.4 Impulse Syntax: impulse [src exp] [coord lo] [coord hi] {[field id]} ...; impulse point [src exp] [coord] [field id] ; Parameters: src exp Source expression defined with one of the source functions coord lo Lower coordinate enclosing the source plane coord hi Upper coordinate enclosing the source plane field id One or more source field IDs to force coord Coordinate where the point source should be located Description: Creates an impulse source for the simulation. The inpulse source is similiar to a forced source, but components are only forced at t=0. If no field IDs are specified, the statement assumes that all field IDs are to be forced. The first form is for plane sources and the second is for point sources. 3.4.5 Incident Syntax: incident [source exp] ; Parameters: source exp Source expression to use for incident field Description: Defines the incident source function for scattered grids. 3.4.6 Phased Syntax: phased [src exp] [coord lo] [coord hi] {[field id]}...; Parameters: src exp Source expression defined with one of the source functions. coord lo Lower coordinate enclosing the source plane coord hi Upper coordinate enclosing the source plane 17 field id One or more source field IDs Description: The “phased” source is similar to the split source in that it excites a source which propagates in only one direction. The source is achieved by adding two harmonic sources so that phases add constructively to one side of a plane and destructively on the other. Currently the driving plane is snapped to one with tangential E (normal H) components. The coordinates coord lo and coord hi define the plane where the source is excited, and this plane must align with one of the principal axes. 3.4.7 Split Syntax: split [source exp] [lo coord] [hi coord] ; Parameters: source exp Expression which evaluates to a source lo coord Lower coordinate of the plane which divides split and total field regions hi coord Upper coordinate of the division plane Description: This function defines a split source. A split source is one in which total field occurs on one side of a plane and scattered field occurs on the other. This type of source is very useful for finding reflection and transmission coefficients of structures. To use this source, the simulation grid type should be total field, NOT scattered field. The source expression defines the source driving function as well as a plane where the function is defined. lo coord and hi coord also define a plane, but this is the plane where the actual split occurs. One of the components of the two coordinates must be equal (the plane needs to be aligned with one of the principal axes). The coordinates also define the region in which the source is driven. 3.4.8 Window Syntax: window gauss (tau [tau] | slope [slope] | rise [rise]) ; window clear ; Parameters: tau slope Time constant for the Gaussian window function (time units) Maximum slope of the Gaussian window function (1/time) 18 rise 99% rise time of the Gaussian window function (time units) Description: This function multiplies all source functions by a Gaussian window in time: 1 − exp[−(t/τ )2 ]. Defining a window can reduce the effect of transients which occur at the beginning of a simulation. 3.5 Simulate Section The simulate section begins with the keyword simulate. Currently, no statements occur inside of the simulation section. 3.6 Debug Section The debug section begins with the keyword debug. This section is used to debug the FDTD simulator. 3.6.1 Axis Syntax: axis [dir1] [dir2] [dir3] [dir4] ; Parameters: dir1, dir2, dir3, dir4 Each direction specifies a direction for the nth principal axis Description: This statement sets the principal axes for any following plot statements. 3.6.2 Plot Syntax: plot [identifier] {[filename]} ; Parameters: indentifier The quantity which is to be plotted. The following values are recognized: 2D: eps, mu, sigma, sigma x,sigma y, eps avg, mu avg, sigma avg, sigma x avg, sigma y avg, ex,ey, ez, hx, hy, hz, ex freq, ey freq, ez freq, hx freq, hy freq, hz freq 3D: eps, mu, sigma, sigma x,sigma y, sigma z, eps avg, mu avg, sigma avg, sigma x avg, sigma y avg, sigma z avg, ez, ez freq, f eps, f mu, f sigma, f sigma x, f sigma y, f sigma z, f sigma x star, f sigma y star, f sigma z star 19 filename If specified, the program automatically dumps the x-window to a file using XWD. Description: This command opens an x-window and plots the specified quantity. 3.6.3 Plotfile Syntax: plotfile [identifier] [filename] ; Parameters: identifier filename Name of identifier to plot String containing name of file to create Description: Stores a complete plot into a file which can later be displayed with the plotfile unix command. Valid identifiers are the same as the plot command (Section 3.6.2). 3.6.4 Range Syntax: range [lo coord] [hi coord] ; Parameters: lo coord Sets the lower coordinate of the set to plot hi coord Sets the upper coordinate of the set to plot Description: This function sets the region which is to be plotted. This allows the user to zoom in on a particular part of a data set. 3.6.5 Scale Syntax: scale {[min] [max]} ; Parameters: min Minimum value on the debug plot scale max Maximum value on the debug plot scale Description: This command is used to specify the range of values to be plotted. Passing no parameters sets the scale back to the default. In the default case, min is the minimum value in the data set and max is the maximum value. 3.7 Data Section The data section begins with the keyword data. This section allows the user to manipulate the simulation data and to do some rudimentary post-processing. 20 3.7.1 Farfield Syntax: farfield [var id] [field id] [plane exp] [lo coord] [hi coord] [phi start] [phi end] [phi points] {[th start] [th end] [th points]} ; Parameters: var id Variable in which to store the far fields. field id Identifier of the field component to store (relative to the local coordinate system). Currently allowed values are Ex, Ey, Ez, Eth, Ephi. plane exp A plane which defines the local coordinate system. lo coord Low coordinate of the bounding box where the far fields will be computed. hi coord High coordinate of the bounding box where the far fields will be computed. phi start, phi end, phi points Start, end, and number of points to store in angle phi. th start, th end, th points Start, end and number of points to store in angle theta (3D only). Description: This function computes the far field radiation pattern over the specified range of angles. Units are V/length 2 for 3D simulations and V/length for 2D simulations. For 2D simulations, only one range of angles is specified. Note: The FFT command must have been executed for this statement to have any effect. 3.7.2 FFT Syntax: fft [freq] [n] ; Parameters: freq n Fundamental frequency for the FFT. This is usually the frequency of your source. Number of points per period to use for the FFT. 21 Description: This command calculates the steady state field values from the simulated time-domain data. The function will attempt to adjust the actual number of points used if it doesn’t fit nicely with the simulation time steps. 3.7.3 Field Syntax: field line [var id] [field id] [plane exp] [x start] [x stop] [x points] {time [start] {[stop] [n]}} ; field rect [var id] [field id] [plane exp] [x start] [x stop][x points] [y start] [y stop] [y points] {time [start] {[stop] [n]}} ; field box [var id] [field id] [plane exp] [x start] [x stop] [x points] [y start] [y stop] [y points] [z start] [z stop] [z points] {time [start] [stop] [n]} ; Parameters: var id Identifier in which to store the line of field information field id The field component being stored plane exp An expression evaluating to a plane. This defines the local coordinate system in which the line/rect/box is defined. x start Real number denoting the starting x point along the local x-axis x stop Real number denoting the ending y point along the local x-axis x points Number of points subdividing the line y start, y stop, y points Same as above except in y direction z start, z stop, z points Same as above except in z direction start Starting time value stop Ending time value n Number of time samples to store 22 Description: This command stores field components along a line, in a rectangle, or in a box. Electric and magnetic fields have units of V/length and A/length, respectively. The plane expression defines a local coordinate system in which the field components are to be extracted. Either sinusoidal steadystate values or time varying fields may be stored. If the time clause is omitted, steady-state values are stored. Note: This command operates on fields which have been averaged to the center of each cell. Also, fields are interpolated (in general) to obtain values at arbitrary spatial coordinates. If high precision is required, consider using the raw command (Section 3.3.10). 3.7.4 Power Absorbed Syntax: Pa [var id] [lo coord] [hi coord] ; Parameters: var id Varible in which to store the absorbed power lo coord Lower coordinate of bounding box, inside of which power absorbed is calculated hi coord Upper coordinate of bounding box Description: This command stores the total (steady-state) power absorbed inside of a box (in Watts). 3.7.5 Power Scattered Syntax: Ps {farfield} [var id] [lo coord] [hi coord] ; Parameters: var id Variable in which to store the power scattered lo coord Lower coordinate of the bounding box where power scattered is calculated hi coord Upper coordinate of bounding box Description: This command calculates the total power scattered from the given bounding box (in Watts). If farfield is specified, the farfields are first calculated and then the power is found by integrating over an enclosing surface. The farfield method is much less efficient than performing the calculation in the near field. However, it seems to be a little less sensitive to phase error. 23 3.7.6 Scattered Syntax: scattered [source exp] ; Parameters: source exp A source expression defining the incident source Description: This command converts total fields into scattered fields by subtracting the incident source at each point in space. 3.7.7 Total Syntax: total [source exp] ; Parameters: source exp A source expression defining the incident source Description: This function converts a scattered fields into total fields by adding the incident field (the source) at each point in space. 4 Base Types These types are used in statements in expressions throughout the input file. 4.1 Literals 4.1.1 Cell Syntax: "[" i j "]" | "[" i j k "]" Description: Used to identify a cell in the simulation grid. 4.1.2 Complex Syntax: "(" x "," y ")" | "(" α @ θ ")" Description: Defines a complex literal by specifying real and imaginary parts or by specifying magnitude and phase (in degrees). 4.1.3 Coordinate Syntax: "{" x y "}" | "{" x y z "}" Description: Used to identify a logical point in space. 4.1.4 Direction Syntax: "<x>" | "<y>" | "<z>" | "<t>" Description: Used to identify one of the principal directions. 24 4.1.5 Expression Syntax: ’ exp string ’ Description: Defines a literal expression which is not immediately evaluated. 4.1.6 Field id Syntax: "Ex" | "Ey" | "Ez" | "Eth" | "Ephi" | "Hx" | "Hy" | "Hz" | "Hth" | "Hphi" Description: Speficies a field component. 4.1.7 Integer Syntax: n | "(-" n ")" Description: Defines an integer literal. Note that parenthesis are required to define negative integers. 4.1.8 Real Syntax: x | "(-" x ")" Description: Defines a real literal. Parenthesis are required for negative reals. 4.1.9 String Syntax: ‘‘s’’ Description: Defines a literal string. Note that double quotes are used to enclose the string. 5 Operators/Precedence Currently, all operators are left associative. , | & || && == != < <= > >= + * / % mod div ^ ! ( ) [ ] Positional separator Logical OR and AND Equal, NOT equal Inequality operators Addition, subtraction Multiplication, division, real modulo, integer modulo, integer div Power operator Logical NOT Associative operators 6 Functions/Variables 25 6.1 I/O Functions 6.1.1 print Syntax: void print(expression) Description: This function evaluates the expression, formats it as a string, and prints it to the console. 6.2 Math Functions 6.2.1 abs Syntax: int abs(int) real abs(real) real abs(cplx) Description: Absolute value function. 6.2.2 acos Syntax: real acos(real) Description: Real inverse cosine. 6.2.3 arg Syntax: real arg(cplx) Description: Returns the angle of the argument (radians). 6.2.4 asin Syntax: real asin(real) Description: Real inverse sine. 6.2.5 atan Syntax: real atan(real) Description: Real inverse tangent. 6.2.6 atan2 Syntax: real atan(real, real) Description: Two argument real inverse tangent. 26 6.2.7 cos Syntax: real cos(real) cplx cos(cplx) Description: Real and complex cosine. 6.2.8 exp Syntax: real exp(real) cplx exp(cplx) Description: Real and complex exponential function. 6.2.9 Imag Syntax: real imag(cplx) Description: Takes the imaginary part. 6.2.10 ln Syntax: real ln(real) cplx ln(cplx) Description: Real and complex natural log function. 6.2.11 real Syntax: real real(cplx) Description: Takes the real part. 6.2.12 sin Syntax: real sin(real) cplx sin(cplx) Description: Real and complex sin function. 6.2.13 sin Syntax: real sinc(real) cplx sinc(cplx) Description: Real and complex sin(x)/x function. 27 6.2.14 sqrt Syntax: real sqrt(int) real sqrt(real) cplx sqrt(cplx) Description: Square root function. 6.2.15 Tan Syntax: real tan(real) cplx tan(cplx) Description: Real and complex tangent. 6.3 Geometric Functions 6.3.1 polybox Syntax: polygon polybox(lo coord, hi coord); polyhedron polybox(lo coord, hi coord); Description: This function returns a polygon (in 2D) or a polyhedron (in 3D) given a lower and upper coordinate. 6.3.2 plane Syntax: plane plane(origin coord, x hat coord) plane plane(origin coord, x hat coord, y hat coord) Description: This function returns an oriented plane given a point representing the origin of the plane, the x̂ direction in the plane, and a vector with a component in the ŷ direction. If x̂ is orthogonal to ŷ, then ŷ is actually the unit ŷ vector in the plane. Note that in 2D, only a single vector in the the plane is required. The other unit vector is made to be the −ẑ direction 6.3.3 polycircle Syntax: polyhedron polycircle(plane, a real, N int) Description: Generates a polygon which approximates a circle. plane is the plane in which the circle lies, and N is the number of points to use. 28 6.3.4 polyellipse Syntax: polyhedron polyellipse(plane, a real, b real, {x0 real, y0 real,} N int) Description: Generates a polygon which approximates an ellipse. plane is the plane in which the ellipse lies, a and b represent the major axes, x0 and y0 are the optional origin, and N is the number of points to use. 6.3.5 polycone Syntax: polyhedron polycone(plane, a1 real, {b1 real, {x01 real, y01 real,}} a2 real, {b2 real, {x02 real, y01 real,}} l real, N int, faces int) Description: Approximates an elliptical cone out of polygons. plane is the local plane of reference for drawing the cylinder. The first face of the cone defined by major axes a1 and b1 and origin (x01, y01) is in the xy plane. The second face is drawn in a plane parallel to the xy plane at a distance of l with major axes a2 and b2 and origin (x02, y02). The elliptical faces are approxmated with polygons having N points. The flag faces int specifies whether or not the faces should be included in the object. 6.3.6 polycyl Syntax: polyhedron polycyl(plane, a real, l real, N int, faces int) Description: Approximates a cylinder out of polygons. plane is the local plane of reference for drawing the cylinder. The first face of the cylinder is in the xy plane. The cylinder is drawn in the ẑ direction with a length l. The circular faces are approxmated with polygons having N points. faces is a flag specifying whether or not the faces should be included. 6.3.7 polygon Syntax: polygon polygon(coord, ...) Description: Generates a polygon given a list of coordinates. The last coordinate connects with the first. The coordinates should lie in the same plane, but this is not enforced. 6.3.8 polyline Syntax: polygon polyline(coord, ...) 29 Description: Generates a polygon given a list of coordinates. The last point is not connected with the first, and the points need not lie in the same plane. 6.3.9 polygontype Syntax: polygon polygontype(polygon, type int) Description: Switches a from a polygon to a polyline and vice versa. polygon is the polygon to switch, and type int is the desired type: 0=polygon, 1=polyline. 6.3.10 polyhedron Syntax: polyhedron polyhedron(polygon, ...) Description: Generates a polyhedron given a list of polygons. This function does not force the polyhedron to be closed. 6.3.11 read var Syntax: void read var(filename string, format string) Description: This function reads in variables from the file filename given a specific format in format. Only irit is recognized as a valid format currently. Variables are stored in the global variable table. 6.3.12 rotate Syntax: spat func rotate(spat func, angle, origin coord,vec coord) polygon rotate(polygon, angle, origin coord, vec coord) polyhedron rotate(polyhedron, angle, origin coord, vec coord) plane rotate(plane, angle, origin coord, vec coord) Description: Rotates the spcified spatial function, polygon, polyhedron, or plane by angle degrees about a vector defined by vec coord which has an origin at origin coord. 30 6.3.13 scale Syntax: spat func scale(spat func, mult coord, origin coord) polygon scale(polygon, mult coord, origin coord) polyhedron scale(polyhedron, mult coord, origin coord) plane scale(plane, mult coord, origin coord) Description: Scales the specified object by the vector defined by mult coord about the center point origin coord. 6.3.14 source lumped Syntax: source source lumped(time params) Description: Creates a lumped element source that only depends on time. The format of the time params is described under source plane (Section 6.3.16). 6.3.15 source plane Syntax: source source plane(plane, c, time params, shape params) time params = "harmonic", freq, amp, phase "gauss", freq, amp, phase, tau, t0 "gauss2", freq, amp, phase, tau, t0 "exp", f exp, df dt exp, "grid", grid shape params = "const" , "field id", value ... "exp" , "field id", exp ... "grid" , "field id", grid ... time params: The time parameters define the propagation of the source as a function of time and orthogonal distance from the reference plane. harmonic The harmonic source creates a sine wave with constant amplitude 31 shape params: gauss The gauss source is a sinewave in time with a Gaussian time window. The propagation function is given as f (d, t) = exp(−(t − t0)2 /τ 2 ) cos(2πf (t − d/c)). gauss2 The gauss2 source is a Gaussian modulated sinewave in time and space. The gaussian pulse moves in the +z direction at the specified wave speed. The propagation function is f (d, t) = exp(−(t − d/c − t0)2 /τ 2 ) cos(2πf (t − d/c)). exp For this type of source, arbitrary closedform expressions are provided for f (d, t) and ∂f ∂t (d, t). grid For the grid source, either a 1D grid is specified for the function f (t − x/c) or a 2D grid is specified for the function f (t, x). The function is differenced in time to obtain ∂f ∂t . The shape parameters define the shape of the source projected orthogonally onto the reference plane. The available source types are explained below. const Fields are constant in the plane. The value of each component can be specified separately. exp Each field component is specified by an expression which depends on the variables x, y, and z. grid Each field component is specified by a 2D grid. Description: This somewhat complex function is used to create a new plane wave source variable. The source is defined by passing in a reference plane, propagation parameters, and shape parameters. The source is assumed to travel in the +z direction relative to the reference plane. 6.3.16 source vol Syntax: source source vol("plane", freq, amp, phase, k, E, eps, mu, sigma); 32 Description: This function creates a volume source. This source type is not tied to any particular reference plane. These sources are useful for excitation at every point in space (like incident sources). plane source Defines a plane wave volume source. freq, amp, and phase are scalars representing the frequency, amplitude, and phase of the source. k is a coordinate representing the propagation vector, E is a coordinate representing the E field vector, and eps, mu, and sigma are the relative permittivity, permeability, and conductivity seen by the propagating wave. H field components are computed using H = k̂ × E. The source then has the functional form E(x, y, z) = E exp(jk · r). 6.3.17 translate Syntax: spat func translate(spat func, coord) polygon translate(polygon, coord) polyhedron translate(polyhedron, coord) plane translate(plane, coord) Description: Moves the specific object in space by the displacement vector given in coord. 6.4 Builtin Variables Expressions for sources and drawing objects often require referencing the current time value or the current spatial coordinate. The following table lists the available builtin variables. eta0 Characteristic impedance of free space c0 Wave speed in free space d Distance from reference plane e exp(1) √ j −1 null Returns new integer = 0 pi π t Current real time (sources) x, y, z Current spatial coordinate (sources/objects) 7 GDB Functions This section explains some of the commands that are available from GDB at runtime when the simulate is built with symbols. Each function is invoked by issuing the call command in GDB. 7.1 dPlot Syntax: void dPlot(offset) 33 Inputs: offset The offset of the quantity to be plotted. Description: This function plots the quantity associated with the offset. Execute dPlot(-1) for a list of available offsets. Enumeration values starting with the prefix node offset followed by the name of the quantity (node offset ex, for example) may also be used. 7.2 dPrintCell Syntax: void dPrintCell(i, j, k) void dPrintCell(i, j) Inputs: i, j, k Spatial cell number. Only two coordinates are specified in the 2D code. Description: Prints information on the specified cell. Cells contain physical quantities (, µ, σ) in the simulation region. 7.3 dPrintNode Syntax: nodeDef *dPrintNode(i, j, k, n) nodeDef *dPrintNode(i, j, n) Inputs: i, j, k Spatial coordinate. Only two components are specified in the 2D code. n Time step. Only two time steps (0 and 1) are stored in RAM. Returns: A pointer to the node structure. Description: This function prints out information stored about the specified node. 8 Data Input/Output This section explains the formats which the FDTD simulator can read and write. 8.1 Save/Load Formats The save/load format was created with the intention of being able to save variables in a format which can be read back without any loss of information. However, this generality comes at the loss of readability of the files which are created. This section is useful for writing programs which must read or write these formats. 8.1.1 IRIT Format The IRIT format is currently not supported for Save operations. However, the ASCII IRIT format may be loaded. See documentation on IRIT for the format. Currenlty, only polygons and polyhedra may be read. 8.1.2 Matlab (ASCII) Format Each variable in the Matlab file is saved with an identifier of the form 34 [local id] [type ext] , where local id is the identifier for the variable in the FDTD simulator, and type ext is a string which identifies the variable type. The following extensions are used: int Integer Stored as an integer scalar. real Real number Stored as a real scalar. cplx Complex number Stored as a complex scalar in. cell Cell Stored as a 3 element row vector. coord 2D or 3D coordinate Stored as a 3 element row vector. str String Stored as a string array. id Identifier Stored as a string array. rgrid Real grid Stored as a stacked row vector with following elements: [dims] [elem 1] [elem 2] . . . [elem dims] [range lo 1] [range lo 2] . . . [range lo dims] [range hi 1] [range hi 2] . . . [range hi dims] [a 0 0 0 . . . 0] [a 1 0 0 . . . 0] [a 2 0 0 . . . 0] . . . [a n1 0 0 . . . 0] .. . [a 0 n2 n3 n4] [a 1 n2 n3 n4] . . . [a n1 n2 n3 n4] The vectors are stack with the leftmost indicies counting first. cgrid Complex grid Has the same format as the real grid, except each element is ofthe format (re, im). polyg polyh plane pt Polygon Polyhedron Plane Field point. 35 src exp spfunc Source Expression Spatial function Not supported yet. 8.2 Write Format The write format is intended to allow the writing of data files which are easier for humans to read and use. However, insufficient detail is stored about the data to allow the file to be converted back into FDTD variables. Many of the types are stored in the same format as the Load/Save format, except the extension [type] is dropped. The main exception to the rule is the grid format. For each grid variable, two variables are written to the Matlab file. One variable (stored under the internal variable name) stores the data, and another called [var name] range stores the range variables for the grid. For the data variable, the column dimension stores the first dimension of the grid. The rest of the dimensions are lumped into the rows with the leftmost dimension counting first. The range variable is stored as a matrix of the following format: [range lo 1] [range hi 1] [elem 1] [range lo 2] [range hi 2] [elem 2] ... ... ... [range lo n] [range hi n] [elem n] 9 Theory of Operation This section contains information on the internal workings of the FDTD simulator. 9.1 Gridding The 2D and 3D FDTD codes use a similar gridding scheme. Figure 9.1 shows how the space is gridded. (0,N) (0,M,N) (M,N) (M,N,O) Ex PML Ex Ey Ez Ey Ez Hx (0,0,O) Hy Hx PML Simulation Region PML Hz Hy Hz (M,N,0) z y x (0,0) (M,0) (a) 2D (0,0,0) (M,0,0) (b) 3D Figure 9.1: Grid configurations for the 2D and 3D grids. Note that the corners of the domain and the PML always occur on Ez nodes. Nodes are numbered using whole integers 0, 1, 2, ..., {M, N, O} rather than half-integers, which is sometimes used in the theoretical formulation. The use of whole integers 36 simplifies translation from the equations to actual code. The full grid of nodes is represented internally using a multi-dimensional array of pointers. Then, each pointer may point to a different structure depending on the type of node. Field nodes are updated in time according to the standard time marching procedure. Time steps are numbered using the discrete integers 0, 1, 2, ..., TimeSteps. E field quantities are assumed to occupy whole-integer time steps, and H field quantities occupy half integer time steps. Thus, in time, the update procedure computes the fields E0 , H1/2 , E1 , H3/2 , E2 , . . . , H2(TimeSteps−1)/2 . However, since the computer requires arrays to be indexed with whole integers, the order is E0 , H0 , E1 , H1 , E2 , . . . , ETimeSteps−1 , HTimeSteps−1 . in terms of true indices. Since the update equations for each field quantity only depend on the previous time step, only the current time step (n) and previous time step (n−1) are stored in RAM. The field values are stored in a two element array indexed by the integers np and nm which are either 0 or 1. Field values which are required for later computations are stored to disk, thus conserving RAM. The following piece of pseuocode shows the basic procedure for updating field quantities: E0 = H 0 = 0 for n = 1 to TimeSteps np = n mod 2 ; Index into array for current time step nm = (n − 1) mod 2 ; Index into array for previous time step Compute update for En according to governing E equations Adjust En according to E field sources Adjust En according to lumped elements Adjust En according to Mur sheets Adjust En according to special grid truncation conditions Compute and store electric current mesh values Compute update for Hn according to governing H equations Adjust Hn according to H field sources Adjust Hn according to Mur sheets Adjust Hn according to special grid truncation conditions Store raw field element (E or H) values If n is a stored time step, 37 Average quantities to center of each cell Store to disk end if end for 9.2 Governing Equations This section lists the governing differential equations that are used for the FDTD simulator and the corresponding discrete update equations. The governing equations are obtained from Maxwell’s equations in point form expanded in terms of individual components. Normalizations have been applied to obtain the equations in terms of relative quantities. 9.2.1 Incident/Scattered Field Formulation For certain problems, it is more efficient (and possibly more accurate) to model only the scattered field rather than the total field. First, we define the background geometry as the physical parameters of a medium where the incident field propagates without scattering. Next, we can write the total fields (which satisfy Maxwell’s equations) as E = Ei + Es (9.1) H = H i + H s. (9.2) Faraday’s law and Ampere’s law are satisfied for the total field on the total geometry and the incident field on the background geometry: ∂H µr η0 c0 ∂t µi ∂H i ∇ × E i = − η0 c0 ∂t r ∂E ∇ × η0 H = + σ η0 E c0 ∂t i ∂E ∇ × η0 H i = + σ i η0 E i . c0 ∂t ∇×E = − (9.3) (9.4) (9.5) (9.6) Expanding total field in terms of the incident field plus scattered for Faraday’s law gives ∇ × [E i + E s ] = − ∂[H i + H s ] µr η0 c0 ∂t (9.7) 38 µr µr ∂H s ∂H i η0 − ∇ × Ei − η0 c0 ∂t c0 ∂t ∂H s µr − µi ∂H i µr η0 − η0 = − c0 ∂t c0 ∂t ∇ × Es = − (9.8) (9.9) and for Ampere’s law gives ∇ × η0 [H i + H s ] = ∇ × η0 H s = = r ∂[E i + E s ] (9.10) + σ η0 [E i + E s ] c0 ∂t r ∂E s r ∂E i + σ η0 E s − ∇ × η 0 H i + + ση0 E i (9.11) c0 ∂t c0 ∂t r ∂E s r − i ∂E i + σ η0 E s + + (σ − σi )η0 E i . (9.12) c0 ∂t c0 ∂t Therefore, each point where the total geometry is different from the background geometry presents a source in terms of the incident field. Then, our simulation region only contains scattered fields. This method can simplify excitation of the incident wave as well as avoiding dynamic range problems. 9.2.2 2D TM Continuous µr η0 c0 µr η0 c0 r ∂Ez +σ c0 ∂t 9.2.3 ∂Hx ∂t ∂Hy ∂t η 0 Ez ∂Ez ∂y ∂Ez = ∂x ∂Hy ∂Hx = η0 − ∂x ∂y = − (9.13) (9.14) (9.15) 2D TE Continuous r ∂Ex +σ c0 ∂t r ∂Ey +σ c0 ∂t µr η0 c0 ∂Hz ∂y ∂Hz = −η0 ∂x ∂Ex ∂Ey = − ∂y ∂x η 0 Ex = η 0 (9.16) η 0 Ey (9.17) ∂Hz ∂t (9.18) (9.19) 39 9.2.4 2D Incident/Scattered TE Continuous ∂Hsx µr η0 c0 ∂t µr ∂Hsy η0 c0 ∂t r ∂Esz + σ η0 Esz c0 ∂t 9.2.5 ∂Esz µr − µ i ∂Hix − η0 ∂y c0 ∂t ∂Esz µr − µ i ∂Hiy = − η0 ∂x c0 ∂t ∂Hsy ∂Hsx = η0 − ∂x ∂y r − i ∂Eiz − − (σ − σi ) η0 Eiy c0 ∂t = − (9.20) (9.21) (9.22) 2D Incident/Scattered TM Continuous r ∂Esx ∂Hsz r − i ∂Eix + σ η0 Esx = η0 − − (σ − σi ) η0 Eix (9.23) c0 ∂t ∂y c0 ∂t r ∂Esy ∂Hsz r − i ∂Eiy + σ η0 Esy = −η0 − − (σ − σi ) η0 Eiy (9.24) c0 ∂t ∂x c0 ∂t µr ∂Hsz ∂Esx ∂Esy µr − µi ∂Hiz η0 η0 = − − (9.25) c0 ∂t ∂y ∂x c0 ∂t 9.2.6 2D PML TM Continuous µr c0 µr c0 9.2.7 r ∂Ezx + σx η0 Ezx c0 ∂t r ∂Ezy + σy η0 Ezy c0 ∂t σy∗ η0 DHx t + η0 Hx η0 σx∗ η0 DHy t + η0 Hy η0 ∂Hy ∂x ∂Hx = −η0 ∂y ∂[Ezx + Ezy ] = − ∂y ∂[Ezx + Ezy ] = − ∂x = η0 (9.26) (9.27) (9.28) (9.29) 2D PML TE Continuous r ∂Ex ∂[Hzx + Hzy ] + σ y η0 Ex = η 0 c0 ∂t ∂y ∂[Hzx + Hzy ] r ∂Ey + σx η0 Ey = −η0 c0 ∂t ∂x ∗ ∂Hzx σx ∂Ey µr η0 + η0 Hzx = − c0 ∂t η0 ∂x (9.30) (9.31) (9.32) 40 σy∗ ∂Hzy ∂Ex µr η0 + η0 Hzy = − c0 ∂t η0 ∂y 9.2.8 2D TM Discrete np η0 Hx,ij np η0 Hy,ij np Ez,ij " # = np np c0 ∆t Ez,i,j−1 − Ez,i,j+1 nm + η0 Hx,i,j µr ∆y (9.34) = np np c0 ∆t Ez,i+1,j − Ez,i−1,j nm + η0 Hy,i,j µr ∆x (9.35) = " # " nm nm nm nm η0 Hy,i+1,j − η0 Hy,i−1,j η0 Hx,i,j−1 − η0 Hx,i,j+1 + ∆x ∆y r σ η0 nm + − Ez,ij c0 ∆t 2 9.2.9 np Ex,ij np Ey,ij np η0 Hz,ij = (9.33) # σ η0 r + c0 ∆t 2 −1 (9.36) 2D TE Discrete " nm nm η0 Hz,i,j+1 − η0 Hz,i,j−1 + ∆y r σ η0 nm − Ex,ij c0 ∆t 2 # = " = np np np np c0 ∆t Ex,i,j+1 − Ex,i,j−1 Ey,i−1,j − Ey,i+1,j nm + + Hz,ij µr ∆y ∆x nm nm η0 Hz,i−1,j − η0 Hz,i+1,j + ∆x " σ η0 r nm Ey,ij − c0 ∆t 2 # # r σ η0 + c0 ∆t 2 r σ η0 + c0 ∆t 2 −1 −1 (9.37) (9.38) (9.39) 9.2.10 2D PML TM Discrete np Ezx,ij np Ezy,ij np η0 Hx,ij np η0 Hy,ij = = = = " " " " nm nm η0 Hy,i+1,j − η0 Hy,i−1,j + ∆x nm nm η0 Hx,i,j−1 − η0 Hx,i,j+1 + ∆y r σ η0 nm Ezx,ij − c0 ∆t 2 σ η0 r nm Ezy,ij − c0 ∆t 2 np np np np Ezx,i,j−1 − Ezx,i,j+1 + Ezy,i,j−1 − Ezy,i,j+1 + ∆y ! σy∗ η0 µr nm − η0 Hx,ij c0 ∆t 2 # σy∗ η0 µr + c0 ∆t 2 !−1 np np np np Ezx,i+1,j − Ezx,i−1,j + Ezy,i+1,j − Ezy,i−1,j + ∆x # # r σ η0 + c0 ∆t 2 σ η0 r + c0 ∆t 2 −1 −1 (9.40) (9.41) (9.42) 41 σ ∗ η0 µr nm η0 Hy,ij − x c0 ∆t 2 # σ ∗ η0 µr + x c0 ∆t 2 −1 (9.43) 9.2.11 2D PML TE Discrete np Ex,ij = " nm nm nm nm η0 Hzx,i,j+1 − η0 Hzx,i,j−1 + Hzy,i,j+1 − η0 Hzy,i,j−1 ∆y σy η0 r nm − + Ex,ij c0 ∆t 2 np Ey,ij = " np η0 Hzy,ij = = " " σy η0 r + c0 ∆t 2 −1 (9.44) nm nm nm nm η0 Hzx,i−1,j − η0 Hzx,i+1,j + Hzy,i−1,j − η0 Hzy,i+1,j ∆x σx η0 r nm − + Ey,ij c0 ∆t 2 np η0 Hzx,ij # np np Ey,i−1,j − Ey,i+1,j + ∆x np np Ex,i,j+1 − Ex,i,j−1 + ∆y # σx η0 r + c0 ∆t 2 −1 (9.45) µr σ ∗ η0 nm η0 Hzx,ij − x c0 ∆t 2 ! # σy∗ η0 µr nm − η0 Hzy,ij c0 ∆t 2 # σ ∗ η0 µr + x c0 ∆t 2 σy∗ η0 µr + c0 ∆t 2 −1 !−1 (9.46) (9.47) 9.2.12 2D Incident/Scattered TM Discrete np η0 Hx,ij = np η0 Hy,ij np Ez,ij = = " # np np c0 ∆t Ez,i,j−1 − Ez,i,j+1 (µr − µi ) ∂Hix nm + η0 Hx,i,j − η0 (9.48) µr ∆y µr ∂t t=(np−0.5)∆t " # np np c0 ∆t Ez,i+1,j − Ez,i−1,j (µr − µi ) ∂Hiy nm η0 (9.49) + η0 Hy,i,j − µr ∆x µr ∂t t=(np−0.5)∆t " nm nm nm nm η0 Hy,i+1,j − η0 Hy,i−1,j η0 Hx,i,j+1 − η0 Hx,i,j−1 − + ∆x ∆y (r − i ) ∂Eiz − (σ − σi )η0 Eiz − c0 ∂t t=(np−0.5)∆t t=(np−0.5)∆t # σ η0 r nm Ez,ij − c0 ∆t 2 r σ η0 + c0 ∆t 2 −1 (9.50) 9.2.13 2D Incident/Scattered TE Discrete np Ex,ij = " nm nm η0 Hz,i,j+1 − η0 Hz,i,j−1 + ∆y σ η0 r nm − Ex,ij c0 ∆t 2 (r − i ) ∂Eix − (σ − σi )η0 Eix − c0 ∂t t=(np−0.5)∆t t=(np−0.5)∆t # r σ η0 + c0 ∆t 2 −1 (9.51) 42 np Ey,ij np η0 Hz,ij = = " nm nm η0 Hz,i−1,j − η0 Hz,i+1,j + ∆x σ η0 r nm Ey,ij − c0 ∆t 2 (r − i ) ∂Eiy − − (σ − σi )η0 Eiy c0 ∂t t=(np−0.5)∆t t=(np−0.5)∆t " np np np np c0 ∆t Ex,i,j+1 − Ex,i,j−1 Ey,i+1,j − Ey,i−1,j − µr ∆y ∆x # # r σ η0 + c0 ∆t 2 −1 (µr − µi ) ∂Hiz nm η0 +η0 Hz,ij − µr ∂t t=(np−0.5)∆t (9.52) (9.53) 9.2.14 3D Continuous ∂Hx µr η0 c0 ∂t ∂Hy µr η0 c0 ∂t µr ∂Hz η0 c0 ∂t = = = r ∂Ex + σ η 0 Ex = c0 ∂t r ∂Ey + σ η 0 Ey = c0 ∂t r ∂Ez + σ η 0 Ez = c0 ∂t ∂Ey ∂Ez − ∂z ∂y ∂Ez ∂Ex − ∂x ∂z ∂Ex ∂Ey − ∂y ∂x ∂Hz ∂Hy η0 − ∂y ∂z ∂Hx ∂Hz η0 − ∂z ∂x ∂Hx ∂Hy η0 − ∂x ∂y (9.54) (9.55) (9.56) (9.57) (9.58) (9.59) 9.2.15 3D Incident/Scattered Continuous ∂Hsx µr η0 c0 ∂t ∂Hsy µr η0 c0 ∂t ∂Hsz µr η0 c0 ∂t = = = r ∂Esx + σ η0 Esx = c0 ∂t r ∂Esy + σ η0 Esy = c0 ∂t r ∂Esz + σ η0 Esz = c0 ∂t ∂Hix ∂Esy ∂Esz µr − µ i η0 − − ∂z ∂y c0 ∂t ∂Hiy ∂Esz ∂Esx µr − µi η0 − − ∂x ∂z c0 ∂t ∂Hiz ∂Esx ∂Esy µr − µ i η0 − − ∂y ∂x c0 ∂t ∂Hsz ∂Hsy r − i ∂Eix η0 − − − (σ − σi ) η0 Eix ∂y ∂z c0 ∂t ∂Hsx ∂Hsz r − i ∂Eiy η0 − − − (σ − σi ) η0 Eiy ∂z ∂x c0 ∂t ∂Hsy ∂Hsx r − i ∂Eiz η0 − − − (σ − σi ) η0 Eiz ∂x ∂y c0 ∂t (9.60) (9.61) (9.62) (9.63) (9.64) (9.65) (9.66) 43 9.2.16 3D PML Continuous µr c0 µr c0 µr c0 µr c0 µr c0 µr c0 ∂Hxz σ∗ + z η0 Hxz ∂t η0 ∗ σ ∂Hxy y η0 + η0 Hxy ∂t η0 ∂Hyx σx∗ η0 + η0 Hyx ∂t η0 ∂Hyz σ∗ η0 + z η0 Hyz ∂t η0 σy∗ ∂Hzy η0 + η0 Hzy ∂t η0 ∂Hzx σx∗ η0 + η0 Hzx ∂t η0 r ∂Exy + σy η0 Exy c0 ∂t r ∂Exz + σz η0 Exz c0 ∂t r ∂Eyz + σz η0 Eyz c0 ∂t r ∂Eyx + σx η0 Eyx c0 ∂t r ∂Ezx + σx η0 Ezx c0 ∂t r ∂Ezy + σy η0 Ezy c0 ∂t η0 = = = = = = = = = = = = ∂Ey ∂z ∂Ez − ∂y ∂Ez ∂x ∂Ex − ∂z ∂Ex ∂y ∂Ey − ∂x ∂Hz η0 ∂y ∂Hy −η0 ∂z ∂Hx η0 ∂z ∂Hz −η0 ∂x ∂Hy η0 ∂x ∂Hx −η0 ∂y (9.67) (9.68) (9.69) (9.70) (9.71) (9.72) (9.73) (9.74) (9.75) (9.76) (9.77) (9.78) 9.2.17 3D Discrete np η0 Hx,ijk np η0 Hy,ijk np η0 Hz,ijk np Ex,ijk " = (9.79) = np np np np c0 ∆t Ez,i+1,jk − Ez,i−1,jk Ex,ij,k+1 − Ex,ij,k−1 nm + η0 Hy,ijk − µr ∆x ∆z (9.80) = np np np np c0 ∆t Ex,i,j+1,k − Ex,i,j−1,k Ey,i+1,jk − Ey,i−1,jk nm + η0 Hz,ijk − µr ∆y ∆x (9.81) = " " = " # " # nm nm nm η0 Hz,i,j+1,k − η0 Hz,i,j−1,k η0 Hy,i,j,k+1 − η0 Hy,i,j,k−1 − ∆y ∆z nm +Ex,ijk np Ey,ijk # np np np np c0 ∆t Ey,ij,k+1 − Ey,ij,k−1 Ez,i,j+1,k − Ez,i,j−1,k nm − + η0 Hx,ijk µr ∆z ∆y σ η0 r − c0 ∆t 2 # σ η0 r + c0 ∆t 2 −1 nm nm nm − η0 Hz,i−1,jk − η0 Hx,ij,k−1 η0 Hz,i+1,jk η0 Hx,ij,k+1 − ∆z ∆x (9.82) 44 nm +Ey,ijk np Ez,ijk = " σ η0 r − c0 ∆t 2 # σ η0 r + c0 ∆t 2 nm η0 Hy,i+1,jk − η0 Hy,i−1,jk ∆x nm +Ez,ijk r σ η0 − c0 ∆t 2 − # −1 (9.83) nm nm η0 Hx,i,j+1,k − η0 Hx,i,j−1,k ∆y r σ η0 + c0 ∆t 2 −1 (9.84) (9.85) 9.2.18 3D PML Discrete np η0 Hxz,ijk np η0 Hxy,ijk np η0 Hyx,ijk np η0 Hyz,ijk np η0 Hzy,ijk np η0 Hzx,ijk np Exy,ijk np Exz,ijk np Eyz,ijk np Eyx,ijk np Ezx,ijk np Ezy,ijk = = = = = = = = = = = = " " " " " " " " " " " " np np Ey,ij,k+1 − Ey,ij,k−1 ∆z + np np Ez,i,j−1,k − Ez,i,j+1,k ∆y nm η0 Hxz,ijk + nm η0 Hxy,ijk np np Ez,i+1,jk − Ez,i−1,jk nm + η0 Hyx,ijk np np Ex,ij,k−1 − Ex,ij,k+1 nm η0 Hyz,ijk ∆x ∆z + np np Ex,i,j+1,k − Ex,i,j−1,k ∆y np np Ey,i−1,jk − Ey,i+1,jk ∆x + + nm η0 Hzy,ijk nm η0 Hzx,ijk µr σ ∗ η0 − z c0 ∆t 2 # σy∗ η0 µr − c0 ∆t 2 µr σ ∗ η0 − x c0 ∆t 2 µr σ ∗ η0 − z c0 ∆t 2 # # σy∗ η0 µr − c0 ∆t 2 µr σ ∗ η0 − x c0 ∆t 2 !# !# # nm nm − η0 Hz,i,j−1,k η0 Hz,i,j+1,k σy η0 r nm + Exy,ijk − ∆y c0 ∆t 2 µr σ ∗ η0 + z c0 ∆t 2 −1 σy∗ η0 µr + c0 ∆t 2 µr σ ∗ η0 + x c0 ∆t 2 µr σ ∗ η0 + z c0 ∆t 2 −1 −1 σy∗ η0 µr + c0 ∆t 2 µr σ ∗ η0 + x c0 ∆t 2 # !−1 !−1 −1 σy η0 r + c0 ∆t 2 −1 # nm nm − η0 Hy,ij,k+1 η0 Hy,ij,k−1 r r σz η0 σz η0 −1 nm + Exz,ijk − + ∆z c0 ∆t 2 c0 ∆t 2 # nm nm η0 Hx,ij,k+1 − η0 Hx,ij,k−1 r r σz η0 σz η0 −1 nm + Eyz,ijk − + ∆z c0 ∆t 2 c0 ∆t 2 nm nm − η0 Hz,i+1,jk η0 Hz,i−1,jk r σx η0 nm + Eyx,ijk − ∆x c0 ∆t 2 nm nm − η0 Hz,i−1,jk η0 Hy,i+1,jk r σx η0 nm + Ezx,ijk − ∆x c0 ∆t 2 # # r σx η0 + c0 ∆t 2 r σx η0 + c0 ∆t 2 −1 −1 (9.86) (9.87) (9.88) (9.89) (9.90) (9.91) (9.92) (9.93) (9.94) (9.95) (9.96) # nm nm − η0 Hx,i,j+1,k η0 Hx,i,j−1,k σy η0 σy η0 −1 r r nm + Ezy,ijk − + (9.97) ∆x c0 ∆t 2 c0 ∆t 2 45 9.2.19 3D Incident/Scatterd Discrete np η0 Hx,ijk = " np np np np c0 ∆t Ey,ij,k+1 − Ey,ij,k−1 Ez,i,j+1,k − Ez,i,j−1,k − µr ∆z ∆y nm +η0 Hx,ijk np η0 Hy,ijk = " np Ex,ijk = = (9.98) np np np np c0 ∆t Ez,i+1,jk − Ez,i−1,jk Ex,ij,k+1 − Ex,ij,k−1 − µr ∆x ∆z nm +η0 Hy,ijk np η0 Hz,ijk (µr − µi ) ∂Hix η0 − µr ∂t t=(np−0.5)∆t " # (µr − µi ) ∂Hiy η0 − µr ∂t t=(np−0.5)∆t # (9.99) np np np np c0 ∆t Ex,i,j+1,k − Ex,i,j−1,k Ey,i+1,jk − Ey,i−1,jk − µr ∆y ∆x # (µr − µi ) ∂Hiz nm +η0 Hz,ijk − η0 µr ∂t t=(np−0.5)∆t " (9.100) nm nm nm nm η0 Hy,ij,k+1 − η0 Hy,ij,k−1 η0 Hz,i,j+1,k − η0 Hz,i,j−1,k − ∆y ∆z r σ η0 (r − i ) ∂Eix nm − + Ex,ijk − c0 ∆t 2 c0 ∂t t=(np−0.5)∆t np Ey,ijk = # r σ η0 −1 −(σ − σi )η0 Eix + c0 ∆t 2 t=(np−0.5)∆t " nm nm nm nm η0 Hx,ij,k+1 − η0 Hx,ij,k−1 η0 Hz,i+1,jk − η0 Hz,i−1,jk − ∆z ∆x (r − i ) ∂Eiy r σ η0 nm + Ey,ijk − − c0 ∆t 2 c0 ∂t t=(np−0.5)∆t np Ez,ijk = (9.101) # r σ η0 −1 + −(σ − σi )η0 Eiy c0 ∆t 2 t=(np−0.5)∆t " nm nm nm (9.102) nm η0 Hy,i+1,jk − η0 Hy,i−1,jk η0 Hx,i,j+1,k − η0 Hx,i,j−1,k − ∆x ∆y r σ η0 (r − i ) ∂Eiz nm − + Ez,ijk − c0 ∆t 2 c0 ∂t t=(np−0.5)∆t −(σ − σi )η0 Eiz t=(np−0.5)∆t # r σ η0 + c0 ∆t 2 −1 (9.103) 9.3 Lumped Elements This section describes how lumped elements are suppored in the FDTD code. 46 9.3.1 Resistor The lumped resistor is implemented by just placing conductive cells in the simulation. If the resistor occupies a single cell, the resistor is “lumped.” If not, the resistor is “distributed.” When the bounds of the resistor are defined, the outer coordinates are snapped to the nearest even (E field) nodes. The required conductivity is then calculated using σ= ` 1 , R wd (9.104) where ` is the length of the resistor (in direction of current flow), R is the resistance in ohms, and w and d are the width and depth. Loaded Voltage Source The vsrc command creates a voltage source with a series load. - V + 9.3.2 R Vs Figure 9.2: Loaded Voltage Source Element The voltage source supplies a current which is dependent on the voltage seen at its terminals I= Vs − V . R (9.105) The user specifies a box containing the voltage source. The simulator assumes that the current is constant (equal to 9.105) in the volume occupied by the source. Assuming the current is directed in the x direction, the current density at each point in the voltage element is Jx = (V s − Vx )/R I = . ∆y∆z ∆y∆z (9.106) Next, write Ampere’s law anywhere in the voltage source as r ∂Ex + σ η 0 Ex + J x c0 ∂t ∂Hy ∂Hz − η0 ∂y ∂z r ∂Ex (Vs − ∆xEx )/R + σ η 0 Ex + c0 ∂t ∆y∆z Vs 1 ∆x r ∂Ex Ex + + σ η0 − c0 ∂t R ∆y∆z R∆y∆z = (9.107) = f (H) (9.108) = f (H) (9.109) = f (H) (9.110) 47 where f (H) has replaced everything depending on H fields. Also, note the voltage (V ) across each cell has been replaced with E x ∆x. Next, perform the standard discretization. To obtain E at the odd time step, just average in time. np nm 1 ∆x r Ex,ijk − Ex,ijk + ση0 − c0 ∆t R ∆y∆z np nm Ex,ijk + Ex,ijk 2 ! + Vs R∆y∆z = f (H) (9.111) Next, write E for the current time step in terms of E for the previous time step. ση0 ∆x r np + − Ex,ijk = c0 ∆t 2 2R∆y∆z ση0 ∆x r nm − + Ex,ijk c0 ∆t 2 2R∆y∆z Vs + f (H) (9.112) − R∆y∆z Our standard FDTD update equation will compute ση0 r + c0 ∆t 2 np Ex,ijk = ση0 r − c0 ∆t 2 nm Ex,ijk + f (H) (9.113) where E represents an invalid E component since the source has not been np accounted for. Subtracting (∆x/(2R∆y∆z))E x,ijk from both sides gives r ση0 ∆x np + − Ex,ijk = c0 ∆t 2 2R∆y∆z r ση0 nm − Ex,ijk c0 ∆t 2 ∆x np − Ex,ijk + f (H). 2R∆y∆z (9.114) Taking the difference of Equations 9.112 and 9.114 yields ση0 ∆x r np np + − Ex,ijk − Ex,ijk = c0 ∆t 2 2R∆y∆z Vs ση0 ∆x r nm Ex,ijk − − + + f (H) c0 ∆t 2 2R∆y∆z R∆y∆z ∆x ση0 r nm Ex,ijk + − − E np − f (H). c0 ∆t 2 2R∆y∆z x,ijk (9.115) 48 Canceling the appropriate terms and solving for the current time step gives np np Ex,ijk = Ex,ijk + h ∆x 2R∆y∆z nm + E np Ex,ijk x,ijk − r c0 ∆t + ση0 2 − ∆x 2R∆y∆z Vs R∆y∆z i (9.116) which provides the correction factor to convert the partially updated field (E) to the actual field (E). 9.4 Sources This section explains how the various sources are excited in the simulation grid. 9.4.1 Time Windows Time windows help avoid transient behavior in a simulation. Gaussian Window The Gaussian window has the following form: 2 W (t) = 1 − e−(t/τ ) . (9.117) Given the 99% rise time, the parameter τ is found as 9.4.2 RT τ = p 99% . ln(100) (9.118) Forced Plane Source Planar sources in general consist of a shape function and a propagation function. The shape function (S) defines the field in a plane transverse to the direction of propagation. The propagation function (P ) defines how planes of constant phase move over time. The complete source function is given as F (x, y, z, t) = <{S(x, y)P (z, t)} (9.119) where x and y define a point in the local reference plane, z is the direction of propagation, and t is a time value. The user specifies two coordinates denoting the corners of the desired excitation plane. Since FDTD uses a staggered grid, and the user may choose arbitrary coordinates, certain field components will not lie in the specified plane. The simulator chooses the nearest compatible plane (parallel to the specified excitation plane) containing each component. A point list is generated for each field component to be forced. The point list contains an entry for each location where the field component exists in 49 the excitation plane. Each entry stores the distance to the reference plane and the value of the shape function. The shape function is computed by projecting the spatial coordinate onto the reference plane and evaluating S(x, y). During the simulation, the propagation function is evaluated using the current time step and the distance to the reference plane. The real part of this value times the shape value is stored in the field element. Forced sources overwrite the E and H values in the excitation plane which are originally written by the standard update equations. These sources present a zero-field condition for incident fields, which may be undesirable. Since a forced planar source is only forced in a single plane, two symmetric plane-waves will be created propagating in opposite directions from the excitation plane. 9.4.3 Additive Plane Source Planar sources may also be created by adding a value for E or H to the existing value rather than overwriting it. This corresponds to an electric current sheet or magnetic current sheet, respectively. The simulator computes what the current must be in order to obtain a plane wave of correct amplitude. Assume that we wish to excite a plane wave propagating in the z direction polarized with electric field in the x direction. The E and H fields for our plane wave will have the form Ex,src (z) = E0 (x, y)e−jkz |z−z0 | Hy,src (z) = sgn(z − z0 )H0 (x, y)e−jkz |z−z0 | (9.120) where kz is the propagation constant and z0 is the reference plane. Note that this corresponds to two symmetric plane waves radiating out from the plane where our current is specified. The discrete update equation for E x in this plane is np Ex,ijk = " nm nm nm η0 Hz,i,j+1,k − η0 Hz,i,j−1,k η0 Hy,i,j,k+1 − η0 Hy,i,j,k−1 − ∆y ∆z nm +Ex,ijk σ η0 r − c0 ∆t 2 # r σ η0 + c0 ∆t 2 −1 + Ex,add (9.121) where Ex,add needs to be found to generate 9.120. Substituting values for the source and noting that Hy,i,j,k−1 = −Hy,i,j,k+1, we obtain np Ex,ijk = " nm nm − η0 Hz,i,j−1,k 2η0 Hy,i,j,k+1 η0 Hz,i,j+1,k − ∆y ∆z (9.122) 50 nm +Ex,ijk σ η0 r − c0 ∆t 2 # σ η0 r + c0 ∆t 2 −1 + Ex,add where E and H are the source E and H fields to be excited. Adding and subtracting η0 Hz,i,j,k−1/∆y inside the brackets gives np Ex,ijk − " nm nm nm − η0 Hy,i,j,k−1 η0 Hz,i,j+1,k − η0 Hz,i,j−1,k η0 Hy,i,j,k+1 − ∆y ∆z + = − " nm Ex,ijk r σ η0 − c0 ∆t 2 # σ η0 r + c0 ∆t 2 −1 (9.123) # nm nm η0 Hy,i,j,k+1 + η0 Hy,i,j,k−1 σ η0 −1 r + + Ex,add . ∆z c0 ∆t 2 Since the source (presumably) satisfies Maxwell’s equations, the expression on the left hand side of the equation goes to zero, and we obtain Ex,add " nm nm + η0 Hy,i,j,k−1 η0 Hy,i,j,k+1 = ∆z # r σ η0 + c0 ∆t 2 −1 . (9.124) Similar equations can be derived for other field components and different propagation directions using the following convention: 1. For additive Edir or Hdir source, use the update equation for E dir or Hdir , respectively. 2. Additive component will be of the form (E, H)add " nm η0 (H, E)nm i+1 + η0 (H, E)i−1 =s ∆ # r σ η0 + c0 ∆t 2 −1 . 3. The component on the right hand side is the one differenced in the propagation direction, and i is the index in the propagation direction. 4. The sign s is chosen as the sign opposite the one in front of the i + 1 component in the update equation. 9.5 Power Scattering/Absorption This section explains the equations used to compute power scattered out of a box and power absorbed inside of a box. 9.5.1 Power Absorption Power absorption is calculated by considering the inifinitesimal cylinder depicted below. 51 J σ A L (a) Figure 9.3: Volume used for power absorption calculation For a cylinder of finite size with constant current, we have Pa = 1 2 |I| R 2 I = JA = σE · A (9.125) Solving for absorbed power we have Pa = = = 1 |σE · A|2 2 1 2 |E| σLA 2 1 2 |E| σV. 2 L σA (9.126) (9.127) (9.128) In terms of differentials, we have Pa = 9.5.2 1 2 Z σ|E|2 dV. (9.129) V Total Scattered Power To compute scattered power, we compute the time-harmonic Poynting vector on the surface of a box and integrate the normal component. Ps = = = I 1 ∗ < E × H · ds 2 IS 1 ∗ (3D) < n̂ · (E × H )dS 2 IS 1 ∗ n̂ · (E × H )d` < (2D) 2 c (9.130) (9.131) (9.132) 52 y Ez Hx - Ex Hz z Ex Hy - Ey Hx -Ey Hz + Ez Hy -x y x Ey Hz - Ez Hy -x -Ey Hz + Ez Hy x Ey Hz - Ez Hy -Ez Hx + Ex Hz -Ez Hx + Ex Hz -Ex Hy + Ey Hx Ez Hx - Ex Hz -y -z (a) 2D (b) 3D Figure 9.4: Box used for computing total power scattered in the 2D and 3D simulators. x̂ Ex Hx ŷ ẑ E ×H = Ey Ez Hy Hz = x̂(Ey Hz − Ez Hy ) + ŷ(Ez Hx − Ex Hz ) +ẑ(Ex Hy − Ey Hx ) 9.5.3 (9.133) (9.134) Scattering/Absorption Cross-Sections This section gives the conversion from total scattered/absorbed power to scattering and absorption cross-sections for a plane wave. Assume an incident plane wave with electric-field peak amplitude E 0 . Time harmonic electric field is Ei = E 0 V ∆ (9.135) where V /∆ specifies units of volts per length. Incident power denisity is given as Si = 1 2 1 E02 W |E| = . 2 2 η0 ∆2 (9.136) Next, we define absorption and scattering cross sections as σa = Pa Si ∆2 (9.137) 53 σs = Ps Si ∆2 (9.138) which by substitution are found to be σa = σs = 2Pa η0 E02 2Ps η0 E02 ∆2 (9.139) ∆2 . (9.140) 9.6 Geometry The FDTD interpreter contains code to handle several geometric constructs. This section outlines the theory behind the required operations. 9.6.1 Coordinate Systems Parts of the code require transformations from cartesian coordinates to spherical coordinates or vice versa. The following equations are used to convert scattered farfields from spherical coordinates to cartesian coordinates: θ̂ = x̂ cos θ cos φ + ŷ cos θ sin φ − ẑ sin θ (9.141) r̂ = x̂ sin θ cos φ + ŷ sin θ sin φ + ẑ cos θ (9.143) Ex = x̂ · (Eθ θ̂ + Eφ φ̂) (9.144) φ̂ = −x̂ sin φ + ŷ cos φ (9.142) = Eθ cos θ cos φ − Eφ sin φ (9.145) = Eθ cos θ sin φ + Eφ cos φ (9.147) Ey = ŷ · (Eθ θ̂ + Eφ φ̂) Ez = ẑ · (Eθ θ̂ + Eφ φ̂) = −Eθ sin θ (9.146) (9.148) (9.149) 9.7 Complex Dielectric Constant To perform time-domain analysis of structures, we need to convert complex dielectric constants to real permittivity and conductivity using the relation er = r − j σc0 η0 ω (9.150) 54 9.8 DFT Time domain fields are converted to the frequency domain using the DFT. For a time-domain field quantity X x[n] = ak ej 2πkn N , (9.151) k=<N > where < N > denotes summation over a single period, the corresponding steady state coefficients are ak = 1 N X x[n]e−j 2πkn N . (9.152) n=<N > 9.9 Units This section provides the units that are used for physical quantities. ∆ = Distance unit (9.153) ∆t = Time unit (9.154) ∆x ∼ ∆ (9.155) ∆z ∼ ∆ V E ∼ ∆ V η0 H ∼ ∆ η0 ∼ Ω ∆ c0 ∼ ∆t r ∼ 1 (9.157) ∆y ∼ ∆ µr ∼ 1 σr = σ η 0 c0 ∼ 1 1 σ ∼ Ω∆ Pa ∼ W Ps ∼ W (9.156) (9.158) (9.159) (9.160) (9.161) (9.162) (9.163) (9.164) (9.165) (9.166) (9.167) 55 Chapter 3: MIEV Tool 1 Introduction This chapter explains the MIEV tool. This tool provides a MATLAB/Octave front-end for Wiscombe’s useful Mie scatterting calculator. 2 Octave Functions This section describes the octave routines which are part of this tool. 2.1 miev Syntax: [qext qsca s1 s2] = miev(chi, eps, ang) ; Inputs: chi Scattering efficiency. The scattering efficiency is radius of the scatter times the propagation constant in the background medium (χ = kb a = 2πa/λb ). eps Dielectric constant of the scattering sphere assuming the background to be free space. A background which is not free space may be accomodated by letting = sphere /bkg . ang Angles over which to compute scattered fields (radians). qext Extinction (scattering + absorption) efficiency factor, which is the ratio of the extinction cross section to the physical cross section. σe = qext πa2 . qsca Scattering efficiency. σs = qsca πa2 . s1 Power scattered to far field as a function of angle for E polarized perpendicular (H) to the plane of incidence. Units are W/λ2b . s2 Power scattered for E polarized parallel (V) to the plane of incidence. Units are W/λ2b . Outputs: Description: This command computes the Mie scattering cross sections and scattered fields for a sphere of specified size. Any one of the input arguments may be a vector or matrix and the others should be scalars. Thus, the function can compute scattering across sphere sizes, dielectric constants, or anlges. 3 Matlab Functions This section describes the matlab routines which are part of the tool. 56 3.1 miev Syntax: [qext qsca s1 s2] = miev(chi, eps, ang) ; Description: See description of octave function in Section 2.1. 4 C/C++ Library Functions This section describes the functions which are compiled into libmiev.a. 4.1 mieScat Syntax: void mieScat( double chi, Complex eps, const MatrixClass& angles, double& qext out, double& qscat out, MatrixClass& s1 out, MatrixClass& s2 out); Description: C++ Function. Computes the Mie scattering parameters for the sphere of interest. See Section 2.1 for a description of the parameters. 57 Chapter 4: MODE Tool 1 Introduction This chapter describes the MODE tool, a 2D waveguide mode solver. The user provides a mesh of relative permittivities, and the tool generates a set of finite difference equations in sparse format to be solved. For a description of the sparse format see Section 2 in Chapter 8. 2 Octave Functions This section describes the Octave functions which are part of the MODE tool. 2.1 mode eig Syntax: [a d] = mode eig(x, y, bound, eps) ; Inputs: x, y Dimensions of the simulation region (in free space wavelengths). bound Specifies the type of boundary at the domain edge. 0: Force fields on √ the boundary to 0. 1: Assume a 1/ R decay at the boundary. eps Matrix of relative permittivity values. The row dimension is the y direction and the column dimension is the x direction. a Sparse field coefficient matrix. d Matrix dimension information. To form a matrix equation, the field components must be stacked into a vector. This matrix stores information on how the stacking was done. Each field component is stored in matrix form with the row dimension corresponding to y and the column dimension corresponding to x. Each component is stacked columnwise into a vector. Outputs: The d matrix has the following format: Ex start Ey start Ez start Hx start Hy start Hz start Ex end Ey end Ez end Hx end Hy end Hz end Ex rows Ey rows Ez rows Hx rows Hy rows Hz rows Ex columns Ey columns Ez columns Hx columns Hy columns Hz columns 58 Description: This command generates an eigenvalue problem in sparse format for the 2D structure: Af = βz f . 2.2 mode lin Syntax: [m r d] = mode lin(x, y, bz, bound, eps, force) ; Inputs: x, y Dimensions of the simulation region (in free space wavelengths). bz ẑ propagation constant. bound Specifies the type of boundary at the domain edge. 0: Force fields on to 0. √ the boundary √ − βz2 −(2πnb )2 R 1: Assume a e / R decay. eps Matrix of relative permittivity values. The row dimension is the y direction and the column dimension is the x direction. force Matrix of field points to force. Each row specifies a field point in space to force and has the format [type x y val] where type is 1=Ex , 2=Ey , 3=Ez , 4=Hx , 5=Hy , 6=Hz (x, y) is the coordinate to force relative to the center val is the value to force (usually 1 or 0). m Equation matrix in sparse format. r RHS vector. d Stacked matrix dimension information (see Section 2.1 for format). Outputs: Description: This command generates an linear equation problem in sparse format for the 2D structure: M f = r. 2.3 resample Syntax: [ex ey ez hx hy hz] = resample(ex1, ey1, ez1, hx1, hy1, hz1, Nx, Ny) ; [ex] = resample(ex1, xr1, yr1, xr2, Nx2, yr2, Ny2) ; Inputs: ex1, ey1, ez1, hx1, hy1, hz1 Input sample grids. Dimensions are inferred from the sizes of the matrix. Nx, Ny Number of cells in the new matrix ex, ey, ez, hx, hy, hz New grid with the field components colocated at the center of each cell. Outputs: 59 Description: This function resamples a staggered FD grid onto a common grid using linear interpolation. 60 Chapter 5: PLOT Tools 1 Introduction This chapter describes the use of the PLOT tools. 2 Octave Functions 2.1 plotfield Syntax: plotfield(x, y, zx, zy, zz {, pix x, pix y} ) ; Inputs: x x coordinates corresponding to columns in the z matrix. y y coordinates corresponding to rows in the z matrix. zx Matrix of vector x̂ components. zy Matrix of vector ŷ components. zz Matrix of vector ẑ components. Set to the empty matrix [ ] if the vector field is 2D. pix x Optional width of the plot in pixels. pix y Optional height of the plot in pixels. Description: This command plots the vector field (zx x̂ + zy ŷ + zz ẑ)[x, y]. The vector field may be specified as 2D by making zz the empty matrix. 2.2 plotimg Syntax: plotimg(x, y, z, {, pix x, pix y, grad type} ) ; Inputs: x x coordinates corresponding to columns in the z matrix. y y coordinates corresponding to rows in the z matrix. z Matrix of (real) scalar values z[x, y]. pix x Optional width of the plot in pixels. pix y Optional height of the plot in pixels. grad type Gradient type: 0=Black and White, 1=Color. 61 Description: This command plots the scalar function z[x, y] on a 2D map using a color gradient. 3 Shell Functions This section describes functions available from the UNIX shell. 3.1 plotfile Syntax: plotfile [filename] {[width] {[height] {[grad]}}} Parameters: filename Name of the plotfile to plot. width Width of the plot in pixels. height Height of the plot in pixels. grad Type of gradient to use. 0=BW, 1=Color. Description: This function allows plot files to be viewed from the UNIX shell. Plot files are generated by the FDTD simulator plotfile command or other programs that use the plotfile capabilities of the C++ plot library. 62 Chapter 6: QCA-CP Tool 1 Introduction This chapter explains the functions that are part of the QCA-CP tool. This tool is useful for computing scattering and absorption in a random medium containing densely-packed dielectric spheres. 2 Octave Functions 2.1 percus Syntax: [g] = percus(f, x) ; Inputs: f Scalar fill fraction. Note: 0 < f < 1. x Displacement of sphere centers (in sphere diameters). This value should be greater than 1 to have physical meaning. May be a vector or matrix. g Potential values. Outputs: Description: This function computes the Percus-Yevick pairwise distribution function. Note that because of the way the function is computed, it is sensitive to values of x which are large or close to 1. 2.2 qca cp Syntax: [K] = qca cp(f, a, eps) ; Inputs: f Fill fraction of the spheres (0 < f < 1). a Radius of spheres (in wavelengths). eps (Possibly complex) dielectric constant for spheres assuming free space background. K Complex effective propagation constant. Units are rad/λb . The imaginary part represents a loss which is due to absorption (if eps is complex) and scattering. Outputs: Description: This command computes the effective propagation constant for a random medium consisting of densely-packed dielectric spheres. The function searches for K using Muller’s method with the closed-form lowfrequency solution as an initial guess. 63 2.3 w3j Syntax: [b] = w3j(l1, l2, l3, m1, m2, m3) ; Inputs: l1, l2, l3, m1, m2 Wigner-3j parameters. Outputs: b Output value of function. Description: This function returns the Wigner-3j symbols for l1 l2 l3 m1 m2 −(m1 + m2) ! . 64 Chapter 7: Radiative Transfer 1 Introduction The Radiative Transfer tool simulates active and passive electromagnetic propagation through a layered medium. 2 M-Files This section describes the .M files that are part of this tool. 2.1 active mult Syntax: [sigma0 ang dv] = active mult(L, N, M, Ppoi, mu P, n, kei, d, debug); Inputs: L Number of scattering layers. N Number of look angles. M Number of azmimuth angles. Ppoi Structure containing the phase matrix for each scattering layer in the plane of incidece. Ppoi.l[l] = Block vector containing the phase matrix in the lth layer. l = {1, 2, . . .}. Each 4 × 4 block in the vector corresponds to the phase matrix at an angle cosine in mu P. Units are 1/length 3 . mu P Structure containing the angle cosines at which Ppoi is defined in each layer. mu P.l[l] = Vector of angle cosines for the l th layer. l = {1, 2, . . .}. n Vector of effective indices of refraction for each layer: n(1) = Index of refraction of the homogeneous top layer (usually air = 1). n(l + 1) = Index of refraction of the l th scattering layer. n(L + 2) = Index of refration of the homogeneous bottom layer. kei Vector containing the isotropic extinction coefficient of each scattering layer. Units are 1/length. d Vector containing the depth of each scattering layer. Units are length. debug If set, a debug structure dv is created. 65 Outputs: sigma0 Matrix containing backscatter coefficients looking into the top medium for the various polarizations. Each row is a different look angle (corresponding to an element in ang. The column number determines polarization: 1=V→V, 2=V→H, 3=H→V, 4=H→H. ang Vector of angles that were used (in radians). dv Structure containing debug information. Description: This command solves for the active backscatter as a function of angle for a multiple layer radiative transfer model. 2.2 active single Syntax: [sigma0 ang dv] = active single(N, M, Ppoi, mu P, n1, n2, n3, kei, d, debug) ; Inputs: N Number of look angles. M Number of azimuth angles. Ppoi Block vector containing the phase matrix in the plane of incidence for the single scattering layer. Each 4 × 4 block in the vector corresponds to an angle cosine in mu P. Units are 1/length 3 . mu P Vector of angle cosines at which Ppoi is defined. n1 Index of refraction of the homogeneous top layer (usually air = 1). n2 Effective index of refraction of the scattering layer. n3 Index of refraction of the homogeneous bottom layer. kei Isotropic extinction coefficient for the scattering layer. Units are 1/length. d Depth of the scattering layer (length units). debug Flag. If set, debug information is stored in structure dv. sigma0 Backscatter coefficients. See Section 2.1 for format. ang Angles at which sigma0 is defined (in radians). dv Structure containing debug information. Outputs: 66 Description: This function computes the active backscatter for a single scattering layer radiative transfer model. 2.3 keRay Syntax: [ks ka] = keRay(f, a, eps s, eps b) ; Inputs: f Fill fraction. a Radius of spheres (in wavelengths). eps s Dielectric constant of scatterers. eps b Dielectric constant of the background. ks Scattering coefficient (units 1/λ b ). ka Absorption coefficient (units 1/λ b ). Outputs: Description: Computes the scattering and absorption coefficients for Rayleigh spheres. 2.4 mie Syntax: [eth ephi] = mie(eps, a, freq, c0, kvec, evec, th, phi) ; Inputs: eps Dielectric constant of the sphere assuming a free space background. a Radius of the sphere. Units are length. freq Frequency of illumination. Units are 1/time. c0 Background wave speed. Units are length/time. kvec 3D unit vector for the propagation direction [kx , ky , kz ]. evec 3D unit vector for the polarization of the incident E field. th Sample angles in theta for scattered far field. phi Sample angles in phi for scattered far field. eth Vector of scattered electric field in the θ̂ direction. ephi Vector of scattered electric field in the φ̂ direction. Outputs: Description: Computes the scattering of electric field from a single Mie sphere. 67 2.5 mie phase Syntax: [ke ks p11 p22 ang] = mie phase(eps, a, f, n) ; Inputs: eps Dielectric constant of spheres. a Radius of spheres (in wavelengths). f Fractional volume of spheres. n Number of look angles to compute over. ke Extinction coefficient. ks Scattering coefficient. p11 Vector containing P11 as a function of angle in the plane of incidence. p22 Vector containing P22 as a function of angle in the plane of incidence. ang Angles over which p11 and p22 were computed. Outputs: Description: Computes the phase matrix elements P 11 and P22 for a collection of Mie spheres. 2.6 mieq Syntax: [sigma a sigma s] = mieq(eps, sigma, a, freq, c0); Inputs: eps Dielectric constant of the sphere. sigma Conductivity of the sphere. a Radius of the sphere. freq Frequency of illumination. c0 Wave speed. sigma a Absorption cross section of sphere. sigma s Scattering cross section of sphere. Outputs: Description: Returns absorption and scattering cross sections for a Mie sphere. 68 2.7 passive mult Syntax: [Tb ang dv] = passive mult(L, N, M, Ppoi, mu P, n, T, kei, kai, d, debug); Inputs: L Number of scattering layers. N Number of look angles. M Number of azmimuth angles. Ppoi Structure containing the phase matrix for each scattering layer in the plane of incidece. Ppoi.l[l] = Block vector containing the phase matrix in the lth layer. l = {1, 2, . . .}. Each 2 × 2 block in the vector corresponds to the phase matrix at an angle cosine in mu P. Units are 1/length 3 . mu P Structure containing the angle cosines at which Ppoi is defined in each layer. mu P.l[l] = Vector of angle cosines for the l th layer. l = {1, 2, . . .}. n Vector of effective indices of refraction for each layer: n(1) = Index of refraction of the homogeneous top layer (usually air = 1). n(l + 1) = Index of refraction of the l th scattering layer. n(L + 2) = Index of refration of the homogeneous bottom layer. T Vector containing the physical temperature (deg K) of each layer. T (1) = Temperature of the top homogeneous layer. T (l + 1) = Temperature of the lth scattering layer. T (L+2) = Temperature of the bottom homogeneous layer. kei Vector containing the isotropic extinction coefficient of each scattering layer. Units are 1/length. kai Vector containing the absorption (emission) coefficient of each scattering layer. d Vector containing the depth of each scattering layer. Units are length. debug If set, a debug structure dv is created. 69 Outputs: Tb Matrix containing brightness temperature values. Each row is a different look angle (corresponding to an element in ang. The column index determines polarization: 1=V 2=H. ang Vector of angles that were used (in radians). dv Structure containing debug information. Description: Computes brightness temperature according to a multiple-layer passive radiative transfer model. 2.8 passive single Syntax: [Tb ang dv] = passive single(N, M, Ppoi, mu P, n1, n2, n3, T1, T2, T3, kei, kai, d, debug); Inputs: N Number of look angles. M Number of azimuth angles. Ppoi Block vector containing the phase matrix in the plane of incidence for the single scattering layer. Each 2 × 2 block in the vector corresponds to an angle cosine in mu P. Units are 1/length 3 . mu P Vector of angle cosines at which Ppoi is defined. n1, n2, n3 Index of refraction of top homogeneous layer, scattering layer, and bottom homogeneous layer. T1, T2, T3 Physical temperature of the top homogeneous layer, scattering layer, and bottom homogeneous layer. kei Isotropic extinction coefficient for the scattering layer. Units are 1/length. kai Isotropic absorption (emission) coefficient for the scattering layer. d Depth of the scattering layer (length units). debug Flag. If set, debug information is stored in structure dv. Tb Brightness temperatures. See Section 2.7 for format. ang Angles at which Tb is defined (in radians). dv Structure containing debug information. Outputs: 70 Description: Returns the brightness temperature according to a single scattering layer passive radiative transfer model. 2.9 phaseMiePoi Syntax: [P ke ks] = phaseMiePoi(mu, a, eps, f) ; Inputs: mu Angle cosines over which to compute the phase matrix. a Radius of spheres in wavelengths. eps Dielectric constant of spheres. f Fill fraction of spheres. P Phase matrix in the plane of incidence scaled by 1/ks. ke Extinction coefficient for independent scattering 1/lambda. ka Absorption coefficient for independent scattering 1/lambda. Outputs: Description: This function returns the phase matrix in the plane of incidence and the extinction and scattering coefficients for a random medium of Mie spheres. 2.10phaseRayPoi Syntax: [P] = phaseRayPoi(mu) ; Inputs: mu Vector of angle cosines. Outputs: P Phase matrix in plane of incidence scaled by 1/ks. Description: This function returns the phase matrix in the plane of incidence for a random medium of Rayleigh spheres. 3 Octave Functions This section describes the Octave functions that are part of this tool. 3.1 interpVec Syntax: [w1 i1 w2 i2] = interpVec(x, x vec) ; Inputs: x Real point where value of function is wanted. x vec Vector of points where the function is defined. 71 Outputs: w1, w2 Weights of the points used in the interpolation. i1 i2 Indices of the points used in the interpolation. Description: This function returns the weights and indices which are required to perform a linear interpolation operation on the vector x vec at the real point x. The interpolated value is obtained by computing f (x) = w1 ∗ x vec[i1] + w2 ∗ x vec[i2]. 3.2 phaseRot Syntax: [P] = phaseRot(mu, Ppoi, muo, w, phi {, pflag }) ; Inputs: mu A vector containing the cosines of the angles at which the phase matrix in the plane of incidence Ppoi is defined. Ppoi Block vector containing the phase matrix in the plane of incidence. The matrix should be a block column vector, where each row is a 4 × 4 phase matrix. Each block corresponds to an element of mu. muo Downward range of angle cosines for incident and scattered angles where P will be calculated. w Corresponding summation weights for points in muo. phi Scalar representing the scattered azimuth angle. The incident azimuth angle is fixed at 0. pflag If set, only the first two stokes parameters are returned. P Block matrix containing the phase matrices at each incident and scattered look angle. Indices are P [n, n0 ][., .], where n0 is a incident angle index and n is a scattered angle index, and [., .] refers to the 4 × 4 or 2 × 2 single angle phase matrix. Outputs: Description: This command takes a phase matrix defined in the plane of incidence and rotates it to obtain the phase matrix at all desired incident and scattered look angles. The incident and scattered azimuth angles are fixed. Note that the function returns the full integrated phase matrix, which allows the matrix to be used directly in the discretized radiative transfer equations. 3.3 planeSurf Syntax: [R mup] = planeSurf(mu, med, n1, n2, {,pflag}) ; 72 Inputs: Outputs mu Cosine of downward angles in the range [−1, 0] where the reflection/transmission matrix should be computed. med Flag indicating which medium the angles are defined in (1=region1, 2=region2). If med = 0, the same angles are used for both sides of the interface, and the transmission function is interpolated. n1 Index of refraction of the top layer n2 Index of refraction of the bottom layer pflag Flag: If nonzero indicates that only the first two stokes parameters are returned. Used for passive radiative transfer. R Reflection/transmission matrix. mup Transmitted downward angle cosines (for angles opposite medium where angles were defined) if med=1 or 2. Description: This command returns the reflection/transmission matrix for a planar (Fresnel) interface. The returned reflection/transmission matrix is a block matrix containing reflection and transmission matrices seen in each medium at the interface. R= " T12 R21 R12 T21 # 73 Chapter 8: SPARSE Tool 1 Introduction The Sparse Tool provides basic functions for manipulating sparse matrices, which arise in practice from systems of finite-difference equations. This toolkit borrows from SuperLU and ARPACK libraries to support matrix inversion and eigenvalue/eigenvector searches. 2 Sparse Format The Sparse format that was chosen provides a tradeoff between readibility and compactness. The compressed sparse matrix contains a single descriptor row defining the size of the matrix. Then, each nonzero element of the full matrix is described using an additional row. A matrix with M nonzero elements would have the following representation Nrows row1 row2 .. . Ncolumns column1 column2 unused value1 value2 .. . rowM columnM valueM , where row m , columnm , and valuem are the row, column, and value of the m th nonzero element. Note that the row and column indices are 1-indexed. Also, as a convention, elements are defined in column order, i.e., nonzero entries begin with the first column (in order of ascending rows), followed by the second column, etc. 3 Octave Functions 3.1 full Syntax: [x] = full(y) ; Inputs: y A matrix in sparse format. Outputs: x A full matrix. Description: This function generates a full matrix out of a sparse matrix. 3.2 printMatrix Syntax: printMatrix(fn, A) ; Inputs: fn Filename to dump matrix in. A Matrix to print. 74 Description: This function prints a matrix to a file for debug purposes. The matrix is stored in ASCII format with the rows and columns labeled appropriately. 3.3 sparse Syntax: [x] = sparse(y) ; Inputs: y Full matrix to convert. Outputs: x Resulting sparse matrix. Description: This function generates a sparse matrix from a standard full matrix. If elements are not identically zero, and entry is created in the sparse matrix. 3.4 sparse areig Syntax: [d v] = sparse areig(N, A, B, {, type, tol, maxit, sigma}); Inputs: N Number of eigenvalues/eigenvectors to find. A Sparse matrix. B Sparse matrix (Symmetric and PSD) for general eigenvalues. Pass in [ ] for standard eigenvalues. type Type of problem to solve. This is the criterion used when searching for N eigenvalues. ’LA’ Largest algebraic value ’SA’ Smallest algebraic value ’LM’ Largest magnitude ’SM’ Smallest magnitude ’LR’ Largest real part ’SR’ Smallest real part ’LI’ Largest imaginary part ’SI’ Smallest imaginary part ’BE’ Both ends (largest/smallest magnitude) tol Tolerance. Specifies the accuracy of the eigenvalues. maxit Maximum number of iterations to perform before stopping. 75 Outputs: sigma Shift factor. This parameter allows the search to zoom in on a particular region of the eigenvalue spectrum. The eigenvalue problem is transformed using (A−σI)−1 v = νv for standard eigenvalues and (A − σB)−1 v = νv for general eigenvalues. Now, for example, searching for eigenvalues of largest magnitude will yield eigenvalues closest to σ. d Vector of eigenvalues. v Matrix of eigenvectors (one per column). Description: This function solves for either standard or general eigenvalues using the ARPACK/ARPACK++ library routines. Standard eigenvalues satisfy the equation Av = λv, where λ is the eigenvalue and v is the corresponding eigenvector. A is a general matrix. General eigenvalues satisfy the equation Av = λBv, where A is general and B must be symmetric and positive semidefinite. 3.5 sparse diag Syntax: [x] = sparse diag(y) ; Inputs: y Sparse matrix. Outputs: x Full vector containing the diagonal. Description: This function extracts the diagonal of a sparse matrix, returning a full vector. 3.6 sparse lu Syntax: [{L U} x {pr pc id}] = sparse lu(A, {, b, perm, thres, equ, id in}); Inputs: A Sparse matrix to factor. b RHS of equation. Pass [ ] if only the LU decomposition is required. perm Type of permutation to use. 0 Natural ording Pc = I 1 MMD applied to A0 A (works well for FD) 2 MMD applied to A + A0 76 Outputs: thres Threshold for pivoting. 0 <= thres <= 1. 0 Use user provided pivot or diagonal pivot 1 Classical partial pivoting equ Flag: If nonzero, equilibrate matrix to attempt to reduce condition number. id in ID of a previous LU decomposition. Should save time by saving key variables. If several problems with the same A matrix are to be solved, the LU decomposition can be found once. Then, the problem can be solved quickly by passing in different b vectors and the ID of the first run. L, U Lower and upper triangular matrices stored in sparse format. x Solution to equation if vector b was provided. pr, pc Row and column permutation matrices. id ID that can be used to refactor a matrix. Description: This function uses the SuperLU package to either solve the equation Ax = b or perform a sparse LU decomposition of the matrix A. Note: If only the solution is needed, considerable time (and memory) may be saved by just having the function return the solution x rather than returning L, U , and x. 3.7 sparse mult Syntax: [x] = sparse mult(m1, m2) ; Inputs: m1, m2 The sparse matrices to multiply. Outputs: x The resulting sparse matrix. Description: Performs the multiplication of two sparse matrices, returing a sparse matrix. Note that function currently uses a very slow algorithm. 3.8 sparse mult vec Syntax: [x] = sparse mult vec(m1, v) ; Inputs: m1 Sparse matrix. v Full vector. x Resulting full vector which is v = m1 x. Outputs: 77 Description: Multiplies a sparse matrix by a full vector. Performance is reasonably fast. 3.9 sparse tran Syntax: [x] = sparse tran(y) ; Inputs: y Sparse matrix to transpose. Outputs: x Transposed matrix. Description: Performs a transpose of a sparse matrix.