flaport / fdtd

A 3D electromagnetic FDTD simulator written in Python with optional GPU support
https://fdtd.readthedocs.io
MIT License
454 stars 116 forks source link

Frequency dependent permittivity #31

Open lupettolab opened 2 years ago

lupettolab commented 2 years ago

Hi, thank you very much for this awesome repository!

If I understand the code correctly at the moment it's not possible to use Objects with a frequency dependent permittivity (like gold nanoparticles for instance), is there any plan to support it?

flaport commented 2 years ago

Hi @lupettolab ,

Adding support for frequency-dependent permittivity is a bit outside my comfort zone / area of expertise. However, I would happily accept a PR for an Object that can do this ;-)

GenB31415 commented 2 years ago

Hi @flaport, I ques that to extend fdtd for case of dispersive materials is not too advanced task for your package. Please look at https://eecs.wsu.edu/~schneidj/ufdtd/chap10.pdf and then see details in Eq.(10.47) and Eq.(10.62). One has only to add a new variable the polarization current J and elaborate the coefficients for the Debye and the Drude materials respectively. The structure of the update equations change a little. After that your fdtd can support the studies not only for conventional materials, but metamaterials too.

GenB31415 commented 2 years ago

PS. Upon a time I converted C code from the book eecs.wsu.edu/~schneidj/ufdtd/chap10.pdf to C# (with GUIs and classes) and I assure that the code worked exactly as expected. Thanks

flaport commented 2 years ago

Thanks for the pointer @GenB31415 , I love that book... most of this library is loosely based on it. I'm pretty sure I could implement it with the right amount of time, but that has been a big problem lately...

So like I said... it might happen at some point if I ever find the courage and time, but you'll have a better chance of having it fast with a PR ;-)

GenB31415 commented 2 years ago

Hi @flaport. I understand your situation. Well, I would like only to briefly discuss the following approach (when you will have time). I (or anyone) will prepare a new structure: class GridDrude(fdtd.Grid): ... , which will have your fdtd.Grid as a base class. The idea is to get the access to the methods and fields of fdtd.Grid, but with the possibility to add (extend) new methods allowing to create update field functions for the Drude model (and maybe other) as it is described in chapter 10 of the book. However, before one would like to hear some general advices on the possible structure of such a hierarchy. Thanks.

GenB31415 commented 2 years ago

Hi @flaport! I'd like to continue the discussion of FDTD for a case of material with a frequency-dependent dispersion. I propose here the FDTD solution for a simple case of homogeneous medium with a dispersion based on the Drude model, see details in the book Taflove/Hagness, 9.2.3 (Ed.3). As an illustration, I attach FDTD code of Cherenkov radiation in 2D case (which admits a direct generalization to 3D). The question is, if this approach can be applied to the inhomogeneous situation, e.g., a compound medium with the inserted parallel cylinders? Thanks. EnergyDrude EnergyNoDrude Example.zip ks

GenB31415 commented 2 years ago

PS. First graph shows the energy of field radiated by moving point source for the Drude medium with the plasma frequency indicated in the graph. The second plot shows the same but for disperiveless dielectric. One can see that the field structures in medium with the frequency (Drude) dispersion significantly differs from the dispersiveless case.

GenB31415 commented 2 years ago

PS-2.

  1. In the above toy model to switch between the Drude case (graph-1) and the conventional (non-dispersive) case (graph-2), one needs to swap the comments in lines 197-198 in the Main.
  2. The toy model generates the expected result - the Mach cone of the emitted field at fast source velocities in the non-dispersive case (Graph-2). In the case of a metallic medium (Drude's model), the field should quickly decay (Graph-1).
  3. The disadvantage is the appearance of some inhomogeneous (almost empty) regions of the field in the radiation cone.
  4. This (and other drawbacks) can probably be corrected by better matching (or even inheritance) with the base class fdtd. Thanks.
flaport commented 2 years ago

Hey @GenB31415 , this looks cool! I'll try to have a look at it this week!

flaport commented 2 years ago

Hi @GenB31415 , feel free to make a PR and add GridDrude to grid.py. Thanks :)

GenB31415 commented 2 years ago

Hello to everybody. In this message I propose a way to apply a wrapping class technique to the system with the frequency (Drude) dispersion in the fdtd package. This approach avoids disturbing the internal structure of fdtd code that is desired in many situations. Attached is a working file that uses as a prototype one of fdtd example.

  1. As expected in such a system, the control parameter is the plasma frequency Wp with a critical value WpC about 1e7.
  2. For cases Wp <WpC, the system allows the field of the line source to pass freely through the object just like in the example.
  3. But for the cases Wp> WpC, the object already reflects the field like as a metal.
  4. If Wp = WpC, only a small part of the field passes through the object.
  5. In the attached example, the variable hasUseDrude = True (or False) is used to switch between the cases of which part of the compound object (left, right or center) has the Drude dispersion. Changing the value drudeOmegaPe to 1e6 (or less) one can see that independently of hasUseDrude the system behaves as a dielectric that reproduces the fdtd example.
  6. This approach can be easily extended to apply in advanced systems, e.g. for materials with the Lorentz frequency dispersion, and even to 3D case.

Thanks to @flaport for sharing the fdtd great package.

Drude1a_wp=1e6F Drude1a_wp=1e6T Drude1a_wp=1e8F Drude1a_wp=1e8T Drude3D Example.zip

flaport commented 2 years ago

Hi @GenB31415 ,

This looks pretty cool! I would be happy to include those additions into fdtd.

Can you fork the repository, make the necessary changes in your branch and then create a pull request please?

Thanks!

GenB31415 commented 2 years ago

Hi @flaport, thanks, please tell us more. In the meantime, I attach two figure that follow your other example. Figure Fig0_1cDrudeWp = 7.5e7.png shows the case when the upper object is a normal dielectric, and the lower object has the Drude frequency dispersion with Wp = 1.5e7. We observe that the field is significantly disturbed and is completely reflected from such an object. For comparison, the second figure Fig0_1cNoDrude.png shows the same case, except that now both objects are dielectrics. Thanks. Fig0_1cDrudeWp=7 5e7 Fig0_1cNoDrude

flaport commented 2 years ago

Hey @GenB31415 . I love your additions to the fdtd simulator and I would like to add them. Could you please fork the repository, make the changes that you want to see in this library and make a pull request?

You can find more information on how to do this here: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

jviquerat commented 2 years ago

@GenB31415 @flaport Is there any update ? I would definitely be interested to use a Drude-like material as a base for a small POC

flaport commented 1 year ago

Hi @jviquerat , Drude materials are a bit out of my comfort zone... I think you can probably use the example zip file attached above as a starting point. Feel free to open a PR if you get it working 🙂