Show filtered power on trends and ease DNB SCRAM threshold

This commit is contained in:
Codex Agent
2025-11-28 20:56:34 +01:00
parent c0b97cbe6b
commit a600b59809
2 changed files with 8 additions and 4 deletions

View File

@@ -433,7 +433,7 @@ class ReactorDashboard:
left_win,
left_y,
"Trends",
self._trend_lines(),
self._trend_lines(state),
)
left_y = self._draw_section(left_win, left_y, "Key Poisons / Emitters", self._poison_lines(state))
left_y = self._draw_section(
@@ -820,9 +820,9 @@ class ReactorDashboard:
def _update_trends(self, state: PlantState) -> None:
self._trend_history.append((state.time_elapsed, state.core.fuel_temperature, state.core.power_output_mw))
def _trend_lines(self) -> list[tuple[str, str]]:
def _trend_lines(self, state: PlantState) -> list[tuple[str, str]]:
if len(self._trend_history) < 2:
return [("Fuel Temp Δ", "n/a"), ("Core Power Δ", "n/a")]
return [("Fuel Temp Δ", "n/a"), ("Core Power Δ", "n/a"), ("P(meas)", "n/a")]
start_t, start_temp, start_power = self._trend_history[0]
end_t, end_temp, end_power = self._trend_history[-1]
duration = max(1.0, end_t - start_t)
@@ -830,9 +830,11 @@ class ReactorDashboard:
power_delta = end_power - start_power
temp_rate = temp_delta / duration
power_rate = power_delta / duration
measured = getattr(self.reactor.control, "_filtered_power_mw", 0.0) if hasattr(self.reactor, "control") else 0.0
return [
("Fuel Temp Δ", f"{end_temp:7.1f} K (Δ{temp_delta:+6.1f} / {duration:4.0f}s, {temp_rate:+5.2f}/s)"),
("Core Power Δ", f"{end_power:7.1f} MW (Δ{power_delta:+6.1f} / {duration:4.0f}s, {power_rate:+5.2f}/s)"),
("P(meas)", f"{measured:7.1f} MW" if measured > 0 else "n/a"),
]
def _draw_health_bars(self, win: "curses._CursesWindow", start_y: int) -> int:

View File

@@ -446,10 +446,12 @@ class Reactor:
if (not self.secondary_pump_active or state.secondary_loop.mass_flow_rate <= 1.0) and total_power > 50.0:
self._handle_heat_sink_loss(state)
# SCRAM matrix: DNB, subcooling, steam generator level/pressure
if state.core.dnb_margin is not None and state.core.dnb_margin < 0.5:
if state.core.dnb_margin is not None and state.core.dnb_margin < 0.45:
LOGGER.critical("DNB margin low: %.2f, initiating SCRAM", state.core.dnb_margin)
self.shutdown = True
self.control.scram()
elif state.core.dnb_margin is not None and state.core.dnb_margin < 0.6:
LOGGER.warning("DNB margin low: %.2f", state.core.dnb_margin)
if state.core.subcooling_margin is not None and state.core.subcooling_margin < 2.0:
LOGGER.critical("Subcooling margin lost: %.1fK, initiating SCRAM", state.core.subcooling_margin)
self.shutdown = True