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)
220 stars 291 forks source link

How to get output of rescaling of ncdm distributions ? #497

Closed ravi398 closed 1 year ago

ravi398 commented 1 year ago

Hello, When we specify both omega_ncdm and m_ncdm in the class input file. it rescales the distribution function to satisfy both conditions.

Is there any way to get that rescale parameters as class output especially when I am not using the standard Fermi Dirac distribution?

@ThomasTram would you please help regarding this ?

Thank you in advance.

Regards Ravi sharma

ThomasTram commented 1 year ago

Hi Ravi

I am assuming that you are using the Python wrapper. You need to add a few entries to python/cclassy.pxd and python/classy.pyx:

python/cclassy.pxd, around line 102, inside the cdef background scope:

        int N_ncdm
        double * deg_ncdm

python/classy.pyx, at the end of the file inside the Class class scope:

    def get_ncdm_deg(self):
        cdef int i
        cdef np.ndarray[DTYPE_t, ndim=1] deg_ncdm = np.zeros(self.ba.N_ncdm,'float64')
        for i in range(self.ba.N_ncdm):
            deg_ncdm[i] = self.ba.deg_ncdm[i]
        return deg_ncdm

Now you can test it using

from classy import Class
ncdm = {'N_ncdm':1, 'Omega_cdm':0.125, 'Omega_ncdm':0.125, 'm_ncdm':1000}
cosmo = Class()
cosmo.set(ncdm)
cosmo.compute(['input'])
deg_ncdm = cosmo.get_ncdm_deg()
print(deg_ncdm)

Cheers, Thomas

ravi398 commented 1 year ago

It worked. Thank you for your help.

Regards Ravi sharma