{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Refractive index\n\nPlot material properties.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nimport refidx as ri" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the database\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "db = ri.DataBase()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The ``materials`` attribute is a nested dictionary with all the materials\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mat = db.materials\nmat.print()\n\n\nprint(mat.findkeys(\"Si\"))\n\nprint(mat.find(\"Au\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get a material (an instance of the ``Material`` class). For example:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mat = db.materials[\"main\"][\"Au\"][\"Johnson\"]\nprint(mat)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print material information\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(mat.info)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the wavelength range\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "wr = mat.wavelength_range\nprint(\"wavelength range (in microns): \", wr)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define wavelengths array\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lamb = np.linspace(*wr, 1000)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the refractive index\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "index = mat.get_index(lamb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot refractive index dispersion\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.style.use(\"../doc/refidx.mplstyle\")\n\nfig, ax = plt.subplots(2, 1, figsize=(3, 3))\nax[0].plot(lamb, index.real, \"-\", color=\"#aa0044\")\nax[1].plot(lamb, index.imag, \"-\", color=\"#6886b3\")\nax[0].set_xlabel(r\"Wavelength ($\\rm \u03bcm$)\")\nax[1].set_xlabel(r\"Wavelength ($\\rm \u03bcm$)\")\nax[0].set_ylabel(r\"$n^{\\prime}$\")\nax[1].set_ylabel(r\"$n^{\\prime\\prime}$\")\nplt.suptitle(mat)\nplt.tight_layout()\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add data reference and comments\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mat.print_info(html=True, tmp_dir=os.path.join(\"..\", \"doc\", \"auto_examples\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. raw:: html\n :file: out.html\n\n" ] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 0 }