How to selectively pass values to only some parameters of a function?

NsadikNsadik Member Posts: 4

Hello,

I am looking for a way to selectively pass values to some of the parameters of a built-in function(of lumerical script language), and let other parameters use their default values. For example, 'farfield3d' has the following syntax:

out = farfield3d("mname",f, na, nb, illumination, periodsa, periodsb, index, direction); [https://support.lumerical.com/hc/en-us/articles/360034930693-farfield3d-Script-command]

I want to use the first 4 and last one parameters(i.e. "mname",f,na,nb and direction) and let the remaining parameters use their default values. But I do not understand how to skip these unnecessary parameters. I tried to use something like:

out=farfield3d("mname",f,na,nb,direction=direction_val); but that didn't work.

Any help is highly appreciated.

Best Answer

  • gsungsun Posts: 1,376Ansys Employee
    Accepted Answer

    The standard use of this function is out = farfield3d("mname",f, na, nb, illumination, periodsa, periodsb, index, direction);

    so if some parameter is missing, the function may not recognize it. Please use the full default values. The previous reply was to correct the "=" usage inside the function.

Answers

  • gsungsun Posts: 1,376Ansys Employee

    Sine farfield3d is the built in function, I strongly suggest that you give all the new parameter values before the default ones. Inside the function, you cannot use direction=direction_val. Instead you can use

    out=farfield3d("mname",f,na,nb,direction_val)

    Please try and let me know if you have questions.

  • NsadikNsadik Posts: 10Member

    Thanks for replying, Mr. @gsun . As you have told to use : out=farfield3d("mname",f,na,nb,direction_val); I tried to use: out=farfield3d("mname",f,na,nb,-1) where -1 is the value of 'direction' parameter.

    But I got this error message: Error: in farfield3d, the illumination pattern requested was not understood, it can be either 1 or 2

    I think lumerical thought -1 was the value passed to the 5th parameter of farfield3d function called 'illumination'.

    I am sharing the code snippet I am struggling with, so that you can guide me better:

    m="monitor"; # Monitor name

    res = 501; # projection resolution

    freq_pt=25; #no. of frequency points at which farfield is calculated

    freqindex=1:freq_pt;

    E2 = farfield3d(m,freqindex,res,res,-1);


    Thanks for all your help and suggestions.

  • NsadikNsadik Posts: 10Member

    Thanks for keep helping me. I have understood what you are saying and now I am using all the parameters including the default values.

Sign In or Register to comment.