import numpy as np
import scipy.integrate as integrate
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = "serif"
plt.rcParams['font.serif'] = ["Source Han Serif JP", "DejaVu Serif", ]
plt.rcParams["mathtext.fontset"] = "cm"
plt.rcParams["font.size"] = 12
fig = plt.figure(figsize=(6,4), )
ax = fig.add_subplot(111)
z_max = 2
z = np.linspace(0, z_max, 64)
c_per_H0 = 2.998e3 #[Mpc/h]
Omega_rad = 9.14E-5
for Omega_mat, color, ls, label in [
(0, "#005aff", "-", "$\Omega_{m0} = 0$"),
(0.315, "#ff4b00", "-.", "$\Omega_{m0} = 0.315$"),
(1, "#03af7a", ":", "$\Omega_{m0} = 1$"),
]:
Omega_lam = 1. - Omega_mat - Omega_rad
def E(z):
'''Hubble parameter per Hubble constant H(z)/H0'''
return np.sqrt( Omega_lam + Omega_mat*(1.+z)**3 + Omega_rad*(1.+z)**4 )
def comoving(z):
result, err = integrate.quad(lambda x: 1./E(x), 0, z)
return c_per_H0 * result
comoving = np.vectorize(comoving)
x = comoving(z)
dl = (1. + z) * x
ax.plot(z, dl, c=color, ls=ls, label=label)
ax.set_xlim([0, z_max])
ax.set_ylim([0, 1e4])
fontsize = 13
ax.set_xlabel(r"赤方偏移 $z$", fontsize=fontsize)
ax.set_ylabel(r"光度距離 $d_L$ [$\mathrm{Mpc}/h$]", fontsize=fontsize)
ax.grid()
ax.legend(loc=4)
left=0.15
plt.subplots_adjust(bottom=0.15, left=left, right=1-left)
plt.plot()
#plt.show()
plt.savefig("Dependence_of_luminosity_distance_on_density_parameter.svg")
plt.close()