Photonic crystal¶
Spheres with permittivity 12.4 and radius 0.2 on a simple cubic lattice with period 0.5 form a photonic crystal. The lattice interaction matrix is I - T C, where T is the T-matrix of one sphere and C expands the waves scattered by all other spheres about it. The crystal has a mode with zero Bloch wave vector where this matrix is singular, so dips of its smallest singular value mark the mode frequencies. Lengths have no unit; the frequency column is k0 / 2π, the inverse vacuum wavelength.
"""A simple cubic crystal of spheres: where its lattice modes lie."""
import numpy as np
import treams_rs as tr
# Enlarge for a full spectrum: treams uses 200 frequencies.
FREQUENCIES = 5
k0s = 2 * np.pi * np.linspace(0.01, 1, FREQUENCIES)
material = tr.Material(12.4)
lmax = 3
radius = 0.2
lattice = tr.Lattice.cubic(0.5)
kpar = [0, 0, 0]
# A mode of the crystal exists where the lattice interaction matrix
# I - T C is singular; its smallest singular value dips towards zero there.
res = []
for k0 in k0s:
sphere = tr.sphere_tmatrix(k0=k0, lmax=lmax, radius=radius, material=material)
svd = np.linalg.svd(sphere.latticeinteraction(lattice, kpar), compute_uv=False)
res.append(svd[-1])
if __name__ == "__main__":
print("Smallest singular value of the lattice interaction matrix")
print(f"{'k0/(2 pi)':>13}{'value':>13}")
for k0, value in zip(k0s, res, strict=True):
print(f"{k0 / (2 * np.pi):>13.6g}{value:>13.6g}")
# Source: https://github.com/tfp-photonics/treams/blob/1f5d0d6ebb007288f28bc9e16f6d266e8b55dc39/docs/examples/crystal.py
# Adapted: reduced sizes, plotting removed.
# MIT license, copyright Dominik Beutel; see LICENSE.treams.
import numpy as np
import treams
k0s = 2 * np.pi * np.linspace(0.01, 1, 5)
materials = [treams.Material(12.4), treams.Material()]
lmax = 3
radius = 0.2
lattice = treams.Lattice.cubic(0.5)
kpar = [0, 0, 0]
res = []
for k0 in k0s:
sphere = treams.TMatrix.sphere(lmax, k0, radius, materials)
svd = np.linalg.svd(sphere.latticeinteraction(lattice, kpar), compute_uv=False)
res.append(svd[-1])
Output¶
Smallest singular value of the lattice interaction matrix
k0/(2 pi) value
0.01 7.76916e-05
0.2575 0.0498661
0.505 0.169893
0.7525 0.0197625
1 0.242333
Differences from the treams version¶
latticeinteraction(lattice, kpar)keeps its treams name: treams-rs has no other name for the lattice interaction matrix.solve_periodicsolves the same system when the response itself is needed.sphere_tmatrixtakes keywords and the sphere'smaterial; the exteriormediumis vacuum unless given.