Value of interpolated data using the "interptri" command is much larger than the source data


#1

Dear Alam,

I’m trying to use the interptri comment for my simulation file attached below:

The code I’m using is;

electrostatics=getresult(“CHARGE::E_field”,“electrostatics”);
E = pinch(electrostatics.E);
x = pinch(electrostatics.x);
y = pinch(electrostatics.y);
z = pinch(electrostatics.z);

vtx = [x,z];
elements = electrostatics.elements;

kern = size(E);
Ne = kern(1);
Nv = kern(2); # Number of bias points

x_rect = linspace(min(x),max(x),500);
y_rect = linspace(min(y),max(y),500);
z_rect = linspace(min(z),max(z),500);

E = E(1:Ne,Nv);

Interpolate
E_rect = interptri(elements,vtx,E,x_rect,z_rect);

However, after the interpolation is done, the maximum size of my E field changes from -687744 to -9223372036854775808! I’m not sure what I’m doing wrong in my code. Could you please take a look?

Thanks,
Shiva


Interpolate finite element data onto a rectilinear grid
#2

Hi Shiva, The data you are trying to interpolate is a vector with x, y, and z components. The “interptri” command is not deasigned to work with such vector data so you will have to interpolate each of the components separately. The proper way to do the interpolation would therefore be to first create matrices for Ex, Ey, and Ez from E and then calculate Ex_rect, Ey_rect, and Ez_rect separately. Let me know if that solves the problem.


#3

Dear Ahsan,

I do the same for the Ex, Ey, Ez and I still have the same problem (for instance my max of Ex is 1.38981e+006 while maximum of E_rectx is 9223372036854775808).

Here is the code I use:

electrostatics=getresult(“CHARGE::E_field”,“electrostatics”);
Ex = pinch(electrostatics.Ex);
Ey = pinch(electrostatics.Ey);
Ez = pinch(electrostatics.Ez);

x = pinch(electrostatics.x);
y = pinch(electrostatics.y);
z = pinch(electrostatics.z);

vtx = [x,z];
elements = electrostatics.elements; # connectivity matrix

kern = size(E);
Ne = kern(1);
Nv = kern(2); # Number of bias points
delta = 1e-9;

x_rect = linspace(min(x),max(x),500);
y_rect = linspace(min(y),max(y),500);
z_rect = linspace(min(z),max(z),500);

Ex = Ex(1:Ne,Nv);
Ey = Ey(1:Ne,Nv);
Ez = Ez(1:Ne,Nv);

Interpolate

E_rectx = interptri(elements,vtx,Ex,x_rect,z_rect); # interpolating n
E_recty = interptri(elements,vtx,Ey,x_rect,z_rect); # interpolating n
E_rectz = interptri(elements,vtx,Ez,x_rect,z_rect); # interpolating n


#4

Hi @SHSHAHIN, The “electrostatics.Ex” option was actually designed for FDTD and MODE and therefore they only work with rectilinear data and not with the finite element data of DEVICE. You will have to get Ex, Ey, Ez manually from E. The script can be like this:

electrostatics=getresult(“CHARGE::E_field”,“electrostatics”);
E = pinch(electrostatics.E);
kern = size(E);
Ne = kern(1);
Nv = kern(3); # Number of bias points [notice that kern(2) should be 3 for the three vector components]
Ex = pinch(E(1:Ne,1,NV)); # last bias point
Ey = pinch(E(1:Ne,2,NV));
Ez = pinch(E(1:Ne,3,NV));

Once you have Ex, Ey, and Ez you can calculate the interpolated components in the same as in your script.


#5

Hi @aalam,

I did the same code as you mentioned and my E_x, E_y, and E-z have a huge maximum value, much larger than what they are supposed to me. I attached my file once again:

electrostatics=getresult(“CHARGE::E_field”,“electrostatics”);
E = pinch(electrostatics.E);
kern = size(E);
Ne = kern(1);
#Nv = kern(3); # Number of bias points [notice that kern(2) should be 3 for the three vector components]
Ex = pinch(E(1:Ne,1)); # last bias point
Ey = pinch(E(1:Ne,2));
Ez = pinch(E(1:Ne,3));

x = pinch(electrostatics.x);
y = pinch(electrostatics.y);
z = pinch(electrostatics.z);

vtx = [x,z];
elements = electrostatics.elements; # connectivity matrix

x_rect = linspace(min(x),max(x),500);
y_rect = linspace(min(y),max(y),500);
z_rect = linspace(min(z),max(z),500);

Interpolate

E_rectx = interptri(elements,vtx,Ex,x_rect,z_rect); # interpolating n
E_recty = interptri(elements,vtx,Ey,x_rect,z_rect); # interpolating n
E_rectz = interptri(elements,vtx,Ez,x_rect,z_rect); # interpolating n

final-optimization.ldev (6.2 MB)

Please let me know if I’m doing anything wrong.

Shiva


#6

Hi @SHSHAHIN, I think what is happening here is that you have quite a few points in the rectangular grid which fall outside the region where you have finite element data available. If a point falls outside the region of the original data then the value at that point is set to Infinity (https://kb.lumerical.com/en/index.html?ref_scripts_interptri.html). You can avoid this problem by setting this value to zero (additional argument in the command, see the KB page mentioned above). The last three lines will then look like:

E_rectx = interptri(elements,vtx,Ex,x_rect,z_rect,0); # interpolating n
E_recty = interptri(elements,vtx,Ey,x_rect,z_rect,0); # interpolating n
E_rectz = interptri(elements,vtx,Ez,x_rect,z_rect,0); # interpolating n