Skip to content

Commit

Permalink
Resolved a couple of comments. (#5)
Browse files Browse the repository at this point in the history
* Reworked the continuum process selection function a little bit to work with the new continuum jitclass

* started addition of free-free emission handler

* updated interactions to work with new macroatom

* Added continuum process frquency samplers to the continuum jitclass constructor

* Fixed typo from merge conflict

* Fixed spacing

* small formatting updates to get the changes to track

* propagated continuum through single packet loop

* Cleaned up file, bound-free and free-free emission pathways should be in the correct place now

* added fixture for a new continuum object

* Added placeholder test for calculating the continuum opacities.  I'm weary to put in exact values until we're done

* reworked the contruction of the continuum class so that only a plasma object needs to be passed

* Updated interaction to now get the macro activation level from the continuum object

* refer to previous commit

* Added the continuum_process into the single packet loop so packets can now actually interact with the contniuum

* various small bugfixes to get the numba funcs to compile properly

* Removed extra functions

* No longer recalculate the local continuum opacities before interacting

* Resolved comment from Christian, do the same process for BF cooling as BF emission

* Minor formatting, currently we still don't actually run through any continuum processes because the new macroatom is not in
  • Loading branch information
Rodot- authored Aug 16, 2021
1 parent 7d8291d commit fd0267b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions tardis/montecarlo/montecarlo_numba/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,22 @@ def continuum_event(r_packet, time_explosion, continuum, numba_plasma):
# Then use this to get a transition id from the macroatom
if transition_type == MacroAtomTransitionType.FF_EMISSION:
free_free_emission(r_packet, time_explosion, numba_plasma, continuum)
elif transition_type == MacroAtomTransitionType.BF_EMISSION:
elif transition_type == MacroAtomTransitionType.BF_EMISSION or \
transition_type == MacroAtomTransitionType.BF_COOLING:
bound_free_emission(r_packet,
time_explosion,
numba_plasma,
continuum,
transition_id)

@njit(**njit_dict_no_parallel)
def get_current_line_id(nu, numba_plasma):
def get_current_line_id(nu, line_list):
'''
Get the next line id corresponding to a packet at frequency nu
'''

reverse_line_list = numba_plasma.line_list_nu[::-1]
number_of_lines = len(numba_plasma.line_list_nu)
reverse_line_list = line_list[::-1]
number_of_lines = len(line_list)
line_id = number_of_lines - np.searchsorted(reverse_line_list, nu)
return line_id

Expand All @@ -100,7 +101,10 @@ def free_free_emission(r_packet, time_explosion, numba_plasma, continuum):
# maybe I'll update the numba_plasma?
comov_nu = continuum.sample_nu_free_free(r_packet.current_shell_id)
r_packet.nu = comov_nu * inverse_doppler_factor
current_line_id = get_current_line_id(comov_nu, numba_plasma)
current_line_id = get_current_line_id(
comov_nu,
numba_plasma.line_list_nu
)
r_packet.next_line_id = current_line_id

if montecarlo_configuration.full_relativity:
Expand All @@ -120,7 +124,10 @@ def bound_free_emission(r_packet, time_explosion, numba_plasma, continuum, conti
continuum_id)

r_packet.nu = comov_nu * inverse_doppler_factor
current_line_id = get_current_line_id(r_packet.nu, numba_plasma)
current_line_id = get_current_line_id(
comov_nu,
numba_plasma.line_list_nu
)
r_packet.next_line_id = current_line_id

if montecarlo_configuration.full_relativity:
Expand Down
1 change: 0 additions & 1 deletion tardis/montecarlo/montecarlo_numba/numba_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def sample_nu_free_free(self, shell):

def determine_macro_activation_idx(self, nu, shell):

self.calculate(nu, shell) # maybe don't do this here
idx = get_macro_activation_idx(
nu, self.chi_bf_tot, self.chi_ff,
self.chi_bf_contributions, self.current_continua
Expand Down
3 changes: 2 additions & 1 deletion tardis/montecarlo/montecarlo_numba/single_packet_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def single_packet_loop(
r_packet, vpacket_collection, numba_model, numba_plasma
)

elif interaction_type == InteractionType.ESCATTERING or interaction_type == InteractionType.CONTINUUM_PROCESS:
elif interaction_type == InteractionType.ESCATTERING or \
interaction_type == InteractionType.CONTINUUM_PROCESS:
r_packet.last_interaction_type = 1

move_r_packet(
Expand Down

0 comments on commit fd0267b

Please sign in to comment.