- #1
member 657093
- TL;DR Summary
- Computing the Peebles Equation
I am trying to compute the Peebles equation as found here:
I am doing so in Python and the following is my attempt:
However, I'm unable to solve it. Either my solver is not enough, or I have wrongly done the function for calculating the Equation.
The graph I get is this
Can someone point out my mistake please? Or should I be using some other solver?
I have used both Runge Kutta 4th order and Radau IIA 5th order.
My initial conditions are:
a (scale factor) start (ts) = log(1e-5)
a end (tn) = log(1)
dt = (tn-ts)/1000
Xe = [1.2]
I am doing so in Python and the following is my attempt:
However, I'm unable to solve it. Either my solver is not enough, or I have wrongly done the function for calculating the Equation.
peebles:
# imports
from scipy.optimize import fsolve
from mpmath import *
mp.dps = 50 # (dps between 200 and 600)# constants
c = mpf('299792458') # Speed of light
g = mpf('6.67430e-11') # Gravitational constant
pc = mpf('149597870700') * (mpf('648000') / pi) # parsec
mpc = pc * mpf('1000000') # Megaparsec
kb = mpf('1.380649e-23') # Boltzmann constant
hp = mpf('6.62607015e-34') # Planck constant
hp1= hp/(mpf('2')*pi) # Reduced Planck constant
eV = mpf('1.602176634e-19') # electron Volt (energy)
eVc2 = eV / c**2 # electron Volt (mass)
ly = c * mpf('3600') * mpf('24') * mpf('365.25') # lightyear
pcl = pc / ly # pc in ly
amc = mpf('1.66053906660e-27') # atomic mass constant
mpu = mpf('1.007276466621') # mass of proton in u
meu = mpf('5.48579909065e-4') # mass of electron in u
mp = amc*mpu # mass of proton
mel = amc*meu # mass of electron
mH = amc*(mpu+meu) # mass of hydrogen
e = mpf('1.602176634e-19') # elementary charge
u0 = mpf('1.25663706212e-6') # vacuum permeability (magnetic constant)
e0 = mpf('1')/(u0*c**2) # vacuum permittivity (electric constant)
alpha = e**2/(mpf('4')*pi*e0*hp1*c) # Fine-structure constant
Ry = (mel*e**4)/(mpf('8')*e0**2*hp**2) # Rydberg unit of energy
RyV = Ry/(eVc2*c**2)
cer = (e**2)/(mpf('4')*pi*e0*mel*c**2) # classical electron radius
tcs = (mpf('8')*pi)/mpf('3') * cer**2 # Thomson Cross Section
Yp = mpf('0.245') # fraction of Helium
cmbt = mpf('2.72548') # CMBR Temperature
#a = (mpf('1') + mpf('0'))**mpf('-1') # scale factor
#z = (mpf('1')/ a)-mpf('1') # redshift
h = mpf('67.66') # Hubble constant
pbdp = mpf('.02242') # physical baryon density parameter
pdmdp = mpf('.11933') # physical dark matter density parameterh3 = (h * mpf('1000')) / mpcsigmaT = (mpf('8')*pi)/mpf('3') * (alpha**2 * hp1**2)/(c**2 * mel**2)
def fu(a, Xe):
a = exp(a)
Tb = cmbt/a
o2Tb = mpf('0.448')*ln(Ry/(kb*Tb))
a2Tb = mpf('8')/sqrt(mpf('3')*pi) *\
c*sigmaT * sqrt(Ry/(kb*Tb))*o2Tb
BTb = a2Tb*((mel*kb*Tb)/(mpf('2')*pi*hp1**2))**(mpf('1.5')) *\
exp(-Ry/(kb*Tb))
B2Tb = BTb * exp((mpf('3')*Ry)/(mpf('4')*kb* Tb))
np = (mpf('1')- Yp)**2 * (mpf('3')*h3**2*pbdp)/ \
(mpf('8')*pi*g*mH*a**3)
n1s = (mpf('1') - Xe[0])*np
La = h3 * ((mpf('3')*Ry)**3)/((mpf('8')*pi)**2 * c**3 * hp1**3* n1s)
L2s1s = mpf('8.227')
CrTb = (L2s1s + La)/(L2s1s + La + B2Tb)
f = [CrTb/h3 *(BTb*(1-Xe[0])-np*a2Tb*Xe[0]**2)]
return f
Can someone point out my mistake please? Or should I be using some other solver?
I have used both Runge Kutta 4th order and Radau IIA 5th order.
My initial conditions are:
a (scale factor) start (ts) = log(1e-5)
a end (tn) = log(1)
dt = (tn-ts)/1000
Xe = [1.2]