diff --git a/src/reactor_sim/control.py b/src/reactor_sim/control.py index c68586c..271a98e 100644 --- a/src/reactor_sim/control.py +++ b/src/reactor_sim/control.py @@ -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( diff --git a/src/reactor_sim/reactor.py b/src/reactor_sim/reactor.py index ca1d6f1..a3882d4 100644 --- a/src/reactor_sim/reactor.py +++ b/src/reactor_sim/reactor.py @@ -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 = [