Skip to content

Commit

Permalink
Refactor montecarlo_main_loop and FormalIntegrator classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed Jan 6, 2024
1 parent 0cceb79 commit ca18310
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
9 changes: 4 additions & 5 deletions tardis/montecarlo/montecarlo_numba/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ def montecarlo_main_loop(
n_threads = get_num_threads()

estimator_list = List()
for i in range(
n_threads
): # betting get thread_id goes from 0 to num threads
# Note that get_thread_id() returns values from 0 to n_threads-1,
# so we iterate from 0 to n_threads-1 to create the estimator_list
# betting get thread_id goes from 0 to num threads
# Note that get_thread_id() returns values from 0 to n_threads-1,
# so we iterate from 0 to n_threads-1 to create the estimator_list
for i in range(n_threads):
estimator_list.append(
Estimators(
np.copy(estimators.j_estimator),
Expand Down
19 changes: 12 additions & 7 deletions tardis/montecarlo/montecarlo_numba/formal_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,9 @@ def make_source_function(self):
-------
Numpy array containing ( 1 - exp(-tau_ul) ) S_ul ordered by wavelength of the transition u -> l
"""

simulation_state = self.simulation_state
transport = self.transport
mct_state = transport.transport_state
montecarlo_transport_state = transport.transport_state

# macro_ref = self.atomic_data.macro_atom_references
macro_ref = self.atomic_data.macro_atom_references
Expand All @@ -442,12 +441,14 @@ def make_source_function(self):
destination_level_idx = ma_int_data.destination_level_idx.values

Edotlu_norm_factor = 1 / (
mct_state.packet_collection.time_of_simulation
montecarlo_transport_state.packet_collection.time_of_simulation
* simulation_state.volume
)
exptau = 1 - np.exp(-self.original_plasma.tau_sobolevs)
Edotlu = (
Edotlu_norm_factor * exptau * mct_state.estimators.Edotlu_estimator
Edotlu_norm_factor
* exptau
* montecarlo_transport_state.estimators.Edotlu_estimator
)

# The following may be achieved by calling the appropriate plasma
Expand All @@ -459,7 +460,7 @@ def make_source_function(self):
/ (
4
* np.pi
* mct_state.time_of_simulation
* montecarlo_transport_state.time_of_simulation
* simulation_state.volume
)
)
Expand Down Expand Up @@ -538,8 +539,12 @@ def make_source_function(self):
att_S_ul, Jredlu, Jbluelu, e_dot_u
)
else:
transport.r_inner_i = mct_state.geometry_state.r_inner
transport.r_outer_i = mct_state.geometry_state.r_outer
transport.r_inner_i = (
montecarlo_transport_state.geometry_state.r_inner
)
transport.r_outer_i = (
montecarlo_transport_state.geometry_state.r_outer
)
transport.tau_sobolevs_integ = (
self.original_plasma.tau_sobolevs.values
)
Expand Down
File renamed without changes.

0 comments on commit ca18310

Please sign in to comment.