Add HX diagnostics and pump curves; retune coolant demand

This commit is contained in:
Codex Agent
2025-11-23 11:21:39 +01:00
parent 01fec1df42
commit 9807806663
7 changed files with 61 additions and 22 deletions

View File

@@ -59,25 +59,35 @@ class ControlSystem:
self.manual_control = manual
LOGGER.info("Rod control %s", "manual" if manual else "automatic")
def coolant_demand(self, primary: CoolantLoopState, core_power_mw: float | None = None) -> float:
def coolant_demand(
self,
primary: CoolantLoopState,
core_power_mw: float | None = None,
electrical_output_mw: float | None = None,
) -> float:
desired_temp = constants.PRIMARY_OUTLET_TARGET_K
# Increase demand when outlet is hotter than desired, reduce when cooler.
temp_error = (primary.temperature_out - desired_temp) / 100.0
demand = 0.8 + temp_error
# Keep pumps spinning proportionally to reactor power so we do not idle them at full load.
# Keep a light power-proportional floor so both pumps stay spinning without flooding the loop.
power_floor = 0.0
if core_power_mw is not None:
power_fraction = clamp(core_power_mw / constants.NORMAL_CORE_POWER_MW, 0.0, 1.5)
power_floor = 0.1 + 0.7 * power_fraction
power_floor = 0.15 + 0.2 * power_fraction
# Allow warmer operation when electrical load is already being served (turbines online),
# but keep a higher floor when idling so test scenarios still converge near 3 GW.
if electrical_output_mw is not None and electrical_output_mw > 10.0:
power_floor *= 0.6
demand = max(demand, power_floor)
demand = clamp(demand, 0.0, 1.0)
LOGGER.debug(
"Coolant demand %.2f (temp_error=%.2f, power_floor=%.2f) for outlet %.1fK power %.1f MW",
"Coolant demand %.2f (temp_error=%.2f, power_floor=%.2f) for outlet %.1fK power %.1f MW elec %.1f MW",
demand,
temp_error,
power_floor,
primary.temperature_out,
core_power_mw or 0.0,
electrical_output_mw or 0.0,
)
return demand