#!/usr/bin/env python # coding: utf-8 # In[ ]: get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib import matplotlib.pyplot as plt import numpy as np from classy import Class from scipy import interpolate # In[ ]: w0vec = [-0.7, -1.0, -1.3] wavec = [-0.2,0.0,0.2] #w0vec = [-1.0] #wavec = [0.0] cosmo = {} for w0 in w0vec: for wa in wavec: if w0==-1.0 and wa==0.0: M='LCDM' else: M = '('+str(w0)+','+str(wa)+')' cosmo[M] = Class() cosmo[M].set({'input_verbose':1,'background_verbose':1,'gauge' : 'Newtonian'}) if M!='LCDM': cosmo[M].set({'Omega_Lambda':0.,'w0_fld':w0,'wa_fld':wa}) cosmo[M].compute() # In[ ]: import scipy import scipy.special import scipy.integrate def D_hypergeom(avec,csm): bg = csm.get_background() Om = csm.Omega0_m() if '(.)rho_lambda' in bg: Ol = bg['(.)rho_lambda'][-1]/bg['(.)rho_crit'][-1] else: Ol = bg['(.)rho_fld'][-1]/bg['(.)rho_crit'][-1] x = Ol/Om*avec**3 D = avec*scipy.special.hyp2f1(1./3.,1,11./6.,-x) D_today = scipy.special.hyp2f1(1./3.,1,11./6.,-Ol/Om) return D/D_today def f_hypergeom(avec,csm): bg = csm.get_background() Om = csm.Omega0_m() if '(.)rho_lambda' in bg: Ol = bg['(.)rho_lambda'][-1]/bg['(.)rho_crit'][-1] else: Ol = bg['(.)rho_fld'][-1]/bg['(.)rho_crit'][-1] x = Ol/Om*avec**3 D = avec*scipy.special.hyp2f1(1./3.,1,11./6.,-x) f = 1.-6./11.*x*avec/D*scipy.special.hyp2f1(4./3.,2,17./6.,-x) return f def D_integral2(avec,csm): bg = csm.get_background() Om = csm.Omega0_m() if '(.)rho_lambda' in bg: Ol = bg['(.)rho_lambda'][-1]/bg['(.)rho_crit'][-1] w0 = -1 wa = 0.0 else: Ol = bg['(.)rho_fld'][-1]/bg['(.)rho_crit'][-1] w0 = csm.pars['w0_fld'] wa = csm.pars['wa_fld'] D = np.zeros(avec.shape) for idx, a in enumerate(avec): Hc = a*np.sqrt(Om/a**3 + Ol*a**(-3*(1+w0+wa))*np.exp(-3.*(1.0-a)*wa) ) Dintegrand2 = lambda a: (a*np.sqrt(Om/a**3 + Ol*a**(-3*(1+w0+wa))*np.exp(-3.*(1.0-a)*wa) ))**(-3) I = scipy.integrate.quad(Dintegrand2, 1e-15,a) D[idx] = Hc/a*I[0] D = D/scipy.integrate.quad(Dintegrand2,1e-15,1)[0] return D def D_integral(avec,csm): bg = csm.get_background() Om = csm.Omega0_m() Ol = bg['(.)rho_lambda'][-1]/bg['(.)rho_crit'][-1] Or = 1-Om-Ol def Dintegrand(a): Hc = np.sqrt(Om/a+Ol*a*a+Or/a/a) #print a,Hc return Hc**(-3) D = np.zeros(avec.shape) for idx, a in enumerate(avec): #if a<1e-4: # continue Hc = np.sqrt(Om/a+Ol*a*a+Or/a/a) I = scipy.integrate.quad(Dintegrand,1e-15,a,args=()) D[idx] = Hc/a*I[0] D = D/scipy.integrate.quad(Dintegrand,1e-15,1,args=())[0] return D def D_linder(avec,csm): bg = csm.get_background() if '(.)rho_lambda' in bg: Ol = bg['(.)rho_lambda'][-1]/bg['(.)rho_crit'][-1] w0 = -1 wa = 0.0 else: Ol = bg['(.)rho_fld'][-1]/bg['(.)rho_crit'][-1] w0 = csm.pars['w0_fld'] wa = csm.pars['wa_fld'] Om_of_a = (bg['(.)rho_cdm']+bg['(.)rho_b'])/bg['H [1/Mpc]']**2 gamma = 0.55+0.05*(w0+0.5*wa) a_bg = 1./(1.+bg['z']) integ = (Om_of_a**gamma-1.)/a_bg integ_interp = interpolate.interp1d(a_bg,integ) D = np.zeros(avec.shape) amin = min(a_bg) amin = 1e-3 for idx, a in enumerate(avec): if a