diff --git a/tardis/plasma/tests/test_complete_plasmas.py b/tardis/plasma/tests/test_complete_plasmas.py index 33701e7aebd..621270feb50 100644 --- a/tardis/plasma/tests/test_complete_plasmas.py +++ b/tardis/plasma/tests/test_complete_plasmas.py @@ -174,7 +174,6 @@ def plasma( ) yield sim.plasma data.close() - @pytest.mark.parametrize("attr", combined_properties) def test_plasma_properties(self, plasma, attr): key = f"plasma/{attr}" diff --git a/tardis/tests/test_tardis_full.py b/tardis/tests/test_tardis_full.py index 80ac724a84d..d43df7f4931 100644 --- a/tardis/tests/test_tardis_full.py +++ b/tardis/tests/test_tardis_full.py @@ -2,9 +2,11 @@ import numpy.testing as npt import pandas as pd +import numpy as np import pytest from astropy import units as u from astropy.tests.helper import assert_quantity_allclose +from tardis.io.logger.logger import logging_state from tardis import run_tardis from tardis.io.configuration.config_reader import Configuration @@ -45,10 +47,12 @@ def simulation( generate_reference, example_configuration_dir: Path, ): + config = Configuration.from_yaml( str(example_configuration_dir / "tardis_configv1_verysimple.yml") ) config["atom_data"] = atomic_data_fname + logging_state("WARNING", config, None) simulation = Simulation.from_config(config) simulation.run_convergence() @@ -66,6 +70,9 @@ def get_expected_data(self, key: str): def test_j_blue_estimators(self, simulation): key = "simulation/transport/transport_state/j_blue_estimator" expected = self.get_expected_data(key) + + # np.save("j_blue_estimator.npy", simulation.transport.transport_state.radfield_mc_estimators.j_blue_estimator) + npt.assert_allclose( simulation.transport.transport_state.radfield_mc_estimators.j_blue_estimator, diff --git a/tardis/transport/montecarlo/estimators/mc_rad_field_solver.py b/tardis/transport/montecarlo/estimators/mc_rad_field_solver.py index 8682ec7a156..549337e9151 100644 --- a/tardis/transport/montecarlo/estimators/mc_rad_field_solver.py +++ b/tardis/transport/montecarlo/estimators/mc_rad_field_solver.py @@ -96,16 +96,25 @@ def estimate_jblues( volume, line_list_nu, ): + print("[J_BLUE_DEBUG] Input j_blue_estimator:", j_blue_estimator) + j_blues_norm_factor = ( const.c.cgs * time_explosion / (4 * np.pi * time_of_simulation * volume) ) + print("[J_BLUE_DEBUG] Normalization factor:", j_blues_norm_factor.cgs.value) + j_blues = j_blue_estimator * j_blues_norm_factor.cgs.value + print("[J_BLUE_DEBUG] After normalization:", j_blues) + planck_j_blues = estimated_radfield_state.calculate_mean_intensity( line_list_nu ) + print("[J_BLUE_DEBUG] Planck j_blues:", planck_j_blues) + zero_j_blues = j_blues == 0.0 j_blues[zero_j_blues] = self.w_epsilon * planck_j_blues[zero_j_blues] - + print("[J_BLUE_DEBUG] Final j_blues after zero handling:", j_blues) + return j_blues diff --git a/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py b/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py index 0e20f3a15bb..8b058e83cc6 100644 --- a/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py +++ b/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py @@ -112,9 +112,14 @@ def update_line_estimators( else: energy = calc_packet_energy_full_relativity(r_packet) + print(f"[J_BLUE_DEBUG] Updating j_blue_estimator at line_id={cur_line_id}, shell_id={r_packet.current_shell_id}") + print(f"[J_BLUE_DEBUG] Adding value: {energy/r_packet.nu}") + radfield_mc_estimators.j_blue_estimator[ cur_line_id, r_packet.current_shell_id ] += (energy / r_packet.nu) + + print(f"[J_BLUE_DEBUG] New value at position: {radfield_mc_estimators.j_blue_estimator[cur_line_id, r_packet.current_shell_id]}") radfield_mc_estimators.Edotlu_estimator[ cur_line_id, r_packet.current_shell_id ] += energy diff --git a/tardis/transport/montecarlo/estimators/radfield_mc_estimators.py b/tardis/transport/montecarlo/estimators/radfield_mc_estimators.py index de91643e5a5..eaa681ba521 100644 --- a/tardis/transport/montecarlo/estimators/radfield_mc_estimators.py +++ b/tardis/transport/montecarlo/estimators/radfield_mc_estimators.py @@ -30,6 +30,8 @@ def initialize_estimator_statistics(tau_sobolev_shape, gamma_shape): j_estimator = np.zeros(tau_sobolev_shape[1], dtype=np.float64) nu_bar_estimator = np.zeros(tau_sobolev_shape[1], dtype=np.float64) j_blue_estimator = np.zeros(tau_sobolev_shape) + print("[J_BLUE_DEBUG] Initialized j_blue_estimator with shape:", tau_sobolev_shape) + print("[J_BLUE_DEBUG] Initial values:", j_blue_estimator) Edotlu_estimator = np.zeros(tau_sobolev_shape) photo_ion_estimator = np.zeros(gamma_shape, dtype=np.float64)