Skip to content

Commit

Permalink
debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Atharva Arya committed Dec 26, 2024
1 parent 3ad9302 commit c6b9d1b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
1 change: 0 additions & 1 deletion tardis/plasma/tests/test_complete_plasmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
7 changes: 7 additions & 0 deletions tardis/tests/test_tardis_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion tardis/transport/montecarlo/estimators/mc_rad_field_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c6b9d1b

Please sign in to comment.