feat: improve manual rod control and reactor power

This commit is contained in:
Andrii Prokhorov
2025-11-21 17:59:25 +02:00
parent 6e8520c925
commit 2400ce669e
6 changed files with 33 additions and 15 deletions

View File

@@ -21,8 +21,11 @@ def clamp(value: float, lo: float, hi: float) -> float:
class ControlSystem:
setpoint_mw: float = 3_000.0
rod_fraction: float = 0.5
manual_control: bool = False
def update_rods(self, state: CoreState, dt: float) -> float:
if self.manual_control:
return self.rod_fraction
error = (state.power_output_mw - self.setpoint_mw) / self.setpoint_mw
adjustment = -error * 0.3
adjustment = clamp(adjustment, -constants.CONTROL_ROD_SPEED * dt, constants.CONTROL_ROD_SPEED * dt)
@@ -50,6 +53,11 @@ class ControlSystem:
self.setpoint_mw = clamp(megawatts, 100.0, 4_000.0)
LOGGER.info("Power setpoint %.0f -> %.0f MW", previous, self.setpoint_mw)
def set_manual_mode(self, manual: bool) -> None:
if self.manual_control != manual:
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
error = (primary.temperature_out - desired_temp) / 100.0