TAGGED: interconnect, source
-
-
May 12, 2025 at 2:03 am
pengzheng97
SubscriberHi,
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!
-
May 15, 2025 at 12:36 pm
Artemis Karvounis
Ansys EmployeeHello,
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-
May 16, 2025 at 1:52 am
pengzheng97
SubscriberThank 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!
😄😄
-
-
- You must be logged in to reply to this topic.
-
3049
-
971
-
905
-
858
-
792
© 2025 Copyright ANSYS, Inc. All rights reserved.