Script for update source mode

#1

Hi,

I read from an old post that it is not possible to select modes by scripting. I have tried to insert the below commands in my script and it gave me wrong result. But, when I execute the same commands in the command window, it gives correct mode index. My question is that is there any way to select higher order modes by scripting. I am sweeping some parameters so manually selecting modes is really cumbersome.

select(“mode source”");
neff_source = getresult("“mode source”, “neff”);
?neff_source.neff;

#2

Your script should work. You need to select the number of mode of interest in the updatesourcemode script command:

select("mode source");
neff_source = getresult("mode source", "neff");
?neff_source.neff;


Please elaborate what were the wrong results that you obtained in your scripts.

#3

Hi @bkhanaliloo,
Let’s take this simple example: geometry_tilt_RWG.lsf (9.6 KB)

I am selecting ‘mode 1’ (line 259) and expanding for the ‘mode 1’ (line 357) but I get different T_backward and T_forward than selecting these modes manually. Also, the script for finding the neff for mode source is giving some strange index.

#4

I am not seeing any problem with updatesourcemode or updatemode commands. They correctly modify the mode of interest.

The neff results also obtained from mode source is correct:

I am not sure what was the problem here. Please elaborate on your problem and I will be happy to be of a help.

#5

Hello @bkhanaliloo,
It works fine in command window but when I use the set of commands in the script file and run that, I get wrong index. Please take a look here:

#6

Dear @nouman.zia

This is because you calculate the mode before setting the wavelength span and theta. You can use a code like below instead:

select("mode source");

set("wavelength start", 1.90e-6);

set("wavelength stop", 2.0e-6);

set("theta", -theta);