Skip to content

Commit

Permalink
Merge branch 'master' into xcor_cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
vitenti committed May 15, 2024
2 parents e678f1e + ec80ef6 commit eeb4342
Show file tree
Hide file tree
Showing 46 changed files with 682 additions and 788 deletions.
4 changes: 2 additions & 2 deletions numcosmo/lss/nc_cluster_abundance.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ nc_cluster_abundance_init (NcClusterAbundance *cad)

cad->dbdlnM = NULL;

cad->inv_z = ncm_spline_cubic_notaknot_new ();
cad->inv_lnM = ncm_spline_cubic_notaknot_new ();
cad->inv_z = NCM_SPLINE (ncm_spline_cubic_notaknot_new ());
cad->inv_lnM = NCM_SPLINE (ncm_spline_cubic_notaknot_new ());

ncm_spline_set (cad->inv_z, u1_knots, integ_z_knots, FALSE);
ncm_spline_set (cad->inv_lnM, u2_knots, integ_lnM_knots, FALSE);
Expand Down
134 changes: 73 additions & 61 deletions numcosmo/lss/nc_galaxy_acf.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@
G_DEFINE_TYPE (NcGalaxyAcf, nc_galaxy_acf, G_TYPE_OBJECT)

NcGalaxyAcf *
nc_galaxy_acf_new (NcGrowthFunc *gf, NcDistance *dist, NcTransferFunc *tf)
nc_galaxy_acf_new (NcGrowthFunc * gf, NcDistance * dist, NcTransferFunc * tf)
{
NcGalaxyAcf *acf = g_object_new (NC_TYPE_GALAXY_ACF, NULL);

acf->gf = gf;
acf->dist = dist;
acf->tf = tf;
acf->b = 2.0;
acf->s = ncm_spline_cubic_notaknot_new ();
acf->s = NCM_SPLINE (ncm_spline_cubic_notaknot_new ());
{
NcWindow *wp = nc_window_tophat_new ();
nc_window_free (wp);
NcWindow *wp = nc_window_tophat_new ();

nc_window_free (wp);
}

return acf;
}

Expand All @@ -77,90 +80,96 @@ static gdouble
nc_galaxy_acf_psi_kernel_l (gdouble z, gpointer p)
{
NcmGalaxyAcfPsiKernel *apk = (NcmGalaxyAcfPsiKernel *) p;
const gdouble cd = ncm_c_hubble_radius_hm1_Mpc () * nc_distance_comoving (apk->acf->dist, apk->cosmo, z);
const gdouble Dz = nc_growth_func_eval (apk->acf->gf, apk->cosmo, z);
const gdouble fz = nc_growth_func_eval_deriv (apk->acf->gf, apk->cosmo, z);
const gdouble x = apk->k * cd;
const gdouble x2 = x * x;
const gdouble sel_func = 1.0;
const gdouble psi_kernel_l = Dz * sel_func * (apk->acf->b + fz * ((1.0 - (apk->l * (apk->l - 1)) / x2) ));
const gdouble cd = ncm_c_hubble_radius_hm1_Mpc () * nc_distance_comoving (apk->acf->dist, apk->cosmo, z);
const gdouble Dz = nc_growth_func_eval (apk->acf->gf, apk->cosmo, z);
const gdouble fz = nc_growth_func_eval_deriv (apk->acf->gf, apk->cosmo, z);
const gdouble x = apk->k * cd;
const gdouble x2 = x * x;
const gdouble sel_func = 1.0;
const gdouble psi_kernel_l = Dz * sel_func * (apk->acf->b + fz * ((1.0 - (apk->l * (apk->l - 1)) / x2)));

return psi_kernel_l;
}

static gdouble
nc_galaxy_acf_psi_kernel_lp1 (gdouble z, gpointer p)
{
NcmGalaxyAcfPsiKernel *apk = (NcmGalaxyAcfPsiKernel *) p;
const gdouble cd = ncm_c_hubble_radius_hm1_Mpc () * nc_distance_comoving (apk->acf->dist, apk->cosmo, z);
const gdouble Dz = nc_growth_func_eval (apk->acf->gf, apk->cosmo, z);
const gdouble fz = nc_growth_func_eval_deriv (apk->acf->gf, apk->cosmo, z);
const gdouble x = apk->k * cd;
const gdouble sel_func = 1.0;
NcmGalaxyAcfPsiKernel *apk = (NcmGalaxyAcfPsiKernel *) p;
const gdouble cd = ncm_c_hubble_radius_hm1_Mpc () * nc_distance_comoving (apk->acf->dist, apk->cosmo, z);
const gdouble Dz = nc_growth_func_eval (apk->acf->gf, apk->cosmo, z);
const gdouble fz = nc_growth_func_eval_deriv (apk->acf->gf, apk->cosmo, z);
const gdouble x = apk->k * cd;
const gdouble sel_func = 1.0;
const gdouble psi_kernel_lp1 = -2.0 * Dz * sel_func * fz / x;

return psi_kernel_lp1;
}

static gdouble
nc_galaxy_acf_psi_kernel (gdouble z, gpointer p)
{
NcmGalaxyAcfPsiKernel *apk = (NcmGalaxyAcfPsiKernel *) p;
const gdouble cd = ncm_c_hubble_radius_hm1_Mpc () * nc_distance_comoving (apk->acf->dist, apk->cosmo, z);
const gdouble x = apk->k * cd;
const gdouble x2 = x * x;
const gdouble sel_func = 1.0;
const gdouble jl = gsl_sf_bessel_jl (apk->l, x);//ncm_sf_sbessel (apk->l, x);//
const gdouble jlp1 = gsl_sf_bessel_jl (apk->l + 1, x); //ncm_sf_sbessel (apk->l + 1, x);//
const gdouble cd = ncm_c_hubble_radius_hm1_Mpc () * nc_distance_comoving (apk->acf->dist, apk->cosmo, z);
const gdouble x = apk->k * cd;
const gdouble x2 = x * x;
const gdouble sel_func = 1.0;
const gdouble jl = gsl_sf_bessel_jl (apk->l, x); /*ncm_sf_sbessel (apk->l, x);// */
const gdouble jlp1 = gsl_sf_bessel_jl (apk->l + 1, x); /*ncm_sf_sbessel (apk->l + 1, x);// */
gdouble Dz, fz;

nc_growth_func_eval_both (apk->acf->gf, apk->cosmo, z, &Dz, &fz);

fz *= -(1 + z) / Dz;

return Dz * sel_func * (apk->acf->b * jl +
fz * (
((apk->l * (1.0 - apk->l) + x2) * jl - 2 * x * jlp1) / x2
)
);
((apk->l * (1.0 - apk->l) + x2) * jl - 2 * x * jlp1) / x2
)
);
}

gdouble
nc_galaxy_acf_psi (NcGalaxyAcf *acf, NcHICosmo *cosmo, gdouble k, guint l)
{
NcmGalaxyAcfPsiKernel psi_kernel;
gsl_function F;

F.function = &nc_galaxy_acf_psi_kernel_l;
F.function = &nc_galaxy_acf_psi_kernel_lp1;
F.function = &nc_galaxy_acf_psi_kernel;
F.params = &psi_kernel;
F.params = &psi_kernel;

psi_kernel.k = k;
psi_kernel.l = l;
psi_kernel.acf = acf;
psi_kernel.k = k;
psi_kernel.l = l;
psi_kernel.acf = acf;
psi_kernel.cosmo = cosmo;
//psi_kernel.jl = ncm_sf_sbessel_spline (l, 1e-5, xf, 1.0e-6);
/*psi_kernel.jl = ncm_sf_sbessel_spline (l, 1e-5, xf, 1.0e-6); */

{
gdouble res, err;
ncm_integral_locked_a_b (&F, 0.9, 1.0, 0.0, 1e-5, &res, &err);
return res;
}
gdouble res, err;

ncm_integral_locked_a_b (&F, 0.9, 1.0, 0.0, 1e-5, &res, &err);

return res;
}
}

static gdouble
nc_galaxy_acf_psi_int (gdouble mu, gpointer p)
{
// static glong count = 0;
/* static glong count = 0; */
NcmGalaxyAcfPsiKernel *apk = (NcmGalaxyAcfPsiKernel *) p;
const gdouble k = exp (mu);
const gdouble Pk = 1.0;/*nc_transfer_func_matter_powerspectrum (apk->acf->tf, apk->cosmo, k);*/
const gdouble psi = nc_galaxy_acf_psi (apk->acf, apk->cosmo, k, apk->l);
printf ("% 20.15g % 20.15g\n", mu, psi * psi);
//printf ("% 20.15g % 20.15g\n", mu, k * k * k * Pk * psi * psi);
//if ((count++) % 200 == 0)
//printf(".");fflush (stdout);
const gdouble k = exp (mu);
const gdouble Pk = 1.0; /*nc_transfer_func_matter_powerspectrum (apk->acf->tf, apk->cosmo, k);*/
const gdouble psi = nc_galaxy_acf_psi (apk->acf, apk->cosmo, k, apk->l);

printf ("% 20.15g % 20.15g\n", mu, psi * psi);
/*printf ("% 20.15g % 20.15g\n", mu, k * k * k * Pk * psi * psi); */
/*if ((count++) % 200 == 0) */
/*printf(".");fflush (stdout); */

g_assert_not_reached ();

return k * k * k * Pk * psi * psi;
}

Expand All @@ -169,38 +178,42 @@ nc_galaxy_acf_prepare_psi (NcGalaxyAcf *acf, NcHICosmo *cosmo, guint l)
{
NcmGalaxyAcfPsiKernel psi_kernel;
gsl_function F;
// const gdouble sqrt_norma = nc_matter_var_sigma8_sqrtvar0 (acf->vp, cosmo);
// const gdouble norma = sqrt_norma * sqrt_norma;

/* const gdouble sqrt_norma = nc_matter_var_sigma8_sqrtvar0 (acf->vp, cosmo); */
/* const gdouble norma = sqrt_norma * sqrt_norma; */
F.function = &nc_galaxy_acf_psi_int;
F.params = &psi_kernel;
F.params = &psi_kernel;

psi_kernel.h = nc_hicosmo_h (cosmo);
psi_kernel.l = l;
psi_kernel.acf = acf;
psi_kernel.h = nc_hicosmo_h (cosmo);
psi_kernel.l = l;
psi_kernel.acf = acf;
psi_kernel.cosmo = cosmo;

nc_transfer_func_prepare (acf->tf, cosmo);

{
gdouble res, err;
printf("#");fflush (stdout);

printf ("#");
fflush (stdout);
ncm_integral_locked_a_b (&F,
log (1.0e-10 / psi_kernel.h),
log (1.0e3 / psi_kernel.h),
0.0, 1e-6,
&res, &err);
//printf ("\n%u % 20.15g\n", l, norma * res);
/*printf ("\n%u % 20.15g\n", l, norma * res); */
fflush (stdout);
//exit (0);

/*exit (0); */
return;
}

/*
ncm_spline_set_func (acf->s, NCM_SPLINE_FUNCTION_SPLINE, &F,
log (1.0e-12 * ncm_c_hubble_radius ()),
log (1.0e1 * ncm_c_hubble_radius ()),
0, 1e-6);
*/
* ncm_spline_set_func (acf->s, NCM_SPLINE_FUNCTION_SPLINE, &F,
* log (1.0e-12 * ncm_c_hubble_radius ()),
* log (1.0e1 * ncm_c_hubble_radius ()),
* 0, 1e-6);
*/
}

static void
Expand All @@ -212,15 +225,14 @@ nc_galaxy_acf_init (NcGalaxyAcf *nc_galaxy_acf)
static void
nc_galaxy_acf_finalize (GObject *object)
{

/* Chain up : end */
G_OBJECT_CLASS (nc_galaxy_acf_parent_class)->finalize (object);
}

static void
nc_galaxy_acf_class_init (NcGalaxyAcfClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);

object_class->finalize = nc_galaxy_acf_finalize;
}
Expand Down

0 comments on commit eeb4342

Please sign in to comment.