CAMB: power_tilt modification question for Antony (or anyone else)

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Hiranya Peiris
Posts: 54
Joined: September 28 2004
Affiliation: University College London

CAMB: power_tilt modification question for Antony (or anyone

Post by Hiranya Peiris » May 11 2005

Hello,

I've modified CAMB to call another program from ScalarPower which returns the primordial P(k) for a given k value. However, this program takes too long and the resulting P(k) is a smooth function so I want to compute only a few of the k values in advance, store them, and then in ScalarPower only interpolate between these precomputed P(k) values.

So my plan was to precompute a few k values by calling a new routine in subroutine InitializePowers and then call the interpolation routine in ScalarPowers. However, this means InitializePowers needs to know about which k values CAMB is going to compute. I tracked down where these values are stored to CTrans%q_int, the number of k values being CTrans%num_q_int. However, I am not sure which module to USE in InitializePowers to let it know about these parameters. Could you please help me out with this problem?

Thanks!
Hiranya

Antony Lewis
Posts: 1522
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: CAMB: power_tilt modification question

Post by Antony Lewis » May 11 2005

If you are going to interpolate anyway, why do you need to know the exact k values that CAMB will require?

The values used by CAMB will depend on the cosmological parameters, and unfortunately fortran's baroque module-handling probably means that you can't include the relevant module without generating a circular module reference error. Also those arrays may not be allocated when InitializePowers is called.

(if you need to work around a cicular module reference, the messy trick is to define a non-module subroutine after the module you want to use has been compiled, then call this non-module subroutine from within the original module. e.g. like the non-module wrapper function NonLinear_GetRatios in halofit.f90.)

Hiranya Peiris
Posts: 54
Joined: September 28 2004
Affiliation: University College London

CAMB: power_tilt modification question for Antony (or anyone

Post by Hiranya Peiris » May 11 2005

I wanted to make sure that CAMB didn't request some k value that was out of bounds of what the interpolation array contained. However, it occurs to me that all I need to make sure is that the k array used for interpolation is bounded by k_high and k_low that are higher and lower than anything CAMB will request. This will avoid all these module issues.

Could you recommend a lowest possible and highest possible pair of k values that will be out of the range requested by CAMB for flat LCDM models are within what is allowed by current data? Just a rough guesstimate will do.

Thanks a lot for the quick reply!

Cheers
Hiranya

Antony Lewis
Posts: 1522
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: CAMB: power_tilt modification question for Antony (or an

Post by Antony Lewis » May 11 2005

The maximum will depend on your input parameters (e.g. whether or not you are computing the matter power spectrum to high k, your l_max for the C_l, etc). For the lowest value something like ~10^-6 should be safe I think.

Paul Hunt
Posts: 3
Joined: May 16 2005
Affiliation: Oxford University

CAMB: power_tilt modification question for Antony (or anyone

Post by Paul Hunt » May 16 2005

I had the same problem, Hiranya.

I modified CAMB so that it samples P(k) more often where it is curved and then finds ScalarPower([q]k[/q]) by interpolating between these points.

I added to InitializePowers in power_tilt.f90 the adaptive sampling subroutine and the subroutine (eg spline from Numerical Recipes) that returns the second derivative of P(k) at the values of k to be interpolated between. I also changed the argument of InitializePowers to [q]InitializePowers(AParamSet,acurv,k_low,k_high)[/q] where [q]k_low and k_high[/q] are the lowest and highest wavenumbers respectively for which ScalarPower is called. ScalarPower was set equal to the function that performs the interpolation (eg splint from Numerical Recipes).

Then the call to InitializePowers needs to be made after [q]k_low[/q] and [q]k_high[/q] have been calculated but before ScalarPower is used. I found that a suitable place is near the beginning of the subroutine Transfer_Get_sigma8 in modules.f90, where I added:

[q]k_low=H*MTrans%TransferData(Transfer_kh,1,1)
k_high=H*MTrans%TransferData(Transfer_kh,MTrans%num_q_trans,1)

call InitializePowers(CP%InitPower,CP%curv,k_low,k_high).
[/q]

Then I deleted the calls to InitializePowers in cmbmain.f90 and camb.f90.

If you are using CAMB with COSMOMC you also need to move the call to Transfer_Get_sigma8 in the subroutine CAMB_TransfersToPowers in camb.f90 ahead of the lines if (CData%Params%WantCls) then ... end if.

If you are using CAMB just to find the Cls ScalarPower is called over a smaller k range. Therefore you should instead move the InitializePowers call in cmbmain.f90 to just below the call to SetkValuesForInt and change the argument to [q](CP%InitPower,CP%curv,ThisCT%q_int(1),ThisCT%q_int(num_q_int))[/q]. You should also delete the call to InitializePowers in camb.f90.

Lastly, if using CAMB for the Cls alone with COSMOMC you should instead change the argument of the InitializePowers call in CAMB_TransfersToPowers to read
[q](CP%InitPower,CP%curv,CData%ClTransScal%q_int(1),CData%ClTransScal%q_int(num_q_int))[/q] and delete the call in cmbmain.f90.

This works with the November 2004 version of CAMB but I haven't checked it for more complicated things like lensing.

Post Reply