Skip to content

Commit 548ab2e

Browse files
Jeffrey ReepJeffrey Reep
Jeffrey Reep
authored and
Jeffrey Reep
committed
add 2p method for IonCollection
1 parent 0666c6e commit 548ab2e

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

fiasco/collections.py

+20
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,26 @@ def free_bound(self, wavelength: u.angstrom, **kwargs):
167167
free_bound += fb * abundance * ioneq[:, np.newaxis]
168168
return free_bound
169169

170+
@u.quantity_input
171+
def two_photon(self, wavelength: u.angstrom, electron_density: u.cm**-3, **kwargs):
172+
"""
173+
"""
174+
wavelength = np.atleast_1d(wavelength)
175+
two_photon = u.Quantity(np.zeros(self.temperature.shape + wavelength.shape),
176+
'erg cm^3 s^-1 Angstrom^-1')
177+
for ion in self:
178+
if ion.hydrogenic or ion.helium_like:
179+
try:
180+
tp = ion.two_photon(wavelength, electron_density, **kwargs)
181+
abundance = ion.abundance
182+
ioneq = ion.ioneq
183+
except MissingDatasetException as e:
184+
self.log.warning(f'{ion.ion_name} not included in two-photon emission. {e}')
185+
continue
186+
else:
187+
two_photon += tp * abundance * ioneq[:, np.newaxis]
188+
return two_photon
189+
170190
@u.quantity_input
171191
def spectrum(self, density: u.cm**(-3), emission_measure: u.cm**(-5), wavelength_range=None,
172192
bin_width=None, kernel=None, **kwargs):

fiasco/ions.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,10 @@ def _karzas_cross_section(self, photon_energy: u.erg, ionization_energy: u.erg,
14711471
def two_photon(self, wavelength: u.angstrom, electron_density: u.cm**(-3)) -> u.erg * u.cm**3 / u.s / u.angstrom:
14721472
"""
14731473
"""
1474+
wavelength = np.atleast_1d(wavelength)
1475+
14741476
prefactor = (const.h * const.c) / (4*np.pi)
1477+
EM = 1 * u.cm**-5 # CHIANTI assumes a column EM with value of 1 if not specified
14751478

14761479
if self.hydrogenic:
14771480
A_ji = self._hseq['A']
@@ -1497,8 +1500,8 @@ def two_photon(self, wavelength: u.angstrom, electron_density: u.cm**(-3)) -> u.
14971500
psi_interp = cubic_spline(y_interp)
14981501
energy_dist = (A_ji * y_interp * psi_interp) / (A_sum * wavelength[indices])
14991502

1500-
pe_ratio = proton_electron_ratio(self.temperature, **self._instance_kwargs)
1501-
level_population = self.level_populations(electron_density, **self._instance_kwargs)
1503+
pe_ratio = proton_electron_ratio(self.temperature)
1504+
level_population = self.level_populations(electron_density)
15021505

15031506
# N_j(X+m) = N_j(X+m)/N(X+m) * N(X+m)/N(X) * N(X)/N(H) * N(H)/Ne * Ne
15041507
level_density = level_population[:,0,1] * self.ioneq * self.abundance * pe_ratio * electron_density
@@ -1507,4 +1510,4 @@ def two_photon(self, wavelength: u.angstrom, electron_density: u.cm**(-3)) -> u.
15071510

15081511
#prefactor * matrix = u.erg / (u.s * u.angstrom * u.cm**2)
15091512

1510-
return 0.0 * u.erg * u.cm**3 / u.s / u.angstrom
1513+
return (prefactor * matrix / EM)

0 commit comments

Comments
 (0)