We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Photonics

Photonics

Topics related to Lumerical and more.

Source with amplitude and phase in INTERCONNECT

    • pengzheng97
      Subscriber

      Hi,

      I encountered a problem when using INTERCONNECT. I want to verify my simulation results in matlab, so I need to input an optical signal, including amplitude and phase. However, I tried the 'Scripted Optical Source' module, and used the script as shown below, and the txt file content is also as shown below. The signal obtained does not contain complex numbers, and there is no phase information.
      How should I solve this problem? Can I use other modules? As long as I can get the optical signal containing amplitude and phase that I need, it will be fine.

      Thank you very much and look forward to your reply!

    • Artemis Karvounis
      Ansys Employee

      Hello,

      this is going to work if you use the script file editor and define what values the scripted element should expect. For example:

      #Write file
      filename = "optical_signal_test.txt";
      src=zeros(4, 3);
      src(:,1) = linspace(0, 4e-9, 4); # time
      src(:,2) = linspace(0,50,4); # real part of signal
      src(:,3) = linspace(0,0.5,4); # imaginary part of signal
      write(filename,num2str(src), "overwrite");
      # Apply script to element
      script = "signal = readdata('optical_signal_source.txt'); output_real = interp(signal(:,2), signal(:,1), TIME); output_imag = interp(signal(:,3), signal(:,1), TIME); OUTPUT = output_real + 1i*output_imag;";
      setnamed("SOURCE_1", "script", script);
       

      Alternatively, you can directly import the txt data, which will contain seperate columns for the time, the real part of the signal, and the imaginary part of the signal. Here's an example:

      0    0    0
      1.33333e-09    16.6667    0.166667
      2.66667e-09    33.3333    0.333333
      4e-09    50    0.5

      It will ignore any lines in the data file that start with a letter. More details on how Lumerical reads txt files can be found here.

      After you run the interconnect file you should get both the real and imaginary part of your imported source with the oscilloscope(OOSC_1: plot format: rectangular)

      I hope this helps. 
       
      Best Regards,
      Artemis

      • pengzheng97
        Subscriber

        Thank you for your patient answer and professional examples. I completely solved this problem with your method and learned how to use readdata.

        Thank you very much! Have a good day!

        😄😄

Viewing 1 reply thread
  • You must be logged in to reply to this topic.