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

disable subpixel smoothing for mesh_size=1 #150

Closed flaport closed 2 years ago

flaport commented 2 years ago

Currently it was not possible to disable subpixel smoothing in mpb (closes NanoComp/meep#2167).

This PR fixes this.

Here is a plot that shows the convergence of the mode calculation of a simple circular cross section before and after introducing the fix. You can clearly see that convergence is now slower for mesh_size=1, which is actually the behavior you'd want.

image

Moreover, looking at an image of the crossection at resolution 16 clearly shows that subpixel smoothing is now disabled:

before: image

after: image

stevengj commented 2 years ago

Can you update the docs as well?

flaport commented 2 years ago

done!

stevengj commented 2 years ago

Yes, if the caller provides mepsilon, they are responsible for disabling (or not) subpixel smoothing themselves.

stevengj commented 2 years ago

(meep_mpb_eps doesn't do any of its own subpixel averaging, it just samples the pre-existing Meep ε, which may already have some smoothing)