TAGGED: -2d-materials-and-metals
-
-
March 17, 2023 at 5:43 pm
PENG LI
SubscriberHi, I am trying to duplicate the apodized grating from https://optics.ansys.com/hc/en-us/articles/360042800573-Inverse-Design-of-Grating-Coupler-2D-
I came across an issue when adding the sweep result. In the official document (available from the link above). The sweep result T is defined in the model: analysis as:
temp = getresult("fom_exp", "expansion for fom");
T = -temp.T_backward;
I followed the same definition in my lsf file, but it kept telling me that Can not find result 'expansion for fom' in the result provider 'fom_exp'.
I have checked the difference between the official file and my file, and to be honest, I did not find any term named "expansion for fom" in the original file either.
Can someone help me find what did I miss or mistake here?
Thank you for all the help and suggestion.
Yours sincerely
Peng
-
March 17, 2023 at 9:21 pm
-
March 19, 2023 at 11:49 am
PENG LI
SubscriberHi Amrita
Thank you so much for your reply. I actually cannot find it from the GUI. Indeed, I cannot find it in the official file either. (The official file can be accessed via https://optics.ansys.com/hc/en-us/articles/360042800573-Inverse-Design-of-Grating-Coupler-2D-). Below is the screenshot of the mode monitor from the official file, there is no expansion for fom.
What I have done: first I added the description below under the model and then I can add this result into sweep manually and the result is fine.
temp = getresult("fom_exp", "expansion for fom");
T = -temp.T_backward;
So it seems that the results do exist and can be used for the sweep. But again it does not show in the GUI. From my lsf, I have linked the " fom " monitor to this mode expansion monitor. Below is the screenshot of my lsf and the setting inside the mode expansion monitor.
I reckon it will automatically generate the expansion for fom. Or are there any settings I should pay attention to?
Thank you again for your help! I am looking forward to hearing from you soon.
Yours sincerely
Peng
-
March 20, 2023 at 4:42 pm
Amrita Pati
Ansys EmployeeHi Peng,
Thank you for providing more information. Correct me if I am wrong, my understanding is that you want to obtain the “expansion for fom” results for all sweep parameters after the sweep is completed. In that case you will have to record this result during the parameter sweep as shown below or using the addsweepresult script command:
Then you can use getsweepresult script command to get these results. It should also show up in the GUI in results. Please let me know if you have more questions.
Regards,
Amrita -
March 21, 2023 at 1:14 pm
PENG LI
SubscriberHi Amrita
Thank you for your reply. I totally agree with you that I need to add the result into the sweep setting. However, my problem is that I cannot find this result in the first place.
In the official file, they define the parameter T under the model analysis, and T is defined as below:
temp = getresult("fom_exp", "expansion for fom");
T = -temp.T_backward;
And my understanding is that the result is from fom_exp : expansion for fom.
And here comes my issue: there is no expansion for fom underneath the fom_exp. Therefore I cannot add it into the sweep result because it will keep giving me error like this:
But I cannot find out where to set up the expansion for fom. As you mentioned before, there is actually no such a term in my GUI. Funny thing is that if I followed the setting in the official file, which is defined T in model analysis and used exactly the same code shown above, it worked. Lumerical will find out the expansion for fom and get T.
To conclude it, I cannot access the results from expansion for fom via normal lsf code because it will give me an error that cannot find the result expansion for fom. But if I manually define T in the model analysis, it will work. To make it clearer, my problem should be how can I obtain expansion for fom monitor in mode expansion monitor like in your screenshot? I reckon if I can see it in the GUI then I can access it via normal code.
I apologize for my poor expression and fingers cross i have expressed my problem clearly to you.
Thank you again for the help.
Yours sincerely
Peng
-
March 21, 2023 at 3:12 pm
Amrita Pati
Ansys EmployeeHi Peng,
Thank you for sharing more information. That is unusal. You should be able to add the expansion for fom (to the sweep result) result using the addsweepresult script command. Once you add it and run the sweep then you will see it in the GUI Results. I was able to do so in the same file from the article you mentioned above. What happens when you use the addsweepresult command? Do you also get the same error? In the first screenshot that you shared, you were using getresult which resulted in the error message.You have to use addsweepresult.
You can also do it manually in the Edit Parameter Sweep window? Can you find it in the Parameter Sweep window as shown below?
Regards,
Amrita -
March 21, 2023 at 3:33 pm
Amrita Pati
Ansys EmployeeHi Peng,
If you wish to do it by script, in your file adding sweep.lsf, I would suggest you to replace Line 36 to 41 by the following code and then run the script:sweep_result = struct;
sweep_result.Name = “fom”;
sweep_result.Result = “::model::fom_exp::expansion for fom”;
addsweepresult(“sweep source position”,sweep_result);
runsweep(“sweep source position”);
result = getsweepresult(“sweep source position”,”fom”);
T = result.T_backward;Please let me know what happens when you do this. Thank you!
Regards,
Amrita -
March 21, 2023 at 4:29 pm
PENG LI
SubscriberHi Amrita
Thank you so much for the quick reply. I changed my lsf as you suggested and it is working.
However, I came across a new issue.
In the official file, the final result I need is adding a minus sign and _backward suffix to the data from the expansion for fom, as shown below.
temp = getresult("fom_exp", "expansion for fom");
T = -temp.T_backward;
I actually cannot understand what _backward and minus sign exactly mean. (I tried to search _backward in the script library but I cannot find it).
Anyways, the new problem is that I set the original data as temp, and wanna do the same change to the temp and use it as the final result into the sweep, the code is as shown as below:
result_1 = struct;
result_1.Name = "T";
temp = "::model::fom_exp::expansion for fom";
result_1.Result = -temp_backward;
addsweepresult("sweep source position", result_1);
And it will give errors like the screenshot below:
I reckon it is related to the minus sign and _backward suffix. What do these two functions exactly do, and how may I adjust to correct this error?
Thank you so much for your help!
Yours sincerely
Peng
-
March 21, 2023 at 5:10 pm
Amrita Pati
Ansys EmployeeHello Peng,
A few things to note here:
1. The mode expansion monitor provides a number of expansion results including T_backward. T_backward is the backward (the direction of the negative coordinate axis) transmission into the selected modal field(s). As it is in the negative direction, there is a negative sign by default. If you just want the portion of power and are not concerned about the direction then you can use – sign at the front of the T_backward result and it will give you the corresponding positive values as has been done in the original script. In the code I sent it can be done by modifying the last line as follows:
sweep_result = struct;
sweep_result.Name = “fom”;
sweep_result.Result = “::model::fom_exp::expansion for fom”;
addsweepresult(“sweep source position”,sweep_result);
runsweep(“sweep source position”);
result = getsweepresult(“sweep source position”,”fom”);
T = -result.T_backward;The code above will give the same result as the code in the original file on the website.
For more information on Mode Expansion Monitors and the various results it calculates, please refer to the following links:
Monitors – Mode Expansion – Results & Applications
Monitors – Mode Expansion – Setup & Tips
Mode expansion monitor – Simulation object
Using and understanding Mode Expansion Monitors
2. You can not use the following code:
i. result_1 = struct;
ii. result_1.Name = “T”;
iii. temp = “::model::fom_exp::expansion for fom”;
iv. result_1.Result = -temp_backward;
v. addsweepresult(“sweep source position”, result_1);
I assume you wanted Line iv. to be iv. result_1.Result = -temp.T_backward; As temp_backward variable is never used before in your code and as a result you get the error. However, even making the above code change would result in an error. Since in addsweepresult you can only add the monitor results that are available, which include the following:
For including any other result you have to output this result from the model (or Structure/Analysis group) like it was done in the original file in the Analysis-Variables Tab of model:
If you want to do it in .lsf file and not use the model, I would suggest you to record the complete set of results from “expansion for fom” and access the T_backward result with the negative sign using the code I have provided. Hope that helps.
Regards,
Amrita
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

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: addfdtd is not a valid function or a variable name
- Error on Lumerical device
- Using a license file on a new license server
- Ansys Insight: Transmission results greater than one
- Ansys Insight: Diverging Simulations
- Ansys Insight: About override mesh in FDTD: its use and settings
- Is there a Lumerical script command to output the Simulation and Memory requirements?
- Ansys Insight: Convergence issues in CHARGE
-
3862
-
2639
-
1859
-
1254
-
602
© 2023 Copyright ANSYS, Inc. All rights reserved.