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)
223 stars 292 forks source link

Traceback error for Scalar field model #447

Open ajcosmology opened 2 years ago

ajcosmology commented 2 years ago

Hi, I tried to run montepython code for the scalar field and I am getting an error. I added the following lines in input param file to include the scalar field:

Cosmological parameters list

data.parameters['Omega_cdm'] = [0.2562, None, None, 0.008, 1, 'cosmo'] data.parameters['scf_alpha']=[0, None, None, 1, 1, 'cosmo'] data.parameters['scf_lambda']=[10, None, None,1, 1, 'cosmo'] data.parameters['scf_A']=[0, None, None, 1,1, 'cosmo'] data.parameters['scf_B']=[0, None, None, 1,1, 'cosmo'] data.parameters['Omega_m'] = [0, -1, -1, 0,1, 'derived'] data.cosmo_arguments['Omega_Lambda'] = 0.0

I made no other changes and ran the montepython code but I am getting the traceback error:

Traceback (most recent call last): File "/home/montepython_public-3.4/montepython/sampler.py", line 748, in compute_lkl cosmo.compute(["lensing"]) File "classy.pyx", line 366, in classy.Class.compute classy.CosmoSevereError:

Error in Class: Class did not read input parameter(s): scf_alpha, scf_lambda, scf_A, scf_B

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "montepython/MontePython.py", line 40, in sys.exit(run()) File "/home/montepython_public-3.4/montepython/run.py", line 45, in run sampler.run(cosmo, data, command_line) File "/home/montepython_public-3.4/montepython/sampler.py", line 46, in run mcmc.chain(cosmo, data, command_line) File "/home/montepython_public-3.4/montepython/mcmc.py", line 474, in chain loglike = sampler.compute_lkl(cosmo, data) File "/home/montepython_public-3.4/montepython/sampler.py", line 759, in compute_lkl raise io_mp.CosmologicalModuleError( io_mp.CosmologicalModuleError:

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


I don't know how to include the scalar field parameters in the code and don't know where to make changes to resolve the error. Also, how to get 1-sigma value for parameters? I am new to class so if anyone can help me, thank you in advance.

arsalanadil commented 2 years ago

Hi,

I had faced the same issue once upon a time (reported here). Here's what I think happens:

The problem is that if MontePython takes you into a very bad part of parameter space then CLASS' shooting algorithm may erroneously return shooting_parameter = infty and Omega_scf = nan, instead of "shooting failed" as it normally would. This is a problem because then MontePython thinks that Omega_scf!=-1 (which is the flag to tell CLASS to use scalar field) and so CLASS returns an error saying that it did not read the input scf_parameters.

The dirty fix I have is to catch this situation in Classy (around Line 365 in the def compute() method) so that it returns a CosmoComputationError (which treats the output as a valid point but with zero likelihood) as opposed to a CosmoSevereError (which erroneously aborts the MP run). I can share the code with you, although I'm embarrassed of it because it really is quite a dirty fix and the issue should really be addressed somewhere in CLASS instead of MP.

Hope this helps, Arsalan

ajcosmology commented 2 years ago

Dear Arsalan, Thank you for your reply and reaching out. I shall try and modify the code as you suggested. But if you could share the code with me then please do so, It would be a great help.

Thank you and best regards, Alex

On Wed, Oct 27, 2021 at 2:36 PM Arsalan Adil @.***> wrote:

Hi,

I had faced the same issue once upon a time (reported here https://github.com/brinckmann/montepython_public/issues/139). Here's what I think happens:

The problem is that if MontePython takes you into a very bad part of parameter space then CLASS' shooting algorithm may erroneously return shooting_parameter = infty and Omega_scf = nan, instead of "shooting failed" as it normally would. This is a problem because then MontePython thinks that Omega_scf!=-1 (which is the flag to tell CLASS to use scalar field) and so CLASS returns an error saying that it did not read the input scf_parameters.

The dirty fix I have is to catch this situation in Classy (around Line 365 in the def compute() method) so that it returns a CosmoComputationError (which treats the output as a valid point but with zero likelihood) as opposed to a CosmoSevereError (which erroneously aborts the MP run). I can share the code with you, although I'm embarrassed of it because it really is quite a dirty fix and the issue should really be addressed somewhere in CLASS instead of MP.

Hope this helps, Arsalan

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lesgourg/class_public/issues/447#issuecomment-952700888, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWAGCHUZ375TTAO4UXPJTK3UI66HZANCNFSM5FXWFKFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.