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)
220 stars 291 forks source link

Background_init error from free(pvecback) #496

Closed joshuaange closed 9 months ago

joshuaange commented 1 year ago

In trying to run CLASS with varying values for alpha and me, this error occurs:

Error running background_init =>background_init(L:822) :condition (pba->shooting_failed == TRUE) is true; Shooting failed, try optimising input_get_guess(). Error message:

input_shooting(L:653) :error in input_find_root(&xzero, &fevals, ppr->tol_shooting_deltax_rel, &fzw, errmsg); =>input_find_root(L:930) :error in input_fzerofun_1d(x1, pfzw, &f1, errmsg); =>input_fzerofun_1d(L:1003) :error in input_try_unknown_parameters(&input, 1, pfzw, output, error_message); =>input_try_unknown_parameters(L:1383) :error in thermodynamics_init(&pr,&ba,&th); =>thermodynamics_init(L:360) :error in thermodynamics_checks(ppr,pba,pth); =>thermodynamics_checks(L:704) :condition ((pth->YHe < _YHESMALL)||(pth->YHe > _YHEBIG)) is true; Y_He=-21.1258 out of bounds (0.01<Y_He<0.5) getting deriv w.r.t. omega_c_h2

As far as I can tell, it's because in thermodynamics.c, line 523 has free(pvecback) and line 668 then tries to find its value with pvecback[pba->index_bg_varc_alpha]. Moving the free(pvecback) to line 678 (after the other deallocation) seemingly fixes the issue.

Note: this was done in modified CLASS https://github.com/selimhotinli/class_delens merged with class_public, but I don't think that's playing a role

schoeneberg commented 1 year ago

Dear @joshuaange, I implemented the solution in the git release pipeline, and hopefully it will be published relatively soon!

lesgourg commented 9 months ago

Fixed in v3.2.1. Thanks!