Variables

The following commands are used to create and access variables.

= (equal) - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Assignment operators.

Syntax

Description

x = 5+2i;

Assign a value to a variable.

: (array operator, colon) - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Array operator.

Syntax

Description

x = 2 : 10;

x will be an array of numbers that start at 2 and increase by 1 for each consecutive number. The last entry will be <= 10. x will equal 2,3,...,9,10.

x = 6 : -1.5 : 2;

x will be the array were the first element is 6, and consecutive elements decrease by 1.5. All elements will be >=2. In this example, the array will be [6, 4.5, 3].

B=A(:, 2)

B will be the array containing all the elements from the second dimension of A.

Examples

Create a vector, then access a portion of that matrix in reverse order with the : operator.

a=l:5;     # a will be vector (1, 2, 3, 4, 5)
?b=a(4:-1:2);  # b will be vector (4, 3, 2) 

Create a matrix, then access all the element of a dimension of that matrix with the : operator:

a=[1,2,3;4,5,6]; 
?b=a(:, 1); # b will be vector (2, 5)

 

[] (specify matrix element, square bracket) - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Specify matrix element by element.

Command

Description

x = [u11,...,u1N; u21,...,u2N; uM1,...,uMN]

Create an N by M matrix. Columns are separated with semicolons. Elements in a row are separated with commas. The entries can either be scalars or matrices of compatible dimension.

Examples

?x=[1,2;3,4;5,6];
result: 
1 2 
3 4 
5 6
?x(1:3,1);
result: 
1 
3 
5   
a=matrix(2,2,2); 
a(1,1)=1;
a(2,2)=2;
b=a+1;
?c=[a,b];
result(i,j,1):
1 0 2 1 
0 2 1 3 
result(i,j,2):
0 0 1 1 
0 0 1 1 

% (space in variable name, percent) - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Used to create variables with spaces in the names.

Command

Description

%variable with space%

To create a variable name that contains spaces, such as "variable with space", put a percentage sign before and after the variable name.

Examples

%variable with space%=2;
?%variable with space%*3;
result: 
6  
%x span% = get("x span");
?%x span% * 1e6;  # x span in um
result:
4.8  

 

linspace - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates a linearly spaced array.

Syntax

Description

x = linspace(min,max,num);

x will be an array with num elements, linearly spaced between min and max. If num is set to 1, then x will be the average of min and max.

Examples

?x=linspace(1,3,4);
result: 
1 
1.66667 
2.33333 
3  

Call linspace with num of 1. The result with be the average of min and max.

?linspace(1,2,1);
result: 
1.5 

matrix - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Initialize a matrix. All elements are set to zero.

Syntax

Description

x = matrix(i,j,k,....);

Initializes an i x j x k x .... matrix.

Examples

?x=matrix(2,2,2);
result(i,j,1):
0 0 
0 0 
result(i,j,2):
0 0 
0 0 

 

ones - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Initialize a matrix. All elements are set to one.

Syntax

Description

x = ones(i,j,k,....);

Initializes an i x j x k x .... matrix.

Examples

?x=ones(2,2,2);
result(i,j,1):
1 1 
1 1 
result(i,j,2):
1 1 
1 1 

zeros - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Initialize a matrix. All elements are set to zero (same as  matrix  ).

Syntax

Description

x = zeros(i,j,k,....);

Initializes an i x j x k x .... matrix.

Examples

?x=zeros(2,2,2);
result(i,j,1):
0 0 
0 0 
result(i,j,2):
0 0 
0 0 

 

randmatrix - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Initialize a matrix. All elements are random numbers between 0 and 1.

Syntax

Description

x = randmatrix(i,j,k,....);

Initializes an i x j x k x .... matrix. The elements are all random numbers between 0 and 1.

Examples

?x=randmatrix(2,2,2);
result(i,j,1):
0.202368 0.503983 
0.570605 0.89404 
result(i,j,2):
0.740623 0.669118 
0.888394 0.295022  

randnmatrix - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Initialize a matrix. All elements are normally distributed random numbers with mean 0 and standard distribution 1.

Syntax

Description

x = randnmatrix(i,j,k,....);

Initializes an i x j x k x .... matrix. The elements are all random normally distributed numbers with mean 0 and standard deviation 1.

 

histogram - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a matrix containing the histogram count of a yield analysis result.

Syntax

Description

out = histogram(y);

Returns a matrix containing the histogram count of y.

out = histogram(y,n);

Returns a matrix containing the histogram count of y, using n bins.

 

meshgridx - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a 2D meshgrid in the x direction

Syntax

Description

out = meshgridx(x,y);

If x and y are single column (or single row vectors), of dimension nX1 and mX1 respectively, the command

  • X = meshgridx(x,y);

Will create a 2D matrix of dimension nXm where X(i,j)=x(i).

Examples

This example uses the image function to show the output of meshgrid. See the image function help for another example that uses meshgrid.

x=linspace(0,10,100);
y=linspace(0,10,10);
image(x,y,meshgridx(x,y),"x","y","meshgridx");
image(x,y,meshgridy(x,y),"x","y","meshgridy");

The following figures show the output of the the example code.

This example uses the mesh grid functions to create an image plot of a 2D gaussian function Z(x,y)=exp( -x^2-y^2).

x=linspace(-3,3,100); 
y=x; 
X=meshgridx(x,y); 
Y=meshgridy(x,y); 
Z=exp( -X^2 -Y^2); 
image(x,y,Z);

meshgridy - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a 2D meshgrid in the y direction

Syntax

Description

out = meshgridy(x,y);

If x and y are single column (or single row vectors), of dimension nX1 and mX1 respectively, the command

  • Y = meshgridy(x,y);

Will create a 2D matrix of dimension nXm where Y(i,j)=y(j).

Examples

See example in meshgridx.

 

meshgrid3dx - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a 3D meshgrid in the x direction

Syntax

Description

out = meshgrid3dx(x,y,z);

The 3D version of meshgridx and meshgridy.

Examples

See example in meshgridx.

meshgrid3dy - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a 3D meshgrid in the y direction

Syntax

Description

out = meshgrid3dy(x,y,z);

The 3D version of meshgridx and meshgridy.

Examples

See example in meshgridx.

 

meshgrid3dz - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a 3D meshgrid in the z direction

Syntax

Description

out = meshgrid3dz(x,y,z);

The 3D version of meshgridx and meshgridy.

Examples

See example in meshgridx.

meshgrid4d - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Create a 4D meshgrid in any direction.

Syntax

Description

out = meshgrid4d(dim, x1, x2, x3, x4);

The 4D meshgrid function.

dim specifies the dimension along which to create the grid

x1,x2,x3,x4 are the position vectors in each direction

Examples

Create a 4D frequency vector from a set of position vectors.

x=linspace(-10,10,20);
y=linspace(-10,10,21);
z=linspace(-10,10,22);
f=linspace(0,100,23);
F=meshgrid4d(4,x,y,z,f); # create meshgrid in 4th (frequency) dimension
?size(F);         # size should be equal to the size of each position vector
result: 
20 21 22 23 

 

clear - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Clears all or specified stored workspace variables. This will not clear any simulation data stored in d-cards. The variables c, pi, eps0, mu0 will be reset to their default values.

Syntax

Description

clear;

Clears all workspace variables.

This function does not return any data.

clear(var1, var2, ...);

Clears only the workspace variables with the specified names.

clearfunctions - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Clears all or specified stored functions.

Syntax

Description

clearfunctions;

Clears all workspace functions.

This function does not return any data.

clearfunctions(func1, func2, ...);

Clears only the workspace functions with the specified names.

 

clearexcept - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Clears the workspace variables except the specified ones.

Syntax

Description

clearexcept(a);

Clears the workspace variables except for variable a.

Examples

a = "my string";
b = 1;
d = 2;
clearexcept(a);

print - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Prints a string.

Syntax

Description

print("hello world");

Prints the string defined in the quotation mark.

Examples

a = "my string";
print(a);my string
print('Hello World!');Hello World!

 

workspace - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Returns a list of all the currently defined variables in the scripting workspace.

Syntax

Description

out = workspace;

Returns a string that lists all currently defined variables in the workspace.

Use ?workspace; to print this to the screen.

Examples

clear;
my_data=4;
result=matrix(2,2);
?workspace;
matrices:
 pi mu0 eps0 my_data result c

Accessing and assigning matrix elements

Accessing and assigning matrix elements.

FDTD   STACK   MODE   DGTD   CHARGE   HEAT   FEEM   INTERCONNECT 

Command

Description

x = [u; v; w]

Create a column vector. u,v,w can either be scalars or matrices of compatible dimension.

x = [u, v, w]

Create a row vector. u,v,w can either be scalars or matrices of compatible dimension.

x(7) = 5;

Set the 7th element of x to 5.

x(7) = y(2);

Set the 7th element of x to the 2nd element of y.

x(3,1,8) = 3;

Set an element of a multidimensional matrix to 3. The script will check that indices are withing range of the corresponding dimensions.

x(2:5,1) = 1:4;

Set a sub-matrix of x to values 1:4. In the assignment A(I,...) = B, if B is not a scalar, the sub-matrix A(I,...) must be the same same size as B. If B is a scalar, then all the values of the sub-matrix are set to B.

x(2:5,1) = 1;

Set all the values in a sub-matrix of x to 1.

x = y(1:10,2,1:20);

x is equal to a sub-matrix of y.

x = matrix(2,3);

x(4)=7;

Multi-dimension matrices can be accessed with a single index.

x=y(z);

Indices stored in matrix (z) used to select elements of matrix y. length(x) will equal length(z).

Example

This example shows how to access a multi dimensional matrix with a single index.

x=matrix(2,3);
x(1,1)=1;
x(2)=2; # same as x(2,1)=2;
x(3)=3; # same as x(1,2)=3;
x(6)=6; # same as x(2,3)=6;
?x;
result: 
1 3 0 
2 0 6 

This example shows how to access data from one matrix with indices stored in another matrix. This is very useful with commands such as findpeaks.

y=10:20;   # create a vector of integers 10-20
z=2:2:6;   # selected values (2,4,6)
?x=y(z);   # x will equal the 2nd, 4th, and 6th value of y. 
result: 
11 
13 
15 

This example shows how to create matrices with the semicolon and colon operators.

?C=[1,2,3;4,5,6];
result: 
1 2 3 
4 5 6 
?A=matrix(3,1);
result: 
0 
0 
0 
?B=matrix(3,4)+1;
result: 
1 1 1 1 
1 1 1 1 
1 1 1 1 
?C=[A,B];
result: 
0 1 1 1 1 
0 1 1 1 1 
0 1 1 1 1

 

Pre-defined constants in Lumericals scripting environment

The following variables are reserved in Lumerical's scripting environment and their value cannot be modified.

Name

Description

pi

The number π.

c

The speed of light in a vacuum in m/s.

eps0

The permittivity of free space in SI units.

mu0

The permeability of free space in SI units.

h

The Planck constant.

hbar

The reduced Planck constant.

true

Logical TRUE (1).

false

Logical FALSE (0);

e

The electron volt.

eye - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates a 2D identity matrix.

Syntax

Description

I = eye;

Returns a 1x1 matrix, value 1.0.

I = eye(n);

Returns nxn identity matrix.

I = eye(n,m);

Returns nxm matrix with ones on main diagonal

Examples

Following are some examples and the results of the script command usage.

?eye;
result: 
1 
?eye(3);
result: 
1 0 0 
0 1 0 
0 0 1 
?eye(2,3);
result: 
1 0 0 
0 1 0 
?eye(3,2);
result: 
1 0 
0 1 
0 0 

 

struct - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates a structure array. Any data type (such as matrix, string, dataset) can be added to structure arrays.

Since Lumerical 2019b R4 version, users can also declare a structure array by using the braces declaration method.

Syntax

Description

a = {"one" : "fish", "two" : "fish", "red" : "fish", "blue" : "fish"}

Creates and initializes a structure array.

a = struct;

Creates an structure array.

a.a = "string";

Adds a string field to the structure array.

a.b = matrix(5,5);

Adds a field of matrix of 5x5 to the structure array.

Examples

A structure can be created and initialized quickly as follows:

C = {"a" : [1, 4, 9],
     "b" : "a string",
     "d" : matrix(5, 5),
     "e" : getresult("monitor", "T")};

The above structure array can also be declared more pedantically:

C = struct;
C.a = [1, 4, 9]; 
C.b = "a string";
C.d = matrix(5,5); 
C.e = getresult("monitor","T");

Both structure arrays are equivalent and will produce the same output:

?C;
Struct with fields:
a
b
d
e

?C.a;
result: 
1 4 9 

?C.a(2);
result: 
4

?C.b;
a string

?C.d;
result: 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 

?C.e;
T vs lambda/f

When two or more objects share the same parameters, a "struct" can be used for all of them:

    addrect;
    props = struct;
    props.x = 1e-6;
    props.y = 2e-6;
    setnamed("rectangle",props);
    addprofile;
    set(props);

In the above example, both the geometry "rectangle" and the profile monitor have the same x and y values, so the "struct" with given "x,y" can be applied to them in setnamed and/or set.

"struct" can also be used to set the properties directly

 addcircle( {"name":"c1","x": 1e-6,"y": 2e-6,"radius":0.5e-6});
 mystruct = {"name":"c2","x":-1e-6,"y":-2e-6,"radius":0.5e-6};
 addcircle(mystruct);

The above scripts will create two circles "c1" and "c2" located in quadrants I and III with the same radius.

cell - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates a cell array variable with specified number of elements. The cell array element can be any data type, such as matrix, string, and dataset.

Since Lumerical 2019b R4 version, users can also declare a cell by using the braces and square brackets declaration method.

Syntax

Description

a = {"a", "b", 1, 2.3}

Creates and initializes a cell array.

a = cell(n);

Creates a cell array with n elements.

a{n} = "string";

Adds a string to the specified element of the cell array.

a{n} = matrix(5,5);

Adds a field of matrix of 5x5 to the specified element of the cell array.

Examples

A cell can be created and initialized quickly as follows:

myCell = {"a", "b", 1, 2.3}; 

# cell with struct
myCellWithStruct = {"a", {"b" : 2, "c" : 3}};

The above cell can also be declared more pedantically:

myCell = cell(4);
myCell{1} = "a";
myCell{2} = "b";
myCell{3} = 1;
myCell{4} = 2.3;

# cell with struct
myCellWithStruct = cell(2);
myCellWithStruct{1} = "a";
myCellWithStruct{2} = struct;
myCellWithStruct{2}.b = 2;
myCellWithStruct{2}.c = 3;

The above declaration methods are equivalent and will produce the same output:

?myCell;
Cell array with 4 elements

?myCell{1};
a

?myCellWithStruct;
Cell array with 2 elements

?myCellWithStruct{1};
a

?myCellWithStruct{2};
Struct with fields:
b
c

?myCellWithStruct{2}.b;
result: 
2  

 When two or more objects have similar properties, such as spacial location of "x" and "y", one can define a "cell" with "x" and "y", and get their values:

    propxy = {"x","y"};
    out1 = getnamed("rectangle",propxy);
    out2 = getnamed("monitor",propxy);
    ?out1.x;
    ?out2.y; 

In the above example, geometry "rectangle" and monitor "monitor" both have "x" and "y" properties.

 The following commands are used to create, access and manipulate datasets. For an introduction to datasets, see the  dataset introduction  page.

rectilineardataset - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates an empty rectilinear dataset that is associate with the x/y/z coordinates (ex. E and H fields). Like matrix datasets, rectilinear datasets can be parameterized, and can contain an arbitrary number of attributes (see addattribute) and parameters (see addparameter).

See Dataset introduction for more information.

For datasets that are not associated with the x/y/z coordinates (ex. transmission as a function of frequency), see  matrixdataset.

Syntax

Description

rectilineardataset(x,y,z);

Creates a empty rectilinear dataset associated with the coordinates x/y/z.

Arguments 'x', 'y' and 'z' may be different lengths and the total number of points is the product of their lengths.

rectilineardataset("dataset_name",x,y,z);

Creates a empty rectilinear dataset named "dataset_name" associated with the coordinates x/y/z.

Arguments 'x', 'y' and 'z' may be different lengths and the total number of points is the product of their lengths.

Examples

This example creates a rectilinear dataset (with the name "Absorption") that contains 2 data attributes: the power absorption Pabs, and the refractive index n. Both attributes are a function of the spatial parameters x/y/z and frequency 'f'. To allow the user to access the frequency parameter in terms of frequency or wavelength , both frequency (f) and wavelength (c/f) are added as interdependent parameters.

Absorption = rectilineardataset("Absorption",x,y,z);
Absorption.addparameter("lambda",c/f,"f",f);
Absorption.addattribute("Pabs",Pabs);
Absorption.addattribute("refractive index",n);
visualize(Absorption); # visualize this dataset in the Visualizer

The following script code shows how to get the raw data from a frequency monitor in FDTD (using getdata), and how to manually create a dataset from that data. It also shows how to directly get the electric field dataset from the monitor in a single command (using getresult).

# monitor name
m="monitor";
# get individual data elements with getdata
x=getdata(m,"x");
y=getdata(m,"y");
z=getdata(m,"z");
f=getdata(m,"f");
Ex=getdata(m,"Ex");
Ey=getdata(m,"Ey");
Ez=getdata(m,"Ez");
# create the electric field dataset from the raw data
E_manual = rectilineardataset("E_manual",x,y,z);  # initialize dataset and provide spatial position vectors
E_manual.addparameter("lambda",c/f,"f",f);  # add additional parameter: frequency 
E_manual.addattribute("E",Ex,Ey,Ez);     # add vector electric field attribute
# all of the above commands can be avoided with a single getresult command
E_fromMonitor = getresult(m,"E");

The following script code shows how to access the data stored in the 'E_manual' dataset created in the above example

# output contents of dataset to prompt
?E_manual;
# Get parameters
x   = E_manual.x;
y   = E_manual.y;
z   = E_manual.z;
f   = E_manual.f;
lambda = E_manual.lambda;
x_1  = E_manual.x(1); 
# Get attributes. Remember that E is a vector quantity
Ex = E_manual.Ex; # Ex component
Ey = E_manual.Ey; # Ey component
Ez = E_manual.Ez; # Ez component
E2 = E_manual.E2; # |E|^2
E = E_manual.E;  # get all components in a single matrix. An extra dimension of length 3

matrixdataset - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates an empty matrix dataset. Matrix datasets are used for data (attributes and parameters) that don't have any spatial dependence (i.e. Reflection vs frequency). For datasets that do have x/y/z spatial coordinates (i.e. electric fields), use rectilineardataset or unstructureddataset.

Matrix datasets can be parameterized, and can contain an arbitrary number of attributes (see addattribute) and parameters (see addparameter).

See Dataset introduction for more information.

Syntax

Description

matrixdataset;

Creates an empty dataset.

matrixdataset("name");

Creates an empty dataset with the name "name".

Examples

This example uses a matrix dataset to store cross section (sigma) data as a function of frequency. In this case, the cross section data sigma is the attribute, and frequency is the parameter. To allow the user to access the frequency parameter in terms of frequency or wavelength , both frequency (f) and wavelength (c/f) are added as interdependent parameters.

sigma = matrixdataset("cross_section");
sigma.addparameter("lambda",c/f,"f",f); # add parameter f and lambda
sigma.addattribute("sigma",CS); # add attribute CS
visualize(sigma); # visualize this dataset in the Visualizer

The following script code generates some example data, then creates a R(radius,height) dataset.

# create example results
radius = 0:10; 
height = 1:0.1:3;
reflection = randmatrix(length(radius),length(height)); 
# create Reflection dataset
R = matrixdataset("R"); # initialize dataset
R.addparameter("radius",radius); # add radius parameter
R.addparameter("height",height); # add height parameter
R.addattribute("R",reflection); # add reflection attribute
# plot data
image(radius,height,reflection); # use original matrices
image(R.radius,R.height,R.R);  # use dataset
# send dataset to visualizer
visualize(R); 

 

unstructureddataset - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Creates an empty dataset that is associated with arbitrary x/y/z coordinate in space, and with additional matrix, a connectivity matrix to connect them. The connectivity matrix comes after x, y, and z. Like rectilinear datasets, unstructured datasets can be parameterized, and can contain an arbitrary number of attributes (see  addattribute)  and parameters (see  addparameter)  .

See  Dataset introduction  for more information. For datasets that are not associated with the x/y/z coordinates (ex. transmission as a function of frequency), see  matrixdataset  .

Syntax

Description

unstructureddataset(x,y,z,C);

Creates an empty unstructured dataset associated with the coordinates x/y/z and a connectivity matrix to connect them.

Arguments 'x', 'y' and 'z' must be the same length; equivalent to the total number of points.

The argument 'C' should be a matrix of integers where the number of rows equal to number of shapes in the mesh, the number of columns should be 2 (line segments), 3 (triangles) or 4 (tetrahedra), and values should be integers.

Examples

Below is a simple example of the usage of unstructured dataset. x, y and z vectors represent arbitrary points in space and C represent the connectivity matrix that connects them. The values for the vectors can be loaded from the  unstructured_charge_example.mat  file. It is possible to further script this process and import the data to an object, eg, np density grid attribute, see the  importdataset  command.

# constructing an unstructured dataset
matlabload("unstructured_charge_example.mat"); # taking the data from a CHARGE simulation. The data can be from a different source
x = charge.x;
y = charge.y;
z = charge.z;
C = charge.elements;
data = unstructureddataset("test",x,y,z,C);
V_cathode = charge.V_cathode;
V_anode = charge.V_anode;
n = pinch(charge.n);
p = pinch(charge.p);
data.addparameter("V_cathode",V_cathode);
data.addparameter("V_anode",V_anode);
data.addattribute("n",n);
data.addattribute("p",p);
visualize(data);

This next example creates an unstructured dataset (with the name "Absorption") that contains 2 data attributes: the power absorption Pabs, and the refractive index n. Both attributes are a function of the spatial parameters x/y/z and frequency f. Connectivity matrix cm has also been specified. To allow the user to access the frequency parameter in terms of frequency or wavelength , both frequency (f) and wavelength (c/f) are added as interdependent parameters.

Absorption = unstructureddataset("Absorption",x,y,z,cm);
Absorption.addparameter("lambda",c/f,"f",f);
Absorption.addattribute("Pabs",Pabs);
Absorption.addattribute("refractive index",n);
visualize(Absorption); # visualize this dataset in the Visualizer

This example shows how to define an equilaterial triangle in the plane z=0

x = [0;1;2];
y = [0;sqrt(3);0];
z = [0;0;0];
C = [1,3,2];
ds = unstructureddataset(x,y,z,C);

addparameter - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Adds a parameter to an existing dataset.

Syntax

Description

R.addparameter("p_name", p);

Adds the parameter p to the existing dataset R.

R.addparameter("p1_name", p1, "p2_name", p2);

Adds the interdependent parameter p1_name, p2_name to the R dataset.

The most common interdependent parameter is frequency and wavelength. Parameters that are not interdependent must be added separately.

Examples

This example uses a matrix dataset to store cross section (sigma) data as a function of frequency. In this case, the cross section data sigma is the attribute, and frequency is the parameter. To allow the user to access the frequency parameter in terms of frequency or wavelength , both frequency (f) and wavelength (c/f) are added as interdependent parameters.

sigma = matrixdataset("cross_section");
sigma.addparameter("lambda",c/f,"f",f); # add parameter f and lambda
sigma.addattribute("sigma",CS); # add attribute CS
visualize(sigma); # visualize this dataset in the Visualizer

 

addattribute - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Adds an attribute to an existing dataset.

Syntax

Description

R.addattribute("a_name", a);

Adds the scalar attribute a to the dataset R.

See  Dataset introduction  for details about the required dimensions of attribute data.

R.addattribute("a_vector", a_1, a_2, a_3);

Adds the vector attribute a_vector to the existing dataset R. The components of the vector are a_1, a_2 and a_3.

See  Dataset introduction  for details about the required dimensions of attribute data.

R.addattribute("a_name", [data], "type");

Adds the attribute "a_name" to the unstructured dataset R. [data] can be in one of the forms below:

vertex_scalar_attribute[npts; npar_1; npar_2; ...1]

vertex_vector_attribute[npts; npar_1; npar_2; ...3]

cell_scalar_attribute[ncells; 1]

cell_vector_attribute[ncells; 3]

(npts is the number of vertices, the length of geometric parameters 'x', 'y', 'z'

cells is the number of elements, equal to number of rows of geometry parameter 'elements' )

The "type" argument is an optional string to specify attribute type and can take values of "vertex" or "cell". If not provided, the function will guess the attribute type based on the shape of [data] argument.

Examples

This example uses a matrix dataset to store cross section (sigma) data as a function of frequency. In this case, the cross section data sigma is the attribute, and frequency is the parameter. To allow the user to access the frequency parameter in terms of frequency or wavelength , both frequency (f) and wavelength (c/f) are added as interdependent parameters.

sigma = matrixdataset("cross_section");
sigma.addparameter("lambda",c/f,"f",f); # add parameter f and lambda
sigma.addattribute("sigma",CS); # add attribute CS
visualize(sigma); # visualize this dataset in the Visualizer

Alternatively, one can also create a vector rectilinear dataset (with the name E).

E = rectilineardataset("E",x,y,z);
E.addparameter("f",f);
E.addattribute("E",Ex,Ey,Ez); # add a vector E with the components Ex, Ey and Ez
visualize(E); # visualize this dataset in the Visualizer

getresult - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Get results from simulation objects. Results will be returned as datasets.

Syntax

Description

?getresult("monitor_name");

Returns the names of all the results for the monitor. All the dataset and scalar matrix results will be returned in this case.

R = getresult("monitor_name","T");

Returns the result T from the monitor. T is a dataset.

Examples

This example shows how to get the electric field dataset from a monitor. We then apply a number of operations to the dataset, such as finding the maximum |E|^2 value, viewing the dataset with the visualizer, and creating a plot of Ex at the first frequency point.

Note that E is a dataset, rather than a simple matrix based variable. Data within the dataset can be accessed with the '.' operator, as shown below.

# get Electric field dataset
E=getresult("monitor","E");
# output dataset value to prompt
?E;
# check size of position vectors and data matrices
?size(E.f);
?size(E.Ex);
# find maximum |E|^2 value 
?max(E.E2);
# view dataset with visualizer
visualize(E);
# select first frequency point of Ex data, then create plot
Ex = pinch(E.Ex,4,1); 
image(E.x*1e6,E.y*1e6,Ex,"x (um)","y (um)","Ex");
 E vs x, y, z, lambda/f
 result: 
 5 1 
 result: 
 343 255 1 5 
 result: 
 3.223651 

 

getparameter - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Gets a parameter from an existing dataset.

Syntax

Description

?getparameter(R);

Returns the names of all the parameters in the dataset R.

Parameter = R.getparameter("p");

Retrieves the parameter p from the existing dataset R. The result "Parameter" is a scalar matrix.

See  Dataset introduction  for details about dimensions of attribute data.

Parameter = getparameter(R,"p");

Retrieves the parameter p from the existing dataset R. The result "Parameter" is a scalar matrix.

See  Dataset introduction  for details about dimensions of attribute data.

Examples

This example retrieves the dataset results "E" from a profile monitor, and then uses the getparameter command to get the "f" parameter, and the  getattribute  command to get the "Ex" and "E2" attributes from the dataset. Note that f, Ex and E2 are all scalar matrices, like the results one would get with the  getdata  command.

E = getresult("profile","E");
f = E.getparameter("f");  # the parameter f
Ex = E.getattribute("Ex"); # the x component of the electric field
E2 = E.getattribute("E2"); # the electric field intensity, note that this only works if E is a vector

Note that one can also use the  "." operator  to retrieve the parameters and attributes directly. For example:

E = getresult("profile","E");
f = E.f;  # the parameter f
Ex = E.Ex; # the x component of the electric field
E2 = E.E2; # the electric field intensity, note that this only works if E is a vector

getattribute - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Gets an attribute from an existing dataset.

Syntax

Description

?getattribute(R);

Returns the names of all the attributes in the dataset R.

Attribute = R.getattribute("a");

Retrieves the attribute a from the existing dataset R. The result "Attribute" is a matrix in one of the forms below depending on the type of atrribute:

vertex_scalar_attribute[npts; npar_1; npar_2; ...1]

vertex_vector_attribute[npts; npar_1; npar_2; ...3]

cell_scalar_attribute[ncells; 1]

cell_vector_attribute[ncells; 3]

"npts" is the number of vertices which is equal tothe length of geometric parameters 'x', 'y', 'z'

"ncells" is the number of elements equal to number of rows of geometry parameter 'elements'

Attribute = getparameter(R,"a");

Retrieves the attribute a from the existing dataset R. The result "Attribute" is a matrix in one of the forms below depending on the type of atrribute:

vertex_scalar_attribute[npts; npar_1; npar_2; ...1]

vertex_vector_attribute[npts; npar_1; npar_2; ...3]

cell_scalar_attribute[ncells; 1]

cell_vector_attribute[ncells; 3]

"npts" is the number of vertices which is equal tothe length of geometric parameters 'x', 'y', 'z'

"ncells" is the number of elements equal to number of rows of geometry parameter 'elements'

Examples

This example retrieves the dataset results "E" from a profile monitor, and then uses the  getparameter  command to get the "f" parameter, and the getattribute command to get the "Ex" and "E2" attributes from the dataset. Note that f, Ex and E2 are all scalar matrices, like the results one would get with the  getdata  command.

E = getresult("profile","E");
f = E.getparameter("f");  # the parameter f
Ex = E.getattribute("Ex"); # the x component of the electric field
E2 = E.getattribute("E2"); # the electric field intensity, note that this only works if E is a vector

Note that one can also use the  "." operator  to retrieve the parameters and attributes directly. For example:

E = getresult("profile","E");
f = E.f;  # the parameter f
Ex = E.Ex; # the x component of the electric field
E2 = E.E2; # the electric field intensity, note that this only works if E is a vector

 

deleteattribute - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Deletes an attribute from an existing dataset.

Syntax

Description

R.deleteattribute("a_name");

Deletes the attribute "a_name" from the dataset R. The attribute can be a scalar attribute, a vector attribute or an unstructured attribute.

See  Dataset introduction  for details about the required dimensions of attribute data.

Examples

This example uses a matrix dataset to store cross-section (sigma) data as a function of frequency. In this case, the cross-section data sigma is the attribute, and frequency is the parameter. Then the attribute sigma is deleted from the dataset sigma.

sigma = matrixdataset("cross_section");
sigma.addparameter("lambda",c/f,"f",f); # add parameter f and lambda
sigma.addattribute("sigma",CS); # add attribute CS
visualize(sigma); # visualize this dataset in the Visualizer
sigma.deleteattribute("sigma");
visualize(sigma);

getmeshcontours - Script command

FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT

Gets information about the contours between different domains in an unstructured (finite-element) dataset.  The dataset must contain the "ID" attribute (a unique identified for each domain in the finite-element mesh generated in Finite Element IDE based products).

Syntax

Description

A = getmeshcontours(dataset);

Returns information about the contours between different domains of the unstructured dataset named "dataset".  The output is provided as a cell array.  Each entry is a struct with three fields:

ID: An integer ID that is unique for that contour.

adjacent: Two integers representing the IDs of the adjacent domains.

elements: For 2D, Nx2 array and for 3D, Nx3 array of integers that are the indexes to the vertices for each face on the boundary.

Examples

The script commands below will get the contour information for the "grid" dataset (available after calculating the finite-element mesh).

mesh("CHARGE");  # calculate the mesh in Finite Element IDE using the CHARGE solver
grid = getresult("CHARGE","grid");  # get the mesh information ("grid" dataset)
contours = getmeshcontours(grid);
# get the ID of the first contour
ID_1 = contours{1}.ID;
# get the ID of the two adjacent domains (ID = 0 means external boundary) 
domains_1 = contours{1}.adjacent;
# get the index of vertices forming the first contour
vertices_1 = contours{1}.elements;

The following commands are INTERCONNECT specific.

global

The script command returns the value of a global variable specified. Global variables are root element properties.

INTERCONNECT 

Syntax

Description

out = global (name);

Returns the value of a global variable.

Example

Accessing ‘time window’ and ‘sample rate’ properties from the root element

?global("time window");
result: 
6.4e-009
?global("sample rate");
result: 
1.6e+011

 

simulation - Script command

FDTD MODE INTERCONNECT

The script command simulation returns bandwidth related simulation properties. The time domain simulator will try to accommodate the current channels into non-overlapping simulation bandwidths. Simulation properties include the center frequency, sample rate, number of samples, frequency grid spacing, lower and upper frequency limits. If a single bandwidth is listed, this means all channels fit in the same bandwidth, otherwise multiple bandwidths are required to accommodate all channels with the current sample rate.

The command also returns the list of source channels in the current simulation before the simulation estimate the simulation bandwidths. This list includes the overlapped bandwidths. Simulation properties include the center frequency, sample rate, number of samples, frequency grid spacing, lower and upper frequency limits. If a single bandwidth is listed, this means all channels fit in the same bandwidth, otherwise multiple bandwidths are required to accommodate all channels with the current sample rate.

This function is valid during analysis or run-time mode only.

Syntax

Description

out = simulation(“bandwidth”);

Returns bandwidth related simulation properties.

out = simulation(“channels”);

Returns the list of source channels in the current simulation before the simulation estimate the simulation bandwidths.

out = simulation(“single”);

Returns the recommended setting for simulation using a single band (total field) that will make sure all channels are merged into one simulation bandwidth.

Example

Access simulation properties while the simulation is running, the circuit contains four laser sources.

#list number of simulated channels
?simulation("bandwidth");
result: 
1.9315e+014 1.6e+011 1024 1.5625e+008 1.9307e+014 1.9323e+014 
1.9335e+014 1.6e+011 1024 1.5625e+008 1.9327e+014 1.9343e+01
#list number of available channel sources
?simulation("channels");
result: 
1.931e+014 1.6e+011 1024 1.5625e+008 1.9302e+014 1.9318e+014 
1.932e+014 1.6e+011 1024 1.5625e+008 1.9312e+014 1.9328e+014 
1.933e+014 1.6e+011 1024 1.5625e+008 1.9322e+014 1.9338e+014 
1.934e+014 1.6e+011 1024 1.5625e+008 1.9332e+014 1.9348e+014
#list recommended setting for single bandwidth
?simulation("single");
result: 
1.9325e+014 3.2e+011 2048 1.5625e+008 1.9309e+014 1.9341e+014
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值