feat: improve manual rod control and reactor power
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user