Add ThermoResult object and diffrax throw option#18
Closed
Conversation
Implements two features: 1. ThermoResult object (closes #14): - BackgroundModel now returns a ThermoResult NamedTuple - Contains all thermo outputs plus T_start/T_end used for integration - AbundanceModel accepts ThermoResult directly with auto T_start/T_end detection - Maintains backward compatibility via tuple unpacking (use [:7] slice) 2. diffrax throw option (closes #17): - Add `throw` parameter to both BackgroundModel and AbundanceModel - Default is True (raises exceptions on solver failure) - Set to False for parameter scans where some combinations may fail - Passed through to all internal diffeqsolve calls Usage examples: # New streamlined API thermo_result = BackgroundModel()(0.) abundances = AbundanceModel(nuclear_net)(thermo_result) # Parameter scans with throw=False thermo_model = BackgroundModel(throw=False) abundance_model = AbundanceModel(nuclear_net, throw=False) # Backward compatible t, a, rho_g, rho_nu, rho_extra, P_extra, Neff = thermo_model(0.)[:7] Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements two requested features:
1. ThermoResult object (closes #14)
BackgroundModelnow returns aThermoResultNamedTuple containing all thermo outputs plusT_start/T_endAbundanceModelacceptsThermoResultdirectly with automatic temperature range detection[:7]slice)2. diffrax throw option (closes #17)
throwparameter to bothBackgroundModelandAbundanceModelTrue(raises exceptions on solver failure)Falsefor parameter scans where some combinations may faildiffeqsolvecallsUsage examples
Test plan
pytest pytest/test_abundances.py)🤖 Generated with Claude Code