-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Radiative recombination #933
Merged
wkerzendorf
merged 10 commits into
tardis-sn:master
from
chvogl:radiative_recombination
May 22, 2019
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
95e0cc1
Remove deprecated ion_cx data
chvogl 74a99d9
Remove unused attributes from atom_data
chvogl 3fe9522
Add photoionization cross sections to atom_data
chvogl 1006780
Check if continuum interaction species are in selected atoms
chvogl 253edff
Add calculation of Saha factor
chvogl ebfaef7
Add photoionization properties needed for recombination rates
chvogl 7962279
Add calculation of spontaneous radiative recombination rates
chvogl ae43188
Fix zero division in Saha factor calculation
chvogl 14647c2
Improve index naming scheme in docstrings
chvogl 1ef99dc
Add description of zeta_data in docstring
chvogl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
from tardis.plasma.base import BasePlasma | ||
from tardis.plasma.standard_plasmas import LTEPlasma |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import logging | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
from numba import prange, njit | ||
from astropy import constants as const | ||
|
||
from tardis.plasma.properties.base import ProcessingPlasmaProperty | ||
|
||
__all__ = ['SpontRecombRateCoeff'] | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
njit_dict = {'fastmath': False, 'parallel': False} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should think if we want to have a central one |
||
|
||
|
||
@njit(**njit_dict) | ||
def integrate_array_by_blocks(f, x, block_references): | ||
""" | ||
Integrates a function f defined at locations x over blocks | ||
given in block_references. | ||
|
||
Parameters | ||
---------- | ||
f : Two-dimensional Numpy Array, dtype float | ||
x : One-dimensional Numpy Array, dtype float | ||
block_references : One-dimensional Numpy Array, dtype int | ||
|
||
Returns | ||
------- | ||
integrated : Two-dimensional Numpy Array, dtype float | ||
|
||
""" | ||
integrated = np.zeros((len(block_references) - 1, f.shape[1])) | ||
for i in prange(f.shape[1]): # columns | ||
for j in prange(len(integrated)): # rows | ||
start = block_references[j] | ||
stop = block_references[j + 1] | ||
integrated[j, i] = np.trapz(f[start:stop, i], x[start:stop]) | ||
return integrated | ||
|
||
|
||
def get_ion_multi_index(multi_index_full, next_higher=True): | ||
""" | ||
Integrates a function f defined at locations x over blocks | ||
given in block_references. | ||
|
||
Parameters | ||
---------- | ||
multi_index_full : Pandas MultiIndex (atomic_number, ion_number, | ||
level_number) | ||
next_higher : bool | ||
If true use ion number of next higher ion, else use ion_number from | ||
multi_index_full. | ||
|
||
Returns | ||
------- | ||
multi_index : Pandas MultiIndex (atomic_number, ion_number) | ||
|
||
""" | ||
atomic_number = multi_index_full.get_level_values(0) | ||
ion_number = multi_index_full.get_level_values(1) | ||
if next_higher is True: | ||
ion_number += 1 | ||
return pd.MultiIndex.from_arrays([atomic_number, ion_number]) | ||
|
||
|
||
class SpontRecombRateCoeff(ProcessingPlasmaProperty): | ||
""" | ||
Attributes | ||
---------- | ||
alpha_sp : Pandas DataFrame, dtype float | ||
The rate coefficient for spontaneous recombination. | ||
""" | ||
outputs = ('alpha_sp',) | ||
latex_name = ('\\alpha^{\\textrm{sp}}',) | ||
|
||
def calculate(self, photo_ion_cross_sections, t_electrons, | ||
photo_ion_block_references, photo_ion_index, phi_ik): | ||
x_sect = photo_ion_cross_sections['x_sect'].values | ||
nu = photo_ion_cross_sections['nu'].values | ||
|
||
alpha_sp = (8 * np.pi * x_sect * nu ** 2 / (const.c.cgs.value) ** 2) | ||
alpha_sp = alpha_sp[:, np.newaxis] | ||
boltzmann_factor = np.exp(-nu[np.newaxis].T / t_electrons * | ||
(const.h.cgs.value / const.k_B.cgs.value)) | ||
alpha_sp = alpha_sp * boltzmann_factor | ||
alpha_sp = integrate_array_by_blocks(alpha_sp, nu, | ||
photo_ion_block_references) | ||
alpha_sp = pd.DataFrame(alpha_sp, index=photo_ion_index) | ||
return alpha_sp * phi_ik |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really?