NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.22k stars 621 forks source link

medium introspection routines for permittivity and permeability #859

Closed oskooi closed 5 years ago

oskooi commented 5 years ago

To facilitate debugging, it would be useful to add built-in routines eps(f) and mu(f) to Medium class objects (as well as medium objects in Scheme) which given the frequency f (a real scalar) return the complex-valued permittivity and permeability (scalar). This would enable introspection of dispersive materials such as those in the materials library. While initially supporting only isotropic materials, these routines could be extended to anisotropic materials and thereby return a symmetric complex tensor.

oskooi commented 5 years ago

One possible approach is to provide a Python routine which simply evaluates the Drude-Lorentzian susceptibility from the class object's members. This is demonstrated below for crystalline silicon from the materials library. The accompanying figure shows a plot of the real and imaginary part of the permittivity over the allowed wavelength interval.

import numpy as np
import matplotlib.pyplot as plt

um_scale = 1.0

cSi_frq1 = 3.64/um_scale
cSi_gam1 = 0
cSi_sig1 = 8
cSi_frq2 = 2.76/um_scale
cSi_gam2 = 2*0.063/um_scale
cSi_sig2 = 2.85
cSi_frq3 = 1.73/um_scale
cSi_gam3 = 2*2.5/um_scale
cSi_sig3 = -0.107

cSi_eps_inf = 1.0

frq = [cSi_frq1, cSi_frq2, cSi_frq3]
gam = [cSi_gam1, cSi_gam2, cSi_gam3]
sig = [cSi_sig1, cSi_sig2, cSi_sig3]

cSi_eps = lambda ff: cSi_eps_inf +  sum([s*f**2/(f**2 - 1j*ff*g - ff**2) for f,g,s in zip(frq,gam,sig)])

wvl = np.linspace(0.4,1.0,51)
eps = [cSi_eps(1/l) for l in wvl]

plt.figure()
plt.subplot(1,2,1)
plt.plot(wvl,np.real(eps),'bo-')
plt.xlabel("wavelength (μm)")
plt.ylabel("real ε ")
plt.subplot(1,2,2)
plt.semilogy(wvl,np.imag(eps),'ro-')
plt.xlabel("wavelength (μm)")
plt.ylabel("imaginary ε ")
plt.tight_layout()
plt.show()

cSi_eps

However, for generality since it would be nice to also include this routine in the Scheme interface, the new member functions could be added to the lorentzian_susceptibility class.

stevengj commented 5 years ago

Close as a duplicate of #415