Albi.Pani
Subscriber

I have found the answer here:

Questions about the calculation of the cross-polarization conversion efficiency of metasurface (ansys.com)

Code:

switchtolayout;
setnamed("FDTD","mesh accuracy",3);
setnamed("grating_s_parameters","polarization angle",0);
setglobalmonitor("frequency points",50);
run;
S_pol1 = getresult("grating_s_parameters","S_polarization");
refractive_index_1=1;
refractive_index_2=1;
S12_x=S_pol1.S21_Gn;
S12_x=S12_x/sqrt(refractive_index_1/refractive_index_2);
switchtolayout;
setnamed("grating_s_parameters","polarization angle",90);
run;
S_pol12=getresult("grating_s_parameters","S_polarization");
S12_y=S_pol12.S21_Gn;
S12_y=S12_y/sqrt(refractive_index_1/refractive_index_2);
f=getdata("grating_s_parameters::T","f");
S12_L=(S12_x+1i*S12_y)/sqrt(2);
S12_R=(S12_x-1i*S12_y)/sqrt(2);
S12_RL=(S12_L(:,1)-1i*S12_L(:,2))/sqrt(2);
S12_RR=(S12_L(:,1)+1i*S12_L(:,2))/sqrt(2);

effect=abs(S12_RL)^2;
effect2=abs(S12_RR)^2;

plot(c/f*1e9,effect);
plot(c/f*1e9,effect2);