Questions 1 and 3:
The matrix_transform.lsf script file from the following page is an example of how to set up the uniform permittivity tensor over the entire object since the transform matrix U is set to only a 3x3 matrix which means that the same 3x3 transform matrix is used over all positions inside the structure:
Here, the 3x3 tensor that you mentioned would be the permittivity tensor A that is specified:
[ 11.9740, 11.9722,0; -11.9722, 11.9704, 0; 0, 0, 12.0037]
In the matrix_transform_spatially_varying.lsf the U matrix is set to be a 3x3xMxNxO matrix where N, M, O are the x, y, z positions in space. This means that the 3x3 transform matrix varies over space. In the example script, the multiplication by 2*z(k) in the permittivity is only used as an example to illustrate the case where the permittivity changes as a function of the z position in space, but in your case there is no such relationship between the z position and the permittivity of the structure since the permittivity is only changing depending on the applied stress. Since you have already calculated the permittivity tensor due to the applied stress you don’t need to use the method in the matrix_transform_spatially_varying.lsf script to calculate the permittivity tensor over space.
When you diagonalize the permittivity matrix, the diagonalized values that are used to set up the material can be complex (so the imaginary part of the refractive index is non-zero), however, the actual permittivity tensor that is simulated will be:
eps = Ueps_dctranspose(U)
Where eps is the permittivity tensor with off-diagonal components, U is the applied matrix transform, and eps_d is the matrix with diagonalized elements. Basically, the matrix transform grid attribute applies the Ueps_dctranspose(U) operation to the material of the object where the grid attribute is specified. This idea is discussed on the following page under the “General anisotropic materials” heading:
This means that even though the diagonalized values may have imaginary parts, the permittivity that is simulated will not have the imaginary components.
The script that you have will return Ex, Ey, Ez, and E2 values that are different from the values that you would see if you plotted the E result from the monitor since the E dataset result from the monitor returns results with CW normalization applied. When you use the “getdata” script command to get field data, this is getting the raw field data before CW normalization is applied.
CW normalization is used for frequency domain monitors to give results as though the same source amplitude is being injected at all frequencies, as discussed on this page:
If you could let us know what error you are seeing when you try to use the example script, we may be able to help correct it.