Add spool dynamics for pumps and turbines
This commit is contained in:
@@ -129,3 +129,18 @@ def test_secondary_pump_unit_toggle_can_restart_pump():
|
||||
assert reactor.secondary_pump_units == [True, False]
|
||||
assert reactor.secondary_pump_active is True
|
||||
assert state.secondary_loop.mass_flow_rate > 0.0
|
||||
|
||||
|
||||
def test_primary_pumps_spool_up_over_seconds():
|
||||
reactor = Reactor.default()
|
||||
state = reactor.initial_state()
|
||||
# Enable both pumps and command full flow; spool should take multiple steps.
|
||||
target_flow = reactor.primary_pump.flow_rate(1.0) * len(reactor.primary_pump_units)
|
||||
reactor.step(state, dt=1.0, command=ReactorCommand(primary_pump_on=True, coolant_demand=1.0))
|
||||
first_flow = state.primary_loop.mass_flow_rate
|
||||
assert 0.0 < first_flow < target_flow
|
||||
|
||||
for _ in range(10):
|
||||
reactor.step(state, dt=1.0, command=ReactorCommand(coolant_demand=1.0))
|
||||
|
||||
assert state.primary_loop.mass_flow_rate == pytest.approx(target_flow, rel=0.1)
|
||||
|
||||
33
tests/test_turbine.py
Normal file
33
tests/test_turbine.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
|
||||
from reactor_sim.state import CoolantLoopState, TurbineState
|
||||
from reactor_sim.turbine import Turbine
|
||||
|
||||
|
||||
def test_turbine_spools_toward_target_output():
|
||||
turbine = Turbine()
|
||||
loop = CoolantLoopState(
|
||||
temperature_in=600.0,
|
||||
temperature_out=650.0,
|
||||
pressure=6.0,
|
||||
mass_flow_rate=20_000.0,
|
||||
steam_quality=0.9,
|
||||
)
|
||||
state = TurbineState(
|
||||
steam_enthalpy=0.0,
|
||||
shaft_power_mw=0.0,
|
||||
electrical_output_mw=0.0,
|
||||
condenser_temperature=300.0,
|
||||
)
|
||||
target_electric = min(
|
||||
turbine.rated_output_mw, 300.0 * turbine.mechanical_efficiency * turbine.generator_efficiency
|
||||
)
|
||||
|
||||
dt = 5.0
|
||||
turbine.step(loop, state, steam_power_mw=300.0, dt=dt)
|
||||
assert 0.0 < state.electrical_output_mw < target_electric
|
||||
|
||||
for _ in range(5):
|
||||
turbine.step(loop, state, steam_power_mw=300.0, dt=dt)
|
||||
|
||||
assert state.electrical_output_mw == pytest.approx(target_electric, rel=0.05)
|
||||
Reference in New Issue
Block a user