-
-
Save Dudemanguy/6c615d4391627149b9a0a17b849ad6fc to your computer and use it in GitHub Desktop.
Python script for calculating the value of Planck's constant, h, and its propagated error from an LED circuit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy as np | |
import sys | |
e = float(1.602176565*10**(-19)) | |
c = float(299792458) | |
filename = sys.argv[-1] | |
fin = open(filename, 'r') | |
V = fin.readline() | |
w = fin.readline() | |
V_d = [float(x) for x in V.split()] | |
V_n = np.asarray(V_d) | |
w_n = [float(x) for x in w.split()] | |
v_t = np.multiply(0.0005, V_n) | |
v_e = np.where(v_t<0.001, v_t+0.0005, v_t+0.005) | |
w_t = np.asarray(w_n) | |
W_n = np.multiply(10**(-9), w_t) | |
w_e = np.array([40, 15, 15, 15, 15, 20]) | |
W_e = np.multiply(10**(-9), w_e) | |
h = (V_n*e*W_n)/c | |
H = float(6.62607040*10**(-34)) | |
dv = (e*W_n)/c | |
de = (V_n*W_n)/c | |
dW = (V_n*e)/c | |
e_e = 0.000000035*10**(-19) | |
h_e = ((dv*v_e)**2 + (de*e_e)**2 + (dW*W_e)**2)**0.5 | |
p_e = abs(H - h)/H * 100 | |
h_m = np.mean(h) | |
h_em = np.mean(h_e) | |
print('The calculated value of h is') | |
print(h) | |
print('The error of h is') | |
print(h_e) | |
print ('The average value of h is') | |
print(h_m, 'p/m', h_em) | |
#print('The percent error is') | |
#print(p_e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment