{ "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# Permittivity approximation\n\nGet the Fourier representation of the permittivity as a function of number of harmonics.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport nannos as nn\n\nlattice = nn.Lattice([[1.5, 0], [0.4, 1]], discretization=(2**10, 2**10))\nsup = lattice.Layer(\"Superstrate\", epsilon=1)\nsub = lattice.Layer(\"Substrate\", epsilon=1)\nhole = lattice.ellipse(center=(1.1, 0.6), radii=(0.2, 0.4), rotate=60)\nincl = lattice.rectangle(center=(0.5, 0.3), widths=(0.2, 0.4), rotate=-45)\nepsilon = lattice.ones() * 4\nepsilon[hole] = 1\nepsilon[incl] = 6\nms = lattice.Layer(\"Metasurface\", thickness=0.5, epsilon=epsilon)\npw = nn.PlaneWave(wavelength=1.5, angles=(0, 0, 0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lets first plot the permmitivity we want to approximate\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.figure()\nims = ms.plot(cmap=\"viridis\")\nplt.xlabel(\"$x$\")\nplt.ylabel(\"$y$\")\nplt.colorbar(ims[0], orientation=\"horizontal\")\nplt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Loop through number of harmonics\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "for n in [3, 5, 7, 11, 21, 41]:\n sim = nn.Simulation([sup, ms, sub], pw, nh=n**2)\n eps = sim.get_epsilon(ms)\n plt.figure(figsize=(2, 2))\n approx = plt.pcolormesh(*lattice.grid, eps.real)\n ims = ms.plot(alpha=0.1, cmap=\"Greys\")\n plt.xlabel(\"$x$\")\n plt.ylabel(\"$y$\")\n plt.colorbar(approx, orientation=\"horizontal\")\n plt.title(rf\"$n_h = {sim.nh}$\")\n plt.tight_layout()" ] }, { "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 }