facebookresearch / fmmax

Fourier modal method with Jax
MIT License
101 stars 11 forks source link

Ensure no NaN in gradient with vector formulation and uniform permittivity #73

Closed mfschubert closed 10 months ago

mfschubert commented 10 months ago

Current vector field formulations can lead to NaN gradient when the permittivity is uniform. Here, we adjust how the special case of uniform permittivity is handled, which seems to resolve the issue.

A new test is added to test_grad.py file, which would have failed previously but now passes.

Tests for several examples are adjusted to run at higher resolution (i.e. higher N) so that they (hopefully) become less sensitive to small changes in the code. Results for reasonable N are essentially unchanged, as seen in uLED efficiency plot below. These can be compared to the figure in #70.

image

smartalecH commented 10 months ago

LGTM!