Package pycosmicstar :: Module lcdmcosmology
[hide private]
[frames] | no frames]

Source Code for Module pycosmicstar.lcdmcosmology

  1  #!/usr/bin/env python3 
  2  # *-* Coding: UTF-8 *-* 
  3  from __future__ import division, absolute_import 
  4   
  5  __author__ = "Eduardo dos Santos Pereira" 
  6  __email__ = "pereira.somoza@gmail.com" 
  7  __credits__ = ["Eduardo dos Santos Pereira"] 
  8  __license__ = "GPLV3" 
  9  __version__ = "1.0.1" 
 10  __maintainer__ = "Eduardo dos Santos Pereira" 
 11  __status__ = "Stable" 
 12   
 13  """The Cold Dark Matter plus Cosmological constant Module (LCDM) 
 14   
 15  Na atual versao usamos a normalizacao do WMAP (sem ondas gravitacionais) 
 16  a expressao foi adaptada de Eisenstein e Hu (ApJ 511, 5, 1999) 
 17  de forma a fornecer sigma_8 = 0,84. 
 18  A fracao de massa dos halos e obtida de Sheth e Tormen (MNRAS 308, 119, 1999) 
 19  Todos os modelos consideram Omega_Total = Omega_M + Omega_L = 1,0 
 20   
 21  "Best Fit" do WMAP-3: omega_m = 0,238, omega_b = 0,042, omega_l = 0,762, 
 22  h = 0,734, sigma_8 = 0,744 
 23  Veja que sigma_8 pelo WMAP e' obtido atraves da recombinacao. Outras 
 24  estimativas (p.e. aglomerados de galaxias) fornecem sigma_8 = 0,84. 
 25  Conjunto de dados: WMAP-3: omega_m = 0,238, omega_b = 0,042, omega_l = 0,762 
 26  h = 0,734, sigma_8 = 0,84 
 27  WMAP-1: omega_m = 0,29, omega_b = 0,44, omega_l = 0,71 
 28  h = 0,72, sigma_8 = 0,9 
 29   
 30  This file is part of pystar. 
 31  copyright : Eduardo dos Santos Pereira 
 32   
 33  pystar is free software: you can redistribute it and/or modify 
 34  it under the terms of the GNU General Public License as published by 
 35  the Free Software Foundation, either version 3 of the License. 
 36  pystar is distributed in the hope that it will be useful, 
 37  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 38  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 39  GNU General Public License for more details. 
 40   
 41  You should have received a copy of the GNU General Public License 
 42  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. 
 43   
 44  """ 
 45   
 46  from .cosmology import cosmology 
 47  from numpy import sqrt, pi, log, log10, exp, sin, cos 
 48  from numpy.numarray import zeros, Float64 
 49  from scipy.integrate import romberg 
 50   
 51  cosmolibImportStatus = None 
 52  try: 
 53      from .cosmolib import lcdmlib 
 54      cosmolibImportStatus = True 
 55      print('lcdmlib imported') 
 56  except: 
 57      cosmolibImportStatus = False 
 58      print('lcdmlib not imported, using pure python version of sigma') 
 59   
 60   
61 -class lcdmcosmology(cosmology):
62 """The Cold Dark Matter (CDM) plus Cosmolocical Constan (Lambda) - lcdm 63 64 Keyword arguments: 65 omegam -- (default 0.24) - The dark matter parameter 66 67 omegab -- (default 0.04) - The barionic parameter 68 69 omegal -- (default 0.73) - The dark energy parameter 70 71 h -- (default 0.7) - The h of the Hubble constant (H = h * 100) 72 """ 73
74 - def __init__(self, omegam=0.24, omegab=0.04, omegal=0.73, h=0.7):
75 self.__omegab = omegab 76 self.__omegam = omegam 77 self.__omegal = omegal 78 self.__h = h 79 self.__ct3 = 9.78e+09 / h 80 81 #m / s 82 self.__speedOfLight = 3.0e+8 83 84 self.__cosmolibImportStatus = cosmolibImportStatus 85 86 if(self.__cosmolibImportStatus is True): 87 self.__lcdmlib = lcdmlib 88 self.__lcdmlib.init(omegab, omegam, omegal, h) 89 90 if(self.__omegal >= 0.73): 91 tilt = 1.92 92 elif(omegal >= 0.7 and omegal <= 0.73): 93 tilt = 1.915 94 else: 95 tilt = 1.8 96 97 self.__tilt = tilt 98 99 h2 = h * h 100 h2om = h2 * omegam 101 h2br = h2 * omegab 102 self.__rodm0 = 2.76e+11 * h2om 103 self.__robr0 = 2.76e+11 * h2br 104 self.__deltac = 1.686 105 self.__hsl = h * sqrt(omegal) 106 self.__omegalm = omegal / omegam 107 self.__s2pi = pi * sqrt(2.0) 108 self.__ut = 1.0 / 3.0 109 self.__nr = 14000 110 self.__ct0 = 4.0 * pi 111 self.__ct1 = self.__ct0 * 2.76e+11 / 3.0 112 self.__ct2 = self.__ct1 * h2om 113 self.__ct3 = 9.78e+09 / h 114 115 #Power Spectrun Normalization 116 self.__anorm = 1.94e-5 * \ 117 (self.__omegam ** (-0.785 - 0.05 * log(self.__omegam))) \ 118 * exp(- 0.95 * (tilt - 1.) - 0.169 * (tilt - 1.) ** 2.0)\ 119 / 2.0 / (pi * pi) 120 121 self.__anorm = ((self.__anorm) ** 2.0) * \ 122 ((2997.9 / self.__h) ** (3.0 + tilt)) 123 124 self.__gama1 = omegab * (1.0 + sqrt(2.0 * h) / omegam) 125 self.__gamam = omegam * (h ** 2.0) / (self.__gama1) 126 self.__alfa = 6.4 / self.__gamam / h 127 self.__beta = 3.0 / self.__gamam / h 128 self.__gama = 1.7 / self.__gamam / h
129
130 - def dt_dz(self, z):
131 dtdz = self.__ct3 / ((1.0 + z) * sqrt(self.__omegal + 132 self.__omegam * (1.0 + z) ** 3.0)) 133 return dtdz
134
135 - def dr_dz(self, z):
136 137 #Speed of Light km / s 138 vl = 3.0e+5 139 140 #H_{0}/h = 1/s 141 hub = 3.25e-18 142 143 drdz = (vl / hub / self.__h) / sqrt(self.__omegam * (1.0 + z) ** 3.0 144 + self.__omegal) 145 return drdz
146
147 - def H(self, z):
148 """Return the Hubble parameter as a function of z. 149 150 Keyword arguments: 151 z -- redshift 152 """ 153 return 100.0 * self.__h * sqrt(self.__omegam * (1.0 + z) ** 3.0 154 + self.__omegal)
155
156 - def dV_dz(self, z):
157 """Return the comove volume variation. 158 159 Keyword arguments: 160 z -- redshift 161 """ 162 rz = romberg(self.dr_dz, 0.0, z, tol=1.48e-09) 163 drdz = self.dr_dz(z) 164 dVdz = 4.0 * pi * drdz * rz ** 2.0 165 return dVdz
166
167 - def dgrowth_dt(self, z):
168 """Return the derivative of the growth function with 169 respect to time. 170 171 Keyword arguments: 172 z -- redshift 173 """ 174 z1 = 1.0 + z 175 ascale = 1.0 / z1 176 ascale2 = ascale ** 2.0 177 ascale3 = ascale ** 3.0 178 ascale4 = ascale * ascale3 179 ea = self.__omegam * ascale + self.__omegal * ascale4 180 omegamz = self.__omegam * ascale / ea 181 omegalz = self.__omegal * ascale4 / ea 182 dz1 = 1.0 - omegalz + omegamz ** (4.0 / 7.0) + omegamz / 2.0 183 184 Q = 2.5 * omegamz * ascale 185 dea_da = self.__omegam + 4.0 * ascale3 * self.__omegal ** 6.0 186 domegamz_da = (self.__omegam / ea ** 2.0) * (ea - ea * dea_da) 187 domegalz_da = self.__omegal * (4.0 * ascale3 * ea - 188 ascale4 * dea_da) / (ea ** 2.0) 189 dQ_da = 5.0 * (omegamz + ascale * domegamz_da) 190 dP_da = 2.0 * (- domegalz_da + (4.0 / 7.0) * 191 domegamz_da / (omegamz ** (3.0 / 7.0)) 192 + domegamz_da / 2.0) 193 dadz = ascale2 194 dgrowthdt = (dadz) * (dz1 * dQ_da - Q * dP_da) / (dz1 ** 2.0) 195 return dgrowthdt
196
197 - def growthFunction(self, z):
198 """Return the growth function 199 200 Keyword arguments: 201 z -- redshift 202 """ 203 z1 = 1.0 + z 204 ascale = 1.0 / z1 205 ascale3 = ascale ** 3.0 206 ascale4 = ascale * ascale3 207 ea = self.__omegam * ascale + self.__omegal * ascale4 208 omegamz = self.__omegam * ascale / ea 209 omegalz = self.__omegal * ascale4 / ea 210 dz1 = 1.0 - omegalz + omegamz ** (4.0 / 7.0) + omegamz / 2.0 211 growth = (2.5 * omegamz * ascale / dz1) / (pi * sqrt(2.0)) 212 213 return growth
214
215 - def sigma(self, kmass):
216 """Return the sigma. 217 218 Keyword arguments: 219 kmass -- mass scale 220 """ 221 222 if(self.__cosmolibImportStatus is not True): 223 return self.__sigma(kmass) 224 else: 225 return self.__lcdmlib.sigma(self.__anorm, 226 self.__alfa, 227 self.__beta, 228 self.__gama, 229 self.__ct2, 230 kmass)
231
232 - def dsigma2_dk(self, kl):
233 """"Return the integrating of sigma(M,z) for a top-hat filtering. 234 In z = 0 return sigma_8, for z > 0 return sigma(M,z) 235 """ 236 k = exp(kl) 237 x = self.__escala * k 238 pk1 = 1.0 + (self.__alfa * k + (self.__beta * k) ** 1.5 239 + (self.__gama * k) ** 2.0) ** 1.13 240 pk2 = 1.0 / pk1 241 pdmk = pk2 * (k ** 3.0) 242 dsigdk = pdmk * (3.0 * (sin(x) - x * cos(x)) / (x ** 3.0)) ** 2.0 243 return dsigdk
244
245 - def __sigma(self, kmass):
246 247 n = kmass.size 248 km = zeros(n, type=Float64) 249 sg = zeros(n, type=Float64) 250 251 for i in range(0, n): 252 self.__escala = (kmass[i] / self.__ct2) ** (1.0 / 3.0) 253 km[i] = log10(kmass[i]) 254 255 t0 = log10(1.0e-7 / self.__escala) 256 t1 = log10(1.0e-3 / self.__escala) 257 t2 = log10(1.0e+0 / self.__escala) 258 t3 = log10(10.0e+0 / self.__escala) 259 t4 = log10(100.0e+0 / self.__escala) 260 261 sig2_1 = romberg(self.dsigma2_dk, t0, t1, tol=1.48e-09) 262 sig2_2 = romberg(self.dsigma2_dk, t1, t2, tol=1.48e-09) 263 sig2_3 = romberg(self.dsigma2_dk, t2, t3, tol=1.48e-09) 264 sig2_4 = romberg(self.dsigma2_dk, t3, t4, tol=1.48e-09) 265 266 sg[i] = sqrt(self.__anorm * (sig2_1 + sig2_2 + sig2_3 + sig2_4)) 267 268 return km, sg
269
270 - def rodm(self, z):
271 """Return the dark matter density 272 273 Keyword arguments: 274 z -- redshift 275 """ 276 z1 = 1.0 + z 277 ascale = 1.0 / z1 278 ascale2 = ascale ** 2.0 279 ascale3 = ascale ** 3.0 280 return self.__rodm0 / ascale3, 3.0 * self.__rodm0 / ascale2
281
282 - def robr(self, z):
283 """Return the barionic density. 284 285 Keyword arguments: 286 z -- redshift 287 """ 288 z1 = 1.0 + z 289 ascale = 1.0 / z1 290 ascale3 = ascale ** 3.0 291 return self.__robr0 / ascale3
292
293 - def age(self, z):
294 """Return the age of the Universe for some redshift. 295 296 Keyword arguments: 297 z -- redshift 298 """ 299 if(self.__cosmolibImportStatus is True): 300 return self.__lcdmlib.age(z) 301 else: 302 z1 = 1.0 + z 303 ascale = 1.0 / z1 304 ascale3 = ascale ** 3.0 305 fct = self.__omegalm * ascale3 306 return 6.522916e+09 * log(sqrt(fct) + sqrt(fct + 1.0)) / self.__hsl
307
308 - def setCosmologicalParameter(self, omegam, omegab, omegal, h):
309 """Set the cosmological parameters 310 311 """ 312 self.__omegab = omegab 313 self.__omegam = omegam 314 self.__omegal = omegal 315 self.__h = h 316 return True
317
318 - def getCosmologicalParameter(self):
319 """Return the cosmological parameter 320 """ 321 return self.__omegab, self.__omegam, self.__omegal, self.__h
322
323 - def getDeltaC(self):
324 """Return the critical density 325 """ 326 return self.__deltac
327
328 - def getTilt(self):
329 return self.__tilt
330
331 - def getRobr0(self):
332 """Return the barionic matter density at the present day. 333 """ 334 return self.__robr0
335
336 - def getRodm0(self):
337 """Return the dark matter density at the present day. 338 """ 339 return self.__rodm0
340