Skip to content
Snippets Groups Projects
Commit 9d2934a2 authored by Nicolas Mantilla Molina's avatar Nicolas Mantilla Molina
Browse files

calculos

parent b8fd0ae5
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Difracción de Electrones y Analogía Óptica
%% Cell type:code id: tags:
``` python
# Importamos las librerias necesarias
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Cargamos los datos obtenidos
anillos_electron = pd.read_csv('../data/diametro_anillos_electron.csv', names=["U", "D1", "D2"], skiprows=1)
red_laser = pd.read_csv('../data/red_laser_data.csv', names=["Color", "D1", "D2"], skiprows=1)
white_light = pd.read_csv('../data/white_ligth_data.csv', names=["Color", "D1"], skiprows=1)
# Convertimos todo a MKS
anillos_electron["U"] = anillos_electron["U"] * 1e3
anillos_electron["D1"] = anillos_electron["D1"] * 1e-2
anillos_electron["D2"] = anillos_electron["D2"] * 1e-2
red_laser["D1"] = red_laser["D1"] * 1e-2
red_laser["D2"] = red_laser["D2"] * 1e-2
white_light["D1"] = white_light["D1"] * 1e-2
# Definimos constantes
h = 6.626e-34 # Constante de Planck
dh = 0.001e-34 # Error en la constante de Planck
e = 1.602e-19 # Carga del electron
de = 0.001e-19 # Error en la carga del electron
m = 9.109e-31 # Masa del electron
dm = 0.001e-31 # Error en la masa del electron
# d1 = 3/2 * distancia inter atomica del hexagono, d2 = distancia entre atomos intercalados /2
d = [3/2*(1.42e-10), (2.46/2)*1e-10] # Distancia entre planos del grafito [d1, d2]
dd = 0.01e-10
Le = 13.1e-2 # Distancia grafito - pantalla
Ll = 21.0e-2 # Distancia red difractiva - pantalla
dL = 0.1e-2 # Error en la distancia
dU = 0.1e3 # Error en el voltaje
```
%% Cell type:markdown id: tags:
## Difracción de Electrones
%% Cell type:code id: tags:
``` python
# Longitud de onda del electron (Bragg)
lambda_B = np.zeros((len(anillos_electron), 2))
error_lambda_B = np.zeros((len(anillos_electron), 2))
for i in range(len(anillos_electron)):
lambda_B[i,0] = d[0]*anillos_electron.D1[i]/(2*Le)
lambda_B[i,1] = d[0]*anillos_electron.D2[i]/(4*Le)
error_lambda_B[i,0] = anillos_electron.D1[i]*dd/(2*Le) + d[0]*dL/(2*Le) + d[0]*anillos_electron.D1[i]*dL/(2*Le**2)
error_lambda_B[i,1] = anillos_electron.D2[i]*dd/(4*Le) + d[0]*dL/(4*Le) + d[0]*anillos_electron.D2[i]*dL/(4*Le**2)
# Longitud de onda del electron (De Broglie)
lambda_D = h/np.sqrt(2*e*m*anillos_electron["U"])
error_lambda_D = dh/np.sqrt(2*e*m*anillos_electron["U"]) + h/2 * de/(2*m*anillos_electron["U"])**0.5 / e**1.5 + h/2 * dm/(2*e*anillos_electron["U"])**0.5 / m**1.5 + h/2 * dU/(2*e*m)**0.5 / anillos_electron["U"]**1.5
# Redondeamos a 3 cifras significativas
lambda_B = np.round(lambda_B, 14)
error_lambda_B = np.round(error_lambda_B, 14)
lambda_D = np.round(lambda_D, 14)
error_lambda_D = np.round(error_lambda_D, 14)
```
%% Cell type:code id: tags:
``` python
# Graficamos los valores obtenidos con sus errores
plt.figure()
# plt.errorbar(anillos_electron["U"]*1e-3, lambda_B[:,0], yerr=error_lambda_B[:,0], xerr=np.full(len(anillos_electron), dU*1e-3), fmt='o', label="Bragg D1 (exp)")
plt.errorbar(anillos_electron["U"]*1e-3, lambda_B[:,0], yerr=error_lambda_B[:,0], fmt='o', label="Bragg D1 (exp)")
plt.errorbar(anillos_electron["U"]*1e-3, lambda_B[:,1], yerr=error_lambda_B[:,1], fmt='o', label="Bragg D2 (exp)")
plt.errorbar(anillos_electron["U"]*1e-3, lambda_D, yerr=error_lambda_D, fmt='o', label="De Broglie (teorico)")
plt.xlabel("Voltaje [kV]")
plt.xticks(anillos_electron["U"]*1e-3)
plt.ylabel("Longitud de onda [m]")
plt.title("Longitud de onda del electron, Ley de Bragg vs De Broglie")
plt.grid(alpha=0.3)
plt.legend()
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
# Ajustamos dos rectas para D1 y D2 en funcion de 1/sqrt(U)
ajuste1 = np.polyfit(1/(anillos_electron["U"])**0.5, anillos_electron["D1"], 1)
ajuste2 = np.polyfit(1/(anillos_electron["U"])**0.5, anillos_electron["D2"], 1)
# Graficamos los diametros como funcion del 1/sqrt(U)
plt.figure()
plt.errorbar(1/(anillos_electron["U"]*1e-3)**0.5, anillos_electron["D1"]*1e2, yerr=np.full(len(anillos_electron), dL)*1e2, fmt='or', label="D1")
plt.errorbar(1/(anillos_electron["U"]*1e-3)**0.5, anillos_electron["D2"]*1e2, yerr=np.full(len(anillos_electron), dL)*1e2, fmt='og', label="D2")
plt.plot(1/(anillos_electron["U"]*1e-3)**0.5, np.polyval(ajuste1, 1/(anillos_electron["U"])**0.5)*1e2, 'r')
plt.plot(1/(anillos_electron["U"]*1e-3)**0.5, np.polyval(ajuste2, 1/(anillos_electron["U"])**0.5)*1e2, 'g')
plt.xlabel("1/Voltaje [1/kV]")
plt.ylabel("Diametro [cm]")
plt.title("Diametro de los anillos de difraccion")
plt.grid(alpha=0.3)
plt.legend()
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
# Tomamos las pendientes de los ajustes como k1 y k2 del experimento
k_exp = [ajuste1[0], ajuste2[0]]
# Calculamos los valores teoricos con sus errores
k_teo = [2*Le*h/(d[0]*np.sqrt(2*e*m)), 2*Le*h/(d[1]*np.sqrt(2*e*m))]
error_k_teo = [2*Le*dh/(d[0]*np.sqrt(2*e*m)) + 2*h*dL/(d[0]*np.sqrt(2*e*m)) + 2*Le*h*dd/(d[0]**2*np.sqrt(2*e*m)),
2*Le*dh/(d[1]*np.sqrt(2*e*m)) + 2*h*dL/(d[1]*np.sqrt(2*e*m)) + 2*Le*h*dd/(d[1]**2*np.sqrt(2*e*m))]
# Redondeamos a 3 cifras significativas
k_teo = np.round(k_teo, 3)
error_k_teo = np.round(error_k_teo, 3)
```
%% Cell type:code id: tags:
``` python
lambda_B
# Graficamos los valores obtenidos con sus errores
plt.figure(figsize=(3, 4))
plt.errorbar([1, 2], k_exp, yerr=[dL, dL], fmt='o', label="Experimental")
plt.errorbar([1, 2], k_teo, yerr=error_k_teo, fmt='o', label="Teorico")
plt.xlabel("Anillo de difraccion")
plt.xticks([1, 2], ["D1", "D2"])
plt.ylabel("Pendiente [m]")
plt.title("Pendiente de los anillos de difraccion")
plt.grid(alpha=0.3)
plt.legend()
plt.show()
```
%% Output
array([[3.65839695e-11, 2.80477099e-11],
[3.17061069e-11, 2.56087786e-11],
[2.92671756e-11, 2.47958015e-11],
[2.76412214e-11, 2.35763359e-11],
[2.60152672e-11, 2.15438931e-11],
[2.35763359e-11, 2.07309160e-11]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment