Plotting layers#

Vizualizing a layer pattern in 2D with matplotlib.

import matplotlib.pyplot as plt

import nannos as nn

Let’s define our lattice:

lat = nn.Lattice(basis_vectors=[[1, 0], [0, 1]], discretization=2**9)
epsilon = 6 * lat.ones()
hole = lat.circle(center=(0.5, 0.5), radius=0.2)
epsilon[hole] = 1

lay = lat.Layer(name="metasurface", thickness=0.2, epsilon=epsilon)
lay.plot()
plt.show()
plot layer

Another lattice with non orthogonal basis vectors:

lat = nn.Lattice(basis_vectors=[[1, 0], [0.5, 0.5]], discretization=2**9)
epsilon = lat.ones()
scat = lat.ellipse(center=(0.75, 0.25), radii=(0.4, 0.1), rotate=15)
epsilon[scat] = 3 - 1j

lay = lat.Layer(name="grating", thickness=1.3, epsilon=epsilon)
ims = lay.plot(nper=(3, 2), show_cell=True, cmap="Greens", comp="im", cellstyle="y--")
plt.axis("off")
plt.colorbar(ims[0], orientation="horizontal")
plt.title(r"${\rm Im}\,\varepsilon$")
plt.tight_layout()
plt.show()
${\rm Im}\,\varepsilon$

Total running time of the script: (0 minutes 1.907 seconds)

Estimated memory usage: 519 MB

Gallery generated by Sphinx-Gallery