{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using the Local module\n",
"===================="
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook, we demonstrate how to use the pySCATMECH Local module. Local models are those that calculate the differential scattering cross section (DSC) of individual local defects or particles. The bidirectional reflectance distribution function (BRDF) is then determined from \n",
"$$\n",
"f_\\mathrm{r} = \\frac{1}{\\cos{\\theta_\\mathrm{i}}\\cos{\\theta_\\mathrm{r}}}\\frac{N}{A}\\frac{\\mathrm{d}\\sigma}{\\mathrm{d}\\Omega},\n",
"$$\n",
"where $\\mathrm{d}\\sigma/\\mathrm{d}\\Omega$ is the differential scattering cross section, $N/A$ is the number of the defects or particles per unit area, $\\theta_\\mathrm{i}$ is the incident polar angle, and $\\theta_\\mathrm{r}$ is the reflected polar angle. Local_BRDF_Model provides this conversion to its inherited classes.\n",
"\n",
"In this notebook, we will demonstrate the use of the Local package to calculate the DCS.\n",
"\n",
"First, import the necessary libraries. We will be using matplotlib.pyplot for graphing."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from pySCATMECH.local import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The key class in the BRDF module is the `Local_BRDF_Model`. Let's create a `Local_BRDF_Model` and give it some parameters:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{None : 'Bobbert_Vlieger_BRDF_Model',\n",
"'lambda' : '0.532',\n",
"'substrate' : '(4.06,0.05)',\n",
"'type' : '0',\n",
"'density' : '1',\n",
"'sphere' : '(1.59,0)',\n",
"'radius' : '0.05',\n",
"'spherecoat' : 'No_StackModel',\n",
"'stack' : 'No_StackModel',\n",
"'delta' : '0',\n",
"'lmax' : '0',\n",
"'order' : '-1',\n",
"'Norm_Inc_Approx' : '0',\n",
"'improve' : '3'}\n"
]
}
],
"source": [
"spherecoat = {None : 'No_StackModel'}\n",
"\n",
"stack = {None : 'No_StackModel'}\n",
"\n",
"parameters = {'lambda' : 0.532,\n",
" 'substrate' : 4.06+0.05j,\n",
" 'type' : 0,\n",
" 'sphere' : 1.59,\n",
" 'radius' : 0.05,\n",
" 'spherecoat' : spherecoat,\n",
" 'stack' : stack,\n",
" 'delta' : 0,\n",
" 'lmax' : 0,\n",
" 'order' : -1,\n",
" 'Norm_Inc_Approx' : 0,\n",
" 'improve' : 3}\n",
"\n",
"model = Local_BRDF_Model(\"Bobbert_Vlieger_BRDF_Model\",parameters)\n",
"print(model)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{None : 'Bobbert_Vlieger_BRDF_Model',\n",
"'lambda' : '0.305',\n",
"'substrate' : 'silicon',\n",
"'type' : '0',\n",
"'density' : '1',\n",
"'sphere' : 'qS0EoUuZkPtL.tmp',\n",
"'radius' : '0.05',\n",
"'spherecoat' : {None : 'Stack_StackModel',\n",
" 'stack' : '(empty)'},\n",
"'stack' : {None : 'Stack_StackModel',\n",
" 'stack' : 'YWRQ52vGJqpf.tmp 0.0017'},\n",
"'delta' : '0',\n",
"'lmax' : '0',\n",
"'order' : '-1',\n",
"'Norm_Inc_Approx' : '0',\n",
"'improve' : '3'}\n"
]
}
],
"source": [
"# Needed to use OpticalFunction, Film, and FilmStack...\n",
"from pySCATMECH.fresnel import *\n",
"\n",
"# Define two materials...\n",
"PS = OpticalFunction(lambda L: (1+1.4435*L**2/(L**2-0.020216))**(1/2), np.arange(0.4356,1.052,0.01))\n",
"SiO2 = OpticalFunction(lambda L:(1+0.6961663*L**2/(L**2-0.0684043**2)+\n",
" 0.4079426*L**2/(L**2-0.1162414**2)+\n",
" 0.8974794*L**2/(L**2-9.896161**2))**(1/2), \n",
" np.exp(np.linspace(math.log(0.210),math.log(6.7),50)))\n",
"\n",
"Si = OpticalFunction('silicon')\n",
"\n",
"# Define the stack...\n",
"spherecoat = FilmStack()\n",
"stack = FilmStack([Film(SiO2,thickness =0.0017)])\n",
"\n",
"parameters = {'lambda' : 0.305,\n",
" 'substrate' : Si,\n",
" 'type' : 0,\n",
" 'sphere' : PS,\n",
" 'radius' : 0.05,\n",
" 'spherecoat' : spherecoat,\n",
" 'stack' : stack,\n",
" 'delta' : 0,\n",
" 'lmax' : 0,\n",
" 'order' : -1,\n",
" 'Norm_Inc_Approx' : 0,\n",
" 'improve' : 3}\n",
"\n",
"model.setParameters(parameters)\n",
"print(model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's evaluate the Mueller matrix scattering cross section:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 1.19555904e-03 3.03609177e-04 -5.07893704e-21 -1.92025424e-20]\n",
" [ 3.03609177e-04 1.19555904e-03 -1.20270297e-20 -9.54293898e-21]\n",
" [-1.32848338e-21 -9.94772484e-21 -1.13418331e-03 2.25413141e-04]\n",
" [ 1.74231020e-20 -6.89608692e-21 -2.25413141e-04 -1.13418331e-03]]\n"
]
}
],
"source": [
"mDSC = model.MuellerDSC(60*deg, 30*deg)\n",
"print(mDSC)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\r\n",
"\r\n",
"\r\n",
"\r\n"
],
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"thetaslist = np.linspace(-89, 89, 100)\n",
"DSClist = [model.DSC(60*deg, thetas*deg, inc=Polarization('p'), sens=Sensitivity('u')) for thetas in thetaslist]\n",
"\n",
"plt.plot(thetaslist,DSClist)\n",
"plt.xlabel(r\"$\\theta_s$ [degrees]\")\n",
"plt.ylabel(r\"DSC [$\\mathrm{\\mu m}^2/\\mathrm{sr}$]\")\n",
"plt.xlim((-90,90))\n",
"plt.xticks(np.linspace(-90,90,7))\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\r\n",
"\r\n",
"\r\n",
"\r\n"
],
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"thetaslist = np.linspace(-89, 89, 100)\n",
"\n",
"plt.figure()\n",
"for D in [0.1, 0.2, 0.5, 1.0]:\n",
" parameters[\"radius\"] = D/2\n",
" model.setParameters(parameters)\n",
" DSClist = [model.DSC(60*deg, thetas*deg, inc=Polarization('p'), sens=Sensitivity('u')) for thetas in thetaslist]\n",
" plt.plot(thetaslist, DSClist, label = \"D = %g µm\" % D)\n",
"\n",
"plt.xlabel(r\"$\\theta_s$ [degrees]\")\n",
"plt.ylabel(r\"DSC [$\\mathrm{\\mu m}^2/\\mathrm{sr}$]\")\n",
"plt.xlim((-90,90))\n",
"plt.yscale('log')\n",
"plt.xticks(np.linspace(-90,90,7))\n",
"plt.legend()\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.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}