-
-
Notifications
You must be signed in to change notification settings - Fork 405
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
Macroatom restructure #2786
Merged
andrewfullard
merged 89 commits into
tardis-sn:master
from
Rodot-:macroatom_restructure
Aug 13, 2024
Merged
Macroatom restructure #2786
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
1056501
created file for opacity solver
Rodot- 2dd9178
Added opacity states for the continuum and macroatom
Rodot- e0a9c02
Updated the opacity state and macroatom state to work with legacy plasma
Rodot- 390c4d8
Added numba initialize from opacity state, added methods to solve opa…
Rodot- 9f71324
moved line2macro_level_upper to the macroatom state
Rodot- 7a5e864
renamed a macroatom variable, added solver to montecarlo solver
Rodot- 378dbd5
ran black
Rodot- 462a5e8
corrected an import
Rodot- 89860f9
corrected an import
Rodot- 8672a0c
ran black
Rodot- 8941377
Added line_interaction_type to the to_numba function, should be reqor…
Rodot- 2704633
fixed initialization of opacity state
Rodot- 15b1565
Updated handling of continuum vs noncontinuum macroblock references
Rodot- 80c9f85
Fixed a typo
Rodot- b3a4258
refactored the state objects to put them in the correct folders
Rodot- 6010f40
another typo
Rodot- 95fbc72
added basic docstrings to the continuum state
Rodot- 5da0577
Added docstrings to macroatom state
Rodot- da72b58
Updated docstrings onithe opacity_state file
Rodot- 81dde1b
Added docstrings to the solver
Rodot- e182bb8
Updated Docstring Style
Rodot- b8a527f
Merge branch 'master' of github.com:tardis-sn/tardis into opacity_sta…
Rodot- 148672e
ran black
Rodot- 204d6c9
changed Opacity solver to take kwargs
Rodot- c628eb6
ran black
Rodot- 67e301f
Added class attributes to Opacity Solver
Rodot- 939a9f8
Changed names of the opacity state and numba equivalent
Rodot- 16d8db7
Merge branch 'master' into opacity_state_restructure
Rodot- f52d4ea
Added test for the opacity solver
Rodot- 3131a6b
added conftest to the opacities module
Rodot- cc89f37
fixed up tests for the opacity_solver
Rodot- 5b7bc95
ran black
Rodot- 5d07c65
Added new test for the numba opacity state
Rodot- 62371cb
ran black, updated name of the test
Rodot- acc02e8
Make a function to calculate markov chain indices
Rodot- f417cab
Extracted more functions
Rodot- b1c1b1d
Merged with master
Rodot- 4121ff5
Moved more calculations over to functions (maybe this should be a sep…
Rodot- 21f303f
Forgot an extra arg to the macroatom state
Rodot- 131eead
fixed up continuum vs non-continuum initialization and handling of co…
Rodot- 9213307
broke about the base transition probabilities properties into functions
Rodot- cec24ef
Added the default transition probabilities to the solver
Rodot- 58d04f3
See previous commit, added a comment
Rodot- 8d2428a
Improved code flow for continuum vs non-continuum
Rodot- c58f0bb
See previous commit
Rodot- 39182b8
See previous commit
Rodot- 240fabb
removed non-continuum interaction species from non-continuum solver path
Rodot- 9aea0ad
broke up the solver to have a common method for both continuum and no…
Rodot- a9fcc6a
Made a separate solver for the macroatom when working with the contin…
Rodot- 7587151
cleaned up default solver a bit
Rodot- e140196
ditto
Rodot- f9a1084
ran black, added personal comments
Rodot- add4d0f
first attempt to work basic macroatom solver into the opacity solver
Rodot- 1e135d0
Fixed calculate_deactivation_channel_probs missing argument 'B'
Rodot- 7c3b59f
Fixed calculate_deactivation_channel_probs missing argument 'B'
Rodot- 0515200
Fixed accessign the macro_atom_data from the plasma
Rodot- 0bc5362
Fixed typo
Rodot- ffdb82d
Small fix to make tests pass, need to revisit later
Rodot- d4e2f0a
Small fix to make tests pass, need to revisit later
Rodot- 4b223ae
Small fix to make tests pass, need to revisit later
Rodot- f0ad44e
Small fix to make tests pass, need to revisit later
Rodot- feda179
Small fix to make tests pass, need to revisit later
Rodot- ad0e132
Small fix to make tests pass, need to revisit later
Rodot- cad6d96
Added switch to swap our the macroatom solver when using the continuum
Rodot- f159c84
Made a passthrough when continuum processes are enabled in case we do…
Rodot- 82a70d4
Removed switch to auto-build continuum macrostate using legacy mode
Rodot- 3c9d4ed
Fixed initialization in default macroatom solver
Rodot- fb6ca3a
grab continuum interaction species from the legacy plasma
Rodot- a0adbb6
Added in the rest of the transition probability properties to the con…
Rodot- c3c573b
Removed old method of doing this
Rodot- 69505c8
switch back to using legacy solve for continuum in case we don't want…
Rodot- a39f965
Moved the MacroAtomContinuumSolver to a new file (deleted from this P…
Rodot- aaef58f
moved 'calculate_' functions derived from transition_probabilities.py…
Rodot- 7369c98
Moved MacroAtomState Solving out of the plasma state from_legacy_plasma
Rodot- a74e9ea
Added docstrings to MacroAtomSolver
Rodot- f29d317
Added docstrings to macro_atom base.py
Rodot- a64244f
Fixed up docstrings in macroatom_sovler
Rodot- 30412b0
Added check to verify macroatom_state is None when line_interaction_t…
Rodot- cfff15f
removed some comments, fixed up OpacitySolver initialization
Rodot- 8f9afcd
Moved handling of the opacity solver over to the simulation base
Rodot- 5801932
Fixed typo
Rodot- d9b44b2
Grabbed the line interaction type from the right place (makes me thin…
Rodot- c03d1b0
Changed 'non_markov_transition...' to 'transtiition...'
Rodot- 81f280a
decoupled macro_atom from the opacity solver
Rodot- 67e3603
Fixed typo
Rodot- 20ab5d8
Updated the to_numba tests
Rodot- 7f24cec
UPdated docstrings/removed unused imports
Rodot- 219ceb5
Merge branch 'master' of github.com:tardis-sn/tardis into macroatom_r…
Rodot- 537562c
Merge branch 'master' into macroatom_restructure
Rodot- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
from tardis.opacities.macro_atom.base import ( | ||
calculate_transition_probabilities, | ||
initialize_transition_probabilities, | ||
) | ||
from tardis.opacities.macro_atom.macroatom_state import MacroAtomState | ||
|
||
|
||
class MacroAtomSolver(object): | ||
|
||
initialize: bool = True | ||
normalize: bool = True | ||
|
||
def __init__(self, initialize=True, normalize=True): | ||
"""Solver class for Macro Atom related opacities | ||
Parameters | ||
---------- | ||
initialize: bool | ||
Whether or not to initialize the transition probabilitiy coefficients and block references when solving the first time (default True) | ||
normalize: bool | ||
Whether or not to normalize the transition probabilities to unity. Default True | ||
""" | ||
|
||
self.initialize = initialize | ||
self.normalize = normalize | ||
|
||
def initialize_transition_probabilities(self, atomic_data): | ||
"""initialize the transition probability coefficients and block references when solving the first time | ||
Parameters | ||
---------- | ||
atomic_data : tardis.io.atom_data.AtomData | ||
Atomic Data | ||
""" | ||
|
||
coef_and_block_ref = initialize_transition_probabilities( | ||
atomic_data | ||
) | ||
self.transition_probability_coef = coef_and_block_ref[ | ||
"transition_probability_coef" | ||
] | ||
self.block_references = coef_and_block_ref["block_references"] | ||
self.initialize = False | ||
|
||
def solve_transition_probabilities( | ||
self, | ||
atomic_data, | ||
legacy_plasma, | ||
tau_sobolev, | ||
stimulated_emission_factor, | ||
): | ||
"""Solve the basic transition probabilities for the macroatom | ||
Parameters | ||
---------- | ||
atomic_data : tardis.io.atom_data.AtomData | ||
Atomic Data | ||
legacy_plasma : tarids.plasma.BasePlasma | ||
legacy base plasma | ||
tau_sobolev : pd.DataFrame | ||
Expansion Optical Depths | ||
stimulated_emission_factor : np.ndarray | ||
Returns | ||
------- | ||
pd.DataFrame | ||
Transition Probabilities | ||
""" | ||
if self.initialize: | ||
self.initialize_transition_probabilities(atomic_data) | ||
|
||
transition_probabilities = ( | ||
calculate_transition_probabilities( | ||
atomic_data, | ||
legacy_plasma.beta_sobolev, | ||
legacy_plasma.j_blues, | ||
stimulated_emission_factor, | ||
tau_sobolev, | ||
self.transition_probability_coef, | ||
self.block_references, | ||
normalize=self.normalize, | ||
) | ||
) | ||
|
||
return transition_probabilities | ||
|
||
def solve( | ||
self, | ||
legacy_plasma, | ||
atomic_data, | ||
tau_sobolev, | ||
stimulated_emission_factor, | ||
): | ||
"""Solved the Macro Atom State | ||
Parameters | ||
---------- | ||
legacy_plasma : tarids.plasma.BasePlasma | ||
legacy base plasma | ||
atomic_data : tardis.io.atom_data.AtomData | ||
Atomic Data | ||
tau_sobolev : pd.DataFrame | ||
Expansion Optical Depths | ||
stimulated_emission_factor : pd.DataFrame | ||
Returns | ||
------- | ||
tardis.opacities.macroatom_state.MacroAtomState | ||
State of the macro atom ready to be placed into the OpacityState | ||
""" | ||
|
||
transition_probabilities = ( | ||
self.solve_transition_probabilities( | ||
atomic_data, | ||
legacy_plasma, | ||
tau_sobolev, | ||
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. that is part of the opacity state - I presume? 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. what do you mean? |
||
stimulated_emission_factor, | ||
) | ||
) | ||
|
||
macro_block_references = atomic_data.macro_atom_references[ | ||
"block_references" | ||
] | ||
macro_atom_info = legacy_plasma.atomic_data.macro_atom_data | ||
|
||
return MacroAtomState( | ||
transition_probabilities, | ||
macro_atom_info["transition_type"], | ||
macro_atom_info["destination_level_idx"], | ||
macro_atom_info["lines_idx"], | ||
macro_block_references, | ||
legacy_plasma.atomic_data.lines_upper2macro_reference_idx, | ||
) |
Oops, something went wrong.
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.
I think this shows us that we don't need all the atomic data to be passed around all the time.
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.
Definitely not, some kind of MacroAtomData structure could be useful