lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

CLASS not recognising a new Monte python input parameter #348

Closed astrogirl1 closed 4 years ago

astrogirl1 commented 4 years ago

Hi, I am working with MCMC chains using Monte python and CLASS together for which I need to introduce a new 'cosmo' parameter in the Monte Python input file, like the following: in a .param file:

data.parameters['value'] = [-2.15, -4,-0.3, 6.8 ,1,'cosmo']

This value will be used in the background.c file in the future, so accordingly I have added the following definitions in the required files as a check to see if CLASS can actually read this parameter:

_background.h (inside struct background) -> double value; _input.c -> class_read_double('value', pba->value);

But I keep running into this error:

Cosmological Module Error: /|\ Something went wrong when calling CLASS /o\ Error in Class: Class did not read input parameter(s): value

I am unsure if this is the correct way to add a new parameter that CLASS uses, if this is a monte python issue or if I am missing something in defining the parameter. Any help is greatly appreciated!

Cheers, Meera

Stefan-Heimersheim commented 4 years ago

Hi Meera,

this sounds correct on the CLASS side, adding a parameter in background.h and input.c allows CLASS to run with it. Here is an example implementation of such a value.

Maybe the issue is in Monte Python? I suggest you run your modified CLASS version with just an input file (i.e. without Monte Python) and check if the error occurs. Either just add value = 42 to e.g. explanatory.ini or use the python wrapper:

from classy import Class
cosmo = Class()
p = {'output': 'tCl lCl pCl mPk', 'value': 47}
cosmo.set(p)
cosmo.compute()

If this works the issue should be with implementing the parameter in Monte Python; with that I have no experience.

Cheers, Stefan

astrogirl1 commented 4 years ago

Hi Stefan, Thank you for your help, after looking at your example, I think I missed something when defining the new variable, but now it works! :)