-
Notifications
You must be signed in to change notification settings - Fork 644
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
Python implementation for medium evaluations #862
Changes from 7 commits
6051db7
61f95d6
4345afe
b633fa2
1cd1e11
371f9cc
a7dd4cd
373795c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,12 +258,17 @@ | |
Ag_frq4 = 9.083*eV_um_scale # 0.137 um | ||
Ag_gam4 = 0.916*eV_um_scale | ||
Ag_sig4 = Ag_f4*Ag_plasma_frq**2/Ag_frq4**2 | ||
Ag_f5 = 5.646 | ||
Ag_frq5 = 20.29*eV_um_scale | ||
Ag_gam5 = 2.419*eV_um_scale | ||
Ag_sig5 = Ag_f5*Ag_plasma_frq**2/Ag_frq5**2 | ||
|
||
Ag_susc = [mp.DrudeSusceptibility(frequency=Ag_frq0, gamma=Ag_gam0, sigma=Ag_sig0), | ||
mp.LorentzianSusceptibility(frequency=Ag_frq1, gamma=Ag_gam1, sigma=Ag_sig1), | ||
mp.LorentzianSusceptibility(frequency=Ag_frq2, gamma=Ag_gam2, sigma=Ag_sig2), | ||
mp.LorentzianSusceptibility(frequency=Ag_frq3, gamma=Ag_gam3, sigma=Ag_sig3), | ||
mp.LorentzianSusceptibility(frequency=Ag_frq4, gamma=Ag_gam4, sigma=Ag_sig4)] | ||
mp.LorentzianSusceptibility(frequency=Ag_frq4, gamma=Ag_gam4, sigma=Ag_sig4), | ||
mp.LorentzianSusceptibility(frequency=Ag_frq5, gamma=Ag_gam5, sigma=Ag_sig5)] | ||
|
||
Ag = mp.Medium(epsilon=1.0, E_susceptibilities=Ag_susc, valid_freq_range=metal_range) | ||
|
||
|
@@ -291,12 +296,17 @@ | |
Au_frq4 = 4.304*eV_um_scale # 0.288 um | ||
Au_gam4 = 2.494*eV_um_scale | ||
Au_sig4 = Au_f4*Au_plasma_frq**2/Au_frq4**2 | ||
Au_f5 = 4.384 | ||
Au_frq5 = 13.32*eV_um_scale | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This Lorentzian resonance is at 0.093 μm (or 93 nm). Similar to the additional Ag term; is it really necessary or should we just reduce the tolerance of the test slightly (i.e., matching the results to 4 decimal places rather than 6)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before. Let me know if you want me to remove it. |
||
Au_gam5 = 2.214*eV_um_scale | ||
Au_sig5 = Au_f5*Au_plasma_frq**2/Au_frq5**2 | ||
|
||
Au_susc = [mp.DrudeSusceptibility(frequency=Au_frq0, gamma=Au_gam0, sigma=Au_sig0), | ||
mp.LorentzianSusceptibility(frequency=Au_frq1, gamma=Au_gam1, sigma=Au_sig1), | ||
mp.LorentzianSusceptibility(frequency=Au_frq2, gamma=Au_gam2, sigma=Au_sig2), | ||
mp.LorentzianSusceptibility(frequency=Au_frq3, gamma=Au_gam3, sigma=Au_sig3), | ||
mp.LorentzianSusceptibility(frequency=Au_frq4, gamma=Au_gam4, sigma=Au_sig4)] | ||
mp.LorentzianSusceptibility(frequency=Au_frq4, gamma=Au_gam4, sigma=Au_sig4), | ||
mp.LorentzianSusceptibility(frequency=Au_frq5, gamma=Au_gam5, sigma=Au_sig5)] | ||
|
||
Au = mp.Medium(epsilon=1.0, E_susceptibilities=Au_susc, valid_freq_range=metal_range) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# medium_evaluations.py - Tests the evaluation of material permitivity profiles. | ||
# Checks materials with lorentizian, drude, and non uniform diagonals. | ||
# The extracted values are compared against actual datapoints pulled from | ||
# refractiveindex.info. | ||
# TODO: | ||
# * check materials with off diagonal components | ||
# * check magnetic profiles | ||
|
||
from __future__ import division | ||
|
||
import unittest | ||
import meep as mp | ||
import numpy as np | ||
|
||
|
||
class TestMediumEvaluations(unittest.TestCase): | ||
|
||
def test_medium_evaluations(self): | ||
from meep.materials import Si, Au, LiNbO3 | ||
|
||
# Check Silicon | ||
w0 = 1/1.357 | ||
w1 = 1/11.04 | ||
eps = Si.epsilon([w0,w1]) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[0,0,0])), 3.4975134228247, places=6) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[1,0,0])), 3.4175012372164, places=6) | ||
|
||
# Check Gold | ||
w0 = 1/0.24797 | ||
w1 = 1/6.1992 | ||
eps = Au.epsilon([w0,w1]) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[0,0,0])), 1.0941, places=4) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[1,0,0])), 5.0974, places=4) | ||
|
||
# Check Lithium Niobate | ||
w0 = 1/0.4 | ||
w1 = 1/5.0 | ||
eps = LiNbO3.epsilon([w0,w1]) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[0,0,0])), 2.4392710888511, places=6) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[1,0,0])), 2.0508048794821, places=6) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[0,2,2])), 2.332119801394, places=6) | ||
self.assertAlmostEqual(np.real(np.sqrt(eps[1,2,2])), 2.0025312699385, places=6) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This additional Lorentzian term corresponds to a resonance at a wavelength of 0.061 μm (or 61 nm) that is so far outside the optical range that it should not affect results but it will increase the computational expense due to the additional storage and time stepping of auxiliary fields. (This is why it was originally left out.) Is it really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but it seems to be a pretty broad resonance because even though it's so far away, it does alter the shape of the resonances between 200 nm and 300 nm. After that, however, it's negligible.
Here's a comparison:
The 5 resonance implementation matches refractiveindex.info's raw data points.