Ansys Learning Forum Forums Discuss Simulation Photonics simple question regarding S-parameter data extraction coding. Reply To: simple question regarding S-parameter data extraction coding.

Amrita Pati
Ansys Employee

Hi Jeong Hee,

I think you can not specify the operation in visualize using script. Either you have to create a new dataset with the squared values, and then visualize that dataset. Or you can simply plot the square values using the plot script command and then use write to save the values into a text file. I wrote a sample script to plot data and write them into text file, that might be useful for your case:

S_para= getsweepresult("S-parameters","S parameters");
lambda = S_para.lambda;
S_11_2 = abs(S_para.S11)^2; #_2 after S_11 is just to indicate that it's squared
S_12_2 = abs(S_para.S12)^2;
S_21_2 = abs(S_para.S21)^2;
S_22_2 = abs(S_para.S22)^2;

plot(lambda,S_11_2);
holdon;
plot(lambda,S_12_2);
plot(lambda,S_21_2);
plot(lambda,S_22_2);
holdoff;

write("S_param.txt","S11_2: "+ num2str(S_11_2));
write("S_param.txt","S12_2: "+ num2str(S_12_2));
write("S_param.txt","S21_2: "+ num2str(S_21_2));
write("S_param.txt","S22_2: "+ num2str(S_22_2));

 

Here's a screenshot of the figure window and the created text file:

 

Let me know if you have any questions.

 

Regards,
Amrita

Â