-
-
May 26, 2023 at 8:27 pm
Mateus Corato Zanarella
SubscriberHi,
I cannot figure out how to programatically add a frequency monitor to an existing mode expansion monitor. This is particularly problematic when creating the mode expansion monitor using a construction script in model, because then we cannot manually alter the expansion monitor.
Could someone please tell me how to do it?
Thanks,
Mateus -
May 29, 2023 at 5:42 pm
Amrita Pati
Ansys EmployeeHi Mateus,
You can use the setexpansion script command to select a DFT monitor for expansion. For example, if the name of the DFT monitor is "dft", then you can use the following code:setexpansion("out","::model::dft");
Please let me know if you have any further questions.Â
Regards,
Amrita -
May 31, 2023 at 2:11 pm
Mateus Corato Zanarella
SubscriberThank you for your answer, Amrita! That command worked.
I have another question: now once the simulation is done and I want to calculate the expansion results to then grab them using getresult, how can I do it programmatically? Manually I can do it by right-clicking, but I'd like to to it programmatically in a loop.Â
Thanks again for your help! -
May 31, 2023 at 11:00 pm
Amrita Pati
Ansys EmployeeHi Mateus,
You are welcome!
Generally, if you have a mode expansion monitor called "Exp" and the expansion results are "out" then you use the following code:
out = getresult("Exp","expansion for out");
But if you are using loop, it could be a bit tricky since the expansion results are a dataset. I believe the simplest approach would be to save the individual results of the output (expansion results) in different arrays. And if you wish, you can combine these results to form a dataset after the loop ends.
For example, if I am only interested in T_forward and T_backward results for 2 iterations and the data is collected at a single wavelength then I can use the following code:clear;
T_forward = matrix(2);
T_backward = matrix(2);
for(i = 1:1:2){
switchtolayout;
run;out = getresult("Exp","expansion for out");
T_forward(i) = out.T_forward;
T_backward(i) = out.T_backward;
}
Â
Here, I just have 2 reptitions and a single wavelength, which is why I initialize T_forward and T_backward as matrix(2).
I believe you can also use the sweep utility instead of the loop. The sweep utility automatically reconstructs dataset so you can easily access all the results at one place. Please let me know if you have any further questions.Â
Regards,
Amrita
-
- The topic ‘Programmatically selecting Frequency Monitor for Mode Expansion Monitor’ is closed to new replies.
-
4167
-
1487
-
1363
-
1194
-
1021
© 2025 Copyright ANSYS, Inc. All rights reserved.