Adding a new model parameter in CosmoMC

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Meir Shimon
Posts: 8
Joined: December 16 2019
Affiliation: Tel Aviv University

Adding a new model parameter in CosmoMC

Post by Meir Shimon » December 19 2019

Hi All,

I've unsuccessfully tried to add a new model parameter, alpha, to the latest CosmoMC code (sumer 2019) version. I did follow the instructions appearing in one of the readme's FAQ and was able to add new model parameters in an older, November 2016, version. However, all my efforts to modify the new version so as to accommodate a new model parameter have failed. Indeed, I have noticed significant structural changes between the old a new versions, so I guess this might be the reason.

Could someone instruct me as to the additional changes that should be applied to the new version to allow inclusion of a new cosmological parameter ?
Changes carried out in my most recent attempts to modify Cosmomc 2019:

(1) I defined the new parameter in CosmologyTypes.f90

(2) In CosmologyParameterizations.f90 I replaced:
call this%SetTheoryParameterNumbers(16,last_power_index)
with
call this%SetTheoryParameterNumbers(17,last_power_index)

in addition to defining (in subroutine SetForH):
CMB%alpha = Params(17)

(3) I defined P%alpha = CMB%alpha in subroutine CAMBCalc_CMBToCAMB in Calculator_CAMB.f90

(4) I modified the results.f90 file to effect my cosmological model changes.

(5) I've added the new parameter alpha with appropriate range to the parameter .ini file in batch3.



Thanks,

Meir

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

Re: Adding a new model parameter in CosmoMC

Post by Antony Lewis » December 19 2019

Looks OK, what goes wrong?

Meir Shimon
Posts: 8
Joined: December 16 2019
Affiliation: Tel Aviv University

Re: Adding a new model parameter in CosmoMC

Post by Meir Shimon » December 20 2019

Thanks Antony for your prompt reply.
The compilation error I get relates to results.f90.
Here, just to illustrate the problem, the new parameter alpha_c is an additive contribution to the angular diameter distance.
I'm attaching the relevant excerpt from the compilation error message:


../results.f90(632): error #6460: This is not a field name that is defined in the encompassing structure. [ALPHA_C]
CAMBdata_AngularDiameterDistance = this%CP%alpha_c+this%curvature_radius/(1+z)* &
------------------------------------------------------------------------^
compilation aborted for ../results.f90 (code 1)
make[3]: *** [results.o] Error 1
make[2]: *** [libcamb] Error 2
make[2]: Leaving directory `/cmb_home/meirs/CosmoMC-MPI/camb/fortran'
make[1]: *** [camb] Error 2
make[1]: Leaving directory `/cmb_home/meirs/CosmoMC-MPI/source'
make: *** [cosmomc] Error 2

Thanks,

Meir

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

Re: Adding a new model parameter in CosmoMC

Post by Antony Lewis » December 20 2019

Looks just like an issue with your CAMB modification (have not defined parameter in CAMBparams)- check CAMB works separately before trying to use it in cosmomc.

Meir Shimon
Posts: 8
Joined: December 16 2019
Affiliation: Tel Aviv University

Re: Adding a new model parameter in CosmoMC

Post by Meir Shimon » December 23 2019

Thanks for the tip Antony. After modifying camb.f90 and model.f90 it did compile ok eventually.

Meir Shimon
Posts: 8
Joined: December 16 2019
Affiliation: Tel Aviv University

Re: Adding a new model parameter in CosmoMC

Post by Meir Shimon » December 24 2019

Hi,

As mentioned in my last response, the code now compiles OK.
However, the run stops right after it starts. The error message I get says:

"SetTheoryParameterNumbers: parameter numbers do not match".

I was able to trace this error message to an IF-statement in CosmologyTypes.f90:

if (num_hard + num_initpower /= num_theory_params) &
call MpiStop('SetTheoryParameterNumbers: parameter numbers do not match')

and obviously this condition is NOT satisfied by the modification I carried out in the
code, which causes the code to abort.

Unfortunately, I'm not an expert in F90 and have no idea how to proceed from here.

It is clear that this problem has to do with parameter counting which is changed by the addition
of my new model parameter "alpha". Indeed, when I leave the params_CMB.paramnames
file in its original form (while the other files are modified as described earlier to accommodate
the new model parameter) the code runs OK but then the new parameter "alpha" is simply ignored.
When I do add alpha in line 17 of params_CMB.paramnames (between fdm and logA)
the run aborts with the message "SetTheoryParameterNumbers: parameter numbers do not match".
I guess that this means that the number of lines in params_CMB.paramnames
is somehow counted by the code which is now in conflict with the other modifications I've
made.

I did not experience this (or similar) problem with the 2016 version and I suspect it has to do with the
(somewhat) different structure of CosmologyParameterizations.f90 compared to the older
version, but as mentioned - I have no clue as to how this problem can be fixed.

Any idea as to how to fix it would be much appreciated.

Thanks,

Meir

Cristhian GQ
Posts: 10
Joined: March 27 2019
Affiliation: University of Texas at Dallas

Re: Adding a new model parameter in CosmoMC

Post by Cristhian GQ » February 02 2020

Hello,

I hope you already solve the issue. However, another strategy can be also check MG codes like ISiTGR or MGCAMB (many new parameters are added) so maybe the modifications there can help you to find the issue.

Best regards,
Cristhian Garcia.

Post Reply