Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

Dark Energy Experiment in Python

Project: PHYS
Views: 135
Kernel: SageMath (stable)
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt redshift = np.genfromtxt('sn_data.txt',skip_header= True, usecols=(0)) distance = np.genfromtxt('sn_data.txt',skip_header= True, usecols=(1)) sigma = np.genfromtxt('sn_data.txt',skip_header= True, usecols=(2)) plt.errorbar(redshift,distance, yerr = sigma, marker= '.', c = 'green', ls = 'None') plt.xlabel('Redshift') plt.ylabel('Distance') plt.title('Distance versus Redshift');
Image in a Jupyter notebook

Assumptions

  • z is redshift

  • omegalight is the percentage of matter in the universe [0,1]

  • omegadark is the percent dark energy

  • Hubble_constant = 70 km/s/Mpc

  • c=2.99105km/sc = 2.99*10^5 km/s

DL(z,Ωm,H0,c)=(1+z)cH00zdxΩm(1+x)3+ΩDE\begin{align} D_L(z,\Omega_m, H_0, c) = \,(1+z) \frac{c}{H_0}\int_0^z \frac{dx}{\sqrt{\Omega_m(1+x)^3 + \Omega_{DE}}} \end{align}
hubble = 70 c = 2.99*10**5 import scipy.integrate as integrate def lum_dist(z,omegalight = .7,hubble=70,c=2.9979*10**5): omegadark = 1-omegalight #function = (((omegalight*(1.0+x)**3.0+omegadark)**(1/2))**-1.0) result = integrate.quad(lambda x: (((omegalight*(1.0+x)**3.0+omegadark)**(1/2))**-1.0),0,z)[0] return (1+z)*(c/hubble)* result lum_dist_vec = np.vectorize(lum_dist) lum_dist_vec(redshift,.7);
model1 = lum_dist_vec(redshift,0) model2 = lum_dist_vec(redshift,.3) model3 = lum_dist_vec(redshift,1)
plt.errorbar(redshift,distance, yerr = sigma, marker= '.', c = 'green', ls = 'None') plt.xlabel('Redshift') plt.ylabel('Distance') plt.title('Distance versus Redshift'); plt.plot(redshift, model1, c='red',label='Model 1') plt.plot(redshift, model2, c='yellow',label='Model 2') plt.plot(redshift, model3, c='blue',label='Model 3') plt.legend();
Image in a Jupyter notebook

Task 7

Model 1 has a value of 1 for ΩDE\Omega_{DE}. Model 2 has an ΩDE\Omega_{DE} = .7. Model 3 predicts a zero value for ΩDE\Omega_{DE}. It is clear from these models that ΩDE\Omega_{DE} fits our data the best. However, we can do better than a couples guesses.

def chi_square(x,x_error, y): return np.sum(((x-y)**2)/((x_error)**2))
chi_square(distance,sigma,model1)
447.81951103787316
chi_square(distance,sigma,model2)
308.1221776880534
chi_square(distance,sigma,model3)
1142.2432142471703
test = np.linspace(0,1,21) values = [] results = [] for thing in test: values.append (lum_dist_vec(redshift,thing)) for value in values: results.append (chi_square(distance,sigma,value)) show(results)
test[results.index(min(results))]
0.15000000000000002
plt.scatter(test,results); plt.xlabel('$Omega_m$'); plt.ylabel( '$\chi^2$'); plt.title('$Omega_m$ versus $\chi^2$');
Image in a Jupyter notebook
An omega_m of .15 fits this model the best An omega_dark of .85 fits this model best This model suggests a non-zero value of dark energy.