Quantize manual rod steps to 0.025
This commit is contained in:
40
tests/test_control.py
Normal file
40
tests/test_control.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import pytest
|
||||
|
||||
from reactor_sim.control import ControlSystem
|
||||
from reactor_sim import constants
|
||||
from reactor_sim.state import CoreState
|
||||
|
||||
|
||||
def _core_state() -> CoreState:
|
||||
return CoreState(
|
||||
fuel_temperature=300.0,
|
||||
neutron_flux=1e5,
|
||||
reactivity_margin=0.0,
|
||||
power_output_mw=0.0,
|
||||
burnup=0.0,
|
||||
)
|
||||
|
||||
|
||||
def test_manual_rods_quantized_to_step():
|
||||
control = ControlSystem()
|
||||
control.manual_control = True
|
||||
core = _core_state()
|
||||
|
||||
control.set_rods(0.333)
|
||||
assert control.rod_target == 0.325
|
||||
control.update_rods(core, dt=100.0)
|
||||
assert control.rod_fraction == pytest.approx(0.325, rel=1e-6)
|
||||
|
||||
control.increment_rods(0.014)
|
||||
assert control.rod_target == pytest.approx(0.35)
|
||||
control.update_rods(core, dt=100.0)
|
||||
assert control.rod_fraction == pytest.approx(0.35, rel=1e-6)
|
||||
|
||||
# Clamp upper bound
|
||||
control.set_rods(1.0)
|
||||
control.update_rods(core, dt=100.0)
|
||||
assert control.rod_fraction == 0.95
|
||||
|
||||
|
||||
def test_dashboard_step_constant_exposed():
|
||||
assert constants.ROD_MANUAL_STEP == 0.025
|
||||
Reference in New Issue
Block a user