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

Add new GauntFactor class and add Itoh integrated Gaunt factors to f-f radiative loss #293

Merged
merged 69 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8b36d16
add parsers for itoh_integrated_gaunt files
Aug 15, 2024
92853a7
fix coefficient labels -- wrong order
Aug 15, 2024
a1b7e1f
Merge branch 'wtbarnes:main' into itoh
jwreep Aug 31, 2024
d35c670
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 4, 2024
51075d8
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 10, 2024
cb32bfe
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 11, 2024
8b84276
add parsed data to ContinuumBase
Sep 11, 2024
241f9d8
start implementing new GauntFactor class
Sep 12, 2024
c26a273
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 13, 2024
2402ffb
integrate GauntFactor class into radiation calculations
Sep 13, 2024
9c74997
fix f-f rad loss
Sep 13, 2024
73a498f
update Gaunt factor tests
Sep 13, 2024
aa42780
start refactoring GauntFactor
Sep 13, 2024
f0f07f0
move _itoh dataset to GauntFactor
jwreep Sep 13, 2024
922ef13
tidy up calls to GF
jwreep Sep 13, 2024
83a6854
fix tests + pre-commit
jwreep Sep 13, 2024
4bf791c
fix last two tests
jwreep Sep 14, 2024
c09ed43
Update fiasco/ions.py
jwreep Sep 14, 2024
a0bf0c5
add functions for new Itoh Gaunt factors
Sep 14, 2024
7933c3c
move free-bound and klgfb to GauntFactor
jwreep Sep 16, 2024
001edc5
fix issues with parser preprocessors
jwreep Sep 17, 2024
052fd71
fix new itoh functions
jwreep Sep 17, 2024
7f48cdc
fix up integrated f-f Gaunt factors
jwreep Sep 18, 2024
7f17671
rearrange if-else logic to be more readable
jwreep Sep 18, 2024
2e5fcde
add itoh options to radiative loss calculations
jwreep Sep 18, 2024
0841440
fix docstring error?
jwreep Sep 18, 2024
1366833
add test_gaunt + move GF tests to this file
jwreep Sep 18, 2024
628ecc8
small changes to gaunt tests
Sep 18, 2024
4adf993
fix initialization in test
Sep 18, 2024
7f4b612
add test for new data sources
Sep 18, 2024
b79455b
use Einstein summation to speed up integrated Itoh gf
Sep 19, 2024
c46bae1
dat -> txt
jwreep Sep 20, 2024
8675be0
rename datasets
jwreep Sep 20, 2024
bf42522
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 20, 2024
3c06523
replace total gaunt factor with integrated gaunt factor
Sep 20, 2024
7cf93ea
update the logic of Itoh integrated f-f gf
Sep 20, 2024
af55bc0
import missingdatasetexception
jwreep Sep 21, 2024
97c2b19
add some small tests
jwreep Sep 21, 2024
f5c0d53
test the existence of the datasets for gaunt factors
jwreep Sep 21, 2024
306de75
fix test
Sep 21, 2024
c601e84
first attempt to generalize building the test file list for a new ver…
Sep 21, 2024
8bbb6d7
fix docs issue with change to test_file_test
Sep 21, 2024
a3c90c8
use test file list iff the file list has length 0
Sep 21, 2024
eb1fe59
add a few more tests for itoh gf
Sep 21, 2024
88d75c1
two more tests + try to fix docs build
Sep 22, 2024
6d01f04
make changes to test_gaunt
Sep 23, 2024
d14ada0
make changes to collections
Sep 23, 2024
f0462c7
one more update to collections
Sep 23, 2024
6d4ecea
update ions.py
Sep 23, 2024
2939ba6
Update fiasco/io/sources/continuum_sources.py
jwreep Sep 23, 2024
fff7d4a
Update fiasco/gaunt.py
jwreep Sep 23, 2024
ce92ba5
Update fiasco/gaunt.py
jwreep Sep 23, 2024
fbbd3cc
fix summations for itoh integrated gf
jwreep Sep 24, 2024
d1b69c0
Update fiasco/gaunt.py
jwreep Sep 24, 2024
ef03339
atleast_1d(E_scaled)
jwreep Sep 24, 2024
6334924
remove gf from top level namespace
jwreep Sep 24, 2024
2bd1ccb
update docstring of f-f integrated
jwreep Sep 24, 2024
db0ecaf
remove GauntFactor from init attributes
jwreep Sep 24, 2024
5bccf76
fix docs issue related to change in __init__ file
jwreep Sep 24, 2024
0bdd2f1
how do you revert?
Sep 24, 2024
7fb7d39
minor docstring changes
Sep 25, 2024
b5d103f
add hash table v9.0.1; revert setup_db changes
Sep 25, 2024
aa20621
restore test_file_list
Sep 25, 2024
fb4e2c1
slight docstring change
jwreep Sep 26, 2024
a31457b
fix docstring
jwreep Sep 26, 2024
fb8a1ae
fix indentation -- please build docs
jwreep Sep 26, 2024
1ef87c6
more consistency in docstrings
wtbarnes Sep 26, 2024
7145d47
simplify bibtex entry
wtbarnes Sep 26, 2024
ee77037
more docstring consistency
wtbarnes Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@ @article{itoh_relativistic_2000
doi = {10.1086/313375}
}

@article{itoh_radiative_2002,
title = {Radiative Processes in the Intracluster Plasma},
author = {Itoh, N. and Sakamoto, T. and Kusano, S. and Kawana, Y. and Nozawa, S.},
year = {2002},
month = feb,
journal = {Astronomy and Astrophysics},
volume = {382},
pages = {722--729},
issn = {0004-6361},
doi = {10.1051/0004-6361:20011664},
urldate = {2024-09-23},
annotation = {ADS Bibcode: 2002A\&A...382..722I}
}


@article{karzas_electron_1961,
title = {Electron {{Radiative Transitions}} in a {{Coulomb Field}}.},
author = {Karzas, W. J. and Latter, R.},
Expand Down
2 changes: 2 additions & 0 deletions fiasco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fiasco.collections import IonCollection
from fiasco.elements import Element
from fiasco.fiasco import list_elements, list_ions, proton_electron_ratio
from fiasco.gaunt import GauntFactor
jwreep marked this conversation as resolved.
Show resolved Hide resolved
from fiasco.ions import Ion
from fiasco.levels import Level, Transitions
from fiasco.util.util import setup_paths
Expand Down Expand Up @@ -51,6 +52,7 @@ def _get_bibtex():
"Ion",
"Level",
"Transitions",
"GauntFactor",
"defaults",
"log",
"__version__",
Expand Down
21 changes: 0 additions & 21 deletions fiasco/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,12 @@ class ContinuumBase(Base):
.. note:: This is not meant to be instantiated directly by the user
and primarily serves as a base class for `~fiasco.Ion`.
"""

@property
def _gffgu(self):
data_path = '/'.join(['continuum', 'gffgu'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _gffint(self):
data_path = '/'.join(['continuum', 'gffint'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _klgfb(self):
data_path = '/'.join(['continuum', 'klgfb'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _verner(self):
data_path = '/'.join([self.atomic_symbol.lower(), self._ion_name, 'continuum',
'verner_short'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _itoh(self):
data_path = '/'.join([self.atomic_symbol.lower(), 'continuum', 'itoh'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _hseq(self):
data_path = '/'.join([self.atomic_symbol.lower(), 'continuum', 'hseq_2photon'])
Expand Down
21 changes: 17 additions & 4 deletions fiasco/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def spectrum(self, density: u.cm**(-3), emission_measure: u.cm**(-5), wavelength
return wavelength, spectrum

@u.quantity_input
def radiative_loss(self, density: u.cm**(-3), **kwargs) -> u.Unit('erg cm3 s-1'):
def radiative_loss(self, density: u.cm**(-3), use_itoh=False, **kwargs) -> u.Unit('erg cm3 s-1'):
r"""
Calculate the total wavelength-integrated radiative loss rate including the
bound-bound, free-bound, and free-free emission contributions
Expand All @@ -315,14 +315,17 @@ def radiative_loss(self, density: u.cm**(-3), **kwargs) -> u.Unit('erg cm3 s-1')
----------
density : `~astropy.units.Quantity`
Electron number density
use_itoh : `bool`, optional
Whether to use Gaunt factors taken from :cite:t:`itoh_radiative_2002` for the calculation
of free-free emission. Defaults to false.

Returns
-------
rad_loss_total : `~astropy.units.Quantity`
The total bolometric radiative loss rate
"""
rad_loss_bound_bound = self.bound_bound_radiative_loss(density, **kwargs)
rad_loss_free_free = self.free_free_radiative_loss()
rad_loss_free_free = self.free_free_radiative_loss(use_itoh=use_itoh)
rad_loss_free_bound = self.free_bound_radiative_loss()

rad_loss_total = (rad_loss_bound_bound
Expand Down Expand Up @@ -363,20 +366,30 @@ def bound_bound_radiative_loss(self, density, **kwargs) -> u.Unit('erg cm3 s-1')
return rad_loss

@u.quantity_input
def free_free_radiative_loss(self) -> u.Unit('erg cm3 s-1'):
def free_free_radiative_loss(self, use_itoh=False) -> u.Unit('erg cm3 s-1'):
r"""
Calculate the radiative loss rate from free-free emission (bremsstrahlung)
integrated over wavelength.

Parameters
----------
use_itoh : `bool`, optional
Whether to use Gaunt factors taken from :cite:t:`itoh_radiative_2002`.
Defaults to false.

Returns
-------
rad_loss : `~astropy.units.Quantity`
The bolometric free-free radiative loss rate per unit emission measure

See Also
-------
fiasco.GauntFactor.free_free_integrated
"""
free_free = u.Quantity(np.zeros(self.temperature.shape), 'erg cm^3 s^-1')
for ion in self:
try:
ff = ion.free_free_radiative_loss()
ff = ion.free_free_radiative_loss(use_itoh=use_itoh)
abundance = ion.abundance
ioneq = ion.ioneq
except MissingDatasetException as e:
Expand Down
8 changes: 1 addition & 7 deletions fiasco/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
else:
matplotlib.use('Agg')


# Minimal set of CHIANTI files needed to run the tests
# NOTE: need some way for this to be flexible depending on the supplied database version
TEST_FILES = get_test_file_list()


@pytest.fixture(scope='session')
def ascii_dbase_tree(tmpdir_factory, request):
path = request.config.getoption('--ascii-dbase-root')
Expand Down Expand Up @@ -47,7 +41,7 @@ def hdf5_dbase_root(ascii_dbase_tree, tmpdir_factory, request):
if request.config.getoption('--include-all-files'):
test_files = None
else:
test_files = TEST_FILES
test_files = get_test_file_list()
check_hash = not request.config.getoption('--disable-file-hash')
# Optionally use a different URL for the database (e.g. for testing different versions)
ascii_dbase_url = request.config.getoption('--ascii-dbase-url')
Expand Down
Loading