maxwell_run

Run MaxwellFDFD.

Contents

Syntax

[E_cell, H_cell] = maxwell_run(OSC, DOM, OBJ, SRC, [inspect_only])
[E_cell, H_cell, obj_array, src_array] = maxwell_run(...)
[E_cell, H_cell, obj_array, src_array, extra] = maxwell_run(...)

Description

maxwell_run(OSC, DOM, OBJ, SRC) constructs a simulation domain from given objects and sources, and launches a finite-difference frequency-domain (FDFD) solver to solve Maxwell's equations in the simulation domain.

Each of OSC, DOM, OBJ, and SRC represents a group of parameters. Each group supports several flexible expressions. See the following sections about the input parameter groups for more details.

maxwell_run can take an optional argument inspect_only, which is a logical argument (i.e., true or false). If inspect_only = true, maxwell_run runs without launching the solver. This is useful to inspect input arguments before starting expensive computation.

[E_cell, H_cell] = maxwell_run(...) returns the E- and H-field solutions of Maxwell's equations. E_cell and H_cell are length-3 row cell arrays whose elements are the x-, y-, and z-components of the respective field solutions. Each x-, y-, z-component of the fields are provided as instances of Scalar3d.

[E_cell, H_cell, obj_array, src_array] = maxwell_run(...) returns arrays of instances of Object and Source. The Object and Source elements represent the objects and sources placed in the simulation domain, so they can be used to visualize the simulation domain.

[E_cell, H_cell, obj_array, src_array, extra] = maxwell_run(...) returns extra, which is a structure containing the fields grid3d, J, M, eps, and mu: grid3d is an instance of Grid3d that contains the grid information; J and M are the electric and magnetic current source distributions that have the same structure as E_cell and H_cell; eps and mu are instances of Scalar3d that contain the electric permittivity and magnetic permeability defined at the centers of the grid cells.

Input Parameter Group - OSC

OSC group specifies oscillation parameters. The group begins with 'OSC' and ends with one of the followings:

L0: unit of length in meters. For example, L0 = 1e-9 means 1 nm. All lengths in other parameters are described in this unit.

wvlen: vacuum wavelength in the unit of L0. In other words, the actual wavelength is wvlen * L0.

osc: instance of Oscillation, which contains the information about the length unit and vacuum wavelength.

Input Parameter Group - DOM

DOM group specifies domain parameters. The group begins with 'DOM' and ends with one of the followings:

material: background material filling the simulation domain. See Material Description for various ways to describe a material.

box: range of the simulation doamin in the form of [xmin xmax; ymin ymax; zmin zmax].

dl: default grid cell size in the form of [dx dy dz]. Can be abbreviated to a scalar dl if dx == dy == dz.

bc: boundary conditions in the form of [bc_xn bc_yn bc_zn], whose each element specifies the boundary condition at the negative end in one of the x-, y-, z-axes (e.g., bc_xn for the negative end in the x-axis.). Each element of bc is an instance of BC. The boundary conditions at the positive ends are automatically determined by those at the negative ends: bc_wp == BC.p if bc_wn == BC.p, and bc_wp == BC.m otherwise. Can be further abbreviated to a single BC instance if bc_xn == bc_yn == bc_zn.

Lpml: thicknesses of PML in the form of [Lpml_xn Lpml_xp; Lpml_yn Lpml_yp; Lpml_zn Lpml_zp], whose each element specifies the thickness at either negative or positive end in one of the x-, y-, z-axes (e.g., Lpml_xn for the negative end in the x-axis). Can be abbreviated to [Lpml_x Lpml_y Lpml_z] if Lpml_wn == Lpml_wp for w = x, y, z. Can be further abbreviated to a single scalar thickness if Lpml_x == Lpml_y == Lpml_z. All thicknesses are in the unit of L0.

domain: instance of Domain, which contains the information about material and box.

deg_pml: optional argument to specify the degrees of the polynomial gradings of PML loss parameters in the form of [deg_xn deg_xp; deg_yn deg_yp; deg_zn deg_zp]. Can be abbreviated to [deg_x deg_y deg_z] if deg_wn == deg_wp for w = x, y, z. Can be further abbreviated to a single scalar if deg_x == deg_y == deg_z. The default value is deg_pml = 4, meaning that the polynomials of degree 4 are used to smoothly increase the PML loss parameters for all boundaries with PML.

R_pml: optional argument to specify the target reflectances in the form of [R_xn R_xp; R_yn R_yp; R_zn R_zp]. To specify R_pml, deg_pml should be specified. Can be abbreviated to [R_x R_y R_z] if R_wn == R_wp for w = x, y, z. Can be further abbreviated to a single scalar if R_x == R_y == R_z. The default value is R_pml = exp(-16), meaning that the reflectance from PML is aimed to be as small as exp(-16) ~= 1e-7.

withuniformgrid: optional argument to select a grid generation algorithm. If withuniformgrid = true, a grid is generated uniformly; otherwise a grid is generated dynamically to best fit the objects in the simulation domain. The default value is withuniformgrid = false, i.e., dynamic grid generation is preferred to uniform grid generation.

Input Parameter Group - OBJ and SOBJ

OBJ group specifies obect parameters. The group begins with 'OBJ' and ends with one of the followings:

material_i: material filling shapes_i. See Material Description for various ways to describe a material.

shapes_i: shapes made of material_i. It can be a single shape, an array of shapes (i.e., [shape_a, shape_b, ...]), or can be spanned into several shape arguments (i.e., shape_1, shape_2, ...). Each shape is an instance of Shape.

obj_i: instance or array of instances of Object. Each Object is composed of a material and shape.

eps_node_array is a 3D array of permittivities defined at the centers of grid cells. The size of the array should be the same as the number of grid cells in a generated grid. Because the number of grid cells generated by dynamic grid generation is hard to predict, uniform grid generation is recommended (see DOM group) when eps_node_array is used.

There is a similar, optional parameter group SOBJ that begins with 'SOBJ'. SOBJ stands for scattering objects, and it is used to define scatterers for total-field/scattered-field (TF/SF) simulation. When a TF/SF source is used as a source, the objects defined in SOBJ group are treated as scatterers whereas the objects defined in OBJ group are treated as background objects. If a TF/SF source is not used, SOBJ group works the same as OBJ group.

Input Parameter Group - SRC

SRC group specifies current source parameters. Depending on whether the sources are electric or magnetic, the group begins with 'SRCJ' or 'SRCM' and ends with

src_i: instance or array of instances of Source.

Material Description

Each material is described by one of the followings:

name: string describing the name of the material (e.g., 'vacuum', 'silver', 'Ag').

color: color to be used in visualizing objects made of the material. It can be either a standard color specifier character used in MATLAB (e.g., 'w' for white, 'k' for black, etc.) or [r, g, b] where r, g, b are RGB color scales ranging from 0.0 to 1.0 (e.g., [0.5, 0.5, 0.5] for gray). Use color = 'none' to not draw the material.

permittivity: electric permittivity value in the unit of the vacuum permittivity. It is a complex number.

material_datapath: path to the file of the permittivity data of the material. It is a path relative to material directory. For example, 'Palik/Si' refers to silicon's permittivity data stored in Si.m file in material/Palik directory. The permittivity for the frequency of interest is automatically retrieved from the data file.

Example

gray = [0.5 0.5 0.5];  % [r g b]
inspect_only = true;
[E, H, obj_array, extra] = maxwell_run(...
    'OSC', 1e-9, 1550, ...
    'DOM', {['Palik/SiO2'], 'none'}, [-700, 700; -600, 600; -200, 1700], 20, BC.p, 200, ...
    'OBJ', ...
        {['Palik/SiO2'], 'none'}, Box([-50, 50; -50, 50; -200, 1700], [2, 2, 20]), ...  % OBJ1
        {['CRC/Ag'], gray}, [Box([-700, -25; -25, 25; -200, 1700], 20), Box([25, 700; -25, 25; -200, 1700], 20)], ...  % OBJ2
    'SRCJ', PointSrc(Axis.x, [0, 0, 200]), ...
    inspect_only);