NanoComp / meep

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

Make the initial number of azimuthal grid points in near-to-far field transformation in cylindrical coordinates a user parameter #2764

Closed oskooi closed 5 months ago

oskooi commented 5 months ago

Currently, the computation of the far fields in cylindrical coordinates involves an integration in $\phi$ (azimuthal angle) which is based on repeatedly doubling a grid of $\phi$ points using a hard-coded initial value:

https://github.com/NanoComp/meep/blob/04fa3053650d936114b70331e971031c6ae3eb87/src/near2far.cpp#L288-L291

The value of 4 turns out to be too small in some cases which produces discretization artifacts in the output as demonstrated in #2726 (comment). As such, it would be useful to make the initial number of $\phi$ grid points a user parameter in the routines get_farfield and get_farfields.