CAMB_source: Weak lensing convergence power spectra

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
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 8column 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
I was trying to generate the weak lensing convergence power spectra [tex]C_l^{\kappa\kappa}[/tex] given some window functions. I got a 8column 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

 Posts: 1364
 Joined: September 23 2004
 Affiliation: University of Sussex
 Contact:
Re: CAMB_source: Weak lensing convergence power spectra
Yes, no BB for scalars.
Let me know if you find a fix for the bus error.
Let me know if you find a fix for the bus error.

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
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
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

 Posts: 1364
 Joined: September 23 2004
 Affiliation: University of Sussex
 Contact:
Re: CAMB_source: Weak lensing convergence power spectra
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.

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
Dear all,
Has anyone succeeded in reproducing some convergence power results in the literature (such as fig 2 in astroph/0106399) using CAMB sources? I tried but failed.
Thanks,
GongBo
Has anyone succeeded in reproducing some convergence power results in the literature (such as fig 2 in astroph/0106399) using CAMB sources? I tried but failed.
Thanks,
GongBo

 Posts: 1364
 Joined: September 23 2004
 Affiliation: University of Sussex
 Contact:
Re: CAMB_source: Weak lensing convergence power spectra
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 nonlinear corrections on small scales.
Also note limber_windows = T currently doesn't work, set limber_windows = F (any fixed welcome!)
Note can set evolve_delta_xe = F to speed things up, and check stability to increasing k_eta_max_scalar. Obviously need to include nonlinear corrections on small scales.
Also note limber_windows = T currently doesn't work, set limber_windows = F (any fixed welcome!)

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
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 multibins. (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,
GongBo
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 multibins. (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,
GongBo

 Posts: 1364
 Joined: September 23 2004
 Affiliation: University of Sussex
 Contact:
Re: CAMB_source: Weak lensing convergence power spectra
Probably need to use Limber approximation. If you get it to work please let me know.

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
But I need the crosscorrelations. I tried modifying the k intervals for integration at small scales (using logspacing rather than linear), something like that
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
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.)
Cheers
Gongbo

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
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
Cheers
GongBo
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(nn1+1)=&
ThisCT%Limber_windows(s_ix,ell)%Source(nn1+1)/2*ThisCT%ls%l(ell)*(ThisCT%ls%l(ell)+1)
Cheers
GongBo

 Posts: 69
 Joined: January 04 2005
 Affiliation: ICG, Portsmouth
 Contact:
CAMB_source: Weak lensing convergence power spectra
Update: The above modification only works for single lensing bin. For multibins, replace subroutine CalcLimberScalCls in cmbmain.f90 with the following,
Gongbo
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

 Posts: 16
 Joined: October 06 2008
 Affiliation: University of Manchester
CAMB_source: Weak lensing convergence power spectra
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.
[EDIT] Never mind, got it working now.

 Posts: 16
 Joined: March 31 2009
 Affiliation: IPhT CEASaclay
 Contact:
CAMB_source: Weak lensing convergence power spectra
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 nonlinear 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!
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 nonlinear 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!

 Posts: 1364
 Joined: September 23 2004
 Affiliation: University of Sussex
 Contact:
Re: CAMB_source: Weak lensing convergence power spectra
There seem to be several bugs that stop this working.
In cmbmain.f90 try changing CalcScalarSources to have some traps for j < TimeSteps%npoints:
and in modules.f90
should be something like
(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).
In cmbmain.f90 try changing CalcScalarSources to have some traps for j < TimeSteps%npoints:
Code: Select all
! Calculation of transfer functions.
101 if (CP%WantTransfer.and.itf <= CP%Transfer%num_redshifts) then
if (j < TimeSteps%npoints) then
if (j < TimeSteps%npoints.and.tauend < tautf(itf) .and.TimeSteps%points(j+1) > tautf(itf)) then
call GaugeInterface_EvolveScal(EV,tau,y,tautf(itf),tol1,ind,c,w)
endif
end if
! output transfer functions for this kvalue.
if (abs(tautautf(itf)) < 1.e5_dl) then
call outtransf(EV,y, MT%TransferData(:,EV%q_ix,itf))
itf=itf+1
if (j < TimeSteps%npoints) then
if (j < TimeSteps%npoints.and.itf <= CP%Transfer%num_redshifts.and. &
TimeSteps%points(j+1) > tautf(itf)) goto 101
end if
endif
end if
end if
Code: Select all
if (CP%WantTransfer) then
deallocate(MT%optical_depths, stat = RW_i)
allocate(MT%optical_depths(CP%Transfer%num_redshifts))
do RW_i = 1, CP%Transfer%num_redshifts
MT%optical_depths(RW_i) = sdotmu(transfer_ix(RW_i))+sdotmu(nthermo)
end do
end if
Code: Select all
if (CP%WantTransfer) then
deallocate(MT%optical_depths, stat = RW_i)
allocate(MT%optical_depths(CP%Transfer%num_redshifts))
do RW_i = 1, CP%Transfer%num_redshifts
if (CP%Transfer%Redshifts(RW_i) < 1e3) then
MT%optical_depths(RW_i) = 0 !zero may not be set correctly in transfer_ix
else
MT%optical_depths(RW_i) = sdotmu(transfer_ix(RW_i))+sdotmu(nthermo)
end if
end do
end if
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).

 Posts: 16
 Joined: March 31 2009
 Affiliation: IPhT CEASaclay
 Contact:
CAMB_source: Weak lensing convergence power spectra
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:
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
Thanks a lot, cheers,
Lukas
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(PK_data)
Type(MatterPowerData) :: PK_data
integer i
deallocate(PK_data%log_kh,stat=i)
deallocate(PK_data%matpower,stat=i)
deallocate(PK_data%ddmat,stat=i)
deallocate(PK_data%nonlin_ratio,stat=i)
deallocate(PK_data%redshifts,stat=i)
!! temporary fix to bus error if do_nonlinear=2
! deallocate(PK_data%log_k,stat=i)
! deallocate(PK_data%nonlin_ratio_vv,stat=i)
! deallocate(PK_data%nonlin_ratio_vd,stat=i)
! deallocate(PK_data%vvpower,stat=i)
! deallocate(PK_data%ddvvpower,stat=i)
! deallocate(PK_data%vdpower,stat=i)
! deallocate(PK_data%ddvdpower,stat=i)
call MatterPowerdata_Nullify(PK_data)
end subroutine MatterPowerdata_Free
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
mean that you don't trust the lensing results yet? Or does it only affect the redshift distortions?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).
Thanks a lot, cheers,
Lukas