Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of gyrotropic susceptibilities #863

Merged
merged 66 commits into from
Jun 13, 2019

Conversation

seewhydee
Copy link
Contributor

@seewhydee seewhydee commented May 8, 2019

Closes #60 ...

@stevengj
Copy link
Collaborator

stevengj commented May 9, 2019

Overall, this looks great!

Have you tried it out on any example problems yet? Once there are some minimal tests that indicate that this is essentially working, I would be happy to merge as an experimental feature since it doesn't really affect the rest of the code. If you have an example reproducing something from a paper to use a tutorial that would be good too.

My biggest concern (modulo bugs) is whether this will introduce instabilities, especially at the boundaries of gyrotropic media since inhomogeneous anisotropy is always a bit tricky in a Yee grid.

@seewhydee
Copy link
Contributor Author

seewhydee commented May 10, 2019

Haven't done any rigorous testing yet, will work on that soon. Off the top of my head, there are a few straightforward tests to be done in 2D:

  • In a uniform 2D waveguide with out-of-plane gyrotropy vector, the dispersion relation can be calculated analytically and compared to simulation results for varying gyrotropy.
  • In a 2D disk of gyrotropic medium with out-of-plane gyrotropy vector, I think there should be an analytic solution for the Bessel-type normal modes, which should experience a Zeeman-like splitting. This can be compared to the resonance frequencies found in simulation.
  • (More complicated): In a topological photonic crystal made of ferrite rods, one can look for the bandgap opened by the gyrotropy, and check the dispersion relation against a frequency-domain (e.g. Comsol) result.

For 3D, I'm not sure; it may be necessary to compare to various Comsol simulations.

@seewhydee
Copy link
Contributor Author

seewhydee commented May 27, 2019

Sorry for the long silence. Here's an update.

I wasn't too happy with the equation of motion that just adds a precession term to the Lorentzian damped harmonic oscillator, since it does not reproduce the right frequency dependence for materials like ferrites. So I spent some time implementing another equation of motion, the Landau Lifshitz Gilbert equation, which does give the right frequency dependence (this is on the "landau-lifshitz-gilbert" branch). Implementation notes here.

However, there's a stability problem that I haven't been able to fix. For relatively weak gyrotropy and short runtime, the simulation behaves as expected. Here is a figure plotting Ex and Ey for a wave propagating along a gyrotropy axis z:

gyro-instability

As desired, the Ex component precesses into Ey. But with increasing t, a spatial instability sets in and creates an oscillation on the length scale of the grid.

It doesn't seem to be a problem with the Euler integration of the Landau Lifshitz Gilbert equation by itself -- for an isolated point, the integration doesn't seem to exhibit any instability. There seems to be some kind of bad interaction with the EM fields on the grid.

Kinda stumped right now, so suggestions welcome.

@acerjan
Copy link
Contributor

acerjan commented Jun 5, 2019

I also found a bug in my code (forgot to change the point source to be a line source when I added a finite thickness), but even with the newly updated version, my bandgap is still a bit smaller than I expected. I've also been through your new set of notes and I agree with your derivation.

It may be that the smaller bandgap I'm seeing is entirely correct, and is due to changes in the effective dielectric tensor for frequencies further away from the central frequency, and that the thing to do is run a series of very narrow sources to build up the band structure that way. For reference, the bandgap I'm expecting is ~20% of the central frequency. This change will take a bit of time to implement, so it'll have to wait until I return from holiday.

@seewhydee
Copy link
Contributor Author

@acerjan: the topological band gap you're testing on is really wide, and dispersion is highly likely to be a significant issue. For the quantitative verification, I suggest simply testing against a ~2-3% bandgap.

@stevengj: I think the code is converging, so could you take a look at the proposed interface and comment on whether it's acceptable? (The Scheme interface will track the Python one, once finalized).

@stevengj
Copy link
Collaborator

stevengj commented Jun 5, 2019

If the problem is dispersion, simply double the resolution and see if the agreement improves significantly. I don't recall ever having a big problem with dispersion over a 20% bandwidth, which gets you nowhere near the Nyquist frequency. Oh, never mind, I see what you mean — you're not referring to numerical dispersion, but rather to the fact that the gyrotropic material in MPB is non-dispersive, whereas the one in Meep is dispersive. In principle, you could fix this by self-consistent MPB calculations, where for each band you update the materials as you calculate the frequencies until the results converge (e.g. a fixed-point iteration). You could also use perturbation theory for small dispersive effects.

@seewhydee, the interface looks good.

@stevengj
Copy link
Collaborator

If we can have a sanity test of this feature, I think we can merge it?

@seewhydee
Copy link
Contributor Author

Fine by me. As of now, Faraday rotation of a plane wave quantitatively matches theory for all three types of gyrotropic media. For inhomogenous structures containing both gyrotropic and non-gyrotropic media, the simulations run without field instabilities, but we have not quantitatively checked the results yet. As a clearly-labelled experimental feature, it's OK to merge whenever you like.

Alex will compare the topological photonic crystal band gap size when he gets back, and there are a bunch of other tests I'm interested in doing (e.g. looking at the dispersion relation of magnetic surface plasmons) before removing the "experimental" label.

@stevengj
Copy link
Collaborator

As of now, Faraday rotation of a plane wave quantitatively matches theory for all three types of gyrotropic media.

Great! Can you add an automated test to make check for this? A Python test in the python/tests directory would be fine.

@seewhydee
Copy link
Contributor Author

@stevengj
Copy link
Collaborator

Looks good to merge once tests are green.

@ChristopherHogan
Copy link
Contributor

The faraday_rotation.py test needs to be added to the TESTS variable in python/Makefile.am. Otherwise the test won't run.

@seewhydee
Copy link
Contributor Author

Oh, right. Added it.

@stevengj stevengj merged commit 174b641 into NanoComp:master Jun 13, 2019
@acerjan
Copy link
Contributor

acerjan commented Jul 2, 2019

After returning from a couple of different trips, I've finally had a moment to run simulations which account for the dispersion in MEEP's model of gyrotropic material relative to MPB's. Although Steven's suggestion of doing self-consistent frequency calculations in mpb would probably have been less computer runtime, just running a bunch of meep simulations with different choices of the gyrotropic media was faster to set up, and computer resources are bountiful.

As a reminder, I'm simulating the boundary between a topological and a trivial photonic crystal, so we expect to see a chiral edge state. Of course, mpb finds both edge states, but meep should only find one, as the other border is buried in the absorbing region. As can be seen in this plot comparing mpb (red lines) with meep (blue +s), the results are similar, though some slight differences are seen -- the meep frequencies seem to be reduced by ~2-3% compared with mpb, but the overall shape, and bandgap are nearly the same. Is this a typical amount of discrepancy between the two simulation techniques? Or is this indicative of an error?

TI_boundary_meep_mpb

If you think the error is small enough to not be concerned, I'm happy to prepare some of this as an example for meep / mpb, just let me know what you'd like to have added.

@seewhydee
Copy link
Contributor Author

Could this be a due to discretization? Does changing the resolution alter the frequency shift?

It certainly would be great to have a photonic TI as a Meep tutorial, but doing repeated simulations over a frequency sweep seems like an unnecessary complication for that purpose. Could you try picking parameters where the bandgap is about 1/10 the present size (say a 3% bandgap rather than a ~20% bandgap)? Then dispersion effects ought to be much less pronounced, and it should be possible to compare Meep results to MPB results (using mid-gap values) without a frequency sweep.

@acerjan
Copy link
Contributor

acerjan commented Jul 4, 2019

Yeah, i'll move to a 3% bandgap or something smaller so i can check the discretization more easily. It still might require 2 or 3 runs, but not the ~26 used in the above plot.

bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
* Implement gyrotropic susceptibility class.

* Add Python and Scheme support for gyrotropic media.

* Initialize bias vector in python susceptibility struct.

* Remove "bias" from gyrotropic_susceptibility; the information is already in gyro_tensor.

* Add gyrotropic media to docs

* Minor copyedit

* Fix logic in py_susceptibility_to_susceptibility

* In add_susceptibilities, always pass a 3-vector as gyrotropic bias

* First try at gyrotropic media tutorial

* Fix errors in gyrotropy formulas in notes

* Re-implemention of gyrotropy using LLG equation

* Tweak handling of sigma tensor in gyrotropic case

* Update Python doc.

* Drop 2pi factor from gyrotropic sigma

* Doc updates

* Fix last change to update_P

* Fix printf typo

* Remove spurious 2pi factor in alpha (which is not a rate)

* Minor code tweak

* Use a central-difference scheme for the LLG dynamics, which seems slighly more stable...

* Try implementing the full nonlinear LLG equation

* Add implicit static polarization to gyrotropy implementation

* Put static P back in in subtract_P

* Add gyrotropy example

* Fix; use LOOP_OVER_VOL instead of LOOP_OVER_VOL_OWNED to ensure updating of off-diagonal components

* Clamp the magnitude of the LLG polarization vector.

* Revert inadvertent unrelated change to meep.i

* Minor code cleanup

* Flag "needs_W_notowned" for gyrotropic media

* Update gyrotropic P components explicitly; don't use LOOP_OVER_VOL_OWNED

* Enable needs_P on all components for gyrotropic media

* Fix gyrotropy scheme to track 9 polarization components per unit cell.

* Revert unrelated last change to meep.i

* Avoiding need for allocation of P_tmp in gyrotropy_data.

* Implement num_cinternal_notowned stuff for gyrotropic media

* Update documentation for gyrotropic media, and relax some minor restrictions.

* Add virtual keywords to gyrotropic_susceptibility methods

* Merge latest changes from master

* Remove gyrotropic-dispersion.py (incomplete attempt)

* Complete merge

* Update Materials.md to discuss both Lorentzian and LLG gyrotropic models

* Introduce a new gyrotropy_model enum type, to allow for the LLG model.

* More plumbing to provide support for Landau-Lifshitz-Gilbert type gyrotropy model

* Fix typo in susceptibility update equation

* Fix typos in Faraday rotation formula in docs

* Merge from master

* Reimplement linearized-LLG updating equations

* Fix typo

* Minor code clarification

* Fix Faraday rotation example

* For Landau-Lifshitz-Gilbert model, ignore the magnitude of the bias vector.

* Fix minor hiccup in docs.

* Support dumping and undumping of gyrotropic susceptibilities

* Doc updates and minor tweaks accompanying last merge

* Translate Faraday rotation tutorial from Python to Scheme

* Fix typo in last change

* Fix missing 2pi factor in gyrotropic LLG susceptibility's sigma parameter

* Minor fixes for gyrotropy documentation

* Add Faraday rotation unit test

* Use absolute tolerance (in degrees) for Faraday rotation unit test

* Add faraday rotation test to python/Makefile.am
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: gyrotropic media
5 participants