{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from scipy.interpolate import interp1d\n", "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from solcore.structure import Structure\n", "from solcore.absorption_calculator import calculate_rat" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "E_eV = np.linspace(0.65, 4, 1000)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def nk_convert(fname, energy):\n", " \"\"\" Designed to handle nk data files\"\"\"\n", "\n", " # Import data...\n", " E_n, n, E_k, k = np.loadtxt(fname, delimiter=\",\", unpack=True)\n", " print(\"File :: \" + fname + \" :: Imported Successfully!\")\n", "\n", " # Interpolate data...\n", " n_interp = interp1d(E_n, n, bounds_error=False, fill_value=(n[0], n[-1]))(energy)\n", " k_interp = interp1d(E_k, k, bounds_error=False, fill_value=(k[0], k[-1]))(energy)\n", " return (energy, n_interp, k_interp)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load nk data using nk_convert function..." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "alinp_nk = nk_convert(\"../data/AlInP_nk.csv\", energy=E_eV)\n", "gainp_nk = nk_convert(\"../data/GaInP_nk.csv\", energy=E_eV)\n", "mgf_nk = nk_convert(\"../data/MgF_nk.csv\", energy=E_eV)\n", "sic_nk = nk_convert(\"../data/SiCx_nk.csv\", energy=E_eV)\n", "zns_nk = nk_convert(\"../data/ZnS_nk.csv\", energy=E_eV)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Build the optical stack..." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stack = Structure([\n", " [117, 1240 / E_eV, mgf_nk[1], mgf_nk[2]],\n", " [80, 1240 / E_eV, sic_nk[1], sic_nk[2]],\n", " [61, 1240 / E_eV, zns_nk[1], zns_nk[2]],\n", " [25, 1240 / E_eV, alinp_nk[1], alinp_nk[2]],\n", " [350000, 1240 / E_eV, gainp_nk[1], gainp_nk[2]]\n", "])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "angles = np.linspace(0, 80, 10)\n", "RAT_angles = []" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\"Calculate RAT ::\")\n", "for theta in angles:\n", " print(\"Calculating at angle :: %4.1f deg\" % theta)\n", " # Calculate RAT data...\n", " rat_data = calculate_rat(stack, angle=theta, wavelength=1240 / E_eV)\n", " RAT_angles.append((theta, rat_data[\"R\"], rat_data[\"A\"]))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "colors = plt.cm.jet(np.linspace(1, 0, len(RAT_angles)))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax2 = plt.subplots(1, 1)\n", "\n", "for i, RAT in enumerate(RAT_angles):\n", " ax2.plot(1240 / E_eV, RAT[1] * 100, ls=\"-\", color=colors[i], label=\"%4.1f$^\\circ$\" % RAT[0])\n", " ax2.plot(1240 / E_eV, RAT[2] * 100, ls=\"--\", color=colors[i])\n", "\n", "ax2.set_ylim([0, 100])\n", "ax2.set_xlim([300, 1800])\n", "ax2.set_xlabel(\"Wavelength (nm)\")\n", "ax2.set_ylabel(\"Reflection and Transmission (%)\")\n", "ax2.legend(loc=5)\n", "ax2.text(0.05, 0.45, '(a)', transform=ax2.transAxes, fontsize=12)\n", "\n", "plt.tight_layout(w_pad=4)\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.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }