I wrote a little function to create such a source, and it does work reasonable well in a refractive slab (2TE, 2 TM modes). There is no emission into guided modes other than the one selected (suppression around 10^7), and also fairly low emission into radiative/lossy/freespace modes (about 1-5%). Either magnetic or electric dipole injection is possible, with the dipoles oriented along x,y, or z and the line oriented along x,y,z as well.

The amplitudes of the dipoles just follow the mode amplitudes, without any rescaling based on discretization or material.

There are some issues with convergence, but this may well be due to suboptimal PML configuration.

Unfortunately, it is not possible to implement this into a self-updating analysis group, since the setup script of the analysis group is not able to retrieve mode profile information. So for any change, you have to delete the source completely and recreate it with the script function.

The script is appended as the following corrupted jpg file - rename it to .lsf to retrieve the script.

This is not an image, but an .lsf file. Download and rename