NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.17k stars 598 forks source link

Allow design-grid resolution to accept a tuple #2599

Closed mawc2019 closed 11 months ago

mawc2019 commented 11 months ago

This PR allows the resolution argument in filters.py to accept a tuple, so that different resolutions along different directions can be supported. This PR also refactors the code in filters.py.

codecov-commenter commented 11 months ago

Codecov Report

Merging #2599 (9c48402) into master (cd9a7eb) will decrease coverage by 0.09%. Report is 1 commits behind head on master. The diff coverage is 86.44%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #2599      +/-   ##
==========================================
- Coverage   73.90%   73.81%   -0.09%     
==========================================
  Files          18       18              
  Lines        5293     5294       +1     
==========================================
- Hits         3912     3908       -4     
- Misses       1381     1386       +5     
Files Changed Coverage Δ
python/adjoint/filters.py 77.20% <86.44%> (-2.49%) :arrow_down:
mawc2019 commented 11 months ago

One suggestion would be to simply verify that defining a filter with the resolution tuple (res, res) produces the same result as passing in just res.

I have added a different but more stringent test, in which one of the elements of the resolution tuple is zero, which defines a 1d design pattern. Suppose a 1d design pattern is defined in the x direction. Whether this 1d design pattern is periodic in the y direction or not should make no difference in the filtered 1d patterns. Likewise, suppose a 1d design pattern is defined in the y direction. There should be no difference whether this 1d design pattern is periodic in the x direction. The new test function checks this identity based on lengthscale constraint functions.