PPF Module problem

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Vanessa Smer
Posts: 13
Joined: July 25 2013
Affiliation: ROE at University of Edinburgh

PPF Module problem

Post by Vanessa Smer » May 21 2014

Hi Antony,

I posted this in another thread regarding the PPF code, but it's from 2012 so it could be unnoticed, maybe more people are still having this issue:

Coming back to the PPF problem, while running with the option where you need to modify the equation of state in the function w_de(a) in equations_ppf.f90, this one seems to run fine with cosmomc, I am using April 2014 version. However, while trying to use the tabulated case, it gives the error that some of you describe "bad xa input splint ".

This error comes from the subroutine cubicsplint included in equations_ppf.f90. While trying to run the tabulated version in cosmomc, I added:

write((*,*) 'h, xa(khi), xa(klo)', h, xa(khi), xa(klo)

in cubicsplint, where the variables written are those involved with the crashing of the program. This in order to see if I seeing their values could help to understand what is going on.

Then, before cosmomc stops running it gives me that all these values are zero. That is, it seems like it's not even reading the file with the tabulated data.

Doing some tracing back, the clue seems to be in the function grho_de(a) in equations_ppf.f90. This function works for both cases, in the following way:

For the NOT tabulated case:

Code: Select all

 if(.not. use_tabulated_w) then
        grho_de=grhov*a**(1._dl-3.*w_lam-3.*wa_ppf)*exp(-3.*wa_ppf*(1._dl-a))

For the tabulated case:

Code: Select all

  else
        if(a.eq.0.d0)then
            grho_de=0.d0      !assume rho_de*a^4-->0, when a-->0, OK if w_de always <0.
        else
            al=dlog&#40;a&#41;
            if&#40;al.lt.ade&#40;1&#41;&#41;then
                fint=rde&#40;1&#41;*&#40;a/amin&#41;**&#40;1.-3.*w_de&#40;amin&#41;&#41;    !if a<amin, assume here w=w_de&#40;amin&#41;
            else              !if amin is small enough, this extrapolation will be unnecessary.
                call cubicsplint&#40;ade,rde,ddrde,nde,al,fint&#41;
            endif
            grho_de=grhov*fint
        endif
    endif

As you can see for the tabulated case it is calling cubicsplint, but cubicsplint is only required for the tabulated case, the not tabulated only needs to know the values w0, wa to do the calculation and that's why that case presents no trouble.

Also, the subroutine DarkEnergy_ReadParams(Ini) which reads the tabulated file is nowhere to be called inside equations_ppf.f90, however, it is called in inidriver.F90. Perhaps that's why in CAMB both versions run well but in CosmoMC only the non tabulated does?

I have been trying to do something similar to the quint module case, where the subroutine init_background is used to call the subroutine Quint_init_background and initialize quintessence, to be more specific, what I have tried to do is to add:

use IniFile
Type(TIniFile) :: Ini

call DarkEnergy_ReadParams(Ini)

to init_background in equations_ppf.f90. But it seems like that is not allowed, I get segmentation errors. I have tried to do the same directly into the function grho_de, in order for it to be read straightaway after compilation, but to no avail.

Any ideas would be appreciated,

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

Re: PPF Module problem

Post by Antony Lewis » May 22 2014

CosmoMC as supplied only supports w0, wa, so using tabulated w(a) is a code modication. I've not tried doing that myself, but you can compile cosmomc using "make cosmomc_debug" and then run ./cosmomc_debug to get more helpful error messages and traceback during code development.

Vanessa Smer
Posts: 13
Joined: July 25 2013
Affiliation: ROE at University of Edinburgh

PPF Module problem

Post by Vanessa Smer » May 23 2014

Ok, thanks, I'll try that. If I manage to solve it I'll post here what I found.

Vanessa Smer
Posts: 13
Joined: July 25 2013
Affiliation: ROE at University of Edinburgh

PPF Module problem

Post by Vanessa Smer » May 26 2014

Hi Antony,

Seems I managed an "in the middle solution". When using CAMB only, the tabulated option works well and the subroutines/functions called are in the order:

DarkEnergy_ReadParams(Ini)
w_de
............................
init_background
dtauda
grho_de
dtauda
grho_de
..........................
(And so on) There are more specifications in between, but this is enough to see the problem.

Now, while running in CosmoMC, the routines called are:

init_background
dtauda
grho_de
ERROR STOP: bad xa input in splint

So, what happens is that while trying to run with CosmoMC, the file with the data is never read, nor is there a call to w_de to assign the data file to the arrays used by the program. That's why when dtauda calls grho_de, who in turns calls w_de with all the values zero and later calls cubicsplint, it gives the "bad xa in splint error":

h = xa(khi) - xa(klo) = 0

if (h.eq.0) stop 'bad xa input in splint'

What I tried to do first is to add calls in init_background to the subroutine DarkEnergy_ReadParams(Ini) but this was very troublesome, seems like I am not handling the Ini type correctly. Then I tried to open the file with another number inside init_background but it turned very, very slow. So I modify in this way:

subroutine init_background

use LambdaGeneral

is_cosmological_constant = .not. use_tabulated_w .and. w_lam==-1_dl .and. wa_ppf==0._dl


a_ppf(1) = .1
nw_ppf=0

do i=1,nwmax-1

a_ppf(i+1) = a_ppf(i) + .1
w_ppf(i) = w_lam+wa_ppf*(1 - a_ppf(i))
a_ppf(i)=dlog(a_ppf(i))

enddo

call setddwa
call interpolrde

cs2_lam = 1
call setcgammappf

end subroutine init_background

So what I've got is that even if I have the option use_tabulated_w as True, I am not reading from a file but I am filling the needed arrays from an equation of state (this was a test run, only ten elements in the array and I am using a different equation of state but that does not matter).

So now, while running with CosmoMC it does:

init_background (plus reads the arrays with the needed information)
dtauda
grho_de
.................
(And so on)

The error "bad xa in splint" doesn't appear anymore because when cubicsplint is called it actually has values different from zero. I Have done short test runs with this modification in CosmoMC and runs fine.

On another note, it seems a bit strange that while choosing use_w_tabulated as False, the results of CAMB seem to be independent of the equation of state, you can assign anything to w_de in the function w_de (I am talking about the original version of equations_ppf.f90 included in the latest versions of the program) and the results are the same. This option does run in CosmoMC but I find it a bit worrying. However, the changes to init_background kind of merge together both cases: you specify your equation of state but you bild an array with it.

Post Reply