-
-
September 14, 2022 at 4:02 pm
kemackay
SubscriberHello, 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 -
September 15, 2022 at 3:36 pm
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.
-
September 15, 2022 at 3:58 pm
kemackay
SubscriberHello, 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.
-
September 15, 2022 at 5:04 pm
Guilin Sun
Ansys EmployeeI 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.
-
- You must be logged in to reply to this topic.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- “Import optical generation” or “delta generation rate”?
- Why am I getting “process exited without calling finalize”, and how do I fix it?
- Error on Lumerical device
- Using a license file on a new license server
- Error: addfdtd is not a valid function or a variable name
- Ansys Insight: Diverging Simulations
- Ansys Insight: Transmission results greater than one
- Ansys Insight: About override mesh in FDTD: its use and settings
- Ansys Insight: Convergence issues in CHARGE
- Is there a Lumerical script command to output the Simulation and Memory requirements?
-
2656
-
2120
-
1345
-
1118
-
461
© 2023 Copyright ANSYS, Inc. All rights reserved.