Repository navigation
Conversation
Avoid repeated expensive recomputation in the level populations calculation while keeping the output bit-identical: - Cache the Ion instances returned by next_ion()/previous_ion() for internal use so that rate matrices of the recombining ion are only computed once rather than on every density iteration. - Cache the density-independent sum of the two-ion rate matrices. - Memoize plasmapy atomic_number/atomic_symbol/element_name lookups, which construct an expensive Particle object on every call. - Share the proton-electron ratio with the next ion since it only depends on temperature and the abundance/ionization datasets. Benchmark (21 temperatures x 9 densities): Fe XXIII 73.5->7.2 s, Ca XVIII 74.3->8.1 s, O VI 73.3->9.3 s, Fe XII (single-ion model) 9.9->5.0 s, coupled n-T 14.5->3.0 s.
Further speed up of the level populations calculation (and anything else that creates many Ion instances or reads many datasets), again keeping the output bit-identical: - DataIndexerHDF5.__getitem__ now does the membership check, child indexer creation, and read with a single open of the HDF5 file instead of two to three opens per access. - Memoize the set of available ion names and the database fiasco version per database file, keyed on the file modification time and size so that rebuilding the database invalidates the cache. This avoids re-reading the full ion index on every Ion instantiation. Ion instantiation drops from ~3.7 ms to ~1.9 ms and fiasco.proton_electron_ratio from ~2.1 s to ~1.5 s. O VI level populations (21 T x 9 n): 9.3 -> 8.1 s, dominated by np.linalg.solve.
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.
No description provided.