From fd0267b829746adad6cb190efca06f90fb1b4d2e Mon Sep 17 00:00:00 2001 From: Jack O'Brien Date: Mon, 16 Aug 2021 08:38:53 -0400 Subject: [PATCH] Resolved a couple of comments. (#5) * 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 --- .../montecarlo_numba/interaction.py | 19 +++++++++++++------ .../montecarlo_numba/numba_interface.py | 1 - .../montecarlo_numba/single_packet_loop.py | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tardis/montecarlo/montecarlo_numba/interaction.py b/tardis/montecarlo/montecarlo_numba/interaction.py index 74c08a28bfc..f73d215948b 100644 --- a/tardis/montecarlo/montecarlo_numba/interaction.py +++ b/tardis/montecarlo/montecarlo_numba/interaction.py @@ -71,7 +71,8 @@ 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, @@ -79,13 +80,13 @@ def continuum_event(r_packet, time_explosion, continuum, numba_plasma): 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 @@ -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: @@ -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: diff --git a/tardis/montecarlo/montecarlo_numba/numba_interface.py b/tardis/montecarlo/montecarlo_numba/numba_interface.py index 627d1fee660..c254cbeffc1 100644 --- a/tardis/montecarlo/montecarlo_numba/numba_interface.py +++ b/tardis/montecarlo/montecarlo_numba/numba_interface.py @@ -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 diff --git a/tardis/montecarlo/montecarlo_numba/single_packet_loop.py b/tardis/montecarlo/montecarlo_numba/single_packet_loop.py index a269fab899b..1e58fcf4736 100644 --- a/tardis/montecarlo/montecarlo_numba/single_packet_loop.py +++ b/tardis/montecarlo/montecarlo_numba/single_packet_loop.py @@ -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(