Export electric field distribution image with DGTD script

NusoviNusovi Member Posts: 3


I am working with DGTD in Lumerical and I am using a script to help me obtain several results. I want to represent the electric field values obtained with the simulations. My aim is that the scipt calculates the electric field in the simulation region and then I can export a figure with the electric field distribution. I would like to automatically export the figures that I can see in DGTD>monitor>Visualize>fields when I run DGTD simulation and obtain an image like the one shown bellow. I have a code that works for the FDTD but the data output of the DGTD is different and I cannot manage to do so:

lambda=785e-9;temp_E1 = getresult("DGTD::monitor2D","fields"); #Obtaining the datalamb = temp_E1.lambda; #vetor containing the wavelengths

n = find(lamb,lambda); #search the index of the desired wavelength

temp_E2=pinch(temp_E1.E2,2,n); #Compute E^2 and extract E at the desired lambda     

temp_str="ElectricField.png"; #name the figure

exportfigure(temp_str); #Export the figure

Thank you very much!


  • greg_baethgegreg_baethge Posts: 154Ansys Employee

    Hi @Nusovi,

    Thank you for posting your question. Doing this with DGTD is a bit harder than FDTD as the data is on an unstructured mesh. In FDTD, we can use "image" to plot the image and then export it with "exportfigure".

    To do the same with the field from DGTD, you will have to interpolate the data from the unstructured mesh to a rectilinear grid using interptet or interptri. Once the data is on a rectilinear grid, you can plot it and export it in the same way as in FDTD.

    Let us know if you have any question.

Sign In or Register to comment.