{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# This file is part of nannos\n# License: GPLv3\n%matplotlib notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Dielectric patch array\n\nTransmission spectrum.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\nfrom matplotlib.colors import ListedColormap\nfrom scipy.constants import c, e, h\n\nimport nannos as nn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Results are compared to the reference :cite:p:`Tikhodeev2002`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "eps_quartz = 2.132\neps_active = 3.97\n\nN = 2**7\nperiod = 0.68\nl_patch = 0.8 * period" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the lattice\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lattice = nn.Lattice(([period, 0], [0, period]), discretization=(N, N))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the slab layer with a square patch\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "epsilon = lattice.ones() * eps_quartz\nsquare = lattice.square(center=(0.5 * period, 0.5 * period), width=l_patch)\nepsilon[square] = eps_active\n\nslab = lattice.Layer(\"Slab\", thickness=0.12)\nslab.epsilon = epsilon\n\ncmap = ListedColormap([\"#dddddd\", \"#73a0e8\"])\n\n\nplt.figure(figsize=(3, 2.5))\nim = slab.plot(cmap=cmap)\ncbar = plt.colorbar(im[0], ticks=[eps_quartz, eps_active])\nplt.xlabel(r\"$x$ ($\\mu$m)\")\nplt.ylabel(r\"$y$ ($\\mu$m)\")\nplt.title(r\"$\\varepsilon$\")\nplt.axis(\"scaled\")\nplt.tight_layout()\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the simulation\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "sup = lattice.Layer(\"Superstrate\", epsilon=1)\nsub = lattice.Layer(\"Substrate\", epsilon=eps_quartz)\nstack = [sup, slab, sub]\n\n\ndef compute_transmission(fev):\n w = h * c / e / (fev * 1e-6)\n pw = nn.PlaneWave(wavelength=w, angles=(0, 0, 90))\n sim = nn.Simulation(stack, pw, 100, formulation=\"original\")\n R, T = sim.diffraction_efficiencies()\n print(f\"f = {fev}eV\")\n print(\"T = \", T)\n return T\n\n\nfreqsev = np.linspace(1, 2.6, 101)\nfev_adapted, transmission = nn.adaptive_sampler(\n compute_transmission, freqsev, max_bend=10, max_x_rel=0.001, max_df=0.005\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Figure 4 from :cite:p:`Tikhodeev2002`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.figure()\nplt.plot(fev_adapted * 1000, transmission, c=\"#be4c83\")\nplt.ylim(0.4, 1)\nplt.xlabel(\"frequency (meV)\")\nplt.ylabel(\"Transmissivity\")\nplt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot the fields at the resonant frequency of 2456meV\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fev = 2.456\nw = h * c / e / (fev * 1e-6) # /1000\n\npw = nn.PlaneWave(wavelength=w, angles=(0, 0, 90))\nsim = nn.Simulation(stack, pw, 151, formulation=\"tangent\")\nE, H = sim.get_field_grid(\"Superstrate\", shape=(N, N))\n\nEx, Ey, Ez = E[:, :, :, 0]\nHx, Hy, Hz = H[:, :, :, 0]\nnE2 = np.abs(Ex) ** 2 + np.abs(Ey) ** 2 # + np.abs(Ez)**2\nnH2 = np.abs(Hx) ** 2 + np.abs(Hy) ** 2 # + np.abs(Hz)**2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Electric field\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "extent = [0, period, 0, period]\nx, y = np.linspace(0, period, N), np.linspace(0, period, N)\n\nplt.figure()\nplt.imshow(epsilon.real, cmap=\"Greys\", origin=\"lower\", extent=extent)\nplt.imshow(nE2, alpha=0.9, origin=\"lower\", extent=extent)\nplt.colorbar()\ns = 3\nplt.quiver(x[::s], y[::s], Ex[::s, ::s].real, Ey[::s, ::s].real, color=\"w\")\nplt.xlabel(r\"$x$ ($\\mu$m)\")\nplt.ylabel(r\"$y$ ($\\mu$m)\")\nplt.title(\"$E$\")\nplt.tight_layout()\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Magnetic field\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.figure()\nplt.imshow(epsilon.real, cmap=\"Greys\", origin=\"lower\", extent=extent)\nplt.imshow(nH2, alpha=0.9, origin=\"lower\", extent=extent)\nplt.colorbar()\nplt.quiver(x[::s], y[::s], Hx[::s, ::s].real, Hy[::s, ::s].real, color=\"w\")\nplt.xlabel(r\"$x$ ($\\mu$m)\")\nplt.ylabel(r\"$y$ ($\\mu$m)\")\nplt.title(\"$H$\")\nplt.tight_layout()\nplt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import nannos.utils.jupyter\n%nannos_version_table" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.5" } }, "nbformat": 4, "nbformat_minor": 0 }