-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GaussianBeam2DSource Bug Cases Found #2356
Comments
The refractive index Note that in the original implementation of the Lines 604 to 608 in 802257f
|
Just an update - I fixed the first issue regarding the material change. There was an extra factor of Z (impedance) on H during my normalization that shouldn't be there. Lines 902 to 903 in d29eadc
In addition, the resolution needs to be high enough to support higher epsilon. Lines 851 to 856 in d29eadc
Finally, I reformulated the way I use the polarization vector, because my previous method did not take into account the phases properly. This was the code before: Lines 905 to 914 in d29eadc
Now, in green2d, the polarization vector used in the formulation matches the user provided polarization vector for the electric source: p = np.zeros(3, dtype=complex)
p[0] = beam_E0.x
p[1] = beam_E0.y
p[2] = beam_E0.z
pdotrhat = p[0] * rhat[0] + p[1] * rhat[1]
rhatcrossp = rhat[0] * p[1] - rhat[1] * p[0] And for the magnetic source that is pointed orthogonal to the electric source: p = - np.array([
- p[2] * np.imag(kdir),
p[2] * np.real(kdir),
p[0] * np.imag(kdir) - p[1] * np.real(kdir)
])
pdotrhat = p[0] * rhat[0] + p[1] * rhat[1]
rhatcrossp = rhat[0] * p[1] - rhat[1] * p[0] I will create a PR for these changes, but am still trying to solve the final problem of the overflow. The hankel functions are returning nan's during overflow, which causes problems. |
Hi guys, I have an update on the issue with nan's and infs for high index. Maybe I'm missing something here, but the problem seems more fundamental than a normalization issue. Consider the beam with waist size The complex origin of the dipole is placed at At the origin Passing these arguments into jv, yv, hankel1, and hankel2 shows that this argument is too (imaginarily) large and the bessel/hankel functions break down. This argument is located at the beam waist and should have maximal amplitude. from scipy.special import jv, yv, hankel1, hankel2
>>> yv(0, +710j)
(nan+nanj)
>>> yv(0, -710j)
(nan+nanj)
>>> jv(0, -710j)
(inf+nanj)
>>> jv(0, +710j)
(inf+nanj)
>>> hankel1(0, +710j)
0j
>>> hankel2(0, -710j)
(-0+0j)
>>> hankel1(0, -710j)
(nan+nanj)
>>> hankel1(0, +710j)
0j Note that If anyone has any insights or thoughts, I'd love to hear them. Maybe there is some approximation for large arguments we can normalize analytically beforehand? |
You can always use the exponentially scaled Hankel functions |
This works well. It appears to be working now that I switched to the exponential Hankel functions and am careful to scale and normalize correctly for the hankel1 vs hankel2. I will create a new PR with the changes and a description of how I am performing the proper scaling. |
A few bugs were discovered regarding the new GaussianBeam2DSource implementation.
For example, as can be seen below, after changing the refractive index to 1.5, small issues arise and back propagation below the source region now shows up. I am unsure at this moment if this is an issue in the creation of the beam fields themselves, or in the call to equivalent source, but it appears that a factor of$n$ or $\epsilon$ is either missing or accidentally added.
Currently, as given here in equation 4.4, the equivalent current sources do not contain a factor of$\epsilon$ or $\mu$ , matching how it is currently implemented in MEEP.
This is because calling scipy.special.hankel produces enormous results (on the order of 1e120). When the beam waist is similar in size to the effective wavelength, the order of magnitude is low enough to avoid overflows. We likely need a clever way to fix this issue at this step (calling the hankel function).
The text was updated successfully, but these errors were encountered: