I am having a problem with scripting in the source mode. When I try to add the source mode and choose the mode for the source with updatesourcemode(2), it will not update the source. However, if I type the same command in the command line after selecting the source it will update the source. What am I doing wrong?
Hi. Have you tried adding an extra line of script to select the source first (by using the “select” command) before using the “updatesourcemode” command? Like this:
Yes, I have tried that, it doesn’t help. I can send you my code if you want.
That would be very helpful
Ok, I stopped working on that script for a while and I found a work around (I actually can just use fundamental mode anyway). So it is no longer in the state with that bug, though I never resolved it.
I have a simpler question now. How do I user select the mode for a port in an EME simulation? I can specify user select, but updatemodes and updatesourcemodes don’t work for this case.
Attached is the code for that. Run bS_draw first then bS_MODE. The place where I am talking about is e.g. line 50 where I can set mode selection but can’t figure out how to actually set which mode.
bS_draw.lsf (3.03 KB)
bS_MODE.lsf (1.93 KB)
My apologies for the delayed reply. I am afraid what you are trying to do here cannot be done using script commands alone. You can only choose the fundamental modes from the script environment. If you want to use some other mode (by choosing the “user select” option) then you will have to do it manually using the user interface (UI). The reason behind this limitation is that when you are using the “user select” option, you are free to choose any optical mode. However there is no way to know what the mode number of your intended mode is at all the ports. The only way you can confirm this is by manually calculating and inspecting the modes and then selecting them from the UI. Please note that the script will allow you to select the fundamental TE and/or TM mode directly so as long as you are using these modes you can perform the entire task using script. If you need to use some other modes then you will have to do it manually.
Please let me know if you need more information.
I am simulating a directional coupler and I am interested in obtaining the symmetric and antisymmetric modes of the two waveguide system (this is the code I sent you), which are the first and second TE modes of the system. It is always the same modes. I guess this is not possible?
I have talked with a few of my colleagues and they have also confirmed that unfortunately this cannot be done from the script currently. The only way you can use the first and the second TE modes at the ports is by manually calculating the modes and then selecting the desired ones from the UI. Please note that once you have selected the modes, you can save the file and then use it as a template which you can open up with the script and perform other operations. Let me know if that sounds acceptable. I will make a feature request so that this can be done from the script in some future release.
It is obviously preferable to us if we could script the whole thing. For example, sweeping the gap or output port width of the directional coupler requires me to redraw it, and therefore reselect the modes. So I cannot just run it without user input for example, even though I have some confidence of which modes will be the first and second TE modes. Or do you think the sweep can be done without this? I have not been using Lumerical very long and I haven’t used the sweep functions much. My script would redraw the structure and the EME solver.
Thank you for making the feature request.
Hi Sonia, my apologies for the late reply. I am not a 100% sure but you may still be able to sweep the gap or output port width while using a “template” file as I mentioned earlier. When you create the project file for the first time with a certain gap size and port width, calculate the modes in each port using the user interface and select the desired modes. Next create a (nested) parameter sweep to sweep the gap and width of the ports. If you keep the “auto update before analysis” option checked in the ports, then the solver will re-calculate the modes every time a new simulation is run for new parameter values. It will then select the modes that has the best overlap with your previously selected modes. Because of this feature, even though your structure will be changing, I believe the solver will still keep using the right modes at each point. So the new approach would be,
- Create the file one (using script) and manually select the modes in the ports.
- Create two nested sweeps to vary the gap and width of the ports.
- Run the sweep.
NOTE: You will have to parameterize the structure so that you can vary the gap and width from the sweep. To learn more about parameterization, look at this post: How to sweep a variable defined in “model” or “structure group” in a parameter sweep.