Photonics

Photonics

Saving delta of two field profile monitors

    • kemackay
      Subscriber

      Hello, I am attempting to write a script that takes two field profile monitors (exact same dimensions) and takes the point by point difference between the two. I then want to save this delta field profile as a .mat file, and import this field as an input for a second simulation. My script appears to work correctly when I call the image() function in the code, the issue is when I try to save this delta field. The saved .mat file just reverts back to one of the two original field monitors, which is not the desired result.

      The following is my code:

      matlabload("OutputMonitor_MMI.mat");

      E3 = emeProfile.E;

      E3_x = emeProfile.Ex;

      E3_y = emeProfile.Ey;

      E3_z = emeProfile.Ez;

      x = emeProfile.x;

      y = emeProfile.y;

      z = emeProfile.z;




      matlabload("OutputMonitor_Ports.mat");

      E4 = emeProfile.E;

      E4_x = emeProfile.Ex;

      E4_y = emeProfile.Ey;

      E4_z = emeProfile.Ez;




      DeltaTE1_Ex = E4_x - E3_x;

      DeltaTE1_Ey = E4_y - E3_y;

      DeltaTE1_Ez = E4_z - E3_z;




      DeltaMagTE1 = sqrt((DeltaTE1_Ex)^2+(DeltaTE1_Ey)^2+(DeltaTE1_Ez)^2);




      image(y,z,DeltaMagTE1); #correct field is displayed here




      EM = rectilineardataset("EM fields",x,y,z);

      EM.addattribute("E",DeltaTE1_Ex,DeltaTE1_Ey,DeltaTE1_Ez);

      matlabsave("TestingDeltaNew.mat",EM); #the field saved here is not the same as the one in the image

       

    • Guilin Sun
      Ansys Employee

      "the saved .mat file just reverts back to one of the two original field monitors"

      Do you mean the dataset EM shows one of the original monitor data? or other data?

      I did not find anything wrong with the script. Please clear the data, and save it again. You can use Visualizer to check them before saving: https://optics.ansys.com/hc/en-us/articles/360034929873-addattribute-Script-command 

      Just curious, do the two monitors record data at different wavelength? otherwise for the same simulaiton file, no need to use two different monitors exactly at the same location with same size.

    • kemackay
      Subscriber

      Hello, the two monitors have the exact same y and z dimensions, but are located a very small distance away from each other on the x propagation axis (200nm). The waveguide cross-section changes between these two monitors so the goal is to see how the field profile changes in such a short distance. The wavelength is the same for both monitors.

      The dataset EM shows the original monitor data.

       

       

    • Guilin Sun
      Ansys Employee

      I did not find anything wrong in your script. You may try to create a matrix dataset, similar to vector dataset, and see if they are the same. You may need to clear the data again.  If there is no other script in between, there is no reason the data shows differently.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.