{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

Refractive Index Information DB

" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from solcore.absorption_calculator.nk_db import download_db, search_db\n", "from solcore import material\n", "from solcore import si\n", "from solcore.solar_cell import SolarCell\n", "from solcore.structure import Layer\n", "from solcore.solar_cell_solver import solar_cell_solver, default_options\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "wl = si(np.arange(100, 900, 10), 'nm')\n", "\n", "opts = default_options\n", "opts.optics_method = 'TMM'\n", "opts.wavelength = wl" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Download the database from refractiveindex.info. This only needs to be done once.\n", "Can specify the source URL and number of interpolation points.\n", "(Lines below are commented out to avoid problems in testing, uncomment to run the example.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# download_db()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Can search the database to select an appropriate entry. Search by element/chemical formula.\n", "In this case, look for silver." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# search_db('Ag', exact = True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This prints out, line by line, matching entries. This shows us entries with\n", "\"pageid\"s 0 to 14 correspond to silver.\n", "\n", "Let's compare the optical behaviour of some of those sources:\n", "pageid = 0, Johnson\n", "pageid = 2, McPeak\n", "pageid = 8, Hagemann\n", "pageid = 12, Rakic (BB)\n", "\n", "\n", "create instances of materials with the optical constants from the database.\n", "The name (when using Solcore's built-in materials, this would just be the\n", "name of the material or alloy, like 'GaAs') is the pageid, AS A STRING, while\n", "the flag nk_db must be set to True to tell Solcore to look in the previously\n", "downloaded database from refractiveindex.info" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Ag_Joh = material(name = '0', nk_db=True)()\n", "#\n", "# Ag_McP = material(name = '2', nk_db=True)()\n", "# Ag_Hag = material(name = '8', nk_db=True)()\n", "# Ag_Rak = material(name = '12', nk_db=True)()\n", "#\n", "# Ag_Sol = material(name = 'Ag')() # Solcore built-in (from SOPRA)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "plot the n and k data. Note that not all the data covers the full wavelength range,\n", "so the n/k value stays flat." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# names = ['Johnson', 'McPeak', 'Hagemann', 'Rakic', 'Solcore built-in']\n", "#\n", "# plt.figure()\n", "# plt.plot(wl * 1e9, Ag_Joh.n(wl), wl * 1e9, Ag_McP.n(wl),\n", "# wl * 1e9, Ag_Hag.n(wl), wl * 1e9, Ag_Rak.n(wl), wl * 1e9, Ag_Sol.n(wl))\n", "# plt.legend(labels=names)\n", "# plt.xlabel(\"Wavelength (nm)\")\n", "# plt.ylabel(\"n\")\n", "# plt.show()\n", "#\n", "# plt.figure()\n", "# plt.plot(wl * 1e9, Ag_Joh.k(wl), wl * 1e9, Ag_McP.k(wl),\n", "# wl * 1e9, Ag_Hag.k(wl), wl * 1e9, Ag_Rak.k(wl), wl * 1e9, Ag_Sol.k(wl))\n", "# plt.legend(labels=names)\n", "# plt.xlabel(\"Wavelength (nm)\")\n", "# plt.ylabel(\"k\")\n", "# plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compare performance as a back mirror on a GaAs 'cell'\n", "\n", "Solid line: absorption in GaAs\n", "Dashed line: absorption in Ag" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# GaAs = material('GaAs')()\n", "#\n", "# colors = ['b', 'r', 'k', 'm', 'y']\n", "#\n", "# plt.figure()\n", "# for c, Ag_mat in enumerate([Ag_Joh, Ag_McP, Ag_Hag, Ag_Rak, Ag_Sol]):\n", "# my_solar_cell = SolarCell([Layer(width=si('50nm'), material = GaAs)] +\n", "# [Layer(width = si('100nm'), material = Ag_mat)])\n", "# solar_cell_solver(my_solar_cell, 'optics', opts)\n", "# GaAs_positions = np.linspace(my_solar_cell[0].offset, my_solar_cell[0].offset + my_solar_cell[0].width, 1000)\n", "# Ag_positions = np.linspace(my_solar_cell[1].offset, my_solar_cell[1].offset + my_solar_cell[1].width, 1000)\n", "# GaAs_abs = np.trapz(my_solar_cell[0].diff_absorption(GaAs_positions), GaAs_positions)\n", "# Ag_abs = np.trapz(my_solar_cell[1].diff_absorption(Ag_positions), Ag_positions)\n", "# plt.plot(wl*1e9, GaAs_abs, color=colors[c], linestyle='-', label=names[c])\n", "# plt.plot(wl*1e9, Ag_abs, color=colors[c], linestyle='--')\n", "#\n", "# plt.legend()\n", "# plt.xlabel(\"Wavelength (nm)\")\n", "# plt.ylabel(\"Absorbed\")\n", "# plt.show()" ] } ], "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.6.9" } }, "nbformat": 4, "nbformat_minor": 2 }