best overlap and optimize overlap position


I am trying to calculate the optimum overlap with the fundamental mode of an SMF-28 (saved from project file provided here:
I am sweeping the waveguide geometry, and using the bestoverlap function to find the mode with the best overlap with the fiber’s fundamental mode.

Then I use: overlap(best_overlap_mode, fiber_mode, 0, core_center, 0) to re-center the fiber mode, saved in the d-card, to the center of my waveguide. However, this position is not always the best position of the fiber mode as clicking on the ‘optimize position’ in the overlap analysis tab may produce a better overlap figure at a different fiber-center coordinates/shifts.

My first question is that I can use the optimizeposition function to get this improved overlap, is this correct?

My second question is: the bestoverlap function returns a string containing the name of the mode with the best overlap, but the optimizeposition function expects, as its first argument, the number of the mode. Does this mean that I need to do some string processing in order to pass the mode found from bestoverlap to optimizeposition, or is there a more direct way?

Thank you,



  1. Yes, this is what the optimizeposition command is for. Note, you may have to figure out the plus and minus signs of the shift. I will suggest you to do some sanity check on this.

  2. Correct. The bestoverlap returns a string while the optimizeposition command needs a number. You can make use of the substring and the str2num commands to do the “conversion”. The substring command will find the string you want. The str2num command will convert that to a number.

That’s what I thought, thanks a lot.

All the best

1 Like