{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "

Thin film Interference

\n", "

\n", "A plane wave with wavelength $\\lambda$ strikes a thin film an angle $\\theta_i$ with the normal. The film has refractive index $n$ and thickness $a$. The phase difference between the rays reflected from the first and secods surfaces is:\n", "\\begin{equation}\n", "\\delta= \\frac{4\\pi a n \\cos(\\theta_i)}{\\lambda} +\\pi.\n", "\\end{equation} \n", " \n", "There is additional interference from rays reflected inside the film at the first surface:\n", "\\begin{equation}\n", "\\delta = \\frac{4\\pi a n \\cos(\\theta_i)}{\\lambda}.\n", "\\end{equation} \n", "The program makes a beautiful color plot of the intensity of a given wavelenth." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true, "deletable": true, "editable": true, "scrolled": true }, "outputs": [], "source": [ "\"\"\" From \"COMPUTATIONAL PHYSICS\" & \"COMPUTER PROBLEMS in PHYSICS\"\n", " by RH Landau, MJ Paez, and CC Bordeianu (deceased).\n", " Copyright R Landau, Oregon State Unv, MJ Paez, Univ Antioquia, \n", " C Bordeianu, Univ Bucharest, 2021. \n", " Please respect copyright & acknowledge our work.\"\"\"\n", "\n", "# ThinFilm.py: Thin film interference by reflection (AJP 72,1248-1253)\n", "\n", "from vpython import *\n", "import numpy as np\n", "\n", "escene = display(width=500, height=500, range=400, background=color.white,\\\n", " foreground=color.black, title= 'Thin Film Interference')\n", "Rcurve = curve(color=color.red) \n", "Gcurve = curve(color=color.green) \n", "Bcurve = curve(color=color.blue) \n", "title = label(pos=vec(-20,350,0), text='Intensity vs Thickness nA in nm',box=0)\n", "waves = label(pos=vec(-30,320,0), text='Red, Green, and Blue Intensities',box=0)\n", "trans = label(pos=vec(-280,300,0),text='Transmission',box=0)\n", "refl = label(pos=vec(210,300,0),text='Reflection',box=0)\n", "lamR = 572 # red in nm \n", "lamB = 430 # Blue \n", "lamG = 540; # Green \n", "i = 0 \n", "film = curve(pos=[vec(-150,-250,0),vec(150,-250,0),vec(150,250,0),\n", " vec(-150,250,0),vec(-150,-250,0)]) #rectangle\n", "Rc = []; Gc = []; Bc = [] # R,G,B intensity arrays\n", "N=1250\n", "delR=np.zeros((N)) # phase shift red\n", "delG=np.zeros((N)) # phase shift green) \n", "delB=np.zeros((N)) # phase shift blue\n", "intR=np.zeros((N)) # intensity red \n", "intG=np.zeros((N)) # intensity green\n", "intB=np.zeros((N)) # intensity blue\n", "xrp=np.zeros((N)) # linear ransformation for red\n", "xbp=np.zeros((N)) # linear transformation for blue\n", "xgp=np.zeros((N)) # linear transformation for green\n", "ap=np.zeros((N)) # film height\n", "DelRt=np.zeros((N)) # tansmission phase shift red\n", "DelGt=np.zeros((N)) # trsnm green phase shift\n", "DelBt=np.zeros((N)) # transm blue phase shift\n", "IntRt=np.zeros((N)) # next 3: intesities trnasm red blue green\n", "IntGt=np.zeros((N))\n", "IntBt=np.zeros((N))\n", "INRE=np.zeros((125)) # again for intensity reflexion\n", "INGE=np.zeros((125)) # different index, \n", "INBE=np.zeros((125))\n", "INRET=np.zeros((125)) #again for intensity transmission\n", "INGET=np.zeros((125))\n", "INBET=np.zeros((125))\n", "kk = 0\n", "\n", "for j in np.arange(0,1250,10):\n", " delR [j] = 4*pi*j/lamR+np.pi # phase shift red\n", " delG[j] = 4*pi*j/lamG+np. pi # phase shift green \n", " delB[j] = 4*pi*j/lamB+np.pi # phase shift for blue \n", " intR[j] = (cos(delR[j]/2))**2 #red intensity\n", " intG[j] = (cos(delG[j]/2))**2 # green intensity \n", " intB[j] = (cos(delB[j]/2))**2 # intensity blue\n", " if j%10 == 0: # intensities every 10 steps\n", " INRE[kk]= intR[j]\n", " INGE[kk]= intG[j]\n", " INBE[kk]= intB[j]\n", " kk+=1 \n", "jj = 0 \n", "for nA in np.arange(0,1250,10):\n", " # for REFLECTION INTERFERENCE\n", " ap[nA]= -500*nA/1240 +250 # film height \n", " xrp[nA] = 300*intR[nA]-150\n", " xbp[nA] = 300*intB[nA]-150\n", " xgp[nA] = 300*intG[nA]-150 # Linear TFs = -500*nA/1240 +250 \n", " Rcurve.append(pos = vec(xrp[nA],ap[nA],0))\n", " Gcurve.append(pos=vec(xgp[nA],ap[nA],0))\n", " Bcurve.append(pos=vec( xbp[nA],ap[nA],0 ))\n", " # FOR TRANSMISSION INTERFERENCE \n", " DelRt[nA] = 4*np.pi*nA/lamR # phase shift red Transmission\n", " DelGt[nA] = 4*np.pi*nA/lamG # phase shft green Transmission\n", " DelBt[nA] = 4*np.pi*nA/lamB # phase shft blue transmission\n", " IntRt[nA] = cos(DelRt[nA]/2)**2 # red intensity transmission\n", " IntGt[nA] = cos(DelGt[nA]/2)**2 # green intensity transmission\n", " IntBt[nA] = cos(DelBt[nA]/2)**2 # blue intensity transmission\n", " if nA%10==0: # intensities for transm every 10 steps\n", " INRET[jj] = IntRt[nA]\n", " INGET[jj] = IntGt[nA]\n", " INBET[jj] = IntBt[nA]\n", " jj += 1\n", " \n", "for nA in range (0,125): #to plot 125 boxes\n", " col=vec(INRE[nA],INGE[nA],INBE[nA])\n", " reflesc = -500*nA/125+250 #250=m 0 +b, -250 =m 125 +b \n", " box(pos=vec(205,reflesc,0),width=0.1,height=10,length=50,color=col)\n", " colt=(vec(INRET[nA],INGET[nA],INBET[nA])) #transmission colors\n", " #if you uncomment next line and comment ´previous ne you have whitecolors\n", " # it sums interference by reflection and by transmission intensities\n", " # colt = vec(INRET[nA]+INRE[nA],INGET[nA]+INGE[nA],INBET[nA]+INBE[nA]) # Colors by transmission\n", " box(pos=vec(-270,reflesc,0),width=0.1,height=10, length=50, color=colt) \n", " if (nA%20==0): # Labels for vertical axis\n", " prof = nA*10\n", " escal = -500*nA/125+250\n", " depth = label(pos=vec(-200,escal,0),text='%4d'%prof,box=0)" ] } ], "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.13" } }, "nbformat": 4, "nbformat_minor": 2 }