Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
"""
@author: Pinkman
"""
import numpy as np
import matplotlib.pyplot as mat
c=1
#a
p=2
while p<=3:
t=np.pi/12
plotxy(p,t,c)
p+=1
c+=1
#b
p=3
plotxN(p,c)
c+=1
#c
pi=3
p=100
while True:
if pi>12:
pi=4
t=np.pi/pi
plotxy(p,t,c)
pi*=2
c+=1
if pi==8:
break
#d
#Addenda
p=100
t=(np.pi/12)
xg,yg=[],[]
xf,xfn, yn= 0,0,[]
theta=(np.pi/2)-(t) #theta initial
n=np.linspace(1,1.3,p) ## of slabs
y=np.ones(50) #para magstart sa 1
q=p
while q>=0:
if q!=p:
thetaC=np.arcsin(n[q-1]/n[q])
if theta>thetaC:
print ("For Figure " +str(c)+ ", At the " +str(p-q)+ "th slab, the
incident angle is greater than the critical angle " +str(thetaC*180/np.pi)+ "
degrees; therefore, all the energy is reflected and no refracted ray exists.")
n=np.linspace(n[q],n[p-1],p-q)
p,q=p-q,-1
while q<=p-2:
if q!=-1:
theta =
(np.arcsin((n[q]*np.sin(theta))/n[q+1]))#n[x]*np.sin(15)=n[x+1]*np.sin(theta)
xfn=xf+((1/100)*np.tan(theta)) #boundary of x in next slab
x=np.linspace(xf,xfn) #bounds from one slab to another
xn=np.linspace(0,xfn-xf) #for solving y
yn=(xn/np.tan(theta)) #value of y in (0,0)
y=y[49]+yn #shifts y to the last point of prev slab
ctr=0
while ctr<50:
xg.append(x[ctr])
yg.append(y[ctr])
ctr+=1
xf=xfn
q+=1
break
theta = (np.arcsin((n[q]*np.sin(theta))/n[q-1]))
xfn=xf+((1/p)*np.tan(theta)) #boundary of x in next slab
x=np.linspace(xf,xfn) #bounds from one slab to another
xn=np.linspace(0,xfn-xf) #for solving y
yn=-(xn/np.tan(theta)) #value of y in (0,0)
y=y[49]+yn #shifts y to the last point of prev slab
ctr=0
while ctr<50:
xg.append(x[ctr])
yg.append(y[ctr])
ctr+=1
xf=xfn
q-=1
mat.figure()
mat.plot(xg,yg)
mat.ylim(0,1)
mat.xlim(0,3)
mat.xlabel("X (m)")
mat.ylabel("Y (m)")
mat.title("Figure " +str(c)+ ". Path of light across " +str(p)+ " slabs of
decreasing index of refraction and an initial $\\theta$ =" +str(t*180/np.pi)+
"$\\degree$.\n")
mat.savefig("Figure" +str(c))
c+=1