diff --git a/fiasco/collections.py b/fiasco/collections.py index fce38e36..c80064ef 100644 --- a/fiasco/collections.py +++ b/fiasco/collections.py @@ -336,7 +336,19 @@ def radiative_loss(self, density: u.cm**(-3), **kwargs) -> u.Unit('erg cm3 s-1') @u.quantity_input def radiative_loss_bound_bound(self, density, **kwargs) -> u.Unit('erg cm3 s-1'): - """ + r""" + Calculate the radiative loss rate from bound-bound emission (line emission) + integrated over wavelength. + + Parameters + ---------- + density : `~astropy.units.Quantity` + Electron number density + + Returns + ------- + rad_loss : `~astropy.units.Quantity` + The bolometric bound-bound radiative loss rate per unit emission measure """ density = np.atleast_1d(density) rad_loss = u.Quantity(np.zeros(self.temperature.shape + density.shape), 'erg cm^3 s^-1') @@ -351,7 +363,14 @@ def radiative_loss_bound_bound(self, density, **kwargs) -> u.Unit('erg cm3 s-1') @u.quantity_input def radiative_loss_free_free(self) -> u.Unit('erg cm3 s-1'): - """ + r""" + Calculate the radiative loss rate from free-free emission (bremsstrahlung) + integrated over wavelength. + + Returns + ------- + rad_loss : `~astropy.units.Quantity` + The bolometric free-free radiative loss rate per unit emission measure """ free_free = u.Quantity(np.zeros(self.temperature.shape), 'erg cm^3 s^-1') for ion in self: @@ -368,7 +387,14 @@ def radiative_loss_free_free(self) -> u.Unit('erg cm3 s-1'): @u.quantity_input def radiative_loss_free_bound(self) -> u.Unit('erg cm3 s-1'): - """ + r""" + Calculate the radiative loss rate from free-bound emission (collisional recombination) + integrated over wavelength. + + Returns + ------- + rad_loss : `~astropy.units.Quantity` + The bolometric free-bound radiative loss rate per unit emission measure """ free_bound = u.Quantity(np.zeros(self.temperature.shape), 'erg cm^3 s^-1') for ion in self: diff --git a/fiasco/tests/test_collections.py b/fiasco/tests/test_collections.py index dc6962f8..050fe1b0 100644 --- a/fiasco/tests/test_collections.py +++ b/fiasco/tests/test_collections.py @@ -131,6 +131,34 @@ def test_radiative_loss(collection, hdf5_dbase_root): # These values have not been checked for correctness u.allclose(rl[0], [3.90235371e-24, 4.06540902e-24, 4.08411295e-24] * u.erg * u.cm**3 / u.s) +@pytest.mark.requires_dbase_version('>= 8') +def test_radiative_loss_bound_bound(collection, hdf5_dbase_root): + # add Li III to the test to include an ion that throws a MissingDatasetException + collection = collection + fiasco.Ion('Li III', collection.temperature, hdf5_dbase_root=hdf5_dbase_root) + density = [1e9,1e10,1e11] * u.cm**-3 + rl = collection.radiative_loss_bound_bound(density) + assert rl.shape == (len(temperature), len(density)) + # These values have not been checked for correctness + u.allclose(rl[0], [3.90235371e-24, 4.06540902e-24, 4.08411295e-24] * u.erg * u.cm**3 / u.s) + +@pytest.mark.requires_dbase_version('>=8') +def test_radiative_loss_free_free(collection, hdf5_dbase_root): + # add Li III to the test to include an ion that throws a MissingDatasetException + collection = collection + fiasco.Ion('Li III', collection.temperature, hdf5_dbase_root=hdf5_dbase_root) + rl = collection.radiative_loss_free_free() + assert rl.shape == collection.temperature.shape + # This value has not been checked for correctness + u.isclose(rl[0], 2.72706455e-35 * u.erg * u.cm**3 / u.s) + +@pytest.mark.requires_dbase_version('>=8') +def test_radiative_loss_free_bound(collection, hdf5_dbase_root): + # add Li III to the test to include an ion that throws a MissingDatasetException + collection = collection + fiasco.Ion('Li III', collection.temperature, hdf5_dbase_root=hdf5_dbase_root) + rl = collection.radiative_loss_free_bound() + assert rl.shape == collection.temperature.shape + # This value has not been checked for correctness + u.isclose(rl[0], 1.13808317e-33 * u.erg * u.cm**3 / u.s) + @pytest.mark.requires_dbase_version('>= 8') def test_spectrum(hdf5_dbase_root): i1 = fiasco.Ion('H 1', 1 * u.MK, hdf5_dbase_root=hdf5_dbase_root)