对象设置

This section introduces the functions that can be used to add and manipulate objects such as structures, sources, monitors, groups, materials, and variables.

Structure

addpoly

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a polygon structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addpoly function will constitute a polygon in ZX plane using a set of z, x coordinates called vertices and extrude it along the y direction.

Syntax

Code Function
addpoly; Adds a polygon structure according to the current view plane in the composite window.
addpoly(x_pos, y_pos, z_pos); Adds a polygon structure with designated center position x_pos, y_pos, z_pos(unit: m) according to the current view plane in the composite viewer window.

Example
Switch to the ZX view, then run the following script to create a 3D polygon with the specified vertices decided by matrix "vers".

vers = [0,2;2,4;4,3;2.5,1]*1e-6; # unit: m
addpoly;
set("name", "new_polygon");
set("vertices", vers);
set("y span", 3e-6);

See also
set, add2dpolygon

addrect

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a rectangle structure to the simulation environment.

Syntax

Code Function
addrect; Adds a rectangle structure to the simulation environment.
addrect(x_pos, y_pos, z_pos); Adds a rectangle structure to the simulation environment with designated center position x_pos, y_pos, and z_pos(unit: m).

Example
The following script creates a rectangle structure with designated dimension and material at specified position.

addrect;                          # add a rectangle to the simulation environment
set("name", "new_rectangle");      # set the name of rectangle

# set the dimension and center position of rectangle
set("x", 0);        # unit: m
set("x span", 6e-6);
set("y", 1e-6);
set("y span", 2e-6);
set("z", 0);
set("z span", 3e-6);

# set the material of rectangle
set("material", "Ag (Silver) - CRC");  

See also
set, add2drect

addtriangle

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a triangle structure which can be seen as a 3 vertex, triangle shaped polygon to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addtriangle function will constitute a triangle in ZX plane using a set of three z, x coordinates called vertices and extrude it along the y direction.

Syntax

Code Function
addtriangle; Adds a triangle structure to the simulation environment.
addtriangle(x_pos, y_pos, z_pos); Adds a triangle structure to the simulation environment with designated center position x_pos, y_pos, and z_pos(unit: m).

Example
Switch to the ZX view, then run the following script to create a triangle with the specified vertices decided by matrix "trg".

trg = [1,0;2,2;4,0]*1e-6;  # to store the coordinates of three corners of triangle, unit: m

addtriangle;
set("name", "new_triangle"); 
set("vertices", trg);
set("y span", 6e-6);  # unit: m

See also
set, addpoly

addellipse

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds an ellipse structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addellipse function will constitute an ellipse in ZX plane and extrude it along the y direction.

Syntax

Code Function
addellipse; Adds an ellipse structure to the simulation environment.
addellipse(x_pos, y_pos, z_pos); Adds an ellipse structure to the simulation environment with designated center position x_pos, y_pos, and z_pos(unit: m).

Example

Create an ellipse structure, then set its radius to 1 um and radius 2 to 0.5 um.

addellipse;              # create ellipse structure
set('radius', 1e-6);     # set radius to 1 um
set('radius 2', 0.5e-6); # set radius 2 to 0.5 um

See also
set, addcircle

addcircle

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a circle structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addcircle function will constitute a circle in ZX plane and extrude it along the y direction.

Syntax

Code Function
addcircle; Adds a circle structure to the simulation environment according to the current view plane in the composite viewer window.
addcircle(x_pos, y_pos, z_pos); Adds a circle structure to the simulation environment with designated center position x_pos, y_pos, z_pos(unit: m) according to the current view plane in the composite viewer window.

Example
Create a circle structure, then set its radius to 1 um.

addcircle;
set('radius', 1e-6); # set radius to 1 um

See also
set, addellipse

addsector

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a sector structure which can be seen as part of a circle structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addsector function will constitute a sector in ZX plane and extrude it along the y direction.

Syntax

Code Function
addsector; Adds a sector structure to the simulation environment according to the current view plane in the composite viewer window.
addsector(x_pos, y_pos, z_pos); Adds a sector structure with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment according to the current view plane in the composite viewer window.

Example
Create a sector structure, then set its radius, start angle, and angle span.

addsector;
set('radius', 1e-6);   # unit: m
set('start angle', 0); # unit: degree
set('span angle', 90);

See also
set, addcircle

addcirclering

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a circular ring structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addcirclering function will constitute a circular ring in ZX plane and extrude it along the y direction.

Syntax

Code Function
addcirclering; Adds a circular ring structure to the simulation environment according to the current view plane in the composite viewer window.
addcirclering(x_pos, y_pos, z_pos); Adds a circular ring structure with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment according to the current view plane in the composite viewer window.

Example
Create a circular ring, then set its (outer) radius and width.

addcirclering;
set('radius', 2e-6);  # outer radius (m)
set('width', 1.5e-6); # width (m)

See also
set, addellipsering

addellipsering

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds an elliptic ring structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addellipsering function will constitute an elliptic ring in ZX plane and extrude it along the y direction.

Syntax

Code Function
addellipsering; Adds an elliptic ring structure to the simulation environment according to the current view plane in the composite viewer window.
addellipsering(x_pos, y_pos, z_pos); Adds an elliptic ring structure with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment according to the current view plane in the composite viewer window.

Example
Create an elliptic ring, then set its radius (m), radius 2 (m) and width (m).

addellipsering;
set('radius', 2e-6);    # unit: m
set('radius 2', 1e-6);
set('width', 8e-7);

See also
set, addcirclering

addsphere

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a sphere structure to the simulation environment.

Syntax

Code Function
addsphere; Adds a sphere structure to the simulation environment.
addsphere(x_pos, y_pos, z_pos); Adds a sphere structure with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment according to the current view plane in the composite viewer window.

Example
Example 1 : Create a sphere, then set its radius (m).

addsphere;
set('radius', 2e-6);    # unit: m

Example 2 : Create an ellipsoidal sphere with different radius in x, y, z direction.

addsphere;
set('make ellipse', 1);
set('radius', 1e-6);    # unit: m
set('radius 2', 2e-6);
set('radius 3', 3e-6);

See also
set, addcircle

addpyramid

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a pyramid structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addpyramid function will constitute a pyramid whose bottom is perpendicular to Y axis.

Syntax

Code Function
addpyramid; Adds a pyramid structure to the simulation environment according to the current view plane in the composite viewer window.
addpyramid(x_pos, y_pos, z_pos); Adds a pyramid structure with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment according to the current view plane in the composite viewer window.

Example
Switch to ZX view. Create a pyramid, then set its top dimension, bottom dimension and height(y span).

addpyramid;

# set top and bottom dimension
set('name', 'new_pyramid');
set('top z span', 1e-6);    # unit: m
set('top x span', 1.2e-6);
set('bottom z span', 2e-6);
set('bottom x span', 2.4e-6);

# set height
set('y span', 2.7e-6);

See also
set, addcone

addcone

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a cone structure to the simulation according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addcone function will constitute a cone whose bottom is perpendicular to Y axis.

Syntax

Code Function
addcone; Adds a cone structure to the simulation environment according to the current view plane in the composite viewer window.
addcone(x_pos, y_pos, z_pos); Adds a cone structure with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment according to the current view plane in the composite viewer window.

Example
Switch to ZX view. Create a cone, then set its top dimension, bottom dimension and height.

addcone;

# set top and bottom dimension
set('name', 'new_cone');
set('top make ellipse', 1);
set('top radius', 1e-6);    # unit: m
set('top radius 2', 2e-6);
set('bottom make ellipse', 1);
set('bottom radius', 2e-6);
set('bottom radius 2', 4e-6);

# set height
set('y span', 2.7e-6);

See also
set, addpyramid

addlinearwaveguide

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a linear waveguide to the simulation environment according to the current view plane in the composite viewer window.

Syntax

Code Function
addlinearwaveguide; Adds a linear waveguide to the simulation environment according to the current view plane in the composite viewer window.
addlinearwaveguide(x_pos, y_pos, z_pos); Adds a linear waveguide to the simulation environment with designated center position x_pos, y_pos, z_pos(unit: m) according to the current view plane in the composite viewer window.

See also
addarcwaveguide

addarcwaveguide

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a curved waveguide to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addarcwaveguide function will constitute a partial ring in ZX plane and extrude it along the y direction.

Syntax

Code Function
addarcwaveguide; Adds a curved waveguide to the simulation environment according to the current view plane in the composite viewer window.
addarcwaveguide(x_pos, y_pos, z_pos); Adds a curved waveguide to the simulation environment with designated center position x_pos, y_pos, z_pos(unit: m) according to the current view plane in the composite viewer window.

See also
addlinearwaveguide

addlineartaper

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a linear taper structure to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addlineartaper function will constitute a trapezium in ZX plane and extrude it along the y direction.

Syntax

Code Function
addlineartaper; Adds a linear taper structure to the simulation environment according to the current view plane in the composite viewer window.
addlineartaper(x_pos, y_pos, z_pos); Adds a linear taper structure to the simulation environment with designated center position x_pos, y_pos, z_pos(unit: m) according to the current view plane in the composite viewer window.

See also
addlinearwaveguide

addsidewalllinear

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a linear structure with two sidewalls tilted at a specific angle to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addsidewalllinear function will constitute a taper structure whose top and bottom are parallel to the ZX plane.

Syntax

Code Function
addsidewalllinear; Adds a linear structure with two slanted sidewalls to the simulation environment according to the current view plane in the composite viewer window.
addsidewalllinear(x_pos, y_pos, z_pos); Adds a linear structure with two slanted sidewalls to the simulation environment according to the current view plane in the composite viewer window and specifies the center positions x_pos, y_pos, z_pos(unit: m).

See also
addlinearwaveguide, addlineartaper

addsidewallarc

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a partial ring with two curved sidewalls tilted at a specific angle to the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane is ZX plane, addsidewallarc function will constitute a partial ring structure whose top and bottom are parallel to the ZX plane.

Syntax

Code Function
addsidewallarc; Adds a partial ring with two slanted and curved sidewalls to the simulation environment according to the current view plane in the composite viewer window.
addsidewallarc(x_pos, y_pos, z_pos); Adds a partial ring with two slanted and curved sidewalls to the simulation environment according to the current view plane in the composite viewer window and specifies the center position x_pos, y_pos, z_pos(unit: m).

See also
addarcwaveguide

addsidewallbezier

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a curved waveguide with sidewalls curved by specific Bezier to the simulation environment according to the current view plane in the composite viewer window.

Syntax

Code Function
addsidewallbezier; Adds a curved waveguide with sidewalls curved by specific Bezier to the simulation environment according to the current view plane in the composite viewer window.
addsidewallbezier(x_pos, y_pos, z_pos); Adds a curved waveguide with sidewalls curved by specific Bezier to the simulation environment according to the current view plane in the composite viewer window and specifies the center position x_pos, y_pos, z_pos(unit: m).

See also
addsidewallarc

addequation

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a structure determined by specific equation to the simulation environment.

Syntax

Code Function
addequation; Adds a structure determined by specific equation to the simulation environment.
addequation(x_pos, y_pos, z_pos); Adds a structure determined by specific equation with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addrect

add2drect

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a 2D rectangle into the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane in composite window is ZX plane, add2drect function will add a 2D rectangle parallel to the ZX plane.

Syntax

Code Function
add2drect; Adds a 2D rectangle into the simulation environment according to the current view plane in the composite viewer window.
add2drect(x_pos, y_pos, z_pos); Adds a 2D rectangle with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addrect

addvertex

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a vertex to the selected polygon structure.

Syntax

Code Function
addvertex(cord_1, cord_2, order_num); Adds a vertex to the selected polygon structure. The first and second input numbers are the first and second coordinates of the new vertex respectively. The new vertex is specified as (order_num + 1) th vertex in all vertices.
addvertex(cord_1, cord_2, order_num, k); Adds a vertex to the k th selected polygon structure. The first and second input numbers are the first and second coordinates of the new vertex respectively. The new vertex is specified as (order_num + 1) th vertex in all vertices. The objects are ordered by their location in the object tree. The uppermost selected object is given the index 1, and the index numbers increase as you go down the tree.

See also
delvertex

delvertex

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Deletes the specified vertex of the selected polygon structure.

Syntax

Code Function
delvertex(ver_order_num); Deletes the (ver_order_num + 1) th vertex of the selected polygon structure.
delvertex(ver_order_num, k); Deletes the (ver_order_num + 1) th vertex of the k th selected polygon structure. The objects are ordered by their location in the object tree. The uppermost selected object is given the index 1, and the index numbers increase as you go down the tree.

Example
Convert a rectangle structure to a triangle structure by deleting its vertex.

switchtoZXview;
Vertex = [1, 1; 1, -1; -1, -1; -1, 1].*1e-6; # vertices, unit: m
VertexNum = length(Vertex); # number of vertices

# add a polygon structure
addpoly(0, 0, 0);
set('name', 'NewTriangle');
set('vertices', Vertex);

select('NewTriangle');
delvertex(VertexNum - 1); # delete the vertex whose order number is 4

See also
addvertex

add2dpolygon

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a 2D polygon into the simulation environment according to the current view plane in the composite viewer window.
For example, if the current view plane in composite window is ZX plane, add2dpolygon function will add a 2D polygon parallel to the ZX plane.

Syntax

Code Function
add2dpolygon; Adds a 2D polygon into the simulation environment according to the current view plane in the composite viewer window.
add2dpolygon(x_pos, y_pos, z_pos); Adds a 2D polygon with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addpoly

addphotoniccrystal

FDTD · FDFD · FDE · EME · FDCharge · RCWA

Description
Adds a photonic crystal structure to the simulation environment.

Syntax

Code Function
addphotoniccrystal; Adds a photonic crystal structure to the simulation environment.
addphotoniccrystal(x_pos, y_pos, z_pos); Adds a photonic crystal structure with designated center position x_pos, y_pos, z_pos(unit: m).

Example
This example shows how to create a photonic crystal structure with designated properties.

# switch view plane to ZX plane
switchtoZXview; 

addphotoniccrystal(0, 0, 0);
set('element type', 'ellipse');
set('a', 4e-6); # set lattice constants, unit: m
set('c', 4e-6); 
set('cells x', 4);
set('cells y', 1);
set('cells z', 4);

See also
addstructuregroup

addplanarsolid

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description

Adds a planar solid structure to the solver.

Syntax

Code Function
addplanarsolid; Adds a default planar solid structure (a rectangle) at the origin (0,0,0).
addplanarsolid(x, y, z); Adds a default planar solid structure at the specified coordinates (x, y, z).
addplanarsolid(vertices, facets); Adds a custom planar solid structure at the origin based on the provided vertex and facet data. vertices is a matrix of vertex coordinates, where each row represents the (x, y, z) coordinates of a vertex. facets defines the faces and can be a matrix or a cell array, containing the vertex indices for each face (connected in right-hand rule order).
addplanarsolid(x, y, z, vertices, facets); Adds a custom planar solid structure at the specified coordinates (x, y, z) using the provided vertex and facet data.

Example

# Define the 8 vertex coordinates for a polyhedron (in microns)
vtx=[0,0,0;1,0,0;1,1,0;0,1,0;0,0,2;1,0,2;1,1,2;0,1,2]*1e-6;

# Define vertex indices for 7 faces (connected in right-hand rule order)
a=cell(7,1);
for(i=1:7)
    a{i}=cell(1);
end
a{1}{1}=[1,4,3,2];
a{2}{1}=[1,5,8,4];
a{3}{1}=[1,2,6,5];
a{4}{1}=[2,3,6];
a{5}{1}=[3,8,6];
a{6}{1}=[3,4,8];
a{7}{1}=[5,6,8];

# Add the custom planar solid at the origin
addplanarsolid(vtx,a);

See also

addpoly

(n,k) Material Import

addimportnk

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK

Description

Adds an (n,k) material import structure to the simulation. This structure supports configuration via scripting commands (e.g., get, set).

Syntax

Code Function
addimportnk; Adds an (n,k) material import structure with default properties to the simulation.
addimportnk(x_pos, y_pos, z_pos); Adds an (n,k) material import structure centered at the specified coordinates (x_pos, y_pos, z_pos) (units: meters).

See also

addpoly

importnk

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK

Description

Imports refractive index data into the currently selected (n,k) material structure from a .txt file, specified by its file path.

Syntax

Code Function
importnk('file_path', 'file_units', x0, y0, z0, reverse_index); Imports refractive index data from the specified file. file_path: Required. Path to the data file. file_units: Optional. Unit of the imported data. Valid strings: m, cm, mm, um, nm, pm, fm. x0/y0/z0: Optional. Sets the position of the data origin within the global coordinate system. reverse_index: Optional. Set to 1 to enable Import as Mkji instead of Mijk , which reverses the data reading order.

See also
importnk2

importnk2

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK

Description

Imports refractive index data into the currently selected (n,k) material structure using direct array input.

Syntax

Code Function
importnk2(n, x, y, z); Imports refractive index data from arrays. n: Required. Refractive index array. For a 3D structure, dimensions are N×M×PN\times M\times P (isotropic) or N×M×P×3N\times M\times P\times 3 (anisotropic). x/y/z: Required. Coordinate vectors for each axis. Their lengths must match the dimensions of n (e.g., length(x) = N). Coordinates must be uniformly spaced.

Example

# Generate a volume of refractive index data
x = 1e-6 * linspace(-10, 10, 41);
y = 1e-6 * linspace(-10, 10, 41);
z = 1e-6 * linspace(-10, 10, 41); 

[X, Y, Z] = ndgrid(x, y, z);

n = zeros(length(x), length(y), length(z), 3); # matrix for all 3 directions, anisotropic

n(:, :, :, 1) = 1.5 + sin(2*pi.*X/6) + 0.1i.*cos(Y); # x component
n(:, :, :, 2) = 1.5 + 0.1i.*sin(2*pi.*X/6) + sin(Y); # y component
n(:, :, :, 3) = 1.5 + cos(2*pi.*Y/6) + 0.2i*sin(Y);  # z component

# Note: The structure must be selected before calling importnk2
addimportnk

importnk2(n,x,y,z);

See also
importnk

Group

addgroup

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a group into the simulation environment.

Syntax

Code Function
addgroup; Adds a group into the simulation environment.
addgroup(x_pos, y_pos, z_pos); Adds a group with designated center position(also the origin of the local coordinate system) x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
group, addstructuregroup

addstructuregroup

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a structure group into the simulation environment.

Syntax

Code Function
addstructuregroup; Adds a structure group into the simulation environment.
addstructuregroup(x_pos, y_pos, z_pos); Adds a structure group with designated center position(also the origin of the local coordinate system) x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
group, addgroup

addassemblygroup

FDTD · FDFD · FDE · EME · FDCharge · RCWA

Description
Adds an assembly group into the simulation environment.

Syntax

Code Function
addassemblygroup; Adds an assembly group into the simulation environment.
addassemblygroup(x_pos, y_pos, z_pos); Adds an assembly group with designated center position (also the origin of the local coordinate system) x_pos, y_pos, z_pos (unit: m) to the simulation environment.

See also
addgroup, addtogroup

addanalysisgroup

FDTD · FDFD
Description
Adds an analysis group into the simulation environment.

Syntax

Code Function
addanalysisgroup; Adds an analysis group into the simulation environment.
addanalysisgroup(x_pos, y_pos, z_pos); Adds an analysis group with designated center position(also the origin of the local coordinate system) x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
group, addgroup

addtogroup

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds the selected object into designated group or structure group.

Syntax

Code Function
addtogroup('group_name'); Adds the selected object into the group or structure group named 'group_name' .

See also
addgroup, addstructure

removefromgroup

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Removes the selected object from group, structure group or analysis group.
For analysis groups, only FDTD and FDFD are supported.

Syntax

Code Function
removefromgroup; Removes the selected object from group, structure group or analysis group.

Example
Remove the rectangle name 'Rectangle_1' from group named 'Group'.

select('Group::Rectangle_1');
removefromgroup;

See also
addtogroup

addsetupvariable

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a new setup variable to the selected structure group or analysis group.
For analysis groups, only FDTD and FDFD are supported.

Syntax

Code Function
addsetupvariable('value_name', 'value_type', value_data); Adds a new setup variable named 'value_name' to the selected structure group or analysis group. The 'value_type' can be 'number', 'text', 'length', 'time', 'frequency', 'material', and 'global variable'.

Example
Add a number setup variable named 'new_stvar' to the selected analysis group.

select('FDTD::Analysis Group');
addsetupvariable('new_stvar','Number',2.776);

See also
addgroup, addstructuregroup, addanalysisgroup

addparametervariable

FDTD · FDFD
Description
Adds a new parameter variable to the selected analysis group.

Syntax

Code Function
addparametervariable('value_name', 'value_type', value_data); Adds a new parameter variable named 'value_name' to the selected analysis group. The 'value_type' can be 'number', 'text', 'length', 'time', 'frequency', 'material', and 'global variable'.

See also
addsetupvariable, addresultvariable

addresultvariable

FDTD · FDFD
Description
Adds a new result variable to the selected analysis group.

Syntax

Code Function
addresultvariable('value_name'); Adds a new result variable named 'value_name' to the selected analysis group.

See also
addsetupvariable

addobject

FDTD · FDFD · FDE · EME · FDCharge · RCWA

Description

Adds any object from the software's built‑in library to the current scene. When called without an argument, returns the complete list of all available objects and analysis groups in the object tree.

Syntax

Code Function
a = addobject; Returns a cell array a containing the names of all objects and analysis groups available in the object library (the object tree).
addobject('script_id'); Adds the object identified by script_id from the library to the current scene. This form does not return any data.

See also

addrect

Element

addelement

INTERCONNECT
Description
Adds an element of the specified type from the element library to the current group scope. This function does not return any data.

Syntax

Code Function
addelement("element_type"); Adds an element of type element_type from the element library to the current group scope.

Example
The following script commands will add a waveguide coupler to the simulation environment and edit its properties.

addelement("Waveguide Coupler");
element_name = "coupler_1";
set("name", element_name);
set("x position", 0);
set("y position", 0);
set("coupling coefficient 1", 0.3);

See also
createcompound

setposition

INTERCONNECT
Description
Sets the horizontal and vertical positions of the specified element.

Syntax

Code Function
setposition("element", x_pos, y_pos); Sets the position of the element named element to x_pos and y_pos(unit: m).

Example
Set the position of an element named "coupler_1" to x = 2 μm and y = 4 μm.

setposition("coupler_1", 2e-6, 4e-6);  # unit: m

See also
set, setexpression

flipelement

INTERCONNECT
Description
Flips the specified element horizontally, equivalent to the Horizontal Flip button in the schematic editor.

Syntax

Code Function
flipelement("element"); Flips the element named element horizontally.

Example
Flip the element named straight waveguide_1.

flipelement("straight waveguide_1");

See also
rotateelement

rotateelement

INTERCONNECT
Description
Rotates the specified element by 90 degrees clockwise, equivalent to the Rotate button in the schematic editor.

Syntax

Code Function
rotateelement("element"); Rotates the element named element by 90 degrees clockwise.

Example
Rotate the element named straight waveguide_1.

rotateelement("straight waveguide_1");

See also
flipelement

connect

INTERCONNECT
Description
Connects one element to another via the specified ports.

Syntax

Code Function
connect("element1", "port1", "element2", "port2"); Connects port1 of element1 to port2 of element2.

Example
Connect the port 1 of straight waveguide_1 to the port 2 of coupler_1.

connect("straight waveguide_1", "port 1", "coupler_1", "port 2");

See also
disconnect

disconnect

INTERCONNECT
Description
Removes the connection between two ports of the specified elements, or removes all the connections of the specified element.

Syntax

Code Function
disconnect("element"); Removes all the connections of the element named element.
disconnect("element1", "port1", "element2", "port2"); Removes the connection between port1 of element1 and port2 of element2.

Example
Disconnect the port 1 of straight waveguide_1 from the port 2 of coupler_1.

disconnect("straight waveguide_1", "port 1", "coupler_1", "port 2");

See also
connect

createcompound

INTERCONNECT
Description
Creates a compound element with the currently selected elements.

Syntax

Code Function
createcompound; Creates a compound element with the currently selected elements.

Example
Select all elements and create a compound element with them.

selectall;
createcompound;

See also
addtogroup

autoarrange

INTERCONNECT
Description
Arranges the port positions and dimensions of the specified compound element automatically, equivalent to the Arrange button on the Ports page of the element editor.

Syntax

Code Function
autoarrange("element"); Arranges the port positions and dimensions of the compound element named element. This command does not return anything.

Example
Arrange the ports of the compound element named COMPOUND_1.

autoarrange("COMPOUND_1");

See also
createcompound

setexpression

INTERCONNECT
Description
Sets the specified property of the specified element to an expression.

Syntax

Code Function
setexpression("element", "property_name", "expression"); Sets the property property_name of the element named element to the expression expression.

Example
Set the insertion loss of the element named coupler_1 to the expression sqrt(2)/2.

setexpression("coupler_1", "insertion loss", "sqrt(2)/2");

See also
set, setposition

addport (Interconnect)

INTERCONNECT
Description
Adds a port to the specified compound element. This command does not apply to primitive elements.

Syntax

Code Function
addport("element", "port", "type", "data", "position", location); Adds a port with the specified properties to the specified compound element. Returns the name of the created port.

The meanings of the parameters in the above tabulation are illustrated as following:

name type default description
element string - Name of the compound element to add a port to.
port string - Name of the port to add. It will be modified if a port with the same name already exists.
type string - Type of the port. Options are Bidirectional, Input, Output, and Analyzer Input.
data string - Data type of the port. Options are Variant, Optical Signal, Electrical Signal, and Digital Signal.
position string Left (optional) Position of the port on the element. Options are Top, Bottom, Left, and Right.
location number 0 (optional) Location of the port as a ratio, in the range [0, 1]. Values outside the range are truncated.

Example

# Add an input port for optical signals to the compound element named COMPOUND_1.
addport("COMPOUND_1", "port 1", "input", "optical signal");

# Add an output port for electrical signals to the compound element named COMPOUND_1, with the specified position and location.
addport("COMPOUND_1", "port 2", "output", "electrical signal", "right", 0.5);

See also
autoarrange, getports

Source

adddipole

FDTD · FDFD
Description
Adds a dipole source to the simulation environment.

Syntax

Code Function
adddipole; Adds a dipole source to the simulation environment.
adddipole(x_pos, y_pos, z_pos); Adds a dipole source with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addplane, addtfsf, addmodesource, addgaussiansource

addplane

FDTD · FDFD
Description
Adds a plane source to the simulation environment.

Syntax

Code Function
addplane; Adds a plane source to the simulation environment.
addplane(x_pos, y_pos, z_pos); Adds a plane source with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
adddipole, addtfsf, addmodesource, addgaussiansource

addtfsf

FDTD · FDFD
Description
Adds a tfsf source to the simulation environment.

Syntax

Code Function
addtfsf; Adds a tfsf source to the simulation environment.
addtfsf(x_pos, y_pos, z_pos); Adds a tfsf source with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
adddipole, addplane, addmodesource, addgaussiansource

addmodesource

FDTD · FDFD
Description
Adds a mode source to the simulation environment.

Syntax

Code Function
addmodesource; Adds a mode source to the simulation environment.
addmodesource(x_pos, y_pos, z_pos); Adds a mode source with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
adddipole, addplane, addtfsf, addgaussiansource

addgaussiansource

FDTD · FDFD
Description
Adds a Gaussian source to the simulation environment.

Syntax

Code Function
addgaussiansource; Adds a Gaussian source to the simulation environment.
addgaussiansource(x_pos, y_pos, z_pos); Adds a Gaussian source with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
adddipole, addplane, addtfsf, addmodesource

addportgroup

FDTD
Description
Adds a port group to the simulation environment.

Syntax

Code Function
addportgroup; Adds a port group to the simulation environment.

See also
addport

addport (FDTD)

FDTD
Description
Adds a port to the port group in the simulation environment. If no port group exists, a port group is created at the same time.

Syntax

Code Function
addport; Adds a port to the port group in the simulation environment. If no port group exists, a port group is created at the same time.
addport(x_pos, y_pos, z_pos); Adds a port with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addportgroup, addmodeport, addemeport

addmodeport

FDTD
Description
Adds a mode port to the activated port group.

Syntax

Code Function
addmodeport; Adds a mode port to the activated mode group.
addmodeport(x_pos, y_pos, z_pos); Adds a mode port with center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addportgroup

addemeport

EME

Description

Adds a EMEport to the activated EME port group.

Syntax

Code Function
addemeport; Adds a EMEport to the activated EME port group.

See also

addmodeport

addimportsource

FDTD · FDFD
Description
Adds an import source to the simulation environment.

Syntax

Code Function
addimportsource; Adds an import source to the simulation environment.
addimportsource(x_pos, y_pos, z_pos); Adds an import source with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addportgroup

setsourcesignal

FDTD · FDFD

Description

Assigns a user‑defined time‑domain signal to an existing source. This command does not create a new source; it modifies the waveform of a source that has already been added to the simulation.

Syntax

Code Function
setsourcesignal('name', t, amplitude, phase); Sets the time domain signal of source named "name". t, amplitude, and phase are 1D vectors with the same length. The center frequency and bandwidth are automatically estimated from the time signal.
setsourcesignal('name', t, amplitude, phase, fcentre, bandwidth); Allows you to specify the precise center frequency fcentre and bandwidth (in Hz) that will be used for all simulations. These values are used for materials fits, calculating the mesh, and source limits.

Example

Create a modulated Gaussian pulse and apply it to an existing source:

# Add FDTD solver and plane wave source
addfdtd(0,0,0);
addplane(0,0,0);
set('name','plane');     

# Define time parameters and pulse shaping
dt = 1e-15;
t = 0:dt:200e-15;                   # Time vector from 0, ensures zero initial field
f0 = 300e12;                         # Center frequency
sigma = 8e-15;                       # Pulse width (half-width)
delay1 = 30e-15;                     # Delay of first pulse
delay2 = 70e-15;                     # Delay of second pulse

# Generate double-Gaussian envelope and normalize
amplitude = exp(-((t-delay1)/sigma).^2) + exp(-((t-delay2)/sigma).^2);
amplitude = amplitude / max(amplitude);

# Carrier phase (linear modulation)
phase = 2*pi*f0*t;

# Apply custom time signal to the source
setsourcesignal('FDTD::plane', t, amplitude, phase);

See also

addimportsource

addimportgeneration

FDCharge
Description

This command adds an import generation object to the FD Charge Transport (FDCharge) Solver to introduce the optically generated carrier generation rate as a source term.

Syntax

Code Function
addimportgeneration; Adds an import generation object with default properties. A FDCharge solver must exist in the simulation before using this command.
addimportgeneration(x_pos, y_pos, z_pos); Adds an import generation object with designated center position x_pos, y_pos, z_pos(unit: m). A FDCharge solver must exist in the simulation before using this command.

Example

addfdcharge
# Add an import generation object
addimportgeneration;

See also

addfdcharge

Monitor

addpowermonitor

FDTD · FDFD
Description
Adds a frequency-domain field and power monitor to the simulation environment.

Syntax

Code Function
addpowermonitor; Adds a frequency-domain field and power monitor to the simulation environment.
addpowermonitor(x_pos, y_pos, z_pos); Adds a frequency-domain field and power monitor with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addfieldmonitor, addtimemonitor, addindexmonitor

addfieldmonitor

FDTD · FDFD
Description
Adds a frequency-domain field and power monitor to the simulation environment.

Syntax

Code Function
addfieldmonitor; Adds a frequency-domain field and power monitor to the simulation environment.
addfieldmonitor(x_pos, y_pos, z_pos); Adds a frequency-domain field and power monitor with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addpowermonitor, addtimemonitor, addindexmonitor

addemeprofile

EME
Description

Adds a EME profile monitor to the simulation environment.

Syntax

Code Function
addemeprofile; Adds a EME profile monitor to the simulation environment.
addemeprofile(x_pos, y_pos, z_pos); Adds a EME profile monitor with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also

addfieldmonitor

addtimemonitor

FDTD
Description
Adds a time monitor to the simulation environment.

Syntax

Code Function
addtimemonitor; Adds a time monitor to the simulation environment.
addtimemonitor(x_pos, y_pos, z_pos); Adds a time monitor with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addpowermonitor, addfieldmonitor, addindexmonitor

addindexmonitor

FDTD · FDFD
Description
Adds an index monitor to the simulation environment.

Syntax

Code Function
addindexmonitor; Adds an index monitor to the simulation environment.
addindexmonitor(x_pos, y_pos, z_pos); Adds an index monitor with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also
addpowermonitor, addfieldmonitor, addtimemonitor

addemeindex

EME
Description

Adds an index monitor to the simulation environment.

Syntax

Code Function
addemeindex; Adds an index monitor to the simulation environment.
addemeindex(x_pos, y_pos, z_pos); Adds an index monitor with designated center position x_pos, y_pos, z_pos(unit: m) to the simulation environment.

See also

addindexmonitor

updateindexmonitor

FDTD · FDFD
Description
Updates the data of an index monitor.

Syntax

Code Function
updateindexmonitor('monitor_name') Updates the data of an index monitor. updateindexmonitor provides the data that is exactly the same as the data returned by the simulation run. updateindexmonitor only allows one parameter.

Example
Update the data of two index monitors.

updateindexmonitor('FDTD::Index');  #monitor_name: Index
updateindexmonitor('FDTD::Analysis Group::Index_1');  # Monitor in Analysis Group

addmonitor2dataset

FDTD · FDFD
Description
Adds the field data E, H in the designated monitor to a dataset as the function of position and wavelength.

Syntax

Code Function
addmonitor2dataset('monitor_name') Returns a dataset containing all field data in the designated monitor.

Example
Add the field data E, H in the FDFP monitor named 'FDFP_Monitor' to a dataset.

EM = addmonitor2dataset('FDTD::FDFP_Monitor')

Result:

EM =
E ,H vs x, y, z, lambda/f

Material

addmaterial

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Adds a new material to the project material library.

Syntax

Code Function
addmaterial Lists all the available material models.
addmaterial('model_name', 'material_name'); Adds a new material into project material library by the designated name and material model. If added successfully, the function returns 1, otherwise returns 0.

Example
List all material models available. Then, add a dielectric material named 'new_dielc' into the project material library.

# list all material models available
addmaterial 

# add dielectric material 'new_dielc' 
addmaterial('dielectric', 'new_dielc'); 

Result(all material models available):

val =
dielectric                 
nk                         
conductive                 
sampled data               
drude                      
lorentz                    
debye                      
graphene                   
chi2 nonlinear             
chi3 raman/kerr nonlinear  
pec                        
conductive 2d              
sampled 2d data

See also
setmaterial, getmaterial

setmaterial

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Sets property of the designated material to desired value.

Syntax

Code Function
setmaterial Lists all the materials in the current material library.
setmaterial('material_name') Lists all the property names of specific material that can be modified.
setmaterial('material_name', 'p_name', p_value); Sets the property 'p_name' of the material 'material_name' to value p_value. The argument p_value can be a matrix or a string, which must match with the property.

Examples

  • List all properties of specific material

    # add new material
    output=addmaterial('graphene', 'new_graphene'); 
    
    # list all adjustable properties of material 'new_graphene'
    setmaterial('new_graphene') 
    

    Result:

    val =
    name                     
    color 
    type                   
    tolerance type           
    tolerance                
    max coefficients         
    improve fdtd stability   
    imaginary weight         
    pso user defined         
    pso ratio                
    pso max generations      
    pso generation size      
    scattering rate (eV)     
    chemical potential (eV)  
    temperature (K)          
    conductivity scaling  
    
  • Use number or string to set property

    Add a graphene material named 'new_graphene' into project material library. Then set the property 'scattering rate (eV) ' to 0.00012 and rename the material.

    output=addmaterial('graphene', 'new_graphene');               # add material
    
    setmaterial('new_graphene', 'scattering rate (eV)', 0.00012);  # set scattering rate (eV)
    setmaterial('new_graphene', 'name', 'graphene_material');      # rename the material 
    
  • Use matrix to set property of sampled material

    This example shows how to use matrix to set material property of sampled material.
    To set property 'sampled data' of sampled material, we should create a sampled data matrix to store the permittivity data as function of lambda(m). The sampled data matrix must have 2 or 4 columns:

    • For isotropic sampled material, the shape of 'sampled data' matrix is n * 2: the first column is lambda(m), the second column is complex permittivity epsr.
    • For anisotropic sampled material, the shape of 'sampled data' matrix is n * 4: the first column is lambda(m), the next three columns are epsr_xx, epsr_yy, epsr_zz.
    lam= linspace(1.5e-6, 0.5e-6, 50);                   # lambda(m) data            
    eps= 3.14+((1i*1e6)/(2*pi*c*eps0)).*lam;           # permittivity data
    sampled_data= [lam; eps].';                         # sampled data matrix 
    
    output= addmaterial('sampled data', 'sa_cond');     # add sampled  material 
    setmaterial('sa_cond', 'max coefficients', 5);       # set the number of coefficients   
    setmaterial('sa_cond', 'sampled data', sampled_data);# set property  'sampled data' by matrix 
    setmaterial('sa_cond', 'color', [0.1,0.8,0.6]);      # set property 'color' by matrix
    
    

See also
addmaterial, getmaterial

getmaterial

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Returns desired property of designated material.

Syntax

Code Function
getmaterial Lists all the materials in the current material library.
getmaterial('material_name') Lists all property names of the specific material that can be gained.
mtprop=getmaterial('mt_name', 'p_name'); Returns the property 'p_name' of the material 'mt_name'. The returned variable is either a matrix or a string, depending on the property in the query.

Examples

  • List all properties available of a material

    # add new graphene material 
    output=addmaterial('graphene', 'new_graphene');
    
    # list all property names that can be gained
    getmaterial('new_graphene')  
    

    Result:

    val =
    name                     
    color 
    type                   
    tolerance type           
    tolerance                
    max coefficients         
    improve fdtd stability   
    imaginary weight         
    pso user defined         
    pso ratio                
    pso max generations      
    pso generation size      
    scattering rate (eV)     
    chemical potential (eV)  
    temperature (K)          
    conductivity scaling
    
  • This example shows how to get property in the form of string.
    Add a graphene material named 'new_graphene' and get the value of property 'type '.

    # add new material
    output=addmaterial('graphene', 'new_graphene');
    
    # get the value of property 'type'
    gra_tp=getmaterial('new_graphene', 'type');
    

    Result:

    gra_tp =
            'Graphene'  
    
  • Sampled material: This example shows how to get sampled data (matrix) of a sampled material.

    The returned sampled data (matrix) has 2 or 4 columns:

    • For isotropic sampled materials, the shape of sampled data matrix is n * 2: the first column is lambda(m), the second column is complex permittivity epsr.
    • For anisotropic sampled materials, the shape of sampled data matrix is n * 4: the first column is lambda(m), the next three columns are epsr_xx, epsr_yy, epsr_zz.
    Ag_sd=getmaterial('Ag (Silver) - CRC', 'sampled data');   # get sampled data 
    
    

See also
addmaterial, setmaterial

getmaterialmodel

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Gets index or permittivity data of designated material at specified wavelength (unit: m) .

Syntax

Code Function
getmaterialmodel('material_name', lambda, d_type); Gets index or permittivity data of designated material named 'material_name' at specified wavelength (unit: m) lambda . If d_type is 0, returns the real part and imaginary part of permittivity. If d_type is 1, returns the real part and imaginary part of index.

Note:

If the input parameter lambda is a number or row vector, returns a 2 * N matrix whose first and second row are the real and imaginary part of permittivity(d_type = 0) or index(d_type = 1), respectively. N is the length of lambda.

If the input parameter lambda is a column vector, returns a N * 2 matrix whose first and second column are the real and imaginary part of permittivity(d_type = 0) or index(d_type = 1), respectively. N is the length of lambda.

Example

getmaterialmodel('Ag (Silver) - CRC', 1.24e-6, 1)  # lambda: 1.24 um

Result :

val =
   0.280000206
    9.03000412

See also
getmaterial

Optimizations and Sweeps

addsweep

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a parameter sweep, optimization, or S-matrix sweep as a top-level item in Optimizations and Sweeps.
For S-Matrix sweeps, only FDTD and EME are supported.

Syntax

Code Function
addsweep(type); Adds a parameter sweep, optimization, or S-matrix sweep as a top-level item in Optimizations and Sweeps. If type is not provided, by default type 0 will be applied to add a parameter sweep.

The meanings of the parameters in the above tabulation are illustrated as following:

Name Type Default Description
type number 0 type = 0 for a parameter sweep, type = 1 for an optimization, type = 2 or 3 for an S-matrix sweep.

Example

addsweep;  # add a parameter sweep

addsweep(1);  # add an optimization

addsweep(2);  # add an S-matrix sweep

See also
insertsweep, deletesweep, setsweep, runsweep

insertsweep

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Inserts a sweep item as a parent to an existing analysis item. The existing item becomes a child of the newly inserted sweep.
The outer item can be a parameter sweep or an S-matrix sweep, the optimization cannot be used as an outer sweep.

Syntax

Code Function
insertsweep('name', type); Inserts an outer parameter sweep around 'name'. If type is not provided, by default type 0 will be applied to inserts an outer parameter sweep.

The meanings of the parameters in the above tabulation are illustrated as following:

Name Type Default Description
name struct - name is the absolute name of the existing analysis item.
type number 0 type = 0 for an outer parameter sweep, type = 2 for an outer S-matrix sweep, other values are invalid.

Example

addsweep(0);
setsweep('sweep', 'name', 'inner');
insertsweep('inner');               # outer parameter sweep
setsweep('sweep_1', 'name', 'outer');

See also
addsweep, deletesweep, setsweep

deletesweep

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Deletes the parameter sweep, optimization, or S-matrix sweep named 'name', including its nested children.

Syntax

Code Function
deletesweep('name'); Deletes the sweep, optimization, or S-matrix sweep with the specified name.

Example

deletesweep('width_sweep');

See also
addsweep, insertsweep

setsweep

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Sets a property in a parameter sweep, optimization or S-matrix sweep item.

Syntax

Code Function
setsweep('name') Lists the editable properties of 'name'.
setsweep('name', 'property_name', value); Sets a property in a parameter sweep, optimization or S-matrix sweep item, 'name' is the absolute name of an analysis item, "property_name" is the property showed in the edit window.

In an S-matrix sweep, if the definition method is Auto define, writing a read-only property such as 'S-Matrix ID' or 'Mode label' raises an error.

Example

addsweep(1);
setsweep('optimization', 'algorithm', 'Particle Swarm');
setsweep('optimization', 'type', 'Maximize');
setsweep('optimization', 'maximum generations', 10);
setsweep('optimization', 'generation size', 5);
setsweep('optimization', 'tolerance', 0);
setsweep('optimization', 'reset random generator', false);

See also
getsweep, addsweep, addsweepparameter, addsweepresult

getsweep

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Gets a property from a parameter sweep, optimization, or S-matrix sweep.

Syntax

Code Function
getsweep('name') Lists the readable properties of 'name'.
out = getsweep('name', 'property_name'); Returns one top-level property.
out = getsweep('name', 'parameter_or_result_name'); Returns a struct of that row, including Name, Parameters, and Type.
out = getsweep('name', 'parameter_or_result_name', 'field'); Returns one field of that row.

Example

getsweep('width_sweep');
n = getsweep('width_sweep', 'number of points');
s = getsweep('width_sweep', 'width');            # struct of the parameter named 'width'
a = getsweep('width_sweep', 'width', 'Start');

See also
setsweep, getsweepoptdata

addsweepparameter

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a parameter to a parameter sweep, optimization or S-matrix sweep item.

Syntax

Code Function
addsweepparameter('name', 'path_or_port'); String form: an object property path, or an S-matrix port name whose Mode ID is 1.
addsweepparameter('name', para); Struct form: the fields are listed in the parameter struct section.

Example 1

# add a parameter sweep
addsweep(0);
setsweep('sweep', 'name', 'width_sweep');
setsweep('width_sweep', 'type', 'Range');
setsweep('width_sweep', 'number of points', 5);

# define the parameter
para = struct;
para.Name = 'width';
para.Parameters = 'Objects::wg::x span';
para.Type = 'Length';
para.Start = 0.4;
para.Stop = 0.6;
para.Units = 'microns';

# add the parameter to the sweep
addsweepparameter('width_sweep', para);

Example 2

addsweep(1);  # add an optimization

# define the parameter
para = struct;
para.Parameters = 'Objects::wg::x span';
para.Type = 'Length';
para.Min = 0.05;
para.Max = 0.25;
para.Units = 'microns';

addsweepparameter('optimization', para);  # add the parameter to the sweep

Example 3

addsweep(2);  # add an S-matrix sweep
pm = struct;
pm.['Port Name'] = 'port 1';
pm.['Mode ID'] = 1;
addsweepparameter('s-matrix sweep', pm);

pm2 = struct;
pm2.['Port Name'] = 'port 2';
pm2.['Mode ID'] = 1;
addsweepparameter('s-matrix sweep', pm2);

See also
removesweepparameter, setsweep, loadfullportmodes

removesweepparameter

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Removes a parameter from a parameter sweep, optimization or S-matrix sweep item.

Syntax

Code Function
removesweepparameter('name', 'parameter_name'); Removes the row by parameter Name.
removesweepparameter('name', index); Removes the index-th row (1-based), which is the S-Matrix ID for an S-matrix sweep.

Example

removesweepparameter('width_sweep', 'width');
removesweepparameter('optimization', 1);
removesweepparameter('s-matrix sweep', 2);

See also
addsweepparameter, removesweepresult, removeallportmodes

addsweepresult

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Adds a result to a parameter sweep, or a figure-of-merit row to an optimization. It is invalid on an S-matrix sweep.

Syntax

Code Function
addsweepresult('name', 'result_path'); String form: with the default operations.
addsweepresult('name', result); Struct form: the fields are listed in the result struct section.

Example 1

# parameter sweep
res = struct;
res.Name = 'T';
res.Result = 'Objects::Monitor::T';
res.['Vector operation'] = 'None';
addsweepresult('width_sweep', res);

Example 2

# optimization
fom = struct;
fom.Optimize = true;
fom.Name = 'T';
fom.Result = 'Objects::Monitor::T';
fom.['Scalar operation'] = 'Abs';
fom.['Vector operation'] = 'None';
addsweepresult('optimization', fom);

See also
removesweepresult, setsweep, getsweepoptdata

removesweepresult

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Removes a result to a parameter sweep, or a figure-of-merit row to an optimization. It is invalid on an S-matrix sweep.

Syntax

Code Function
removesweepresult('name', 'result_name'); Removes a result to a parameter sweep, or a figure-of-merit row to an optimization.

Example

removesweepresult('width_sweep', 'T');

See also
addsweepresult, removesweepparameter

loadfullportmodes

FDTD · EME
Description
Adds every available Port×Mode combination to an S-matrix sweep, which is the Load Full PortModes action in the GUI. Existing rows are replaced. An error is raised if 'name' is not an S-matrix sweep, or if there is no port.

Syntax

Code Function
loadfullportmodes('name'); Adds every available Port×Mode combination to an S-matrix sweep.

Example

addsweep(2);
setsweep('s-matrix sweep', 'name', 'sparams');
loadfullportmodes('sparams');

See also
removeallportmodes, addsweepparameter

removeallportmodes

FDTD · EME
Description
Removes all Port×Mode rows from an S-matrix sweep, which is the Remove All PortModes action in the GUI.

Syntax

Code Function
removeallportmodes('name'); Removes all Port×Mode rows from an S-matrix sweep.

Example

removeallportmodes('sparams');

See also
loadfullportmodes, removesweepparameter

Common Manipulation

set

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK · INTERCONNECT
Description
Sets the property of the selected object.

Syntax

Code Function
set Lists all properties of the selected object that can be modified.
set('property_name', value); Sets property named 'property_name' of the selected object to value .
set('property_name', value, k); Sets property named 'property_name' of the k th object to value when multiple objects are selected. The objects are ordered by their location in the object tree. The uppermost selected object is given the index 1, and the index numbers increase as you go down the tree.

Example

Set property 'x span' of selected object to 5e-6(m).

set('x span', 5e-6);    # unit: m

Set property 'name' of selected object to 'new_rectangle'.

set('name', 'new_rectangle');

Disable 'base on source setting' option of selected object.

set('base on source setting', 0);

Set vertices of selected polygon using matrix.

addpoly;        # add polygon structure
theta=linspace(0, 2*pi, 6);
theta=theta(1: 5);
x=cos(theta)*1e-6;    # x (unit: m)
y=sin(theta)*1e-6;    # y (unit: m)
V=[x; y];        # vertices 

set('vertices', V);

See also
setnamed, select, selectall

setnamed

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK · INTERCONNECT
Description
Sets the property of named objects.

Syntax

Code Function
setnamed('object_name') Lists all properties of selected object that can be modified.
setnamed('object_name', 'property_name', value); Sets the property 'property_name' of object 'object_name' to value .
setnamed('group_name::name', 'property_name', value) Sets the property 'property_name' of object 'object_name' in FDTD or group named 'group_name' to value .

Example

Set property 'x span' of the object named 'new_rectangle' to 5e-6 (m).

setnamed('new_rectangle', 'x span', 5e-6); # unit: m

Disable the 'base on source setting' option of the FDFP Monitor named 'T' in FDTD.

setnamed('FDTD::T', 'base on source setting', 0);

See also
set, select

select

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK · INTERCONNECT
Description
Selects the target object.

Syntax

Code Function
select('object_name'); Selects the target object named 'object_name' .
select('param1','param2'); The valid values of param1 are limited to two options: name or type. When param1 is omitted, it defaults to name. "param1 = type" is designed to manipulate multiple objects in one selection according to the objects' type. The values of param2 depend on param1, as detailed below:
  • If param1 is set to name, param2 can be:
    • object_name (e.g., a direct name of the target object)
    • solver_name::object_name (e.g., combining a solver's name and the object's name, separated by "::")
    • group_name::object_name (e.g., combining a group's name and the object's name, separated by "::")
  • If param1 is set to type, param2 can be:
    • object_type (e.g., a direct type of the target object)
    • solver_type::object_type (e.g., combining a solver's type and the object's type, separated by "::")
    • group_type::object_name (e.g., combining a group's type and the object's name, separated by "::")

Example1
Select the target object named 'Index_Monitor' in FDTD solver.

# add FDTD and index monitor 
addfdtd;

addindexmonitor;
set('name', 'Index_Monitor');

select('FDTD::Index_Monitor');

Example2
Create two objects and put them in a group.

deleteall;
addfdtd;      #name: FDTD, type: FDTD
adddipole;    #name: Dipole, type: Dipole
adddipole;    #name: Dipole_1, type: Dipole

select('type','FDTD::Dipole');
addtogroup('Dipole_Group');   #two dipoles will be moved in one selection.

See also
selectall, selectpartial

selectpartial

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Selects all the objects with a common partial name.

Syntax

Code Function
selectpartial('partialname'); Selects any objects where 'partialname' can be found in the object name provided the object is not in a group or solver.
selectpartial('slovername::partialname'); Selects any objects where 'partialname' can be found in the object name provided the object is in a solver.
selectpartial('partialgroupname::partialname'); Selects any objects where 'partialgroupname' can be found in the group name and 'partialname' can be found in the object name.

Example
Select all 2D structures and move them to a new group

addrect;      #name: Rectangle
add2drect;    #name: 2D Rectangle
add2dpoly;    #name: 2D Polygon
selectpartial('2D');        #select structures whose names include "2D"
addtogroup('NewGroup');     #group name: NewGroup
selectpartial('New::2D');   #the group name also can be partial
copy();   #both 2D Rectangle and 2D Polygon will be copied

see also
select, selecall

selectall

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK · INTERCONNECT
Description
Selects all the objects in the simulation environment.

Syntax

Code Function
selectall; Selects all the objects in the simulation environment.

See also
select, selectpartial

shiftselect

FDTD · FDFD · FDE · EME · FDCharge · RCWA

Description

Performs an additive multi‑selection of objects. Adds more objects to the current selection without deselecting existing ones.
Supports filtering by name or type with the same syntax as select.

Syntax

Code Function
shiftselect; Extends selection based on default rules.
shiftselect('object_name'); Adds the object named 'object_name'. Equivalent to shiftselect('name','object_name').
shiftselect('param1','param2'); Parameters follow the same rules as in select (see select documentation).

Note Can only multi‑select items within the same group.

See also

select, shiftselectpartial

shiftselectpartial

FDTD · FDFD · FDE · EME · FDCharge · RCWA

Description

Performs a partial (fuzzy) additive multi‑selection. Adds objects that fuzzily match the specified name or type to the current selection.
Supports fuzzy filtering by name or type with the same syntax as select.

Syntax

Code Function
shiftselectpartial; Performs partial selection based on default criteria.
shiftselectpartial('pattern'); Adds objects whose name fuzzily matches 'pattern'. Equivalent to shiftselectpartial('name','pattern').
shiftselectpartial('param1','param2'); Parameters follow the same rules as in select (see select documentation).

Note Can only multi‑select items within the same group.

See also

select, shiftselect

unselectall

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Unselects all the objects that have been selected before.

Syntax

Code Function
unselectall; Unselects all the objects that have been selected before.

See also
select

pin

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Pins the selected object.

Syntax

Code Function
pin; Pins the selected object.
pin('object_name'); Pins the object named "object_name".

See also
unpin

unpin

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Unpins the selected object.

Syntax

Code Function
unpin; Unpins the selected object.
unpin('object_name'); Unpins the object named "object_name".

See also
pin

disable

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Disables the selected object.

Syntax

Code Function
disable; Disables the selected object.
disable('object_name') Disables the object named 'object_name'.

See also
enable

enable

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Enables the selected object.

Syntax

Code Function
enable; Enables the selected object.
enable('object_name'); Enables the object named "object_name".

See also
disable

copy

FDTD · FDFD · FDE · EME · FDCharge · RCWA
Description
Copies and pastes the selected object.

Syntax

Code Function
copy; Copies and pastes the selected object.
copy('object_name'); Copies and pastes the object named "object_name".

View

switchtotopview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to top view plane.

Syntax

Code Function
switchtotopview; Switches view plane in the composite viewer window to top view plane.

See also
switchtobottomview, switchtofrontview, switchtobackview, switchtoleftview, switchtorightview

switchtobottomview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to bottom view plane.

Syntax

Code Function
switchtobottomview; Switches view plane in the composite viewer window to bottom view plane.

See also
switchtotopview, switchtofrontview, switchtobackview, switchtoleftview, switchtorightview

switchtofrontview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to front view plane.

Syntax

Code Function
switchtofrontview; Switches view plane in the composite viewer window to front view plane.

See also
switchtotopview, switchtobottomview, switchtobackview, switchtoleftview, switchtorightview

switchtobackview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to back view plane.

Syntax

Code Function
switchtobackview; Switches view plane in the composite viewer window to back view plane.

See also
switchtotopview, switchtobottomview, switchtofrontview, switchtoleftview, switchtorightview

switchtoleftview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to left view plane.

Syntax

Code Function
switchtoleftview; Switches view plane in the composite viewer window to left view plane.

See also
switchtotopview, switchtobottomview, switchtofrontview, switchtobackview, switchtorightview

switchtorightview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to right view.

Syntax

Code Function
switchtorightview; Switches view plane in the composite viewer window to right view plane.

See also
switchtotopview, switchtobottomview, switchtofrontview, switchtobackview, switchtoleftview

switchtoZXview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to ZX view plane.

Syntax

Code Function
switchtoZXview; Switches view plane in the composite viewer window to ZX view plane.

See also
switchtoZYview, switchtoXYview

switchtoZYview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to ZY view plane.

Syntax

Code Function
switchtoZYview; Switches view plane in the composite viewer window to ZY view plane.

See also
switchtoZXview, switchtoXYview

switchtoXYview

FDTD · FDFD · FDE · EME · FDCharge · RCWA · STACK
Description
Switches view plane in the composite viewer window to XY view plane.

Syntax

Code Function
switchtoXYview; Switches view plane in the composite viewer window to XY view plane.

See also
switchtoZXview, switchtoXYview