For the mode-coefficient expansion, there is a special case worth optimizing. In particular, if:
-
The flux plane is in a homogeneous medium. (Initially, I would just support homogeneous scalar ε and μ, with no anisotropy.)
-
The flux plane fills the entire unit cell in those directions, and the boundary conditions in those directions are Bloch-periodic.
In this case, the propagating modes are a finite set of planewaves. Computing the mode coefficients is just a discrete Fourier transform. So one option would be to circumvent MPB entirely in this case and just perform a DFT to get the coefficients of the planewaves, appropriately normalized. It could even compute the coefficients of the evanescent waves too.
Alternatively, since MPB is also super-efficient in this case there is no huge need to optimize the eigenmode calculation. What would be nice, however, would be to:
For example suppose we have a 2d calculation with period Λ in the x direction, bloch-periodic boundary conditions with a given kₓ, and have a flux plane of width Λ in a homogeneous region of index n. Then the propagating modes at a frequency ω (in c=1 units) are the real solutions of k = sqrt(ω²n² - (kₓ+2πm/Λ)²) for integers m. That is, you just (a) compute the integers m for which the square root is real = number of modes; and (b) compute the corresponding k values, passing (kₓ,k) to MPB to get the mode at that frequency.
cc @HomerReid
For the mode-coefficient expansion, there is a special case worth optimizing. In particular, if:
The flux plane is in a homogeneous medium. (Initially, I would just support homogeneous scalar ε and μ, with no anisotropy.)
The flux plane fills the entire unit cell in those directions, and the boundary conditions in those directions are Bloch-periodic.
In this case, the propagating modes are a finite set of planewaves. Computing the mode coefficients is just a discrete Fourier transform. So one option would be to circumvent MPB entirely in this case and just perform a DFT to get the coefficients of the planewaves, appropriately normalized. It could even compute the coefficients of the evanescent waves too.
Alternatively, since MPB is also super-efficient in this case there is no huge need to optimize the eigenmode calculation. What would be nice, however, would be to:
Automatically compute the correct number of (non-evanescent) modes for a given frequency.
Give MPB an initial "guess" for each mode consisting of the analytically known k.
For example suppose we have a 2d calculation with period Λ in the x direction, bloch-periodic boundary conditions with a given kₓ, and have a flux plane of width Λ in a homogeneous region of index n. Then the propagating modes at a frequency ω (in c=1 units) are the real solutions of k = sqrt(ω²n² - (kₓ+2πm/Λ)²) for integers m. That is, you just (a) compute the integers m for which the square root is real = number of modes; and (b) compute the corresponding k values, passing (kₓ,k) to MPB to get the mode at that frequency.
cc @HomerReid