Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lightcone ode bug (seemingly from gsl 2.7) #113

Merged
merged 3 commits into from
Jan 8, 2024
Merged

fix lightcone ode bug (seemingly from gsl 2.7) #113

merged 3 commits into from
Jan 8, 2024

Conversation

adrianbayer
Copy link
Collaborator

GSL update now gives error when trying to solve growth ODE at a < aini.

This makes any lightcone run with ODE crash, as the horizon interpolation table is computed from a=0. However, the horizon interpolation table is unused for a less than the starting a of the simulation, so we can safely set the growth to 0.

There would still be a problem (and there always has been a problem) if the user wants to start the simulation at a < aini (i.e. earlier than z=159), but that should be a rare and I leave the fix for another time.

@adrianbayer adrianbayer changed the title fix lightcone ode bug fix lightcone ode bug (seemingly from gsl 2.7) Feb 2, 2023
@rainwoodman
Copy link
Collaborator

Thanks for the fix! This looks good to me.

I feel the warning message may be unnecessary, as it is not actionable and also always there. Sort of like the healpix log you just removed.

  • maybe the right place to raise the warning is when growth factors (and other linear model functions) are requested for a < aini? Then when it is display the action is to avoid any time steps above aini.
  • What if we patch it up, by returning D1 = a and D2 = 0 for a < aini? Is this approximation only valid in matter dominated universe and thus incorrect in this case?

@adrianbayer
Copy link
Collaborator Author

adrianbayer commented Feb 6, 2023

I agree with you on 1, but would that require going round the code and whenever the growth ode function is called we'd have to check if a < aini, apart from when it is called in horizon.c?
Maybe the neatest thing is in fastpm.c when reading in the lua parameters, I can raise an error if the minimum time_step a < aini, where aini is hard coded as 0.00625. Then I can remove the warning in cosmology.c.

Maybe we could set according to the intial conditions (which corresponds to matter domination) so:
soln[0] = a;
soln[1] = a;
soln[2] = - 3./7. * a*a;
soln[3] = 2 * soln[2];
This would break down when there is radiation/neutrinos in the simulation, so may not be useful practically speaking, but perhaps it's better than setting to 0? In any case, if we raise an error in fastpm.c, the values of soln for a < aini should never be used except to fill the horizon table.

@rainwoodman
Copy link
Collaborator

Shall we merge this PR? I feel our discord on whether issuing a warning or fail shouldn't block signaling any 'something' about the undefined behavior. :)

@adrianbayer
Copy link
Collaborator Author

I removed the warning, and added an error in lua if a user tries to use a<0.00625 when using ODE mode. I think this should make everything clear and safe, and a<0.00625 should only occur (in ODE mode) for the horizon table. Will merge now.

@adrianbayer adrianbayer closed this Jan 8, 2024
@adrianbayer adrianbayer reopened this Jan 8, 2024
@adrianbayer adrianbayer merged commit d86ade8 into master Jan 8, 2024
5 checks passed
@adrianbayer adrianbayer mentioned this pull request Jan 8, 2024
@adrianbayer adrianbayer deleted the ode branch January 8, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants