{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from solcore.light_source import LightSource, SmartsSolverError" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "wl = np.linspace(300, 3000, 200)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now different types of light sources can be defined" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "gauss = LightSource(source_type='laser', x=wl, center=800, linewidth=50, power=200)\n", "bb = LightSource(source_type='black body', x=wl, T=5800, entendue='Sun')\n", "am15g = LightSource(source_type='standard', x=wl, version='AM1.5g')\n", "spectral = LightSource(source_type='SPECTRAL2', x=wl)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot comparing the different light sources" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(1)\n", "plt.plot(*gauss.spectrum(), label='Gauss')\n", "plt.plot(*bb.spectrum(), label='Black body')\n", "plt.plot(*am15g.spectrum(), label='AM1.5G')\n", "plt.plot(*spectral.spectrum(), label='SPECTRAL2')\n", "\n", "try:\n", " smarts = LightSource(source_type='SMARTS', x=wl)\n", " plt.plot(*smarts.spectrum(), label='SMARTS')\n", "except SmartsSolverError:\n", " pass\n", "\n", "plt.xlim(300, 3000)\n", "plt.xlabel('Wavelength (nm)')\n", "plt.ylabel('Power density (Wm$^{-2}$nm$^{-1}$)')\n", "plt.tight_layout()\n", "plt.legend()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "try:\n", " if \"smarts\" in locals():\n", " # Plot comparing the spectra calculated with SMARTS at different hours of the day\n", " for h in range(8, 20):\n", " plt.plot(*smarts.spectrum(HOUR=h), label='{} h'.format(h))\n", " plt.xlim(300, 3000)\n", " plt.xlabel('Wavelength (nm)')\n", " plt.ylabel('Power density (Wm$^{-2}$nm$^{-1}$)')\n", " plt.tight_layout()\n", " plt.legend()\n", "except SmartsSolverError:\n", " pass\n", "\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 }