NanoComp / mpb

MIT Photonic-Bands: computation of photonic band structures in periodic media
GNU General Public License v2.0
165 stars 89 forks source link

Slight sanity improvement to interface detection in `mean_epsilon_func` #128

Closed thchr closed 4 years ago

thchr commented 4 years ago

While working on #127, I found that mean_epsilon_func occasionally identified too many interface points, corresponding to voxels where the fill value of one of the materials is zero. I figured the most consistent thing to do would be to just treat these situations as homogeneous, and moreover to set a threshold at the tolerance tol used to compute the filling fraction in the first place.

stevengj commented 4 years ago

The CI failure is new — looks like one of the frequencies in the test has changed slightly because of this averaging change?

thchr commented 4 years ago

On second thought, I'm not completely convinced this is worthwhile: it adds a check to all (~O(res^2)) interface voxels , just to weed out a few (~O(res); in practice, a few handfuls at most) errant voxels. In the case where fill is exactly 1 or 0, the voxel permittivity obviously isn't affected one way or the other. Conversely, when fill is below tol or above 1-tol, I suppose it is at least as consistent to just proceed with the Kottke averaging step as it is to not do it.

So, having thought a bit more, I guess I'm inclined to drop this PR. For now, I'll just close it; let me know if you feel otherwise.