From fef1d32fbef136b2aa824a9f09cbfa5b61b425ad Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Sat, 22 Nov 2025 18:22:24 +0100 Subject: [PATCH] Restore three turbines and update controls --- AGENTS.md | 2 +- src/reactor_sim/dashboard.py | 10 ++++++---- src/reactor_sim/failures.py | 2 +- src/reactor_sim/reactor.py | 2 +- tests/test_simulation.py | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c31d3cd..67973e5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,7 @@ All source code lives under `src/reactor_sim`. Submodules map to plant systems: - A git remote for `origin` is configured; push changes to `origin/main` once work is complete so dashboards stay in sync. ## Operations & Control Hooks -Manual commands live in `reactor_sim.commands.ReactorCommand`. Pass a `command_provider` callable to `ReactorSimulation` to adjust rods, pumps, turbine, coolant demand, or the attached `ElectricalConsumer`. Use `ReactorCommand.scram_all()` for full shutdown, `ReactorCommand(consumer_online=True, consumer_demand=600)` to hook the grid, or toggle pumps (`primary_pump_on=False`) to simulate faults. Control helpers in `control.py` expose `set_rods`, `increment_rods`, and `scram`, and you can switch `set_manual_mode(True)` to pause the automatic rod controller. For hands-on runs, launch the curses dashboard (`FISSION_DASHBOARD=1 FISSION_REALTIME=1 python run_simulation.py`) and use the on-screen shortcuts (q quit/save, space SCRAM, p/o pumps, t turbine, 1/2 toggle individual turbines, y/u turbine maintenance, m/n pump maintenance, k core maintenance, c consumer, r reset/clear saved state, +/- rods in 0.05 steps, [/ ] consumer demand, s/d setpoint, `a` toggles auto/manual rods). Recommended startup: enable manual rods (`a`), withdraw to ~0.3 before ramping the turbine/consumer, then re-enable auto control when you want closed-loop operation. +Manual commands live in `reactor_sim.commands.ReactorCommand`. Pass a `command_provider` callable to `ReactorSimulation` to adjust rods, pumps, turbine, coolant demand, or the attached `ElectricalConsumer`. Use `ReactorCommand.scram_all()` for full shutdown, `ReactorCommand(consumer_online=True, consumer_demand=600)` to hook the grid, or toggle pumps (`primary_pump_on=False`) to simulate faults. Control helpers in `control.py` expose `set_rods`, `increment_rods`, and `scram`, and you can switch `set_manual_mode(True)` to pause the automatic rod controller. For hands-on runs, launch the curses dashboard (`FISSION_DASHBOARD=1 FISSION_REALTIME=1 python run_simulation.py`) and use the on-screen shortcuts (q quit/save, space SCRAM, p/o pumps, t turbine, 1/2/3 toggle individual turbines, y/u/i turbine maintenance, m/n pump maintenance, k core maintenance, c consumer, r reset/clear saved state, +/- rods in 0.05 steps, [/ ] consumer demand, s/d setpoint, `a` toggles auto/manual rods). Recommended startup: enable manual rods (`a`), withdraw to ~0.3 before ramping the turbine/consumer, then re-enable auto control when you want closed-loop operation. The plant now boots cold (ambient core temperature, idle pumps); scripts must sequence startup: enable pumps, gradually withdraw rods, connect the consumer after turbine spin-up, and use `ControlSystem.set_power_setpoint` to chase desired output. Set `FISSION_REALTIME=1` to run continuously with real-time pacing; optionally set `FISSION_SIM_DURATION=infinite` for indefinite runs and send SIGINT/Ctrl+C to stop. Use `FISSION_SIM_DURATION=600` (default) for bounded offline batches. ## Coding Style & Naming Conventions diff --git a/src/reactor_sim/dashboard.py b/src/reactor_sim/dashboard.py index 8452bec..6692c70 100644 --- a/src/reactor_sim/dashboard.py +++ b/src/reactor_sim/dashboard.py @@ -52,8 +52,8 @@ class ReactorDashboard: DashboardKey("p", "Toggle primary pump"), DashboardKey("o", "Toggle secondary pump"), DashboardKey("t", "Toggle turbine"), - DashboardKey("1/2", "Toggle turbine units 1-2"), - DashboardKey("y/u", "Maintain turbine 1/2"), + DashboardKey("1/2/3", "Toggle turbine units 1-3"), + DashboardKey("y/u/i", "Maintain turbine 1/2/3"), DashboardKey("c", "Toggle consumer"), DashboardKey("r", "Reset & clear state"), DashboardKey("m", "Maintain primary pump"), @@ -162,6 +162,8 @@ class ReactorDashboard: self._queue_command(ReactorCommand.maintain("turbine_1")) elif ch in (ord("u"), ord("U")): self._queue_command(ReactorCommand.maintain("turbine_2")) + elif ch in (ord("i"), ord("I")): + self._queue_command(ReactorCommand.maintain("turbine_3")) def _queue_command(self, command: ReactorCommand) -> None: if self.pending_command is None: @@ -321,8 +323,8 @@ class ReactorDashboard: tips = [ "Start pumps before withdrawing rods.", "Bring turbine and consumer online after thermal stabilization.", - "Toggle turbine units (1/2) for staggered maintenance.", - "Use m/n/k/y/u to request maintenance (stop equipment first).", + "Toggle turbine units (1/2/3) for staggered maintenance.", + "Use m/n/k/y/u/i to request maintenance (stop equipment first).", "Press 'r' to reset/clear state if you want a cold start.", "Watch component health to avoid automatic trips.", ] diff --git a/src/reactor_sim/failures.py b/src/reactor_sim/failures.py index d9eb8d9..07760ce 100644 --- a/src/reactor_sim/failures.py +++ b/src/reactor_sim/failures.py @@ -56,7 +56,7 @@ class HealthMonitor: "primary_pump": ComponentHealth("primary_pump"), "secondary_pump": ComponentHealth("secondary_pump"), } - for idx in range(2): + for idx in range(3): name = f"turbine_{idx + 1}" self.components[name] = ComponentHealth(name) self.failure_log: list[str] = [] diff --git a/src/reactor_sim/reactor.py b/src/reactor_sim/reactor.py index 8e87238..f064e9b 100644 --- a/src/reactor_sim/reactor.py +++ b/src/reactor_sim/reactor.py @@ -59,7 +59,7 @@ class Reactor: secondary_pump=Pump(nominal_flow=16_000.0, efficiency=0.85), thermal=ThermalSolver(), steam_generator=SteamGenerator(), - turbines=[Turbine() for _ in range(2)], + turbines=[Turbine() for _ in range(3)], atomic_model=atomic_model, consumer=ElectricalConsumer(name="Grid", demand_mw=800.0, online=False), health_monitor=HealthMonitor(), diff --git a/tests/test_simulation.py b/tests/test_simulation.py index 6bd2720..7ea7fa8 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -37,7 +37,7 @@ def test_health_monitor_flags_core_failure(): reactor = Reactor.default() state = reactor.initial_state() state.core.fuel_temperature = constants.MAX_CORE_TEMPERATURE - failures = reactor.health_monitor.evaluate(state, True, True, [True, True], dt=200.0) + failures = reactor.health_monitor.evaluate(state, True, True, [True, True, True], dt=200.0) assert "core" in failures reactor._handle_failure("core") assert reactor.shutdown is True