Peacock.jl icon indicating copy to clipboard operation
Peacock.jl copied to clipboard

Other solvers (Eg FDFD)

Open sp94 opened this issue 3 years ago • 4 comments

While plane-wave expansion method is efficient for modelling dielectric materials, it is inefficient at modelling materials such as metals or modelling finite (non-periodic) systems

It would therefore be useful to add other methods of solution to Peacock, such as the finite-difference frequency-domain (FDFD) method. We could begin with an implementation of 2D FDFD to solve for eigenmodes of a periodic structure - these results could be compared directly against the existing plane-wave expansion method in Peacock.

A priority would be to keep the interface simple and consistent between the different solvers.

sp94 avatar May 09 '21 16:05 sp94

Hi @sp94 , I have written the slover-function of 2D FDFD, and it support full anisotropy, which can be seen at https://github.com/kabume/Peacock.jl/tree/master/src. Besides, the demo of anisotropic square lattice (time-broken case) can be seen at https://github.com/kabume/Peacock.jl/blob/master/test/test_FDFD_aniso.jl, the relative permittivity and permeability are expressed as eps=[14 -12.4im 0; 12.4im 14 0; 0 0 15] and mu=[14 12.4im 0; -12.4im 14 0; 0 0 15]. The result is the same as Zhao's paper. The result of getting started of Peacock is also listed .

Some existing functions of Peacock can be used directly, like Peacock.sample_path and geometry, which are very useful.

Some problems still need to be solved:

  1. the geometry function is so complicated for fully anisotropic case;
  2. The FDFD solver that I have written is very simple, we still need to make some improvements so that existing functions of Peacock (eg plot_band_diagram) can be used on the new solver;
  3. The FDFD solver only supports the eigenvalue problem now, and the source function and PML (UPML) need to be added.
  4. FDFD seems a better fit for working on the GPU because of the sparse matrix.

kabume avatar May 13 '21 04:05 kabume

Thank you @kabume, this looks really good :)

Here are my first thoughts on how we can merge these together in an easy to use way.


FDFD.__ and PWEM.__ submodules

I think we should create internal submodules Peacock.FDFD and Peacock.PWEM, so that you can do

  1. Using both solvers in the same script (probably less common):
using Peacock

solver1 = FDFD.Solver(...)
solver2 = PWEM.Solver(...)

modes1 = solve(solver1, ...)
modes2 = solve(solver2, ...)
  1. Or just PWEM:
using Peacock.PWEM
solver = Solver(...)
modes = solve(solver, k, polarisation)
plot(modes[1])
  1. Using just FDFD:
using Peacock.FDFD
solver = Solver(...)
modes = solve(solver, k, polarisation)
plot(modes[1])

Then solve(solver, k, polarisation) can use Julia's automatic dispatch to behave differently depending whether solver is a FDFD.Solver or PWEM.Solver, and can return either FDFD.Eigenmode or PWEM.Eigenmode.

Then we will make sure that the solvers and eigenmodes have a consistent interface that can be used by eg plot(mode), plot_band_diagram(solver,...).


Anisotropy

I think we can use the same Geometry for both FDFD and PWEM, but allow epf and muf to return either a scalar, 3-vector, or 3x3-matrix.

Then, we could make multiple types of solvers, eg IsotropicSolver, AnisotropicSolverTE, AnisotropicSolverTM (and maybe later also AnisotropicSolver for when there are anisotropic terms that mix the TE/TM modes together). And similar for PWEM.

When we construct solver = Solver(geometry, ...) we can try and automatically pick the simplest option based on the structure of epf and muf. i.e. if all of epf and muf are scalars, return IsotropicSolver.


These are just my first thoughts, I will probably come back and edit or add more soon :)

Thanks again!

sp94 avatar May 13 '21 10:05 sp94

The method of submodules looks so clear! I'll try it soon.

Besides, the geometry function may add a dielectric averaging function to get more accurate results, like this slide.

kabume avatar May 13 '21 13:05 kabume

Good idea, I've opened an issue for dielectric smoothing https://github.com/sp94/Peacock.jl/issues/22

sp94 avatar May 13 '21 14:05 sp94