lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
233 stars 289 forks source link

Modifying Transfer functions in CLASS? #230

Open brycem1 opened 6 years ago

brycem1 commented 6 years ago

Hello,

I'm new to using CLASS and I'm trying to calculate the transfer function from equation 30 from this paper for my research. Now the tau_dot term is dkappadtau in CLASS and j_L is the spherical bessel function. What I'm unsure about is what would be the relevant modules and functions to modify my local copy of the CLASS c code to output such a Transfer function?

Any help would be appreciated.

Regards,

Bryce

ThomasTram commented 6 years ago

Hi Bryce

The easiest way is to use the Python wrapper of CLASS. The following lines will compute dkappadtau in Mpc^-1:

cosmo = Class()
cosmo.set({})
cosmo.compute()
th = cosmo.get_thermodynamics()
dkappadtau = th["kappa' [Mpc^-1]"]

You can then compute the spherical Bessel functions from scipy and do the the numerical integration in Python as well. You can of course do all this by modifying the CLASS C-code, but it will be somewhat more complicated if you are not familiar with the code.

Cheers, Thomas

brycem1 commented 6 years ago

Hi Thomas,

Yes I tried doing it in python but I had convergence issue when trying to do the integral. I suspect it is because the bessel function is an oscillatory function and the scipy quad integral tolerance/error is the same order as the output which is not ideal. I was wondering how does class deal with the bessel function integrals generally?

Regards,

Bryce

ShazAlvi commented 4 years ago

I do not know if you have found the answer to your question in these years but I can quickly share this paper which might give some insight. https://arxiv.org/pdf/1705.05022.pdf