lbolla / EMpy

Electromagnetic Python
MIT License
194 stars 83 forks source link

Enter guess for n_eff? #3

Closed DanHickstein closed 8 years ago

DanHickstein commented 8 years ago

Hi there! I just started using EMPy - it looks really cool. I am interested in calculating waveguide modes, so I have been playing around with the VFDModesolver. It looks pretty similar to the matlab code "wgmodes", but I noticed that there in this version, there was no place to enter the "guess" for the refractive index as there is in wgmodes, which has the parameter "guess", described as:

% guess - scalar shift to apply when calculating the eigenvalues.
%     This routine will return the eigenpairs which have an
%     effective index closest to this guess

Additionally, I was wondering if there were other significant ways that VFDModesolver performs differently from wgmodes. As I learn more about the VFDModesolver, I may add some docstrings and comments - would that be something that you would be receptive to?

Thanks!

Dan

lbolla commented 8 years ago

It looks like scipy.linalg.sparse.eigs allows to specify v0 as the initial guess. So, I believe it's enough to pass in the guess value here: https://github.com/lbolla/EMpy/blob/master/EMpy/modesolvers/FD.py#L764

It you want to go ahead and submit a pull request for the fix I am more than happy to merge it. Same for additional docs!

DanHickstein commented 8 years ago

So, now that I look WGMODES more closely, I see the following lines:

shift = (guess*k)^2;
[v,d] = eigs(A,speye(size(A)),nmodes,shift,options);

So, it seems like the guess value is passed into eigs in much the same way as the sigma parameter in scipy.linalg.sparse.eigs

So, probably we need to pass the guess as the sigma parameter.

lbolla commented 8 years ago

Sounds right.

DanHickstein commented 8 years ago

This is addressed by #5, so I will close this issue.