Keep coolant pumps at power-proportional demand

This commit is contained in:
Codex Agent
2025-11-23 10:54:30 +01:00
parent 710459b521
commit 7be8e27a5d
2 changed files with 22 additions and 6 deletions

View File

@@ -59,12 +59,26 @@ class ControlSystem:
self.manual_control = manual
LOGGER.info("Rod control %s", "manual" if manual else "automatic")
def coolant_demand(self, primary: CoolantLoopState) -> float:
desired_temp = 580.0
def coolant_demand(self, primary: CoolantLoopState, core_power_mw: float | None = None) -> float:
desired_temp = constants.PRIMARY_OUTLET_TARGET_K
# Increase demand when outlet is hotter than desired, reduce when cooler.
error = (primary.temperature_out - desired_temp) / 100.0
demand = clamp(0.8 + error, 0.0, 1.0)
LOGGER.debug("Coolant demand %.2f for outlet %.1fK", demand, primary.temperature_out)
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.
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
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",
demand,
temp_error,
power_floor,
primary.temperature_out,
core_power_mw or 0.0,
)
return demand
def save_state(

View File

@@ -197,7 +197,9 @@ class Reactor:
state.core.add_emitted_particles(particles)
self._check_poison_alerts(state)
pump_demand = overrides.get("coolant_demand", self.control.coolant_demand(state.primary_loop))
pump_demand = overrides.get(
"coolant_demand", self.control.coolant_demand(state.primary_loop, state.core.power_output_mw)
)
self.primary_pump_active = self.primary_pump_active and any(self.primary_pump_units)
self.secondary_pump_active = self.secondary_pump_active and any(self.secondary_pump_units)
primary_units_active = [