Closed oskooi closed 7 months ago
It turns out there was a bug in my unit test: I had neglected to include the index of the source medium when specifying bfast_k_bar
. The fix required changing:
bfast_k_bar = (np.sin(theta_rad), 0, 0)
to
bfast_k_bar = (self.n1 * np.sin(theta_rad), 0, 0)
It was also necessary to reduce the Courant
parameter otherwise the fields were blowing up.
With these changes, the reflectance values match those from the Fresnel equations. The relative difference also decreases with increasing resolution, as expected.
Adds a unit test for broadband sources at fixed angle in a cell with periodic boundaries (BFAST). This is to be merged after #2609. The test is an extension of
python/tests/test_refl_angular.py
and involves verifying that the reflectance from an interface of two lossless, frequency-independent dielectrics (index of 1.4 and 3.5) given a broadband input planewave at normal and oblique (20.6°) incidence with P polarization matches the Fresnel equations. There are two separate runs: without and with the BFAST feature.There is a large and unexpected discrepancy in the BFAST results and the Fresnel equations for the case of oblique incidence. See the output in 2b below. This required increasing the error threshold by nearly two orders of magnitude compared to the without BFAST case in order for this test to pass:
This discrepancy did not diminish by reducing the
Courant
parameter. In fact, the choice of theCourant
parameter had practically no impact on the results. As such, it would be good to investigate whether it is actually necessary to reduce the Courant as the oblique input angle increases. The results for normal incidence are fine.The results in 2b require more investigation. There could a bug in (1) the way I am using this feature in the test (which is based on its use in the function
planar_reflectance
in the colab in #2609) or (2) the implementation in #2609.1. Without BFAST
a) incident angle = 0°
b) incident angle = 20.6°
2. With BFAST a) incident angle = 0°
b) incident angle = 20.6°
cc @Dan2357