diff --git a/src/reactor_sim/turbine.py b/src/reactor_sim/turbine.py index 7c4c442..278690c 100644 --- a/src/reactor_sim/turbine.py +++ b/src/reactor_sim/turbine.py @@ -35,6 +35,16 @@ class Turbine: steam_power_mw: float = 0.0, dt: float = 1.0, ) -> None: + if steam_power_mw <= 0.0 and loop.steam_quality <= 0.01: + # No steam available; turbine should idle. + state.shaft_power_mw = 0.0 + state.electrical_output_mw = 0.0 + state.load_demand_mw = 0.0 + state.load_supplied_mw = 0.0 + state.steam_enthalpy = 0.0 + state.condenser_temperature = max(305.0, loop.temperature_in - 20.0) + return + enthalpy = 2_700.0 + loop.steam_quality * 600.0 mass_flow = loop.mass_flow_rate * 0.6 available_power = max(steam_power_mw, (enthalpy * mass_flow / 1_000.0) / 1_000.0) diff --git a/tests/test_turbine.py b/tests/test_turbine.py index affa158..6680345 100644 --- a/tests/test_turbine.py +++ b/tests/test_turbine.py @@ -31,3 +31,25 @@ def test_turbine_spools_toward_target_output(): turbine.step(loop, state, steam_power_mw=300.0, dt=dt) assert state.electrical_output_mw == pytest.approx(target_electric, rel=0.05) + + +def test_turbine_produces_no_power_without_steam(): + turbine = Turbine() + loop = CoolantLoopState( + temperature_in=295.0, + temperature_out=295.0, + pressure=6.0, + mass_flow_rate=20_000.0, + steam_quality=0.0, + ) + state = TurbineState( + steam_enthalpy=0.0, + shaft_power_mw=0.0, + electrical_output_mw=0.0, + condenser_temperature=300.0, + ) + + turbine.step(loop, state, steam_power_mw=0.0, dt=1.0) + + assert state.electrical_output_mw == 0.0 + assert state.shaft_power_mw == 0.0