{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from solcore import material\n",
"from solcore import si\n",
"from solcore.material_system import create_new_material\n",
"from solcore.absorption_calculator import create_nk_txt, download_db, search_db\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"When adding custom materials - or getting the refractive index database - the
\n",
"information will be stored in the Solcore's users folder. These can be setup by setting
\n",
"the SOLCORE_USER_DATA environmental variable to your prefered location or, by default,
\n",
"it will be in your home directory, in a directory called .solcore.
\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"EXAMPLE 1
\n",
"need to have n and k data, and a parameter file in the correct format -
\n",
"see examples of parameter files in e.g. material_data/Adachi/binaries.txt
\n",
"create a new material, silicon-germanium-tin, from input files. Here,
\n",
"the parameters in SiGeSn_params.txt have been copied directly from Ge.
\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"create_new_material('SiGeSn', '../data/SiGeSn_n.txt', '../data/SiGeSn_k.txt', '../data/SiGeSn_params.txt')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"can now create an instance of it like any Solcore material"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"SiGeSn = material('SiGeSn')()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure()\n",
"plt.plot(si(np.arange(300, 1700, 5), 'nm')*1e9, SiGeSn.n(si(np.arange(300, 1700, 5), 'nm')))\n",
"plt.plot(si(np.arange(300, 1700, 5), 'nm')*1e9, SiGeSn.k(si(np.arange(300, 1700, 5), 'nm')))\n",
"plt.xlabel('Wavelength (nm)')\n",
"plt.ylabel('SiGeSn n / k')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"EXAMPLE 2
\n",
"Can also create a Solcore material from a material in the refractiveindex.info database:
\n",
"if necessary, download database:
\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"download_db()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"search what options are available for diamond, then use the first result's pageid to
\n",
"create data files for the n & k of diamond:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"results = search_db('Diamond')\n",
"create_nk_txt(pageid=results[0][0], file='C_Diamond')\n",
"create_new_material(mat_name = 'Diamond', n_source='C_Diamond_n.txt', k_source='C_Diamond_k.txt')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Diamond = material('Diamond')()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure()\n",
"plt.plot(si(np.arange(100, 800, 5), 'nm')*1e9, Diamond.n(si(np.arange(100, 800, 5), 'nm')))\n",
"plt.plot(si(np.arange(100, 800, 5), 'nm')*1e9, Diamond.k(si(np.arange(100, 800, 5), 'nm')))\n",
"plt.xlabel('Wavelength (nm)')\n",
"plt.ylabel('Diamond n / k')\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
}