{ "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# Two photonic crystal slabs\n\nMechanically tunable photonic crystal structure consisting of coupled photonic crystal slabs.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nimport nannos as nn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will code the structures studied in :cite:p:`Suh2003`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "nh = 51\nL1 = [1.0, 0]\nL2 = [0, 1.0]\ntheta = 0.0 * np.pi / 180\nphi = 0.0 * np.pi / 180\npsi = 0.0 * np.pi / 180\n\nNx = 2**8\nNy = 2**8\n\nlattice = nn.Lattice((L1, L2), (Nx, Ny))\n\nepsgrid = lattice.ones() * 12.0\nhole = lattice.circle((0.5, 0.5), 0.4)\nepsgrid[hole] = 1.0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the problem\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "sup = lattice.Layer(\"Superstrate\", epsilon=1.0)\nphc_slab = lattice.Layer(\"PC slab\", thickness=0.55)\nsub = lattice.Layer(\"Substrate\", epsilon=1.0)\nphc_slab.epsilon = epsgrid\nstack = [sup, phc_slab, sub]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fig 2 (a) from :cite:p:`Suh2003`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def compute_transmission(fn):\n pw = nn.PlaneWave(wavelength=1 / fn, angles=(0, 0, 0))\n sim = nn.Simulation(stack, pw, nh)\n R, T = sim.diffraction_efficiencies()\n print(f\"f = {fn} (normalized)\")\n print(\"T = \", T)\n return T\n\n\n#\nfreqs_norma = np.linspace(0.49, 0.6, 30)\nfreqs_adapted, transmission = nn.adaptive_sampler(\n compute_transmission,\n freqs_norma,\n)\n\n\nplt.figure()\nplt.plot(freqs_adapted, transmission, c=\"#be4c83\")\nplt.xlim(freqs_norma[0], freqs_norma[-1])\nplt.ylim(0, 1)\nplt.xlabel(r\"frequency ($2\\pi c / a$)\")\nplt.ylabel(\"Transmission\")\nplt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Figs 2 (b-c) from :cite:p:`Suh2003`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phc_slab_top = lattice.Layer(\"PC slab top\", thickness=0.55)\nphc_slab_top.epsilon = epsgrid\nphc_slab_bot = phc_slab_top.copy(\"PC slab bottom\")\n\nplt.figure()\n\nseps = [1.35, 1.1, 0.95, 0.85, 0.75, 0.65, 0.55]\ncolors = plt.cm.turbo(np.linspace(0, 1, len(seps)))\n\nfor i, sep in enumerate(seps):\n spacer = lattice.Layer(\"Spacer\", epsilon=1, thickness=sep)\n stack = [sup, phc_slab_top, spacer, phc_slab_bot, sub]\n\n def compute_transmission(fn):\n pw = nn.PlaneWave(wavelength=1 / fn, angles=(0, 0, 0))\n sim = nn.Simulation(stack, pw, nh)\n R, T = sim.diffraction_efficiencies()\n print(f\"f = {fn} (normalized)\")\n print(\"T = \", T)\n return T\n\n freqs_norma = np.linspace(0.49, 0.6, 30)\n freqs_adapted, transmission = nn.adaptive_sampler(\n compute_transmission,\n freqs_norma,\n )\n\n plt.plot(freqs_adapted, transmission, c=colors[i], label=rf\"$d = {sep}a$\")\n plt.xlim(freqs_norma[0], freqs_norma[-1])\n plt.ylim(0, 1)\n plt.xlabel(r\"frequency ($2\\pi c / a$)\")\n plt.ylabel(\"Transmission\")\n plt.tight_layout()\n plt.pause(0.1)\n\n\nplt.legend(loc=(1.05, 0.3))\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.10.13" } }, "nbformat": 4, "nbformat_minor": 0 }