{ "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# Plotting layers\n\nVizualizing a layer pattern in 2D with matplotlib.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nimport nannos as nn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's define our lattice:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lat = nn.Lattice(basis_vectors=[[1, 0], [0, 1]], discretization=2**9)\nepsilon = 6 * lat.ones()\nhole = lat.circle(center=(0.5, 0.5), radius=0.2)\nepsilon[hole] = 1\n\nlay = lat.Layer(name=\"metasurface\", thickness=0.2, epsilon=epsilon)\nlay.plot()\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Another lattice with non orthogonal basis vectors:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lat = nn.Lattice(basis_vectors=[[1, 0], [0.5, 0.5]], discretization=2**9)\nepsilon = lat.ones()\nscat = lat.ellipse(center=(0.75, 0.25), radii=(0.4, 0.1), rotate=15)\nepsilon[scat] = 3 - 1j\n\nlay = lat.Layer(name=\"grating\", thickness=1.3, epsilon=epsilon)\nims = lay.plot(nper=(3, 2), show_cell=True, cmap=\"Greens\", comp=\"im\", cellstyle=\"y--\")\nplt.axis(\"off\")\nplt.colorbar(ims[0], orientation=\"horizontal\")\nplt.title(r\"${\\rm Im}\\,\\varepsilon$\")\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 }