

April 12, 2022 at 6:37 am

April 13, 2022 at 5:00 pmKhashayar GhaffariAnsys EmployeeHello,
In general when working with variables saved from the visualizer, it is helpful to use the “.” operator to find all the related parameters and attributes; when writing “variable+’.’” in the script prompt, the autocomplete feature will show these quantities in bold.
For example here you have probably used a command like:charge = getresult("CHARGE","charge"); Jn = charge.Jn;
To define the current density matrix.
Now by starting to write “charge.” in the script prompt you will see that t (time), and x,y,z (coordinates) are other related attributes. For example try:T = charge.t; X = charge.x;
Using the size of these new matrices you can tell what each dimension of your original Jn matrix corresponds to.
In the case of a 2D transient simulation the three dimensions correspond to coordinates (XY), the time steps (t), and the component of the current density (x, y, or z).
Best regards 
April 15, 2022 at 6:04 amMariah HaSubscriberThank you for the reply. The matrix I got for Jn is [7836 , 3 , 61] so if I follow your description, the "3" should be the time steps? an "61" are all the current density values ?

April 19, 2022 at 3:44 pmKhashayar GhaffariAnsys EmployeeHi Please check the number of your time steps by referring to the newly created T matrix (according to my previous response). I can't check your project but I suspect 7836 corresponds to current density values, 61 to time steps, and 3 to density component (direction).

April 21, 2022 at 1:37 pmmmarchSubscriberHi,
I had a similar question and have extracted charge.x and charge.z (I have a 2D Ynormal simulation region). Both of these have the dimensions as shown below
So for Jn I think it's like this: 133261 is the amount of nodes, 31 is the amount of voltage steps, 1 is because I only have them at one moment in time(?) and 3 because I have an x, y and z. Is this correct?
If so, how are the nodes/values structured in my X, Y or Z variable?
Best regards

April 21, 2022 at 6:20 pmKhashayar GhaffariAnsys EmployeeHi,
As you suggested, the X, Y, Z matrices indicate the coordinate of the mesh points (nodes). A row number corresponds to the same point for each of them so they can determine the coordinates of a reported result, here current density.
Best regards

April 22, 2022 at 8:41 ammmarchSubscriberHi,
Thanks for quick response. So how do I know where the origin is?
And since I have just column vectors with size 133261, how do I know how many nodes there are every direction in my structure? For example say the x direction is horizontal here. If the most left node at a fixed z and y coordinate is x=0 then what is the x coordinate of the most right node?

May 11, 2022 at 11:10 pmKhashayar GhaffariAnsys EmployeeHi,
You would have the same number of nodes in all directions. So here you have 133261 nodes, meaning there will be 133261 coordinates for x, y, and z.
If the left most node is x = 0, the most right one will be equal to width of the simulation region in x direction. You can also use the min and max commands (and apply them to x,y, and z) to find how much your nodes span in each direction.
Best

May 18, 2022 at 6:14 amMariah HaSubscriberHello,
The answers are still not clear . I am trying to plot J vs x , because having a vector J [133261,3,1] is not meaningful and we can not extract useful knowledge from such vector in the way it looks .
Please help me plot J vs x , what lines should I write exactly because what I wrote did not give me the wanted curve.

May 18, 2022 at 7:17 ammmarchSubscriberHi mariah
I had the same question/problem. I think that it is probably easier if your try to process the data and make your plots in Matlab or Python. I use Matlab to interpolate the data, creating a grid with in each node the interpolated value of J. Once you have this you can simply plot J versus x or z. Here's a snippet of the code I use to do this:
[xq,yq] is the grid I want to have my interpolated J values in
x and z are the vectors I obtained from Lumerical
each column of Jn_ contains the values of Jn in each node for one voltage step,
and here is the explanation of the griddata function: https://www.mathworks.com/help/matlab/ref/griddata.html

May 18, 2022 at 8:12 amMariah HaSubscriberHi mmarch ,
Thank you very much .This is what I am looking for. However, just one more thing, this gives me the current density in a 3d plot although I am looking for a 2D plot where J is in the vertica laxis and x is in the horizontal axis . I tried with "plot" in MATLAB but did not work. Can you help ?
Regards.

May 18, 2022 at 8:29 amMariah HaSubscriberHi mmarch,
Can you please explain why you multiply by e5 in the meshgrid ? If the structure is for example from "2.5 microns " to "2.5 microns " in Lumercical, then may be we should multiply by e6 to get meter right ? Please correct me if I am wrong.

May 27, 2022 at 1:53 pmmmarchSubscriberSo the result of the interpolation gives you a matrix with the value of Jn in each point of the grid. If you now only want to get the current density as a function of x you just need to take only a single column/row (whichever represents the change of x values) and plot this vector against the x coordinate of your mesh grid.
And yes, you are correct, you should use 1e6 to have the coordinates in m

May 27, 2022 at 7:53 pmKhashayar GhaffariAnsys EmployeeThank you for commenting this. Please let me know if you have further questions.
Best regards

May 27, 2022 at 8:44 pmMariah HaSubscriberThank you all for your assistance and answers. So the only way to plot Jn vs x is by postrocessing it with meshgrid in Matlab? Can Lumerical provide a monitor for J similar to the electric field monitor for more simplicity, in the future ? I am now able to plot Jn vs x in matlab but the meshing step is tricky because you can end up taking more mesh nodes than the initial vector coming from lumerical , you can also end up using a finer mesh on y and wider on x , and this affects the accuracy of the graph .

 You must be logged in to reply to this topic.
Simulation World 2022
Check out more than 70 different sessions now available on demand. Get inspired as you hear from visionary companies, leading researchers and educators from around the globe on a variety of topics from lifesaving improvements in healthcare, to bold new realities of space travel. Take a leap of certainty and check out a session today here.
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
 Ansys Insight: Diverging Simulations
 Ansys Insight: About override mesh in FDTD: its use and settings
 Error: addfdtd is not a valid function or a variable name
 Ansys Insight: Transmission results greater than one
 Ansys Insight: Convergence issues in CHARGE
 Is there a Lumerical script command to output the Simulation and Memory requirements?

2048

1730

965

754

415
© 2022 Copyright ANSYS, Inc. All rights reserved.