CAMB_source: Weak lensing convergence power spectra

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » March 08 2008

Dear all,
I was trying to generate the weak lensing convergence power spectra [tex]C_l^{\kappa\kappa}[/tex] given some window functions. I got a 8-column output Cl file by choosing 1 redshift bin and setting

get_scalar_cls = T
get_transfer = F
get_vector_cls = F
get_tensor_cls = F
want_CMB = T

To my understanding, the 8 output columns should be
l,[tex]Cl^{TT,TE,EE},Cl^{\phi\phi}, Cl^{T\phi}, C_l^{\kappa\kappa}, Cl^{T\kappa}[/tex]
there's no [tex]Cl^{BB}[/tex]. Am I right?
BTW, there's a returned 'bus error' when setting nonlinear=2 (I compiled with g95).

Thanks,
Gongbo

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

Re: CAMB_source: Weak lensing convergence power spectra

Post by Antony Lewis » March 08 2008

Yes, no BB for scalars.

Let me know if you find a fix for the bus error.

gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » March 08 2008

Thanks, Antony! I will let you know once I fix the problem.
BTW, the lensing source implemented in output is -2*phi*W%win_lens(j), can you provide the main reference for this issue? or some maple files.



Cheers
Gongbo

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

Re: CAMB_source: Weak lensing convergence power spectra

Post by Antony Lewis » March 09 2008

-2\phi is the standard source for the lensing potential. win_lens should be calculated consistently from your supplied source window function (Gaussian by default). Sorry I don't have any documentation.

gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » March 24 2008

Dear all,

Has anyone succeeded in reproducing some convergence power results in the literature (such as fig 2 in astro-ph/0106399) using CAMB sources? I tried but failed.



Thanks,
Gong-Bo

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

Re: CAMB_source: Weak lensing convergence power spectra

Post by Antony Lewis » March 24 2008

I've checked things look consistent, though not a detailed comparison as no alternative codes to hand.

Note can set evolve_delta_xe = F to speed things up, and check stability to increasing k_eta_max_scalar. Obviously need to include non-linear corrections on small scales.

Also note limber_windows = T currently doesn't work, set limber_windows = F (any fixed welcome!)

gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » March 30 2008

Thanks Antony!
But if my window function peaks at low redshift, 0.1 for example, I have to set a huge max_eta_k, which greatly slows down the computation and might give rise to memory leaks if I have multi-bins. (I tested and found max_eta_k should be larger than 1500000 for the window peaking at z~0.1 to avoid the numerical instability).

So is it a simple solution to this problem? For example, increasing the stepsize for k integration at small scales?


Thanks,
Gong-Bo

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

Re: CAMB_source: Weak lensing convergence power spectra

Post by Antony Lewis » March 30 2008

Probably need to use Limber approximation. If you get it to work please let me know.

gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » March 30 2008

But I need the cross-correlations. I tried modifying the k intervals for integration at small scales (using log-spacing rather than linear), something like that

Code: Select all

            dk2 = 0.005*dlnk1  !very small scales
            dk3 = 10*dk2  !very small scales
          if (qmax_int > max_k_dk) then
           !This allows inclusion of high k modes for computing BB lensed spectrum accurately
           !without taking ages to compute.

            call Ranges_Add_delta(ThisCT%q, max_k_dk, qmax_int/2, dk2, IsLog = .true.)
            call Ranges_Add_delta(ThisCT%q, qmax_int/2, qmax_int, dk3, IsLog = .true.)

 
The results 'seem' fine without ages of computing time. The number of dk2 and dk3 is a guesswork, it can be further optimized. I wonder if there's some better way to do this without limber?


Cheers
Gongbo

gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » April 20 2008

After some tests, I found a fix of the Limber approximation part for lensing. The problem is the missing of a factor of l(l+1)/2 in the limber source. To get it work, do the following,
in the innermost loop in subroutine GetLimberTransfers in cmbmain.f90,
add

Code: Select all

if(W%kind == window_lensing) &
              ThisCT%Limber_windows(s_ix,ell)%Source(n-n1+1)=&
ThisCT%Limber_windows(s_ix,ell)%Source(n-n1+1)/2*ThisCT%ls%l(ell)*(ThisCT%ls%l(ell)+1)

Cheers
Gong-Bo

gongbo zhao
Posts: 69
Joined: January 04 2005
Affiliation: ICG, Portsmouth
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by gongbo zhao » April 20 2008

Update: The above modification only works for single lensing bin. For multi-bins, replace subroutine CalcLimberScalCls in cmbmain.f90 with the following,

Code: Select all


     subroutine CalcLimberScalCls(CTrans)
       Type(ClTransferData) :: CTrans
       integer ell, i, s_ix, ik, pix
        real(dl) CL, reall,fac
        Type(TRedWin), pointer :: W


      if (.not. limber_windows) return
      do pix=1,CP%InitPower%nn

       do i =1, num_redshiftwindows
          W => Redshift_w(i)
          s_ix = 3+i
        if (CTrans%limber_l_min(s_ix) /=0) then

        do ell = CTrans%limber_l_min(s_ix), Ctrans%ls%l0
          Cl = 0
          reall = real(CTrans%ls%l(ell),dl)
          fac = (2*pi**2)/fourpi/reall**3
          do ik = 1, CTrans%Limber_windows(s_ix,ell)%num_k
           if(W%kind == window_lensing) CTrans%Limber_windows(s_ix,ell)%Source(ik)=&
            CTrans%Limber_windows(s_ix,ell)%Source(ik)*reall*(reall+1)/2


           Cl=Cl+  CTrans%Limber_windows(s_ix,ell)%Source(ik)**2 * &
                fac*ScalarPower(CTrans%Limber_windows(s_ix,ell)%k(ik) ,pix)
                !  * reall**2/(2*pi)

          end do
          iCl_scalar(ell,C_PhiTemp + i,pix)  =Cl

        end do
        end if
       end do
      end do

     end subroutine CalcLimberScalCls

Gongbo

Steven Pediani
Posts: 16
Joined: October 06 2008
Affiliation: University of Manchester

CAMB_source: Weak lensing convergence power spectra

Post by Steven Pediani » October 06 2008

I'm guessing that the code has been updated since, as those subroutines don't exist in my copy of CAMB. I'm trying to generate the convergence power spectrum (like the one shown in the link posted by Gongbo Zhao), where the user is able to choose their window function, and one can work out other quantities like aperture mass and shear variance. I have done this for cmbfast, and decided it'd be useful to do the same to CAMB. I was under the impression that there was a simple relation between the convergence and the lensing potential power spectra, C_l _{(\kappa \kappa)} = [tex]\frac{1}{4} [/tex] [tex]l^4[/tex] C_l_{(\phi \phi)}, and so the output in the scalar file, l^4 C_l_{(\phi \phi)}, is the convergence? I ask as I can't get it to agree with any of my other work, and so am wondering if this is not the case, or is there a subtitle change needed in one of the starting parameters.

[EDIT] Never mind, got it working now.

Lukas Hollenstein
Posts: 16
Joined: March 31 2009
Affiliation: IPhT CEA-Saclay
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by Lukas Hollenstein » March 31 2009

Hi,

Im also interested in the convergence power spectrum. Thanks to Gongbo Zhao for pointing out how to get the Limber approximation right. Now I think I get the right answer in the linear case.

As Gongbo already pointed out, there is a problem with the non-linear lensing. When I switch to do_nonlinear=2, I get a bus error, no matter if compiled with gfortran, g95 or ifort.

Did anybody find the problem here? Thanks!

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

Re: CAMB_source: Weak lensing convergence power spectra

Post by Antony Lewis » March 31 2009

There seem to be several bugs that stop this working.

In cmbmain.f90 try changing CalcScalarSources to have some traps for j < TimeSteps%npoints:

Code: Select all

!     Calculation of transfer functions.
101          if &#40;CP%WantTransfer.and.itf <= CP%Transfer%num_redshifts&#41; then
                 if &#40;j < TimeSteps%npoints&#41; then
                  if &#40;j < TimeSteps%npoints.and.tauend < tautf&#40;itf&#41; .and.TimeSteps%points&#40;j+1&#41; > tautf&#40;itf&#41;&#41; then
                          
                     call GaugeInterface_EvolveScal&#40;EV,tau,y,tautf&#40;itf&#41;,tol1,ind,c,w&#41;

                  endif
                 end if 
!     output transfer functions for this k-value.
                      
                  if &#40;abs&#40;tau-tautf&#40;itf&#41;&#41; < 1.e-5_dl&#41; then
                           call outtransf&#40;EV,y, MT%TransferData&#40;&#58;,EV%q_ix,itf&#41;&#41;
                         
                           itf=itf+1
                           if &#40;j < TimeSteps%npoints&#41; then
                            if &#40;j < TimeSteps%npoints.and.itf <= CP%Transfer%num_redshifts.and. &
                                TimeSteps%points&#40;j+1&#41; > tautf&#40;itf&#41;&#41; goto 101
                           end if     
                  endif

                  end if
             end if
and in modules.f90

Code: Select all

        if &#40;CP%WantTransfer&#41; then
            deallocate&#40;MT%optical_depths, stat = RW_i&#41;           
            allocate&#40;MT%optical_depths&#40;CP%Transfer%num_redshifts&#41;&#41;
            do RW_i = 1, CP%Transfer%num_redshifts
                MT%optical_depths&#40;RW_i&#41; =  -sdotmu&#40;transfer_ix&#40;RW_i&#41;&#41;+sdotmu&#40;nthermo&#41; 
            end do
        end if
should be something like

Code: Select all

        if &#40;CP%WantTransfer&#41; then
            deallocate&#40;MT%optical_depths, stat = RW_i&#41;           
            allocate&#40;MT%optical_depths&#40;CP%Transfer%num_redshifts&#41;&#41;
            do RW_i = 1, CP%Transfer%num_redshifts
               if &#40;CP%Transfer%Redshifts&#40;RW_i&#41; < 1e-3&#41; then
                MT%optical_depths&#40;RW_i&#41; = 0 !zero may not be set correctly in transfer_ix
               else
                MT%optical_depths&#40;RW_i&#41; =  -sdotmu&#40;transfer_ix&#40;RW_i&#41;&#41;+sdotmu&#40;nthermo&#41; 
               end if
            end do
        end if
(or fix how it sets up the indices, or just comment out since not needed for lensing anyway)

I do have an updated version of CAMB_sources, but there is a big disagreement with 0902.1759 I would like to undestand first (also in with current version, which includes the effect too).

Lukas Hollenstein
Posts: 16
Joined: March 31 2009
Affiliation: IPhT CEA-Saclay
Contact:

CAMB_source: Weak lensing convergence power spectra

Post by Lukas Hollenstein » April 01 2009

Thanks Antony,

however these fixes don't help with the bus error. After digging a bit I found out that there is a problem with deallocating Pk_data in MatterPowerdata_Free (modules.f90). Commenting a few lines seems to help:

Code: Select all

      subroutine MatterPowerdata_Free&#40;PK_data&#41;
          Type&#40;MatterPowerData&#41; &#58;&#58; PK_data
          integer i

          deallocate&#40;PK_data%log_kh,stat=i&#41;
          deallocate&#40;PK_data%matpower,stat=i&#41;
          deallocate&#40;PK_data%ddmat,stat=i&#41;
          deallocate&#40;PK_data%nonlin_ratio,stat=i&#41;
          deallocate&#40;PK_data%redshifts,stat=i&#41;

       !! temporary fix to bus error if do_nonlinear=2
       !   deallocate&#40;PK_data%log_k,stat=i&#41;
       !   deallocate&#40;PK_data%nonlin_ratio_vv,stat=i&#41;
       !   deallocate&#40;PK_data%nonlin_ratio_vd,stat=i&#41;
       !   deallocate&#40;PK_data%vvpower,stat=i&#41;
       !   deallocate&#40;PK_data%ddvvpower,stat=i&#41;
       !   deallocate&#40;PK_data%vdpower,stat=i&#41;
       !   deallocate&#40;PK_data%ddvdpower,stat=i&#41;

          call MatterPowerdata_Nullify&#40;PK_data&#41;

      end subroutine MatterPowerdata_Free
But obviously then the memory isn't freed. As far as I can see, these arrays are not in all cases allocated and cannot be deallocated consequently. Unfortunately, one cannot check if they're allocated because they're pointers rather than allocatable arrays. I'm not really an expert in Fortran. Any idea?

BTW, there seem to be more problems with pointers and their deallocation as indicated by a list of remaining memory after running CAMB (at least when compiled with g95 and the flag -ftrace=full).

E.g., ThiThisCT%Limber_windows(s_ix,ell)%k, ThisCT%Limber_windows(s_ix,ell)%Source and CTrans%Limber_windows are actually not deallocated.

I don't know if that is worrying?

Does this
I do have an updated version of CAMB_sources, but there is a big disagreement with 0902.1759 I would like to undestand first (also in with current version, which includes the effect too).
mean that you don't trust the lensing results yet? Or does it only affect the redshift distortions?

Thanks a lot, cheers,
Lukas

Post Reply