Photonics

Photonics

Grating S parameters

    • djihad-amina.djemmah
      Subscriber

      I am using grating S-parameters to calculate the S-parameters, but I don't know how to get the value of the S-parameters in double precision, because when I retrievethe values, I only have 6 digits after the decimal point (see attachment).

      Could you please help me to have more digits after the decimal point (double precision).

    • Greg Baethge
      Ansys Employee

      Thank you for posting your question on the forum. There's a couple of different ways to change the precision used to display values. You can do it "globally" using format:
      format long;
      This will set the script interpreter to 16 digits of precision.
      Alternatively, you can also control the number of digits when converting numerical values to string with num2str, for example:
      ?num2str(pi, "%.35f");
      3.14159265358979311599796346854418516
    • djihad-amina.djemmah
      Subscriber
      Hello Thank you for your answer
      The problem I have, I don't know where I have to write "long format;", I am not very familiar with lumerical sript.
      In attachment, you will find a screenshot of my simulation, could you tell me where exactly I have to write "long format" to get the values of the S parameters with 16 digits of precision.

      I am waiting for your answer Thank you in advance
    • djihad-amina.djemmah
      Subscriber
      Hello I have tried several commands, but none of them work (see attachment).
      What I need exactly is to get "S-parameters" data with a precision of 16 digits, if it is possible could you give me the syntax I have to write in the prompt script.
      I have already read all the Lumerical documentation, but I still can't figure out what I need to write to get the data with a double presicion.
      Looking forward to your reply.
      Thank you in advance

    • djihad-amina.djemmah
      Subscriber
      I just realized that I attached the wrong file, you can find the right one here.
      The commands:
      nf=length(f);
      for(i=1: nf){
      str= num2str(f(i))+", "+num2str(T(i));
      write("tetfile.txt",str);
      }
      Works well with T and R monitors but not with S, with S I got this error :"Error: prompt line 2: in expression A(i,...), A must be a matrix".
      Could you please help me to solve this problem.
      Thank you in advance.
    • Greg Baethge
      Ansys Employee

      The issue is, S is a dataset, you can only use num2str on a scalar value or a 2d matrix. You can use the "." operator to access the values, for example:
      f = S.f;
      S21 = S.S21_Gn;
      Then the loop should work.
    • Greg Baethge
      Ansys Employee
      I just realized I forgot to answer one of the questions. "format long" should be placed at the start of the script, that way you are sure it was run before you start writing data.
    • djihad-amina.djemmah
      Subscriber
      Hello Thank you for your your help, with your explanations I managed to do it.
    • Greg Baethge
      Ansys Employee
      You're most welcome, :)
Viewing 8 reply threads
  • You must be logged in to reply to this topic.