From 70608efdc85e96e4d0955f424a3a30b7877b59fa Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Sun, 23 Nov 2025 19:48:02 +0100 Subject: [PATCH] Show xenon/iodine inventories on dashboard --- src/reactor_sim/dashboard.py | 9 ++++----- tests/test_neutronics.py | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/reactor_sim/dashboard.py b/src/reactor_sim/dashboard.py index abfd4b9..2451d38 100644 --- a/src/reactor_sim/dashboard.py +++ b/src/reactor_sim/dashboard.py @@ -548,15 +548,14 @@ class ReactorDashboard: inventory = state.core.fission_product_inventory or {} particles = state.core.emitted_particles or {} lines: list[tuple[str, str]] = [] - def fmt(symbol: str, label: str) -> tuple[str, str]: - qty = inventory.get(symbol, 0.0) + def fmt(symbol: str, label: str, qty: float) -> tuple[str, str]: threshold = constants.KEY_POISON_THRESHOLDS.get(symbol) flag = " !" if threshold is not None and qty >= threshold else "" return (f"{label}{flag}", f"{qty:9.2e}") - lines.append(fmt("Xe", "Xe (xenon)")) - lines.append(fmt("Sm", "Sm (samarium)")) - lines.append(fmt("I", "I (iodine)")) + lines.append(fmt("Xe", "Xe (xenon)", getattr(state.core, "xenon_inventory", 0.0))) + lines.append(fmt("Sm", "Sm (samarium)", inventory.get("Sm", 0.0))) + lines.append(fmt("I", "I (iodine)", getattr(state.core, "iodine_inventory", 0.0))) lines.append(("Neutrons (src)", f"{particles.get('n', 0.0):9.2e}")) lines.append(("Gammas", f"{particles.get('gamma', 0.0):9.2e}")) lines.append(("Alphas", f"{particles.get('alpha', 0.0):9.2e}")) diff --git a/tests/test_neutronics.py b/tests/test_neutronics.py index ca4d994..298a762 100644 --- a/tests/test_neutronics.py +++ b/tests/test_neutronics.py @@ -23,3 +23,12 @@ def test_reactivity_increases_with_rod_withdrawal(): rho_full_out = dynamics.reactivity(state, control_fraction=0.0) rho_half = dynamics.reactivity(state, control_fraction=0.5) assert rho_full_out > rho_half + + +def test_poisons_accumulate_under_power(): + dynamics = NeutronDynamics() + state = _core_state(power=800.0, flux=1e6) + dynamics.update_poisons(state, dt=100.0) + dynamics.update_poisons(state, dt=100.0) + assert state.iodine_inventory > 0.0 + assert state.xenon_inventory > 0.0