The matrix transformation grid attribute is the most general type of unitary transformation, allowing the user to directly specify the full transformation matrix. Advanced material properties such as the Magneto-Optical Kerr Effect (MOKE) can be implemented using this object.

Matrix transformation is used when a permittivity tensor \(\tilde\varepsilon\) is given by a general form as

$$\tilde\varepsilon(x,y,z)=\begin{bmatrix} \varepsilon_{xx}&\varepsilon_{xy}&\varepsilon_{xz} \\ \varepsilon_{yx}&\varepsilon_{yy}&\varepsilon_{yz} \\ \varepsilon_{zx}&\varepsilon_{zy}& \varepsilon_{zz}\end{bmatrix}$$

We first need to calculate diagonal elements of \(\tilde\varepsilon_D\) and transformation matrix \(U\), which are the required inputs into FDTD. Since diagonal elements of \(\tilde\varepsilon_D\) are given by eigenvalues of \(\tilde\varepsilon\) and transformation matrix \(U\) is composed of the complex conjugate transpose of the eigenvectors of \(\tilde\varepsilon\), we use eig script command to calculate these values.

## Properties Editor tab

- NAME: Object name
- ENABLED: Determines if the object will be included in the simulation
- USE RELATIVE COORDINATES: If this is enabled then the source will use the center of the CHARGE solver as its origin (reference). If disabled then it will use the absolute center (0,0,0) as its origin.
- RESAMPLE FOR VIEWING: If this is enabled, NX, NY, NZ are used to resample the drawing of object in the layout editor. NX, NY, NZ are the maximum allowed resolution shown in the CAD view. These numbers are for graphical rendering and should have no effect to the simulation results. These options are only available when spatially-varying data is imported
- X, Y, Z: The center position of the object
- X SPAN, Y SPAN, Z SPAN: The size of the object. This is greyed out and not editable in the GUI. The numbers are updated when data with spatial distribution are imported.
- RESCALE AXES INDEPENDENTLY: If this is enabled, then X SCALE, Y SCALE, Z SCALE can be set differently to rescale the object. If disabled, then X SCALE, Y SCALE, Z SCALE can only be set equally. These options are only available when spatially-varying data is imported
- ENABLE CONFORMAL MESHING: See grid attribute tips for details.
- TRANSFORM U: The 3x3 transformation matrix.
- IMPORT DATA: Import the transformation matrix saved in a .mat file
- CLEAR DATA: Clear the imported data

## Uniform Transform

If we want to set an anisotropic material with permittivity tensor

$$\tilde\varepsilon(x,y,z)=\begin{bmatrix} 1.5&2&0\\ -2&1.5&0\\ 0&0&1.2\end{bmatrix}$$

we first calculate the eigenvalues as shown below.

# permittivity tensor in the reference coordinate system(x,y,z)

A = [ 1.5, 2,0;-2, 1.5,0;0,0,1.2];

Evl=eig(A,1); # calculate eigenvalues

After getting the eigenvalues, we create a new material and define the diagonal elements of refractive indexes using setmaterial script commands as shown below.

# diagonal elements of refractive indexes

DeR=[sqrt(Evl(1));sqrt(Evl(2));sqrt(Evl(3))];

mymaterial = addmaterial("(n,k) Material");

setmaterial(mymaterial,"name","MOKE");

setmaterial("MOKE", "Anisotropy", 1); # enable diagonal anisotropy

setmaterial("MOKE","Refractive Index", real(DeR));

setmaterial("MOKE","Imaginary Refractive Index", imag(DeR));

If we open the material database, we can see that a new material is created as shown below.

Next, to setup transformation matrix we calculate eigenvectors using eig script command as show below.

A = [ 1.5, 2,0;-2, 1.5,0;0,0,1.2];

Evc=eig(A,2); # calculate eigenvectors

Once you get the eigenvectors, you add Matrix attribute object into the layout editor using addgridattribute script command and set the eigenvectors to the property "U" of the Matrix attribute object using set script command as shown below.

addgridattribute("matrix transform"); # add matrix transform grid attribute

# set the complex conjugate transpose of Evc to grid attribute property U

set("U",ctranspose(Evc));

set("name","kerr attribute"); # set Evc to grid attribute property U

If you open edit window of the Matrix attribute and double click the "Value" field, you can check the elements of the matrix U.

After setting the matrix, we assign the Matrix attribute and the material to"grid attribute names" and "material" properties on the Material tab of a structure object which we want to setup an anisotropic material as shown below.

## Spatially-varying Transform

Let's say we have an anisotropic material where the permittivity at each location varies as a function of the z location, so the permittivity tensor is:

$$\tilde\varepsilon(x,y,z)=\begin{bmatrix} 1.5&2z&0\\ -2z&1.5&0\\ 0&0&1.2\end{bmatrix}$$

We can use a loop to loop through the z-positions of the object, and calculate the diagonal anisotropy and required unitary transform matrix at each location. The diagonal anisotropy values can be imported in an (n,k) import object, and the unitary transform matrix can be applied to the import object. This is done in the matrix_transform_spatially_varying.lsf file.