Adding new parameters to CosmoMC, March-13
-
- Posts: 10
- Joined: May 25 2008
- Affiliation: Institute for the early universe
Adding new parameters to CosmoMC, March-13
Hi Antony,
I am trying to add new parameters to CosmoMC. Since the structure has changed in this version and there is no definition of "num_hard" in the settings.f90 anymore, I tried to change it in cmbtypes.f90 as
num_hard = slow_num + 6
And add the new parameters right before the derived parameters (After #21: Aphiphi and #22:omegal). I get errors such as :
params_CMB.f90(188): error #6410: This name has not been declared as an array or a function. [PARAMS]
Params(22) = CMB%mag1
----- ^
Any suggestion?
Thanks,
Alireza
I am trying to add new parameters to CosmoMC. Since the structure has changed in this version and there is no definition of "num_hard" in the settings.f90 anymore, I tried to change it in cmbtypes.f90 as
num_hard = slow_num + 6
And add the new parameters right before the derived parameters (After #21: Aphiphi and #22:omegal). I get errors such as :
params_CMB.f90(188): error #6410: This name has not been declared as an array or a function. [PARAMS]
Params(22) = CMB%mag1
----- ^
Any suggestion?
Thanks,
Alireza
-
- Posts: 1872
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Adding new parameters to CosmoMC, March-13
To add new theory parameters
* add the definition of the physical parameter to CMBParams in cmbtypes.f90
* Change params_CMB.f90 to add a new parameterization or modify an existing one (with a corresponding .paramnames file with the new parameter names in). In particular the _Init routine does
which sets the number of hard and semi-hard parameters (the latter being things like initial power spectrum parameters) and then
to set the parameter names file.
* Modify CMB_Cls_Simple.f90 to pass your new CMBParams parameters to CAMB to actually change the result
* Edit your .ini files to to add range and width settings for the new parameter names
If instead your parameter is a likelihood parameter (nuisance parameter), the new parameter can be handled entirely inside your likelihood function code (see supernovae_SNLS.f90 for a simple example that has two nuisance parameters): you just set the .paramnames file (which determimes the number of new parameters), and then use them when passed in to your likelihood function.
* add the definition of the physical parameter to CMBParams in cmbtypes.f90
* Change params_CMB.f90 to add a new parameterization or modify an existing one (with a corresponding .paramnames file with the new parameter names in). In particular the _Init routine does
Code: Select all
call SetTheoryParameterNumbers(num_slow_params,num_semi_slow_params)
Code: Select all
call this%Init(Ini,Names, 'params_CMB.paramnames')
* Modify CMB_Cls_Simple.f90 to pass your new CMBParams parameters to CAMB to actually change the result
* Edit your .ini files to to add range and width settings for the new parameter names
If instead your parameter is a likelihood parameter (nuisance parameter), the new parameter can be handled entirely inside your likelihood function code (see supernovae_SNLS.f90 for a simple example that has two nuisance parameters): you just set the .paramnames file (which determimes the number of new parameters), and then use them when passed in to your likelihood function.
-
- Posts: 10
- Joined: May 25 2008
- Affiliation: Institute for the early universe
Adding new parameters to CosmoMC, March-13
Thanks, it worked !
-
- Posts: 7
- Joined: May 30 2013
- Affiliation: UC Berkeley
Adding new parameters to CosmoMC, March-13
My likelihood code includes likelihood/nuisance parameters, which I've successfully added as suggested.
My code is faster than the Planck likelihood, but slower than CAMB. Is it possible to assign these nuisance parameters their own fast/slow subspace?
My code is faster than the Planck likelihood, but slower than CAMB. Is it possible to assign these nuisance parameters their own fast/slow subspace?
-
- Posts: 1872
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Adding new parameters to CosmoMC, March-13
Each likelihood object has a speed parameter, just set the appropriate number for the relative speed (CamSpec is set to have speed 5, higher number is faster).
-
- Posts: 7
- Joined: May 30 2013
- Affiliation: UC Berkeley
Adding new parameters to CosmoMC, March-13
Thanks. I noticed some code in paramdef.F90, and the clik_speed_* parameters in the clik-related ini files. How do I set the analogous speed parameter for my likelihood (which I added simply as an .ini file in batch1, a .paramnames file in data, a .f90 file in source, and an entry in DataLikelihoods.f90)?
-
- Posts: 1872
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Adding new parameters to CosmoMC, March-13
In your f90 file defining your descendant of CosmologyLikelihood set the speed parateter. E.g.
Code: Select all
module MyLlike
use likelihood
type, extends(CosmologyLikelihood) :: MyLikelihood
..
contains
..
end type MyLikelihood
..
contains
..
subroutine MyLike_Add(LikeList,Ini)
class(LikelihoodList) :: LikeList
Type(TIniFile) :: ini
type(MyLikelihood), pointer :: like
allocate(like)
like%speed = 2
..
call LikeList%Add(like)
...
end module
-
- Posts: 7
- Joined: May 30 2013
- Affiliation: UC Berkeley
Adding new parameters to CosmoMC, March-13
Awesome, thanks Antony!
-
- Posts: 3
- Joined: March 21 2014
- Affiliation: University of Cambridge
Adding new parameters to CosmoMC, March-13
Hi Antony,
Is the same true for the March 2014 version? I have modifeid the March 2013 according to your suggestions and it worked fine, but in the case of the March 2014 one the program compiles but does not seem to correctly read the parameter in the .ini file.
Best,
Andrei
Is the same true for the March 2014 version? I have modifeid the March 2013 according to your suggestions and it worked fine, but in the case of the March 2014 one the program compiles but does not seem to correctly read the parameter in the .ini file.
Best,
Andrei
-
- Posts: 1872
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Adding new parameters to CosmoMC, March-13
A few things have been renamed. The template is now
You can look at the various provided likelihoods for other examples.
Code: Select all
module MyLlike
use Likelihood_Cosmology
type, extends(TCosmologyLikelihood) :: TMyLikelihood
..
contains
..
end type TMyLikelihood
..
contains
..
subroutine MyLike_Add(LikeList,Ini)
class(TLikelihoodList) :: LikeList
class(TSettingIni) :: ini
type(TMyLikelihood), pointer :: like
allocate(like)
like%speed = 2
..
call LikeList%Add(like)
...
end module
-
- Posts: 3
- Joined: March 21 2014
- Affiliation: University of Cambridge
Adding new parameters to CosmoMC, March-13
Thanks Antony for the reply. In my case the parameter is a physical one so my question is if there is anything different compared to the previous versions apart from the obvious program name renamings, or if there is any other new place where I would have to add the parameter.
To add new theory parameters
* add the definition of the physical parameter to CMBParams in cmbtypes.f90
* Change params_CMB.f90 to add a new parameterization or modify an existing one (with a corresponding .paramnames file with the new parameter names in). In particular the _Init routine does
Code:
call SetTheoryParameterNumbers(num_slow_params,num_semi_slow_params)
which sets the number of hard and semi-hard parameters (the latter being things like initial power spectrum parameters) and then
Code:
call this%Init(Ini,Names, 'params_CMB.paramnames')
to set the parameter names file.
* Modify CMB_Cls_Simple.f90 to pass your new CMBParams parameters to CAMB to actually change the result
* Edit your .ini files to to add range and width settings for the new parameter names
-
- Posts: 1872
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Adding new parameters to CosmoMC, March-13
The readme was out of date, I've now updated that section - thanks.
-
- Posts: 8
- Joined: February 13 2020
- Affiliation: MHRD
Re: Adding parameters to CosmoMC, March-13
Hii
I am trying to add "mnu" as a parameter to the chains and then use it in my Plots.How can I do it? I am using CosmoMC july 2019. Thanks
I am trying to add "mnu" as a parameter to the chains and then use it in my Plots.How can I do it? I am using CosmoMC july 2019. Thanks
-
- Posts: 11
- Joined: March 27 2019
- Affiliation: University of Texas at Dallas
Re: Adding new parameters to CosmoMC, March-13
Hello,
in the file batch3/params_CMB_defaults.ini, you need to change
param[mnu] = 0.06
for a fix value, to a a parameter by adding its center value, min value, max value, start width, and propose width. For example, replace the above by
param[mnu] = 0.06 0 0.9 0.005 0.005
or whatever values you want. Then CosmoMC will vary that parameter also.
Best regards,
Cristhian Garcia.
in the file batch3/params_CMB_defaults.ini, you need to change
param[mnu] = 0.06
for a fix value, to a a parameter by adding its center value, min value, max value, start width, and propose width. For example, replace the above by
param[mnu] = 0.06 0 0.9 0.005 0.005
or whatever values you want. Then CosmoMC will vary that parameter also.
Best regards,
Cristhian Garcia.
-
- Posts: 1872
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Adding new parameters to CosmoMC, March-13
Or, better, set param[mnu] in the ini file for your run rather than changing the default one. Generally you shouldn't need to edit files in batch3, parameters can be overridden in the .ini file actually used.