summaryrefslogtreecommitdiff
path: root/sample_notebooks/ShivaAmruthavakkula
diff options
context:
space:
mode:
authorThomas Stephen Lee2015-09-07 17:46:06 +0530
committerThomas Stephen Lee2015-09-07 17:46:06 +0530
commit78784b374b2d1a9be66eb4ad41470409e2bd4dfa (patch)
tree7b0144248a9d5c9b6c66065697177ee04a30f93e /sample_notebooks/ShivaAmruthavakkula
parent41f1f72e9502f5c3de6ca16b303803dfcf1df594 (diff)
downloadPython-Textbook-Companions-78784b374b2d1a9be66eb4ad41470409e2bd4dfa.tar.gz
Python-Textbook-Companions-78784b374b2d1a9be66eb4ad41470409e2bd4dfa.tar.bz2
Python-Textbook-Companions-78784b374b2d1a9be66eb4ad41470409e2bd4dfa.zip
add/update books
Diffstat (limited to 'sample_notebooks/ShivaAmruthavakkula')
-rwxr-xr-xsample_notebooks/ShivaAmruthavakkula/chapter1.ipynb448
1 files changed, 448 insertions, 0 deletions
diff --git a/sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb b/sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb
new file mode 100755
index 00000000..37ee420b
--- /dev/null
+++ b/sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb
@@ -0,0 +1,448 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the divergence of the beam is 8.05960631817e-05 in radians\n",
+ "the divergence of the beam is 0.00461781426568 in degrees\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.1.1 :Divergence of a beam '''\n",
+ "\n",
+ "import math\n",
+ "\n",
+ " #decalring variables\n",
+ "Lambda=633*(10**-9) #wavelength of laser\n",
+ "s=10*10**-3 #spot size of the laser\n",
+ "w=s/2 # waist radius\n",
+ "\n",
+ "#calculations\n",
+ "\n",
+ "theta_radians=(4*Lambda)/(math.pi*(2*w))\n",
+ "num=math.pi*(w)\n",
+ "theta_degrees=math.degrees(theta_radians)\n",
+ "\n",
+ "#results\n",
+ "print \"the divergence of the beam is\",theta_radians,\"in radians\"\n",
+ "print \"the divergence of the beam is\",theta_degrees,\"in degrees\"\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Materials EpsilonR squareroot(EpsilonR)\n",
+ "\n",
+ "------------------------------------------\n",
+ "\n",
+ "silicon \t11.9 \t3.44963766213 \n",
+ "\n",
+ "Diamond \t5.7 \t2.38746727726 \n",
+ "\n",
+ "GaAs \t13.1 \t3.61939221417 \n",
+ "\n",
+ "SiO2 \t3.84 \t1.95959179423 \n",
+ "\n",
+ "Water \t80 \t8.94427191 \n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.2.1: relative permittivity and refractive index n'''\n",
+ "\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "numbers=[0,1,2,3,4]\n",
+ "\n",
+ "#declaring array variables\n",
+ "materials=['silicon','Diamond','GaAs ','SiO2 ','Water '] #declaring the materials\n",
+ "relative_permittivity=[11.9,5.7,13.1,3.84,80] #declaring the relative permittivity at low frequencies\n",
+ "\n",
+ "#calculations\n",
+ "refractive_index=[] #declaring result set \n",
+ "for i in relative_permittivity:\n",
+ " t=math.sqrt(i)\n",
+ " refractive_index.append(t)\n",
+ " \n",
+ "#Results and Table\n",
+ "print \"Materials EpsilonR squareroot(EpsilonR)\\n\"\n",
+ "print \"------------------------------------------\\n\"\n",
+ "for j in numbers:\n",
+ " print materials[j],\"\\t\",relative_permittivity[j],\"\\t\",refractive_index[j],\"\\n\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The phase velocity is 206896551.724\n",
+ "The group velocity is 205479452.055\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.3.2:Group and phase velocities'''\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "#declaring variables\n",
+ "Lambda=1*10**-6 #wavelength of light\n",
+ "n=1.450 #refractive index\n",
+ "c=3*10**8 #velocity of light in free space\n",
+ "group_index=1.46 #Group index(available from graph)\n",
+ "\n",
+ "#calculations\n",
+ "phase_velocity=c/n #calculation of phase velocity\n",
+ "group_velocity=c/group_index #calculation of group velocity\n",
+ "\n",
+ "#results\n",
+ "\n",
+ "print \"The phase velocity is \",phase_velocity\n",
+ "print \"The group velocity is \",group_velocity"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The Elctric field and Magnetic field of air are 86.7926073205 and 2.89308691068e-07 respectively\n",
+ "The Elctric field and Magnetic field of glass are 72.0773372269 and 3.48373796597e-07 respectively\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.4.1: Electric and magnetic fields in light'''\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "#Declaring variables\n",
+ "Irradiance=1*10**-3*10**4 #Declaring irradiance in standard units\n",
+ "ng=1.45 #declaring refractive index of glass\n",
+ "c=3*10**8 #declaring velocity of light\n",
+ "n=1 #Refractive index of free space\n",
+ "e=8.85*10**-12\n",
+ "\n",
+ "#calculations of magnitude of electrical and magnetic fields in air\n",
+ "El_air=math.sqrt((2*Irradiance)/(c*e*n)) #Electric field calculation(air)\n",
+ "B_air=(n*El_air)/c #Magnetic field calculation(air)\n",
+ "\n",
+ "#calculations of magnitude of electrical and magnetic fields in glass\n",
+ "El_glass=math.sqrt((2*Irradiance)/(c*e*ng)) #Electric field calculation(glass) \n",
+ "B_glass=(ng*El_glass)/c #magnetic field calculation(glass) \n",
+ "\n",
+ "#Results\n",
+ "print \"The Elctric field and Magnetic field of air are \",El_air,\"and\",B_air,\"respectively\"\n",
+ "print \"The Elctric field and Magnetic field of glass are \",El_glass,\"and\",B_glass,\"respectively\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A\n",
+ "the crirical angle is equal to 0.986206896552 \n",
+ "\n",
+ "B\n",
+ "The phase change in medium 1 at incident angle=85 degrees with electrical component perpendicular to the plane of incidence is 116.45255621 degrees\n",
+ "The phase change in medium 1 at incident angle=85 degrees with electrical component parallel to the plane of incidence is -62.1314255434 degrees\n",
+ "The phase change in medium 1 at incident angle=90 degrees with electrical component perpendicular to the plane of incidence is 180.0 degrees\n",
+ "The phase change in medium 1 at incident angle=90 degrees with electrical component parallel to the plane of incidence is -2.84217094304e-14 degrees \n",
+ "\n",
+ "C\n",
+ "The penetration depth of medium 2 at incident angle of 85 degrees is 7.80048054638e-07 meters\n",
+ "The penetration depth of medium 2 at incident angle of 90 degrees is 6.63145596216e-07 meters\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.6.2'''\n",
+ "import math\n",
+ "\n",
+ "#declaration of variables\n",
+ "\n",
+ "n1=1.450 #refractive index of first medium\n",
+ "n2=1.430 #refractive index of second medium\n",
+ "Lambda=1*10**-6 #wavelength of light at standard units\n",
+ "theta_i1=85 #declaration of incidence angle 1\n",
+ "theta_i2=90 #declaration of incidence angle 2\n",
+ "\n",
+ "#Calculation of minimum incidence angle\n",
+ "theta_c=n2/n1 #calculation of critical angle\n",
+ "\n",
+ "#Calculation of phase change in medium 1 at incident angle 85 with perpendicular electrical component\n",
+ "tanphi_pp_85m1=math.sqrt(math.pow(math.sin(math.radians(theta_i1)),2)-math.pow((n2/n1),2))/math.cos(math.radians(theta_i1))\n",
+ "phi_pp_85im1=2*math.degrees(math.atan(tanphi_pp_85m1))\n",
+ "\n",
+ "#Calculation of phase change in medium 1 at incident angle 85 with parallel electrical component\n",
+ "tanphi_prll_85m1=math.pow((n1/n2),2)*tanphi_pp_85m1\n",
+ "phi_prll_85m1=2*(math.degrees(math.atan(tanphi_prll_85m1)))-math.degrees(math.pi)\n",
+ "phi_prll_inv_85m1=180+phi_prll_85m1\n",
+ "\n",
+ "#Calculation of phase change in medium 1 at incident angle 90 with perpendicular electrical component\n",
+ "tanphi_pp_90m1=math.sqrt(math.pow(math.sin(math.radians(theta_i2)),2)-math.pow((n2/n1),2))/math.cos(math.radians(theta_i2))\n",
+ "phi_pp_90m1=2*math.degrees(math.atan(tanphi_pp_90m1))\n",
+ "\n",
+ "#Calculation of phase change in medium 1 at incident angle 85 with parallel electrical component\n",
+ "tanphi_prll_90m1=math.pow((n1/n2),2)*tanphi_pp_90m1\n",
+ "phi_prll_90m1=2*(math.degrees(math.atan(tanphi_prll_90m1)))-math.degrees(math.pi)\n",
+ "phi_prll_inv_90m1=180+phi_prll_90m1\n",
+ "\n",
+ "#Calculation of penetration depth in medium 2 at incident angle 85\n",
+ "alpha_85=(2*math.pi*n2/Lambda)*(math.sqrt((math.pow((n1/n2),2)*math.pow(math.sin(math.radians(theta_i1)),2))-1))\n",
+ "delta_85=1/alpha_85\n",
+ "\n",
+ "#calculation of penetration depth in medium 2 at incident angle 90\n",
+ "alpha_90=(2*math.pi*n2/Lambda)*(math.sqrt((math.pow((n1/n2),2)*math.pow(math.sin(math.radians(theta_i2)),2))-1))\n",
+ "delta_90=1/alpha_90\n",
+ "\n",
+ "#Results\n",
+ "print \"A\"\n",
+ "print \"the crirical angle is equal to \",theta_c,\"\\n\"\n",
+ "print \"B\"\n",
+ "print \"The phase change in medium 1 at incident angle=85 degrees with electrical component perpendicular to the plane of incidence is\",phi_pp_85im1,\"degrees\"\n",
+ "print \"The phase change in medium 1 at incident angle=85 degrees with electrical component parallel to the plane of incidence is\",phi_prll_85m1,\"degrees\"\n",
+ "print \"The phase change in medium 1 at incident angle=90 degrees with electrical component perpendicular to the plane of incidence is\",phi_pp_90m1,\"degrees\"\n",
+ "print \"The phase change in medium 1 at incident angle=90 degrees with electrical component parallel to the plane of incidence is\",phi_prll_90m1,\"degrees \\n\"\n",
+ "print \"C\"\n",
+ "print \"The penetration depth of medium 2 at incident angle of 85 degrees is \",delta_85,\"meters\"\n",
+ "print \"The penetration depth of medium 2 at incident angle of 90 degrees is \",delta_90,\"meters\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A\n",
+ "the reflection coefficient when light travels from air to glass is -0.2\n",
+ "the reflectance when light passes from air to glass is 0.04\n",
+ "The phase change of the reflected light is \n",
+ "180\n",
+ "B\n",
+ "the reflection coefficient when light travels from glass to air is 0.2\n",
+ "the reflectance when light passes from glass to air is 0.04\n",
+ "The phase change of the reflected light is \n",
+ "180\n",
+ "C\n",
+ "The polarisation angle is 56.309932474\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.6.3: Reflection at normal Incidence.Internal and external reflection'''\n",
+ "import math\n",
+ "\n",
+ "#declaration of variables\n",
+ "nglass=1.5\n",
+ "nair=1\n",
+ "\n",
+ "#declaration of phase change\n",
+ "def phasechange(r):\n",
+ " if r<0:\n",
+ " return 180\n",
+ " else:\n",
+ " return 0 \n",
+ "#Calculation of reflection coefficient and intensity from air to glass\n",
+ "r_coeffag=(nair-nglass)/(nair+nglass) #reflection coefficient\n",
+ "Rag=math.pow(r_coeffag,2) #Reflectance\n",
+ "pag=phasechange(r_coeffag)\n",
+ "\n",
+ "\n",
+ "#Calculation of relection and intensity from glass to aie\n",
+ "r_coeffga=(nglass-nair)/(nglass+nair)\n",
+ "Rga=math.pow(r_coeffga,2)\n",
+ "pga=phasechange(r_coeffga)\n",
+ "\n",
+ "#calculation of polarisation angle\n",
+ "theta_p=math.degrees(math.atan(nglass/nair))\n",
+ "\n",
+ "#Results\n",
+ "print \"A\"\n",
+ "print\"the reflection coefficient when light travels from air to glass is \",r_coeffag\n",
+ "print \"the reflectance when light passes from air to glass is \",Rag\n",
+ "print \"The phase change of the reflected light is \\n\",pag\n",
+ "print \"B\"\n",
+ "print\"the reflection coefficient when light travels from glass to air is \",r_coeffga\n",
+ "print \"the reflectance when light passes from glass to air is \",Rga\n",
+ "print \"The phase change of the reflected light is \\n\",pag\n",
+ "\n",
+ "print \"C\"\n",
+ "print \"The polarisation angle is \",theta_p"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the reflectance of the Silicon is 0.308641975309\n",
+ "the refractive index of coating must be 1.87082869339\n",
+ "the thickness of the coating is 9.21052631579e-08 meters\n"
+ ]
+ }
+ ],
+ "source": [
+ "'''Example 1.6.4: Antireflection coatings on solarcells'''\n",
+ "import math\n",
+ "\n",
+ "#Declaration of variables\n",
+ "nair=1\n",
+ "nsi=3.5\n",
+ "ncoating=1.9\n",
+ "Lambda=700*10**-9\n",
+ "\n",
+ "#declaration of phase change\n",
+ "def phasechange(r):\n",
+ " if r<0:\n",
+ " return 180\n",
+ " else:\n",
+ " return 0 \n",
+ "\n",
+ "#Calculation of reflectance at Silicon\n",
+ "rsi=((nair-nsi)/(nair+nsi))\n",
+ "Rsi=math.pow(rsi,2)\n",
+ "psi=phasechange(rsi)\n",
+ "\n",
+ "#calculation of refractive index of coating\n",
+ "ncoating_theoritical=math.sqrt(nair*nsi)\n",
+ "\n",
+ "#calculation of thickness\n",
+ "d=Lambda/(4*ncoating)\n",
+ "\n",
+ "#results\n",
+ "print \"the reflectance of the Silicon is \",Rsi\n",
+ "print \"the refractive index of coating must be \",ncoating_theoritical\n",
+ "print \"the thickness of the coating is \",d,\" meters\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "# '''Example 1.7.1: Resonator modes and spectral width'''\n",
+ "import math\n",
+ "\n",
+ "#declaration of variables\n",
+ "L=100*10**-6\n",
+ "R=0.9\n",
+ "Lambda=900*10**-9\n",
+ "c=3*10**8\n",
+ "\n",
+ "#Calculation of seperation of modes\n",
+ "delta_vm=c/(2*L)\n",
+ "\n",
+ "#calculation of finesse\n",
+ "F=((math.pi)*math.sqrt(R))/(1-R)\n",
+ "\n",
+ "#calculation of modewidth\n",
+ "del_vm=delta_vm/F\n",
+ "\n",
+ "#calculation of mode frequency\n",
+ "vm=c/Lambda\n",
+ "\n",
+ "#calculation of spectral width\n",
+ "del_lambda=(c/math.pow(vm,2))*del_vm\n",
+ "\n",
+ "#Results\n",
+ "print \"The seperation of modes is \",delta_vm,\" Hertz\"\n",
+ "print \"The spectral width is\", del_lambda,\" meters\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "celltoolbar": "Edit Metadata",
+ "kernelspec": {
+ "display_name": "Python 2",
+ "language": "python",
+ "name": "python2"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 2
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython2",
+ "version": "2.7.10"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}