To fit the Einstein’s photoelectric equation to a realistic data set and hence calculate Planck’s constant. To estimate the value of by rectangular method, Simpson rule and Gauss quadrature by numerically evaluating suitable integral.

 To fit the Einstein’s photoelectric equation to a realistic data set and hence calculate Planck’s constant. To estimate the value of by rectangular method, Simpson rule and Gauss quadrature by numerically evaluating suitable integral.






Python Code: (Least Square Fitting)


# ---------------------------------------------------------
# exp -6 (a) Calculating the Plank ’s constant from Einstein ’s
# photoelectric eqaution ( using least square fitting of
# straight line )

# ---------------------------------------------------------

import numpy as np

# --------- experimental data ------------------------------
lam = [500 , 450 , 400 , 350 , 300 , 250]; # wavelength (nm)
y = [0.19 , 0.48 , 0.83 , 1.30 , 1.85 , 2.80]; # V_0 stopping voltage

m = np . size ( lam ); # calculating size of array
x = [0] * m ; # creating empty array
# ---------------------------------------------------------
for i in range (0 , m): # taking x = 1/ lambda
  x[i ] = 1/ lam [i ]
# ---------------------------------------------------------
  sx = sum (x); sy = sum( y);
  sxy = 0; sx2 = 0
for i in range (0 , m):
  sxy = sxy + x[ i ]* y [i ];
  sx2 = sx2 + x[ i ]* x [i ];

# calculating constant A1 and A0 for equation

A1 = ( (m * sxy ) - ( sx * sy ) )/ (( m * sx2 ) - ( sx **2) )
A0 = np . mean (y) - A1 * np . mean (x)

# --------------------------------------------------------
e = 1.6 * 10**( -19)
c = 3 * 10**(8)
h = A1 * e * 10**( -9) / (c)

print (" The value of A1 = ", A1 ) # 10^ -9
print (" The value of A0 = ", A0 )
print (" The value of h = ", h)

# ----------------------------------------------------------



Python Code :(Simpson 1/3)


# -------------------------------------------------------------------------
# exp -6( b) evaluate int_0 ^1 1/(1+ x ^2) dx using simpson 1/3 rule and
# estimate the value of pi using 4 interval .
# f(x) = 1/(1+ x ^2)
# -------------------------------------------------------------------------
import numpy as np
import math
n = 4 # numer of interval
x = [0]*( n +1# empty array
y = [0]*( n +1# empty array
a = 0.0 # higher limit
b = 1.0 # lower limit
h = (b -a) /n # interval gap

x = np . linspace (a ,b , num =n +1)
print (x)

for i in range (0 , n +1 ,1) :
  y[i ] = 1.0/(1.0+ x[i ]**2)
print (y)
# ------------ calculate sum of even and odd term --------
add_odd =0.0
for i in range (1 , n +1 ,2) :
  add_odd = add_odd + y[i]

add_even =0.0
for i in range (2 ,n ,2) :
  add_even = add_even + y[i]
# ------------- simpson 1/3 rule -- ----- ----- ---- ----- -----
T = h *(( y [0]+ y [n ]) +4* add_odd +2* add_even ) /3

p = T *4

print (" The value of pi is ",p)
# -------------------------------------------------------










Comments

Popular posts from this blog

Solving Kepler’s equation by Newton-Raphson method

Velapanti Python Program

To find mean , standard deviation and frequency distribution of an actual data set (Python Program)