Skip to content

Commit

Permalink
Fix most tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfullard committed Jan 22, 2024
1 parent 0064c8c commit 1235772
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/physics/update_and_conv/update_and_conv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
},
"outputs": [],
"source": [
"j_estimator = transport.transport_state.estimators.j_estimator * (u.erg * u.cm) \n",
"j_estimator = transport.transport_state.j_estimator * (u.erg * u.cm) \n",
"j_estimator"
]
},
Expand All @@ -324,7 +324,7 @@
},
"outputs": [],
"source": [
"nu_bar_estimator = transport.transport_state.estimators.nu_bar_estimator * (u.erg * u.cm * u.Hz)\n",
"nu_bar_estimator = transport.transport_state.nu_bar_estimator * (u.erg * u.cm * u.Hz)\n",
"nu_bar_estimator"
]
},
Expand Down
1 change: 1 addition & 0 deletions tardis/model/parse_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ def initialize_packet_source(config, geometry, packet_source):
)
return packet_source


def parse_packet_source(config, geometry):
"""
Parse the packet source based on the given configuration and geometry.
Expand Down
6 changes: 3 additions & 3 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def run(
transport_state.geometry_state,
numba_model,
transport_state.opacity_state,
transport_state.estimators,
transport_state.radfield_mc_estimators,
transport_state.spectrum_frequency.value,
number_of_vpackets,
iteration=iteration,
Expand Down Expand Up @@ -233,8 +233,8 @@ def legacy_return(self):
return (
self.transport_state.packet_collection.output_nus,
self.transport_state.packet_collection.output_energies,
self.transport_state.estimators.j_estimator,
self.transport_state.estimators.nu_bar_estimator,
self.transport_state.j_estimator,
self.transport_state.nu_bar_estimator,
self.transport_state.last_line_interaction_in_id,
self.transport_state.last_line_interaction_out_id,
self.transport_state.last_interaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def solve(self, radfield_mc_estimators, time_of_simulation, volume):
4
* const.sigma_sb.cgs.value
* temperature_radiative.value**4
* (time_of_simulation)
* time_of_simulation.value
* volume
)

Expand Down
4 changes: 2 additions & 2 deletions tardis/montecarlo/montecarlo_numba/formal_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def make_source_function(self):
Edotlu = (
Edotlu_norm_factor
* exptau
* montecarlo_transport_state.estimators.Edotlu_estimator
* montecarlo_transport_state.radfield_mc_estimators.Edotlu_estimator
)

# The following may be achieved by calling the appropriate plasma
Expand All @@ -470,7 +470,7 @@ def make_source_function(self):
# Jbluelu should already by in the correct order, i.e. by wavelength of
# the transition l->u
Jbluelu = (
transport.transport_state.estimators.j_blue_estimator
transport.transport_state.radfield_mc_estimators.j_blue_estimator
* Jbluelu_norm_factor
)

Expand Down
10 changes: 6 additions & 4 deletions tardis/montecarlo/montecarlo_numba/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def test_montecarlo_main_loop(
transport_state = montecarlo_main_loop_simulation.transport.transport_state
actual_energy = transport_state.packet_collection.output_energies
actual_nu = transport_state.packet_collection.output_nus
actual_nu_bar_estimator = transport_state.estimators.nu_bar_estimator
actual_j_estimator = transport_state.estimators.j_estimator
actual_nu_bar_estimator = (
transport_state.radfield_mc_estimators.nu_bar_estimator
)
actual_j_estimator = transport_state.radfield_mc_estimators.j_estimator

# Compare
npt.assert_allclose(
Expand Down Expand Up @@ -116,8 +118,8 @@ def test_montecarlo_main_loop_vpacket_log(

actual_energy = transport_state.packet_collection.output_energies
actual_nu = transport_state.packet_collection.output_nus
actual_nu_bar_estimator = transport_state.estimators.nu_bar_estimator
actual_j_estimator = transport_state.estimators.j_estimator
actual_nu_bar_estimator = transport_state.nu_bar_estimator
actual_j_estimator = transport_state.j_estimator
actual_vpacket_log_nus = transport_state.vpacket_tracker.nus
actual_vpacket_log_energies = transport_state.vpacket_tracker.energies

Expand Down
4 changes: 2 additions & 2 deletions tardis/montecarlo/packet_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def create_packets(self, no_of_packets, seed_offset=0, *args, **kwargs):
self.calculate_radfield_luminosity().to(u.erg / u.s).value
)
return PacketCollection(
radii.cgs.value,
nus.cgs.value,
radii,
nus,
mus,
energies,
packet_seeds,
Expand Down
2 changes: 1 addition & 1 deletion tardis/simulation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def advance_state(self):
# A check to see if the plasma is set with JBluesDetailed, in which
# case it needs some extra kwargs.

estimators = self.transport.transport_state.estimators
estimators = self.transport.transport_state.radfield_mc_estimators
if "j_blue_estimator" in self.plasma.outputs_dict:
update_properties.update(
t_inner=next_t_inner,
Expand Down
3 changes: 2 additions & 1 deletion tardis/simulation/tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def simulation_one_loop(
def test_plasma_estimates(simulation_one_loop, refdata, name):
if name in ["nu_bar_estimator", "j_estimator"]:
actual = getattr(
simulation_one_loop.transport.transport_state.estimators, name
simulation_one_loop.transport.transport_state.radfield_mc_estimators,
name,
)
elif name in ["t_radiative", "dilution_factor"]:
actual = getattr(simulation_one_loop.simulation_state, name)
Expand Down
2 changes: 1 addition & 1 deletion tardis/tests/test_tardis_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_j_blue_estimators(self, transport, refdata):
j_blue_estimator = refdata("j_blue_estimator").values

npt.assert_allclose(
transport.transport_state.estimators.j_blue_estimator,
transport.transport_state.radfield_mc_estimators.j_blue_estimator,
j_blue_estimator,
)

Expand Down
2 changes: 1 addition & 1 deletion tardis/tests/test_tardis_full_formal_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_j_blue_estimators(self, transport, refdata):
j_blue_estimator = refdata("j_blue_estimator").values

npt.assert_allclose(
transport.transport_state.estimators.j_blue_estimator,
transport.transport_state.radfield_mc_estimators.j_blue_estimator,
j_blue_estimator,
)

Expand Down

0 comments on commit 1235772

Please sign in to comment.