Script to find reflectivity more than 0.9 and corresponding phase values

    • Pankaj Kumar Sahoo


      I am following the metalens example to find the reflectivity and phase of nanopillars. I want to find the set of all periods and dutycycles that gives rise to reflections more than 90%. I am unable to write the command how to find the values ofperiod and dutycycle that give more than 90% and the corresponding phase values.

    • Pankaj Kumar Sahoo

      I am using the following script to plot Reflectivity and Phase extracted from period and fillfactor sweep. 

      sname = "period";
      period = getsweepdata(sname,"period");
      fillfactor = getsweepdata(sname,"fillfactor");
      S = getsweepresult(sname,"S");
      T = getsweepresult(sname,"T");
      R = getsweepresult(sname,"R");
      nd = length(fillfactor);

      # Phase in terms of period and fillfactor [S22_Gn for Reflection and S12_Gn for Transmission]
      phase = pinch(angle(S.S22_Gn),1,1); # the dimension of S22_Gn is [frequency,radius,height], 
      image(period*1e9,fillfactor,phase,"Period (nm)","Fill factor","Phase");
      setplot("colorbar min",-pi); setplot("colorbar max",pi);

      # Reflection in terms of period and fill factor
      R0 = pinch(R.R_Gn,1,1); # the dimension of R_Gn is [frequency,radius,height]
      image(period*1e9,fillfactor,R0,"Period (nm)","fillfactor","Reflection");
      setplot("colorbar min",0); setplot("colorbar max",1);


      After this I am unable to write script on how to map the phase and reflection to get the period and fillfaactors for which reflection is more than 90%.


      Please hel me.

    • Amrita Pati
      Ansys Employee

      Hi Pankaj,

      You can use the find script command to obtain the indices of all elements in R0 that have values greater than 0.9.

      ind = find(R0>0.9);

      However, this will return single index values of the desired elements. You would have to convert these single index values into multiple index (i,j) values, which is quite straightforward for a 2D matrix.

      More information on this conversion can be found on the following link:

      Once you have the (i,j) values, you can determine the required period and fill factor as period(i) and fillfactor(j) or vice versa depending upon the way you have defined the parameter sweep.


      Thank you.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.