cosmomc: n_t error when adding new parameter unrelated to n_t/inflation

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 27 2017

Hi,

I have added a new parameter to CAMB and cosmoMC (Nov2016 version). CAMB runs fine, but when I try to run cosmoMC, it stops with the following error message:

Fast divided into 1 blocks
21 parameters ( 7 slow (0 semi-slow), 14 fast (0 semi-fast) )
Starting Monte-Carlo
Error: inflation_consistency but n\_t not set to zero
MpiStop: 0

I have not altered any inflation-settings, so e.g. in the /batch2/params_CMB_defaults.ini, inflation_consistency is set to T and nt = 0 is also set (although a comment notifies that this will be ignored when inflation_consistency is set to T).
The new parameter has nothing to do with inflation or nt, so I really don’t understand why this error occurs.

I would greatly appreciate any ideas as to why this error occurs.

P.S. When adding the new parameter, I follow the description given in http://cosmocoffee.info/viewtopic.php?t ... c&start=15 . I have made no other changes to cosmoMC and the changes I have made in CAMB are not related to inflation or nt.

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

Re: cosmomc: n_t error when adding new parameter unrelated t

Post by Antony Lewis » February 27 2017

I expect the mapping between parameter array indices and physical parameters got mixed up when adding your new parameter, e.g. check your CosmologyParameterizations.f90

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 27 2017

Hi,

Thank you for the quick reply.
Yes, this could very well be the case, because I am a little confused about the .paramnames file: I keep simply using the params_CMB.paramnames and add my new parameter, a_switch, at the bottom of this file. This makes it parameter number 47 in this file. But before adding a_switch, there were only 16 theory-parameters (line 74 in CosmologyParameterizations.f90). I change this to 17 and have tried adding a_switch in SetForH both as "CMB%a_switch = Params(17)" and "CMB%a_switch = Params(47)" (I have also tried adding a_switch as a real(mcp) in SetForH and then simply setting "a_switch = Params(17)" or "a_switch = Params(47)" because this is what is done in the posting I linked to before). I get the same error regardless of which I choose, but maybe I am missing some important detail of how to work with the .paramnames file?

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

Re: cosmomc: n_t error when adding new parameter unrelated t

Post by Antony Lewis » February 27 2017

If you are adding a theory parameter you want to add it in the corresponding place in the paramnames file (line 17).

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 27 2017

Ok, I have made sure that a_switch is added in line 17 of params_CMB.paramnames and that it is entered as Params(17) in SetForH. The error message is different now, and is as follows:

.
.
.
Computing tensors: F
max_eta_k = 14000.00
transfer kmax = 5.000000
SetTheoryParameterNumbers: parameter numbers do not match
MpiStop 0

I have already changed line 74 in CosmologyParameterizations.f90 to include 17 instead of 16 parameters (i.e. the line now reads "call this%SetTheoryParameterNumbers(17,last_power_index)"), so this should not be the problem. Are there other places where I have to change such numbers to let cosmoMC know that there has been added a parameter?

Erick Almaraz
Posts: 29
Joined: June 10 2012
Affiliation: University of Mexico

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Erick Almaraz » February 27 2017

I don't know if this is mandatory, but in my case I declared the extra parameter in

Code: Select all

Type, extends(TTheoryParams) :: CMBParams
in CosmologyTypes.f90

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 28 2017

Hi,

I'm pretty sure this is mandatory and I have already done it, but thank you anyway.

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 28 2017

Hi,

I looked a little more in source/CosmologyTypes.f90 and tried adding "+1" in line 141 so that it now reads:

num_initpower = semi_slow_num+1

The code runs without errors now, but this change was not mentioned in the topic I linked to in my initial post (i.e. in http://cosmocoffee.info/viewtopic.php?t ... c&start=15 ) so I am a little unsure if I am doing the correct thing, or if I have added my new parameter incorrectly somehow.

I would really appreciate any thoughts on whether or not it seems reasonable that I had to change num_initpower.

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

Re: cosmomc: n_t error when adding new parameter unrelated t

Post by Antony Lewis » February 28 2017

You shouldn't have to change that. It sounds as though your .paramnames is still inconsistent, make sure the number of lines in params_CMB.paramnames matches the sum of the arguments you are passing to SetTheoryParameterNumbers.

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 28 2017

Hi,

Thank you for letting me know that the "solution" is NOT a solution!

Originally (before I changed anything in the code), line 74 in sources/CosmologyParameterization.f90 read:

call this%SetTheoryParameteNumbers(16,last_power_index)

I added a_switch as line 17 in paramnames/params_CMB.paramnames and therefore changed the above line to:

call this%SetTheoryParameteNumbers(17,last_power_index)

I.e. I changed "16" to "17" after adding a single parameter. Should I have done it differently?

P.S. paramnames/params_CMB.paramnames is entirely unaltered compared to its original version except that I add a_Switch in line 17 (there seems to be some parameters in the file that aren't used, but I haven't deleted any because I don't want to accidentally delete a line that is in fact used somewhere...)

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 28 2017

Could it be that I am supposed to change lines 12-13 in sources/CosmologyTypes.f90? Those lines currently read:

integer, parameter :: As_index=1, ns_index=2, nrun_index=3, nrunrun_index =4, amp_ratio_index = 5, &
& nt_index = 6, ntrun_index = 7, Aphiphi_index = 8, last_power_index = Aphiphi_index

Do I need to change these indexes now that I have inserted a_switch in line 17 in paramnames/params_CM.paramnames such that A_s, ns, nrun etc. have all been moved down one line in paramnames/params_CM.paramnames?..."last_power_index" is used as the second input in SetTheoryParameterNumbers in source/CosmologyParameterizations.f90, so if Aphiphi_index and hence last_power_index need to be changed, this could be why SetTheoryParameterNumbers gives the error?

As it is currently, SetTheoryParemeterNumbers gets the inputs "17" and "last_power_index" = "Aphiphi_index" = 8, i.e. the total number is 17+8 = 25 which is the number of lines with theory parameters (parameters without a "*") in paramnames/params_CMB.paramnames.

Sofie Marie Koksbang
Posts: 15
Joined: February 27 2017
Affiliation: CP3, University of Southern Denmark

cosmomc: n_t error when adding new parameter unrelated to n_

Post by Sofie Marie Koksbang » February 28 2017

Hi Antony and Erick,

I think the problem is fixed now: I removed the paramnames file and copied a new one from a cosmoMC-version that I haven't altered at all. Then I added a_Switch in line 17 of the paramnames-file and now it's running. So, it seems that the problem was originally my misplacement of a_switch in params_CMB.paramnames and then before that got fixed, I must have messed up something in the file or entire directory (I sometimes accidentally "vim" into directories and start typing before I realize my mistake - maybe that has messed up the paramnames-directory...)

Thank you both for your suggestions and your time.

Post Reply