In [263]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit  # import the curve fitting function
%matplotlib inline

Lead

1


In [264]:
N_net = np.array([10802,6943,5828,4180,3115,2062,1514,1114,805])

In [265]:
thickness = np.array([0,5.35,10.78,16.23,21.56,26.87,32.07,36.78,41.88])*1e-3

In [266]:
Ln = np.array([np.log(entry) for entry in N_net])

In [267]:
dy = np.array([1/np.sqrt(entry) for entry in N_net])

In [268]:
plt.figure(figsize=(12,6))
plt.scatter(thickness,Ln);
plt.xlabel('Thickness',size=20);
plt.ylabel('Ln($N_{net}$)',size=20);
plt.xticks(size = 13);
plt.yticks(size = 13);


2


In [269]:
def myfun(x,N_o,alpha):
    ans = np.log(N_o) - alpha*x  # this is y, "the function to be fit"
    return ans

In [270]:
p0 = [20000,3/(0.04)]

In [271]:
xlots = np.linspace(0,.05,100)  # need lots of data points for smooth curve
yfit = np.zeros((len(N_net),xlots.size))

plsq, pcov = curve_fit(myfun, thickness, Ln, p0,dy)  # curve fit returns p and covariance matrix
# these give the parameters and the uncertainties
N_o = plsq[0]
eN_o = np.sqrt(pcov[0,0])
alpha = plsq[1]
ealpha = np.sqrt(pcov[1,1])

yfit = myfun(xlots,plsq[0],plsq[1])  # use fit results for a, b, c
    
print('N_o = %.0f +/- %.0f' % (plsq[0], np.sqrt(pcov[0,0])))
print('alpha = %.0f +/- %.0f' % (plsq[1], np.sqrt(pcov[1,1])))


N_o = 10584 +/- 326
alpha = 60 +/- 2

3


In [272]:
plt.figure(figsize=(12,6));
plt.xticks(size = 13);
plt.yticks(size = 13);
plt.scatter(thickness*1e2,Ln);
plt.xlabel('x (mm)');
plt.ylabel('y (mm)');
plt.plot(xlots*1e2,yfit);
plt.xlim(0,.05*1e2)
plt.legend(['data','Fit'],loc='best');
#plt.text(0.03,8.5,'$N_o$ = %.0f +/- %.0f' % (plsq[0], np.sqrt(pcov[0,0])),size=17)
#plt.text(0.03,8,'alpha = %.0f +/- %.0f' % (plsq[1], np.sqrt(pcov[1,1])),size=17)
plt.xlabel('Plate Thickness (cm)',size=20);
plt.ylabel('Ln($N_{net}$)',size=20);

plt.savefig('Lead')


4


In [273]:
#range lambda = 1/alpha
ry = 1/alpha
#uncertainty dlambda = alpha^-2 dalpha
dry = 1/alpha**2 *ealpha

In [274]:
ry*1e2 #This is in cm


Out[274]:
1.6694328164558021

In [275]:
dry*1e2 #cm


Out[275]:
0.053400174792917345

5


In [276]:
np.log(2)/alpha * 1e2 #cm


Out[276]:
1.1571626498605878

In [277]:
dry*1e2*np.log(2) #cm


Out[277]:
0.037014180599118915

6


In [278]:
rho = 11.3*1e3 #kg/m^3

In [279]:
mu = alpha/rho
mu


Out[279]:
0.0053009366024752416

In [280]:
dmu = ealpha / rho
dmu


Out[280]:
0.00016956114576644637

In [281]:
#From chart 0.51

Aluminum


In [282]:
N_net = np.array([8313,7145,5867,4845,4060,3072,2799])

In [283]:
thickness = np.arange(1,8)*12.93*1e-3

In [284]:
Ln = np.array([np.log(entry) for entry in N_net])

In [285]:
dy = np.array([1/np.sqrt(entry) for entry in N_net])

In [286]:
plt.figure(figsize=(12,6))
plt.scatter(thickness,Ln);
plt.xlabel('Thickness',size=20);
plt.ylabel('Ln($N_{net}$)',size=20);
plt.xticks(size = 13);
plt.yticks(size = 13);



In [287]:
xlots = np.linspace(0,.1,100)  # need lots of data points for smooth curve
yfit = np.zeros((len(N_net),xlots.size))

plsq, pcov = curve_fit(myfun, thickness, Ln, p0,dy)  # curve fit returns p and covariance matrix
# these give the parameters and the uncertainties
N_o = plsq[0]
eN_o = np.sqrt(pcov[0,0])
alpha = plsq[1]
ealpha = np.sqrt(pcov[1,1])

yfit = myfun(xlots,plsq[0],plsq[1])  # use fit results for a, b, c
    
print('N_o = %.0f +/- %.0f' % (plsq[0], np.sqrt(pcov[0,0])))
print('alpha = %.0f +/- %.0f' % (plsq[1], np.sqrt(pcov[1,1])))


N_o = 10231 +/- 238
alpha = 15 +/- 0

In [288]:
plt.figure(figsize=(12,6));
plt.xticks(size = 15);
plt.yticks(size = 15);
plt.scatter(thickness*1e2,Ln);
plt.plot(xlots*1e2,yfit);
plt.xlim(0,.1*1e2)
plt.legend(['data','Fit'],loc='best');
#plt.text(0.01,8.2,'$N_o$ = %.0f +/- %.0f' % (plsq[0], np.sqrt(pcov[0,0])),size=17)
#plt.text(0.01,8,'alpha = %.1f +/- %.1f' % (plsq[1], np.sqrt(pcov[1,1])),size=17)
plt.xlabel('Plate Thickness (cm)',size=20);
plt.ylabel('Ln($N_{net}$)',size=20);

plt.savefig('Aluminum')



In [289]:
#range lambda = 1/alpha
ry = 1/alpha
#uncertainty dlambda = alpha^-2 dalpha
dry = 1/alpha**2 *ealpha

In [290]:
ry*1e2 #This is in cm


Out[290]:
6.8518298052926623

In [291]:
dry*1e2 #cm


Out[291]:
0.22353858326810663

In [292]:
np.log(2)/alpha * 1e2 #cm


Out[292]:
4.7493265112152088

In [293]:
dry*1e2*np.log(2) #cm


Out[293]:
0.15494513873865268

In [294]:
rho = 2.7*1e3 #kg/m^3

In [295]:
mu = alpha/rho
mu*1e1


Out[295]:
0.054054227979258851

In [296]:
dmu = ealpha / rho
dmu*1e1


Out[296]:
0.001763500537155952

In [297]:
#from chart 0.53

In [ ]: