grad-based Mgas model kernels #101
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is still WIP. It brings in alternative versions of the functions
calc_mgas_galpopandcalc_mgas_singlegalwith new versions based onjax.grad. Current, temporary names for these new functions arecalc_mgas_galpop3andcalc_mgas_singlegal3, defined in the same module,diffstar.mgas_model.Currently, the alternative method gives good agreement with the original method (except at very early times). I have done some preliminary benchmarking, and I think runtimes and memory consumption are comparable when computing gas histories for large galaxy populations, but this should be verified more carefully.
The plot below compares the old and new version for an example galaxy
One thing to watch out for with the current implementation is the hard-coding done with the number of integration steps, which is currently done with a global variable:
N_INT_STEPS = 20I have not tested this very thoroughly. But the performance and especially memory consumption depends sensitively upon this variable.
Closes #100.