tardis-sn/stardis

Only consider nearby elements for voigt profile calculations in opacities

Closed this issue · 1 comments

We could speed up the code greatly by only checking nearby lines for opacity contributions to each wavelength bin. Currently we check every line in the spectrum for contributions to each opacity bin. This is technically faster than the alternative, because our current implementation of nearby line searching manually checks the entire linelist for things that are close and then calculates opacities with those.

Instead, we should use a more sophisticated line finding algorithm, like a kdtree, to only search lines within some reasonable threshold (which could be calculated or could be set as a constant), or only consider lines within some indices. Index checking could be quick but might be tricky to do right because lines are not uniformly spaced. Either way, it's a problem worth thinking about and should provide dramatic speedups for larger wavelength bounds spectrum generation.

A simple implementation of this was merged in #161

This should be improved to use only apply the broadening range treatment to non-hydrogen lines. Hydrogen lines are so much more broad than other lines that it makes sense to ignore them in the broadening range limitation.