Sunday, April 16, 2023

Python and Casio fx-4000P: Transmission and Deviation Angles - Prism

Python and Casio fx-4000P:   Transmission and Deviation Angles - Prism




Celebrating 12 Years in the Blogopshere!   Thank you to my readers, subscribers, and everyone who has stopped by during the years!  




Introduction


Today's program calculates the transmission and deviation angles passing through a prism.   The refractive index of the prism is determined by the material it is made of.   





Formulas Used for the transmission and deviation angles, respectively:


θt = arcsin( α * √(n^2 - sin^2 θi) - sin θi * cos α)


δ = θi + θt - α


The Python program calculates for prisms made of acrylic, glass, fluorite, and plastic.  



Python Script:  prism.py


Program Notes:


1.  The angle mode in Python is always radian angle mode. Conversions between degrees and radians are necessary on this code.


2.  This code was programmed with a Casio fx-9750GIII in the Python app.   I could have used the degrees and radians functions, however, they were not present in the calculator's catalog.  


3.  I used a While loop and initialized the choice variable k as -1 to prevent the user from choosing anything from picking outside the range 0-3.  This simulates the Menu command in Casio graphing calculator programming.


4. The refractive indices are average and approximate.  


5. To make everything fit on the screen, the new line escape character, \n, is used.  


Code:


from math import *

# radians mode

print("Enter in Degrees")

i=float(input("Incidence Angle? \n"))

a=float(input("Top Angle? \n"))


# convert to radians

ir=i*pi/180

ar=a*pi/180


# choice of material

# refractive index

ls=[1.4905,1.52,1.433,1.58]

k=-1

while k<0 or k>3:

  print("Select Material")

  print("0. Acrylic")

  print("1. Glass")

  print("2. Fluorite")

  print("3. Plastic")

  k=int(input())

n=ls[k]


# calculation

t=asin(sin(ar)*sqrt(n**2-sin(ir)**2)-sin(ir)*cos(ar))

d=ir+t-ar


# convert to degrees

td=t*180/pi

dd=d*180/pi


# results

print("Results are in Degrees")

print("Transmission Angle: \n"+str(td))

print("Deviation: \n"+str(dd))



Casio fx-4000P Program:  Prism


Notes:


1.  Variables used:

I = incidence angle

A = top angle of the prism

N = refractive index, must be entered manually


2.  Outputs:

Transmission Angle (T)

Deviation Angle (D)


Code:

(59 steps)


Deg :

"I": ?→ I:

"A": ?→A:

"N": ?→N:

sin⁻¹ ( sin A × √( N² - (sin I)²) - sin I × cos A) → T ◢

I + T - A → D



Examples


I = incidence angle

A = top angle of the prism

T = Transmission Angle

D = Deviation Angle



1.  I = 50°, A = 60°,  Glass (1.52)


T ≈  48.932708276°

D ≈ 38.932708276°


2.  I = 10°, A = 45°, Plastic (1.58)


T ≈ 80.99437617°

D ≈ 45.99437617°


3.  I = 33°, A = 25°,  Acrylic (1.4905)


T ≈ 5.32137979°

I ≈ 13.32137979°


4.  I = 17°, A = 40°, Fluorite (1.433)


T ≈ 42.66957975°

I ≈ 19.66957975°



Source


Woan, Graham.  The Cambridge Handbook of Physics Formulas  Cambridge University Press.  Cambridge, New York.  2003 edition



Here is to many more years, 


Eddie 


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.